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 
46 #ifndef ADS101X_I2C_ADDRESS
47 #define ADS101X_I2C_ADDRESS (0x48)
48 #endif
49 
53 enum {
54  ADS101X_OK = 0,
58 };
59 
63 typedef struct ads101x_params {
65  uint8_t addr;
66  uint8_t mux_gain;
68 
72 typedef struct ads101x_alert_params {
74  uint8_t addr;
75  gpio_t alert_pin;
76  int16_t low_limit;
77  int16_t high_limit;
79 
83 typedef struct ads101x {
85 } ads101x_t;
86 
90 typedef void (*ads101x_alert_cb_t)(void *);
91 
95 typedef struct ads101x_alert {
98  void *arg;
100 
109 int ads101x_init(ads101x_t *dev, const ads101x_params_t *params);
110 
120  const ads101x_alert_params_t *params);
121 
133 int ads101x_set_mux_gain(const ads101x_t *dev, uint8_t mux_gain);
134 
143 int ads101x_read_raw(const ads101x_t *dev, int16_t *raw);
144 
157  ads101x_alert_cb_t cb, void *arg);
158 
171  int16_t low_limit, int16_t high_limit);
172 
173 #ifdef __cplusplus
174 }
175 #endif
176 
177 #endif /* ADS101X_H */
178 
i2c_t i2c
i2c device
Definition: ads101x.h:73
gpio_t alert_pin
alert pin (GPIO_UNDEF if not connected)
Definition: ads101x.h:75
int ads101x_init(ads101x_t *dev, const ads101x_params_t *params)
Initialize an ADS101x/111x ADC device (ADC only)
no ADS101X device found on the bus
Definition: ads101x.h:56
int ads101x_enable_alert(ads101x_alert_t *dev, ads101x_alert_cb_t cb, void *arg)
Enable alert interrupt.
Low-level GPIO peripheral driver interface definitions.
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:157
ADS101x/111x alert device descriptor.
Definition: ads101x.h:95
I2C communication failed.
Definition: ads101x.h:55
struct ads101x_alert ads101x_alert_t
ADS101x/111x alert device descriptor.
ADS101x/111x device descriptor.
Definition: ads101x.h:83
uint8_t addr
i2c address
Definition: ads101x.h:65
struct ads101x ads101x_t
ADS101x/111x device descriptor.
uint8_t addr
i2c address
Definition: ads101x.h:74
ads101x_params_t params
device driver configuration
Definition: ads101x.h:84
ads101x_alert_params_t params
device driver configuration
Definition: ads101x.h:96
int ads101x_set_mux_gain(const ads101x_t *dev, uint8_t mux_gain)
Set mux and gain.
void * arg
alert callback param
Definition: ads101x.h:98
ADS101x/111x params.
Definition: ads101x.h:63
uint8_t mux_gain
Mux and gain boolean settings.
Definition: ads101x.h:66
int ads101x_set_alert_parameters(const ads101x_alert_t *dev, int16_t low_limit, int16_t high_limit)
Set the alert parameters.
void(* ads101x_alert_cb_t)(void *)
ADS101x/111x alert callback.
Definition: ads101x.h:90
int ads101x_read_raw(const ads101x_t *dev, int16_t *raw)
Read a raw ADC value.
int16_t high_limit
alert high value
Definition: ads101x.h:77
ADS101x/111x alert params.
Definition: ads101x.h:72
struct ads101x_alert_params ads101x_alert_params_t
ADS101x/111x alert params.
ads101x_alert_cb_t cb
alert callback
Definition: ads101x.h:97
int16_t low_limit
alert low value
Definition: ads101x.h:76
everything was fine
Definition: ads101x.h:54
struct ads101x_params ads101x_params_t
ADS101x/111x params.
i2c_t i2c
i2c device
Definition: ads101x.h:64
int ads101x_alert_init(ads101x_alert_t *dev, const ads101x_alert_params_t *params)
Initialize an ADS101x/111x alert device.
no data available
Definition: ads101x.h:57
Low-level I2C peripheral driver interface definition.