I2C Analog-to-Digital Converter device driver. More...

Detailed Description

I2C Analog-to-Digital Converter device driver.

This driver works with adc081c, adc101c and adc121c versions.

This driver provides [S]ensor [A]ctuator [U]ber [L]ayer capabilities.

Modules

 ADCXX1C driver compile configurations
 

Files

file  adcxx1c_params.h
 Default configuration for ADCXX1C devices.
 
file  adcxx1c_regs.h
 Register definition for ADCXX1C devices.
 
file  adcxx1c.h
 ADCXX1C ADC device driver.
 

Data Structures

struct  adcxx1c_params
 ADCxx1C params. More...
 
struct  adcxx1c
 ADCxx1C device descriptor. More...
 

Macros

#define ADCXX1C_I2C_ADDRESS   (0x54)
 ADCxx1C default address (ADCxx1C021 address)
 
#define ADCXX1C_RES_DEFAULT   (-1)
 ADC default resolution for device variants.
 

Typedefs

typedef struct adcxx1c_params adcxx1c_params_t
 ADCxx1C params.
 
typedef void(* adcxx1c_cb_t) (void *)
 ADCxx1C alert callback.
 
typedef struct adcxx1c adcxx1c_t
 ADCxx1C device descriptor.
 

Enumerations

enum  { ADCXX1C_RES_8BITS = 8, ADCXX1C_RES_10BITS = 10, ADCXX1C_RES_12BITS = 12 }
 ADC resolution. More...
 
enum  {
  ADCXX1C_CYCLE_DISABLED = 0, ADCXX1C_CYCLE_32, ADCXX1C_CYCLE_64, ADCXX1C_CYCLE_128,
  ADCXX1C_CYCLE_256, ADCXX1C_CYCLE_512, ADCXX1C_CYCLE_1024, ADCXX1C_CYCLE_2048
}
 Conversion interval configuration value. More...
 
enum  { ADCXX1C_OK = 0, ADCXX1C_NOI2C = -1, ADCXX1C_NODEV = -2, ADCXX1C_NODATA = -3 }
 Named return values. More...
 
enum  { ADCXX1C_ALERT_UNDER_RANGE = 1, ADCXX1C_ALERT_OVER_RANGE = 2 }
 Alert values. More...
 

Functions

int adcxx1c_init (adcxx1c_t *dev, const adcxx1c_params_t *params)
 Initialize an ADCxx1C ADC device. More...
 
int adcxx1c_read_raw (const adcxx1c_t *dev, int16_t *raw)
 Read a raw ADC value. More...
 
int adcxx1c_enable_alert (adcxx1c_t *dev, adcxx1c_cb_t cb, void *arg)
 Enable alert interrupt. More...
 
int adcxx1c_set_alert_parameters (const adcxx1c_t *dev, int16_t low_limit, int16_t high_limit, int16_t hysteresis)
 Set the alert parameters. More...
 
int adcxx1c_get_and_clear_alert (const adcxx1c_t *dev)
 Get alert source and clear it. More...
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

ADC resolution.

Enumerator
ADCXX1C_RES_8BITS 

8 bits resolution (ADC081C family)

ADCXX1C_RES_10BITS 

10 bits resolution (ADC101C family)

ADCXX1C_RES_12BITS 

12 bits resolution (ADC121C family)

Definition at line 46 of file adcxx1c.h.

◆ anonymous enum

anonymous enum

Conversion interval configuration value.

Enumerator
ADCXX1C_CYCLE_DISABLED 

No cycle conversion.

ADCXX1C_CYCLE_32 

Conversion cycle = Tconvert x 32.

ADCXX1C_CYCLE_64 

Conversion cycle = Tconvert x 64.

ADCXX1C_CYCLE_128 

Conversion cycle = Tconvert x 128.

ADCXX1C_CYCLE_256 

Conversion cycle = Tconvert x 256.

ADCXX1C_CYCLE_512 

Conversion cycle = Tconvert x 512.

ADCXX1C_CYCLE_1024 

Conversion cycle = Tconvert x 1024.

ADCXX1C_CYCLE_2048 

Conversion cycle = Tconvert x 2048.

Definition at line 69 of file adcxx1c.h.

◆ anonymous enum

anonymous enum

Named return values.

Enumerator
ADCXX1C_OK 

everything was fine

ADCXX1C_NOI2C 

I2C communication failed.

ADCXX1C_NODEV 

no ADCXX1C device found on the bus

ADCXX1C_NODATA 

no data available

Definition at line 83 of file adcxx1c.h.

◆ anonymous enum

anonymous enum

Alert values.

Enumerator
ADCXX1C_ALERT_UNDER_RANGE 

Measured voltage fell below Vlow.

ADCXX1C_ALERT_OVER_RANGE 

Measured voltage exceeded Vhigh.

Definition at line 93 of file adcxx1c.h.

Function Documentation

◆ adcxx1c_enable_alert()

int adcxx1c_enable_alert ( adcxx1c_t dev,
adcxx1c_cb_t  cb,
void *  arg 
)

Enable alert interrupt.

Parameters
[in]devdevice descriptor
[in]cbcallback called when the alert fires
[in]argcallback argument
Returns
zero on success, non zero on error

◆ adcxx1c_get_and_clear_alert()

int adcxx1c_get_and_clear_alert ( const adcxx1c_t dev)

Get alert source and clear it.

Parameters
[in,out]devdevice descriptor
Returns
a combination of ADCXX1C_ALERT_OVER_RANGE and ADCXX1C_ALERT_UNDER_RANGE on success
negative error code on error

◆ adcxx1c_init()

int adcxx1c_init ( adcxx1c_t dev,
const adcxx1c_params_t params 
)

Initialize an ADCxx1C ADC device.

Parameters
[in,out]devdevice descriptor
[in]paramsdevice configuration
Returns
zero on successful initialization, non zero on error

◆ adcxx1c_read_raw()

int adcxx1c_read_raw ( const adcxx1c_t dev,
int16_t *  raw 
)

Read a raw ADC value.

Parameters
[in]devdevice descriptor
[out]rawread value
Returns
zero on successful read, non zero on error

◆ adcxx1c_set_alert_parameters()

int adcxx1c_set_alert_parameters ( const adcxx1c_t dev,
int16_t  low_limit,
int16_t  high_limit,
int16_t  hysteresis 
)

Set the alert parameters.

Parameters
[in,out]devdevice descriptor
[in]low_limitalert low limit
[in]high_limitalert high limit
[in]hysteresisalert hysteresis
Returns
zero on success, non zero on error