ads101x.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 OTA keys S.A.
3  * 2018 Acutam Automation, LLC
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser
6  * General Public License v2.1. See the file LICENSE in the top level
7  * directory for more details.
8  */
9 
31 #ifndef ADS101X_H
32 #define ADS101X_H
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 #include "periph/i2c.h"
39 #include "periph/gpio.h"
40 
52 #ifndef CONFIG_ADS101X_I2C_ADDRESS
53 #define CONFIG_ADS101X_I2C_ADDRESS (0x48)
54 #endif
55 
60 enum {
61  ADS101X_OK = 0,
65 };
66 
70 typedef struct ads101x_params {
72  uint8_t addr;
73  uint8_t mux_gain;
75 
79 typedef struct ads101x_alert_params {
81  uint8_t addr;
82  gpio_t alert_pin;
83  int16_t low_limit;
84  int16_t high_limit;
86 
90 typedef struct ads101x {
92 } ads101x_t;
93 
97 typedef void (*ads101x_alert_cb_t)(void *);
98 
102 typedef struct ads101x_alert {
105  void *arg;
107 
116 int ads101x_init(ads101x_t *dev, const ads101x_params_t *params);
117 
127  const ads101x_alert_params_t *params);
128 
140 int ads101x_set_mux_gain(const ads101x_t *dev, uint8_t mux_gain);
141 
150 int ads101x_read_raw(const ads101x_t *dev, int16_t *raw);
151 
164  ads101x_alert_cb_t cb, void *arg);
165 
178  int16_t low_limit, int16_t high_limit);
179 
180 #ifdef __cplusplus
181 }
182 #endif
183 
184 #endif /* ADS101X_H */
185 
ads101x_params::addr
uint8_t addr
i2c address
Definition: ads101x.h:72
ads101x_params::mux_gain
uint8_t mux_gain
Mux and gain boolean settings.
Definition: ads101x.h:73
ads101x_alert_params::alert_pin
gpio_t alert_pin
alert pin (GPIO_UNDEF if not connected)
Definition: ads101x.h:82
ads101x_alert_params_t
struct ads101x_alert_params ads101x_alert_params_t
ADS101x/111x alert params.
ads101x_t
struct ads101x ads101x_t
ADS101x/111x device descriptor.
ads101x
ADS101x/111x device descriptor.
Definition: ads101x.h:90
ads101x_params
ADS101x/111x params.
Definition: ads101x.h:70
ads101x_alert_t
struct ads101x_alert ads101x_alert_t
ADS101x/111x alert device descriptor.
ADS101X_NODATA
@ ADS101X_NODATA
no data available
Definition: ads101x.h:64
i2c_t
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:151
ads101x_alert_init
int ads101x_alert_init(ads101x_alert_t *dev, const ads101x_alert_params_t *params)
Initialize an ADS101x/111x alert device.
ads101x_set_mux_gain
int ads101x_set_mux_gain(const ads101x_t *dev, uint8_t mux_gain)
Set mux and gain.
ads101x_alert::cb
ads101x_alert_cb_t cb
alert callback
Definition: ads101x.h:104
ads101x_enable_alert
int ads101x_enable_alert(ads101x_alert_t *dev, ads101x_alert_cb_t cb, void *arg)
Enable alert interrupt.
ADS101X_NOI2C
@ ADS101X_NOI2C
I2C communication failed.
Definition: ads101x.h:62
ads101x_alert::params
ads101x_alert_params_t params
device driver configuration
Definition: ads101x.h:103
ads101x_init
int ads101x_init(ads101x_t *dev, const ads101x_params_t *params)
Initialize an ADS101x/111x ADC device (ADC only)
ads101x_params::i2c
i2c_t i2c
i2c device
Definition: ads101x.h:71
ads101x_alert::arg
void * arg
alert callback param
Definition: ads101x.h:105
ads101x_alert
ADS101x/111x alert device descriptor.
Definition: ads101x.h:102
ads101x_alert_params::addr
uint8_t addr
i2c address
Definition: ads101x.h:81
ads101x_params_t
struct ads101x_params ads101x_params_t
ADS101x/111x params.
ads101x_alert_params::high_limit
int16_t high_limit
alert high value
Definition: ads101x.h:84
ADS101X_NODEV
@ ADS101X_NODEV
no ADS101X device found on the bus
Definition: ads101x.h:63
ads101x_alert_params
ADS101x/111x alert params.
Definition: ads101x.h:79
ads101x::params
ads101x_params_t params
device driver configuration
Definition: ads101x.h:91
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.
gpio.h
Low-level GPIO peripheral driver interface definitions.
ads101x_alert_cb_t
void(* ads101x_alert_cb_t)(void *)
ADS101x/111x alert callback.
Definition: ads101x.h:97
i2c.h
Low-level I2C peripheral driver interface definition.
ads101x_alert_params::low_limit
int16_t low_limit
alert low value
Definition: ads101x.h:83
ads101x_alert_params::i2c
i2c_t i2c
i2c device
Definition: ads101x.h:80
ads101x_read_raw
int ads101x_read_raw(const ads101x_t *dev, int16_t *raw)
Read a raw ADC value.
ADS101X_OK
@ ADS101X_OK
everything was fine
Definition: ads101x.h:61