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

Detailed Description

I2C Analog-to-Digital Converter device driver.

This driver works with ADS1013-5 and ADS1113-5.

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

Files

file  ads101x_params.h
 Default configuration for ADS101x/111x devices.
 
file  ads101x_regs.h
 Register definition for ADS101x/111x devices.
 
file  ads101x.h
 ADS101x/111x ADC device driver.
 

Data Structures

struct  ads101x_params
 ADS101x/111x params. More...
 
struct  ads101x_alert_params
 ADS101x/111x alert params. More...
 
struct  ads101x
 ADS101x/111x device descriptor. More...
 
struct  ads101x_alert
 ADS101x/111x alert device descriptor. More...
 

Macros

#define ADS101X_I2C_ADDRESS   (0x48)
 ADS101x/111x default address. More...
 

Typedefs

typedef struct ads101x_params ads101x_params_t
 ADS101x/111x params.
 
typedef struct ads101x_alert_params ads101x_alert_params_t
 ADS101x/111x alert params.
 
typedef struct ads101x ads101x_t
 ADS101x/111x device descriptor.
 
typedef void(* ads101x_alert_cb_t) (void *)
 ADS101x/111x alert callback.
 
typedef struct ads101x_alert ads101x_alert_t
 ADS101x/111x alert device descriptor.
 

Enumerations

enum  { ADS101X_OK = 0, ADS101X_NOI2C = -1, ADS101X_NODEV = -2, ADS101X_NODATA = -3 }
 Named return values. More...
 

Functions

int ads101x_init (ads101x_t *dev, const ads101x_params_t *params)
 Initialize an ADS101x/111x ADC device (ADC only) More...
 
int ads101x_alert_init (ads101x_alert_t *dev, const ads101x_alert_params_t *params)
 Initialize an ADS101x/111x alert device. More...
 
int ads101x_set_mux_gain (const ads101x_t *dev, uint8_t mux_gain)
 Set mux and gain. More...
 
int ads101x_read_raw (const ads101x_t *dev, int16_t *raw)
 Read a raw ADC value. More...
 
int ads101x_enable_alert (ads101x_alert_t *dev, ads101x_alert_cb_t cb, void *arg)
 Enable alert interrupt. More...
 
int ads101x_set_alert_parameters (const ads101x_alert_t *dev, int16_t low_limit, int16_t high_limit)
 Set the alert parameters. More...
 

Macro Definition Documentation

◆ ADS101X_I2C_ADDRESS

#define ADS101X_I2C_ADDRESS   (0x48)

ADS101x/111x default address.

Address pin tied to: GND (0x48), Vcc (0x49), SDA (0x50), SCL (0x51)

Definition at line 47 of file ads101x.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Named return values.

Enumerator
ADS101X_OK 

everything was fine

ADS101X_NOI2C 

I2C communication failed.

ADS101X_NODEV 

no ADS101X device found on the bus

ADS101X_NODATA 

no data available

Definition at line 53 of file ads101x.h.

Function Documentation

◆ ads101x_alert_init()

int ads101x_alert_init ( ads101x_alert_t dev,
const ads101x_alert_params_t params 
)

Initialize an ADS101x/111x alert device.

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

◆ ads101x_enable_alert()

int ads101x_enable_alert ( ads101x_alert_t dev,
ads101x_alert_cb_t  cb,
void *  arg 
)

Enable alert interrupt.

Alert settings have no effect on ADS1013 and ADS1113.

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

◆ ads101x_init()

int ads101x_init ( ads101x_t dev,
const ads101x_params_t params 
)

Initialize an ADS101x/111x ADC device (ADC only)

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

◆ ads101x_read_raw()

int ads101x_read_raw ( const ads101x_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

◆ ads101x_set_alert_parameters()

int ads101x_set_alert_parameters ( const ads101x_alert_t dev,
int16_t  low_limit,
int16_t  high_limit 
)

Set the alert parameters.

Alert settings have no effect on ADS1013 and ADS1113.

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

◆ ads101x_set_mux_gain()

int ads101x_set_mux_gain ( const ads101x_t dev,
uint8_t  mux_gain 
)

Set mux and gain.

Mux settings have no effect on ADS1013-4 and ADS1113-4. Gain settings have no effect on ADS1013 and ADS1113.

Parameters
[in]devdevice descriptor
[in]mux_gainmux and gain boolean values
Returns
zero on successful read, non zero on error