Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
ad7280a.c File Reference
#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/sysfs.h>
#include <linux/spi/spi.h>
#include <linux/err.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
#include <linux/iio/events.h>
#include "ad7280a.h"

Go to the source code of this file.

Data Structures

struct  ad7280_state
 

Macros

#define AD7280A_CELL_VOLTAGE_1   0x0 /* D11 to D0, Read only */
 
#define AD7280A_CELL_VOLTAGE_2   0x1 /* D11 to D0, Read only */
 
#define AD7280A_CELL_VOLTAGE_3   0x2 /* D11 to D0, Read only */
 
#define AD7280A_CELL_VOLTAGE_4   0x3 /* D11 to D0, Read only */
 
#define AD7280A_CELL_VOLTAGE_5   0x4 /* D11 to D0, Read only */
 
#define AD7280A_CELL_VOLTAGE_6   0x5 /* D11 to D0, Read only */
 
#define AD7280A_AUX_ADC_1   0x6 /* D11 to D0, Read only */
 
#define AD7280A_AUX_ADC_2   0x7 /* D11 to D0, Read only */
 
#define AD7280A_AUX_ADC_3   0x8 /* D11 to D0, Read only */
 
#define AD7280A_AUX_ADC_4   0x9 /* D11 to D0, Read only */
 
#define AD7280A_AUX_ADC_5   0xA /* D11 to D0, Read only */
 
#define AD7280A_AUX_ADC_6   0xB /* D11 to D0, Read only */
 
#define AD7280A_SELF_TEST   0xC /* D11 to D0, Read only */
 
#define AD7280A_CONTROL_HB   0xD /* D15 to D8, Read/write */
 
#define AD7280A_CONTROL_LB   0xE /* D7 to D0, Read/write */
 
#define AD7280A_CELL_OVERVOLTAGE   0xF /* D7 to D0, Read/write */
 
#define AD7280A_CELL_UNDERVOLTAGE   0x10 /* D7 to D0, Read/write */
 
#define AD7280A_AUX_ADC_OVERVOLTAGE   0x11 /* D7 to D0, Read/write */
 
#define AD7280A_AUX_ADC_UNDERVOLTAGE   0x12 /* D7 to D0, Read/write */
 
#define AD7280A_ALERT   0x13 /* D7 to D0, Read/write */
 
#define AD7280A_CELL_BALANCE   0x14 /* D7 to D0, Read/write */
 
#define AD7280A_CB1_TIMER   0x15 /* D7 to D0, Read/write */
 
#define AD7280A_CB2_TIMER   0x16 /* D7 to D0, Read/write */
 
#define AD7280A_CB3_TIMER   0x17 /* D7 to D0, Read/write */
 
#define AD7280A_CB4_TIMER   0x18 /* D7 to D0, Read/write */
 
#define AD7280A_CB5_TIMER   0x19 /* D7 to D0, Read/write */
 
#define AD7280A_CB6_TIMER   0x1A /* D7 to D0, Read/write */
 
#define AD7280A_PD_TIMER   0x1B /* D7 to D0, Read/write */
 
#define AD7280A_READ   0x1C /* D7 to D0, Read/write */
 
#define AD7280A_CNVST_CONTROL   0x1D /* D7 to D0, Read/write */
 
#define AD7280A_CTRL_HB_CONV_INPUT_ALL   (0 << 6)
 
#define AD7280A_CTRL_HB_CONV_INPUT_6CELL_AUX1_3_4   (1 << 6)
 
#define AD7280A_CTRL_HB_CONV_INPUT_6CELL   (2 << 6)
 
#define AD7280A_CTRL_HB_CONV_INPUT_SELF_TEST   (3 << 6)
 
#define AD7280A_CTRL_HB_CONV_RES_READ_ALL   (0 << 4)
 
#define AD7280A_CTRL_HB_CONV_RES_READ_6CELL_AUX1_3_4   (1 << 4)
 
#define AD7280A_CTRL_HB_CONV_RES_READ_6CELL   (2 << 4)
 
#define AD7280A_CTRL_HB_CONV_RES_READ_NO   (3 << 4)
 
#define AD7280A_CTRL_HB_CONV_START_CNVST   (0 << 3)
 
#define AD7280A_CTRL_HB_CONV_START_CS   (1 << 3)
 
#define AD7280A_CTRL_HB_CONV_AVG_DIS   (0 << 1)
 
#define AD7280A_CTRL_HB_CONV_AVG_2   (1 << 1)
 
#define AD7280A_CTRL_HB_CONV_AVG_4   (2 << 1)
 
#define AD7280A_CTRL_HB_CONV_AVG_8   (3 << 1)
 
#define AD7280A_CTRL_HB_CONV_AVG(x)   ((x) << 1)
 
#define AD7280A_CTRL_HB_PWRDN_SW   (1 << 0)
 
#define AD7280A_CTRL_LB_SWRST   (1 << 7)
 
#define AD7280A_CTRL_LB_ACQ_TIME_400ns   (0 << 5)
 
#define AD7280A_CTRL_LB_ACQ_TIME_800ns   (1 << 5)
 
#define AD7280A_CTRL_LB_ACQ_TIME_1200ns   (2 << 5)
 
#define AD7280A_CTRL_LB_ACQ_TIME_1600ns   (3 << 5)
 
#define AD7280A_CTRL_LB_ACQ_TIME(x)   ((x) << 5)
 
#define AD7280A_CTRL_LB_MUST_SET   (1 << 4)
 
#define AD7280A_CTRL_LB_THERMISTOR_EN   (1 << 3)
 
#define AD7280A_CTRL_LB_LOCK_DEV_ADDR   (1 << 2)
 
#define AD7280A_CTRL_LB_INC_DEV_ADDR   (1 << 1)
 
#define AD7280A_CTRL_LB_DAISY_CHAIN_RB_EN   (1 << 0)
 
#define AD7280A_ALERT_GEN_STATIC_HIGH   (1 << 6)
 
#define AD7280A_ALERT_RELAY_SIG_CHAIN_DOWN   (3 << 6)
 
#define AD7280A_ALL_CELLS   (0xAD << 16)
 
#define AD7280A_MAX_SPI_CLK_Hz   700000 /* < 1MHz */
 
#define AD7280A_MAX_CHAIN   8
 
#define AD7280A_CELLS_PER_DEV   6
 
#define AD7280A_BITS   12
 
#define AD7280A_NUM_CH
 
#define AD7280A_DEVADDR_MASTER   0
 
#define AD7280A_DEVADDR_ALL   0x1F
 
#define AD7280A_DEVADDR(addr)
 
#define AD7280A_READ_TXVAL   0xF800030A
 
#define POLYNOM   0x2F
 
#define POLYNOM_ORDER   8
 
#define HIGHBIT   1 << (POLYNOM_ORDER - 1);
 

Functions

 MODULE_DEVICE_TABLE (spi, ad7280_id)
 
 module_spi_driver (ad7280_driver)
 
 MODULE_AUTHOR ("Michael Hennerich <[email protected]>")
 
 MODULE_DESCRIPTION ("Analog Devices AD7280A")
 
 MODULE_LICENSE ("GPL v2")
 

Macro Definition Documentation

#define AD7280A_ALERT   0x13 /* D7 to D0, Read/write */

Definition at line 45 of file ad7280a.c.

#define AD7280A_ALERT_GEN_STATIC_HIGH   (1 << 6)

Definition at line 87 of file ad7280a.c.

#define AD7280A_ALERT_RELAY_SIG_CHAIN_DOWN   (3 << 6)

Definition at line 88 of file ad7280a.c.

#define AD7280A_ALL_CELLS   (0xAD << 16)

Definition at line 90 of file ad7280a.c.

#define AD7280A_AUX_ADC_1   0x6 /* D11 to D0, Read only */

Definition at line 32 of file ad7280a.c.

#define AD7280A_AUX_ADC_2   0x7 /* D11 to D0, Read only */

Definition at line 33 of file ad7280a.c.

#define AD7280A_AUX_ADC_3   0x8 /* D11 to D0, Read only */

Definition at line 34 of file ad7280a.c.

#define AD7280A_AUX_ADC_4   0x9 /* D11 to D0, Read only */

Definition at line 35 of file ad7280a.c.

#define AD7280A_AUX_ADC_5   0xA /* D11 to D0, Read only */

Definition at line 36 of file ad7280a.c.

#define AD7280A_AUX_ADC_6   0xB /* D11 to D0, Read only */

Definition at line 37 of file ad7280a.c.

#define AD7280A_AUX_ADC_OVERVOLTAGE   0x11 /* D7 to D0, Read/write */

Definition at line 43 of file ad7280a.c.

#define AD7280A_AUX_ADC_UNDERVOLTAGE   0x12 /* D7 to D0, Read/write */

Definition at line 44 of file ad7280a.c.

#define AD7280A_BITS   12

Definition at line 95 of file ad7280a.c.

#define AD7280A_CB1_TIMER   0x15 /* D7 to D0, Read/write */

Definition at line 47 of file ad7280a.c.

#define AD7280A_CB2_TIMER   0x16 /* D7 to D0, Read/write */

Definition at line 48 of file ad7280a.c.

#define AD7280A_CB3_TIMER   0x17 /* D7 to D0, Read/write */

Definition at line 49 of file ad7280a.c.

#define AD7280A_CB4_TIMER   0x18 /* D7 to D0, Read/write */

Definition at line 50 of file ad7280a.c.

#define AD7280A_CB5_TIMER   0x19 /* D7 to D0, Read/write */

Definition at line 51 of file ad7280a.c.

#define AD7280A_CB6_TIMER   0x1A /* D7 to D0, Read/write */

Definition at line 52 of file ad7280a.c.

#define AD7280A_CELL_BALANCE   0x14 /* D7 to D0, Read/write */

Definition at line 46 of file ad7280a.c.

#define AD7280A_CELL_OVERVOLTAGE   0xF /* D7 to D0, Read/write */

Definition at line 41 of file ad7280a.c.

#define AD7280A_CELL_UNDERVOLTAGE   0x10 /* D7 to D0, Read/write */

Definition at line 42 of file ad7280a.c.

#define AD7280A_CELL_VOLTAGE_1   0x0 /* D11 to D0, Read only */

Definition at line 26 of file ad7280a.c.

#define AD7280A_CELL_VOLTAGE_2   0x1 /* D11 to D0, Read only */

Definition at line 27 of file ad7280a.c.

#define AD7280A_CELL_VOLTAGE_3   0x2 /* D11 to D0, Read only */

Definition at line 28 of file ad7280a.c.

#define AD7280A_CELL_VOLTAGE_4   0x3 /* D11 to D0, Read only */

Definition at line 29 of file ad7280a.c.

#define AD7280A_CELL_VOLTAGE_5   0x4 /* D11 to D0, Read only */

Definition at line 30 of file ad7280a.c.

#define AD7280A_CELL_VOLTAGE_6   0x5 /* D11 to D0, Read only */

Definition at line 31 of file ad7280a.c.

#define AD7280A_CELLS_PER_DEV   6

Definition at line 94 of file ad7280a.c.

#define AD7280A_CNVST_CONTROL   0x1D /* D7 to D0, Read/write */

Definition at line 55 of file ad7280a.c.

#define AD7280A_CONTROL_HB   0xD /* D15 to D8, Read/write */

Definition at line 39 of file ad7280a.c.

#define AD7280A_CONTROL_LB   0xE /* D7 to D0, Read/write */

Definition at line 40 of file ad7280a.c.

#define AD7280A_CTRL_HB_CONV_AVG (   x)    ((x) << 1)

Definition at line 72 of file ad7280a.c.

#define AD7280A_CTRL_HB_CONV_AVG_2   (1 << 1)

Definition at line 69 of file ad7280a.c.

#define AD7280A_CTRL_HB_CONV_AVG_4   (2 << 1)

Definition at line 70 of file ad7280a.c.

#define AD7280A_CTRL_HB_CONV_AVG_8   (3 << 1)

Definition at line 71 of file ad7280a.c.

#define AD7280A_CTRL_HB_CONV_AVG_DIS   (0 << 1)

Definition at line 68 of file ad7280a.c.

#define AD7280A_CTRL_HB_CONV_INPUT_6CELL   (2 << 6)

Definition at line 60 of file ad7280a.c.

#define AD7280A_CTRL_HB_CONV_INPUT_6CELL_AUX1_3_4   (1 << 6)

Definition at line 59 of file ad7280a.c.

#define AD7280A_CTRL_HB_CONV_INPUT_ALL   (0 << 6)

Definition at line 58 of file ad7280a.c.

#define AD7280A_CTRL_HB_CONV_INPUT_SELF_TEST   (3 << 6)

Definition at line 61 of file ad7280a.c.

#define AD7280A_CTRL_HB_CONV_RES_READ_6CELL   (2 << 4)

Definition at line 64 of file ad7280a.c.

#define AD7280A_CTRL_HB_CONV_RES_READ_6CELL_AUX1_3_4   (1 << 4)

Definition at line 63 of file ad7280a.c.

#define AD7280A_CTRL_HB_CONV_RES_READ_ALL   (0 << 4)

Definition at line 62 of file ad7280a.c.

#define AD7280A_CTRL_HB_CONV_RES_READ_NO   (3 << 4)

Definition at line 65 of file ad7280a.c.

#define AD7280A_CTRL_HB_CONV_START_CNVST   (0 << 3)

Definition at line 66 of file ad7280a.c.

#define AD7280A_CTRL_HB_CONV_START_CS   (1 << 3)

Definition at line 67 of file ad7280a.c.

#define AD7280A_CTRL_HB_PWRDN_SW   (1 << 0)

Definition at line 73 of file ad7280a.c.

#define AD7280A_CTRL_LB_ACQ_TIME (   x)    ((x) << 5)

Definition at line 80 of file ad7280a.c.

#define AD7280A_CTRL_LB_ACQ_TIME_1200ns   (2 << 5)

Definition at line 78 of file ad7280a.c.

#define AD7280A_CTRL_LB_ACQ_TIME_1600ns   (3 << 5)

Definition at line 79 of file ad7280a.c.

#define AD7280A_CTRL_LB_ACQ_TIME_400ns   (0 << 5)

Definition at line 76 of file ad7280a.c.

#define AD7280A_CTRL_LB_ACQ_TIME_800ns   (1 << 5)

Definition at line 77 of file ad7280a.c.

#define AD7280A_CTRL_LB_DAISY_CHAIN_RB_EN   (1 << 0)

Definition at line 85 of file ad7280a.c.

#define AD7280A_CTRL_LB_INC_DEV_ADDR   (1 << 1)

Definition at line 84 of file ad7280a.c.

#define AD7280A_CTRL_LB_LOCK_DEV_ADDR   (1 << 2)

Definition at line 83 of file ad7280a.c.

#define AD7280A_CTRL_LB_MUST_SET   (1 << 4)

Definition at line 81 of file ad7280a.c.

#define AD7280A_CTRL_LB_SWRST   (1 << 7)

Definition at line 75 of file ad7280a.c.

#define AD7280A_CTRL_LB_THERMISTOR_EN   (1 << 3)

Definition at line 82 of file ad7280a.c.

#define AD7280A_DEVADDR (   addr)
Value:
(((addr & 0x1) << 4) | ((addr & 0x2) << 3) | \
(addr & 0x4) | ((addr & 0x8) >> 3) | \
((addr & 0x10) >> 4))

Definition at line 102 of file ad7280a.c.

#define AD7280A_DEVADDR_ALL   0x1F

Definition at line 100 of file ad7280a.c.

#define AD7280A_DEVADDR_MASTER   0

Definition at line 99 of file ad7280a.c.

#define AD7280A_MAX_CHAIN   8

Definition at line 93 of file ad7280a.c.

#define AD7280A_MAX_SPI_CLK_Hz   700000 /* < 1MHz */

Definition at line 92 of file ad7280a.c.

#define AD7280A_NUM_CH
Value:
AD7280A_CELL_VOLTAGE_1 + 1)

Definition at line 96 of file ad7280a.c.

#define AD7280A_PD_TIMER   0x1B /* D7 to D0, Read/write */

Definition at line 53 of file ad7280a.c.

#define AD7280A_READ   0x1C /* D7 to D0, Read/write */

Definition at line 54 of file ad7280a.c.

#define AD7280A_READ_TXVAL   0xF800030A

Definition at line 111 of file ad7280a.c.

#define AD7280A_SELF_TEST   0xC /* D11 to D0, Read only */

Definition at line 38 of file ad7280a.c.

#define HIGHBIT   1 << (POLYNOM_ORDER - 1);

Definition at line 120 of file ad7280a.c.

#define POLYNOM   0x2F

Definition at line 118 of file ad7280a.c.

#define POLYNOM_ORDER   8

Definition at line 119 of file ad7280a.c.

Function Documentation

MODULE_AUTHOR ( "Michael Hennerich <[email protected]>"  )
MODULE_DESCRIPTION ( "Analog Devices AD7280A"  )
MODULE_DEVICE_TABLE ( spi  ,
ad7280_id   
)
MODULE_LICENSE ( "GPL v2 )
module_spi_driver ( ad7280_driver  )