34#ifndef TI_ADS1113_ADS1115_H
35#define TI_ADS1113_ADS1115_H
52 TI_ADS_MUX_ApA0_AnA1 = 0,
53 TI_ADS_MUX_ApA0_AnA3 = 1,
54 TI_ADS_MUX_ApA1_AnA3 = 2,
55 TI_ADS_MUX_ApA2_AnA3 = 3,
56 TI_ADS_MUX_ApA0_AnGND = 4,
57 TI_ADS_MUX_ApA1_AnGND = 5,
58 TI_ADS_MUX_ApA2_AnGND = 6,
59 TI_ADS_MUX_ApA3_AnGND = 7
66 TI_ADS_PGA_FS_6_144V = 0,
67 TI_ADS_PGA_FS_4_096V = 1,
68 TI_ADS_PGA_FS_2_048V = 2,
69 TI_ADS_PGA_FS_1_024V = 3,
70 TI_ADS_PGA_FS_0_512V = 4,
71 TI_ADS_PGA_FS_0_256V = 5,
72 TI_ADS_PGA_FS_0_256V_2 = 6,
73 TI_ADS_PGA_FS_0_256V_3 = 7,
80 TI_ADS_MODE_CONTINUOUS = 0,
81 TI_ADS_MODE_SINGLE_SHOT = 1,
88 TI_ADS_DATARATE_8SPS = 0,
89 TI_ADS_DATARATE_16SPS = 1,
90 TI_ADS_DATARATE_32SPS = 2,
91 TI_ADS_DATARATE_64SPS = 3,
92 TI_ADS_DATARATE_128SPS = 4,
93 TI_ADS_DATARATE_250SPS = 5,
94 TI_ADS_DATARATE_475SPS = 6,
95 TI_ADS_DATARATE_860SPS = 7,
96} ti_ads_adc_data_rate;
103#define TI_ADS_COMP_MODE_HYSTERESIS (0 << 4)
104#define TI_ADS_COMP_MODE_WINDOW (1 << 4)
105#define TI_ADS_COMP_POL_ACTIVE_LOW (0 << 3)
106#define TI_ADS_COMP_POL_ACTIVE_HIGH (1 << 3)
107#define TI_ADS_COMP_LAT_NON_LATCHING (0 << 2)
108#define TI_ADS_COMP_LAT_LATCHING (1 << 2)
109#define TI_ADS_COMP_QUE_DISABLE_COMP (3 << 0)
110#define TI_ADS_COMP_QUE_AFTER_4 (2 << 0)
111#define TI_ADS_COMP_QUE_AFTER_2 (1 << 0)
112#define TI_ADS_COMP_QUE_AFTER_1 (0 << 0)
122#define TI_ADS_ADC_GET_CONVERSION (I2C_DEV_IO_CONTROL + 0)
123#define TI_ADS_ADC_SET_MUX (I2C_DEV_IO_CONTROL + 1)
124#define TI_ADS_ADC_SET_PGA (I2C_DEV_IO_CONTROL + 2)
125#define TI_ADS_ADC_SET_MODE (I2C_DEV_IO_CONTROL + 3)
126#define TI_ADS_ADC_SET_DATA_RATE (I2C_DEV_IO_CONTROL + 4)
127#define TI_ADS_ADC_SET_COMP (I2C_DEV_IO_CONTROL + 5)
128#define TI_ADS_ADC_SET_LO_THRESH (I2C_DEV_IO_CONTROL + 6)
129#define TI_ADS_ADC_SET_HI_THRESH (I2C_DEV_IO_CONTROL + 7)
130#define TI_ADS_ADC_SET_CONV_WAIT (I2C_DEV_IO_CONTROL + 8)
135int i2c_dev_register_ti_ads_adc(
const char* bus_path,
136 const char* dev_path,
145ti_ads_adc_convert(
int fd, uint16_t* sample)
147 return ioctl(fd, TI_ADS_ADC_GET_CONVERSION, sample);
154ti_ads_adc_set_mux(
int fd, ti_ads_adc_mux mux)
156 return ioctl(fd, TI_ADS_ADC_SET_MUX, (
void *)(uintptr_t) mux);
163ti_ads_adc_set_pga(
int fd, ti_ads_adc_pga pga)
165 return ioctl(fd, TI_ADS_ADC_SET_PGA, (
void *)(uintptr_t) pga);
172ti_ads_adc_set_mode(
int fd, ti_ads_adc_mode mode)
174 return ioctl(fd, TI_ADS_ADC_SET_MODE, (
void *)(uintptr_t) mode);
181ti_ads_adc_set_data_rate(
int fd, ti_ads_adc_data_rate rate)
183 return ioctl(fd, TI_ADS_ADC_SET_DATA_RATE, (
void *)(uintptr_t) rate);
190ti_ads_adc_set_comparator(
int fd, uint16_t comp)
192 return ioctl(fd, TI_ADS_ADC_SET_COMP, (
void *)(uintptr_t) comp);
199ti_ads_adc_set_low_threshold(
int fd, uint16_t level)
201 return ioctl(fd, TI_ADS_ADC_SET_LO_THRESH, (
void *)(uintptr_t) level);
208ti_ads_adc_set_high_threshold(
int fd, uint16_t level)
210 return ioctl(fd, TI_ADS_ADC_SET_HI_THRESH, (
void *)(uintptr_t) level);
217ti_ads_adc_set_conversion_poll_wait(
int fd, uint32_t micro_seconds)
219 return ioctl(fd, TI_ADS_ADC_SET_CONV_WAIT, (
void *)(uintptr_t) micro_seconds);
Inter-Integrated Circuit (I2C) Driver API.