Loading...
Searching...
No Matches
ads1x1x.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
10#pragma once
11
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37#include "periph/i2c.h"
38#include "periph/gpio.h"
39
45
51#ifndef CONFIG_ADS1X1X_I2C_ADDRESS
52#define CONFIG_ADS1X1X_I2C_ADDRESS (0x48)
53#endif
55
59enum {
64};
65
69typedef struct ads1x1x_params {
71 uint8_t addr;
72 uint8_t mux_gain;
74
85
92
96typedef void (*ads1x1x_alert_cb_t)(void *);
97
106
115int ads1x1x_init(ads1x1x_t *dev, const ads1x1x_params_t *params);
116
126 const ads1x1x_alert_params_t *params);
127
139int ads1x1x_set_mux_gain(const ads1x1x_t *dev, uint8_t mux_gain);
140
149int ads1x1x_read_raw(const ads1x1x_t *dev, int16_t *raw);
150
163 ads1x1x_alert_cb_t cb, void *arg);
164
177 int16_t low_limit, int16_t high_limit);
178
179#ifdef __cplusplus
180}
181#endif
182
Low-level GPIO peripheral driver interface definitions.
int ads1x1x_init(ads1x1x_t *dev, const ads1x1x_params_t *params)
Initialize an ADS101x/111x ADC device (ADC only)
struct ads1x1x_params ads1x1x_params_t
ADS101x/111x params.
struct ads1x1x ads1x1x_t
ADS101x/111x device descriptor.
struct ads1x1x_alert_params ads1x1x_alert_params_t
ADS101x/111x alert params.
int ads1x1x_enable_alert(ads1x1x_alert_t *dev, ads1x1x_alert_cb_t cb, void *arg)
Enable alert interrupt.
int ads1x1x_read_raw(const ads1x1x_t *dev, int16_t *raw)
Read a raw ADC value.
struct ads1x1x_alert ads1x1x_alert_t
ADS101x/111x alert device descriptor.
void(* ads1x1x_alert_cb_t)(void *)
ADS101x/111x alert callback.
Definition ads1x1x.h:96
int ads1x1x_set_alert_parameters(const ads1x1x_alert_t *dev, int16_t low_limit, int16_t high_limit)
Set the alert parameters.
int ads1x1x_alert_init(ads1x1x_alert_t *dev, const ads1x1x_alert_params_t *params)
Initialize an ADS101x/111x alert device.
int ads1x1x_set_mux_gain(const ads1x1x_t *dev, uint8_t mux_gain)
Set mux and gain.
@ ADS1X1X_NODATA
no data available
Definition ads1x1x.h:63
@ ADS1X1X_NOI2C
I2C communication failed.
Definition ads1x1x.h:61
@ ADS1X1X_OK
everything was fine
Definition ads1x1x.h:60
@ ADS1X1X_NODEV
no ADS1X1X device found on the bus
Definition ads1x1x.h:62
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:135
Low-level I2C peripheral driver interface definition.
ADS101x/111x alert params.
Definition ads1x1x.h:78
int16_t low_limit
alert low value
Definition ads1x1x.h:82
int16_t high_limit
alert high value
Definition ads1x1x.h:83
uint8_t addr
i2c address
Definition ads1x1x.h:80
gpio_t alert_pin
alert pin (GPIO_UNDEF if not connected)
Definition ads1x1x.h:81
i2c_t i2c
i2c device
Definition ads1x1x.h:79
ADS101x/111x alert device descriptor.
Definition ads1x1x.h:101
void * arg
alert callback param
Definition ads1x1x.h:104
ads1x1x_alert_params_t params
device driver configuration
Definition ads1x1x.h:102
ads1x1x_alert_cb_t cb
alert callback
Definition ads1x1x.h:103
ADS101x/111x params.
Definition ads1x1x.h:69
uint8_t addr
i2c address
Definition ads1x1x.h:71
i2c_t i2c
i2c device
Definition ads1x1x.h:70
uint8_t mux_gain
Mux and gain boolean settings.
Definition ads1x1x.h:72
ADS101x/111x device descriptor.
Definition ads1x1x.h:89
ads1x1x_params_t params
device driver configuration
Definition ads1x1x.h:90