42#define CHIP_NAME "Texas Instruments ADS1110"
43#define MANUFACTURER_NAME "Texas Instruments"
44#define SUPPLY_VOLTAGE_MIN 2.7f
45#define SUPPLY_VOLTAGE_MAX 5.5f
46#define MAX_CURRENT 0.35f
47#define TEMPERATURE_MIN -40.0f
48#define TEMPERATURE_MAX 85.0f
49#define DRIVER_VERSION 1000
61static uint8_t a_ads1110_iic_read(
ads1110_handle_t *handle, uint8_t *buf, uint16_t len)
81static uint8_t a_ads1110_iic_write(
ads1110_handle_t *handle, uint8_t *buf, uint16_t len)
116 handle->
debug_print(
"ads1110: iic_init is null.\n");
122 handle->
debug_print(
"ads1110: iic_deinit is null.\n");
128 handle->
debug_print(
"ads1110: iic_read_cmd is null.\n");
134 handle->
debug_print(
"ads1110: iic_write_cmd is null.\n");
140 handle->
debug_print(
"ads1110: delay_ms is null.\n");
147 handle->
debug_print(
"ads1110: iic init failed.\n");
152 res = a_ads1110_iic_read(handle, buf, 3);
162 res = a_ads1110_iic_write(handle, &buf[2], 1);
200 res = a_ads1110_iic_read(handle, buf, 3);
203 handle->
debug_print(
"ads1110: power down failed.\n");
209 res = a_ads1110_iic_write(handle, &buf[2], 1);
212 handle->
debug_print(
"ads1110: power down failed.\n");
219 handle->
debug_print(
"ads1110: iic deinit failed.\n");
253 res = a_ads1110_iic_read(handle, buf, 3);
256 handle->
debug_print(
"ads1110: read config failed.\n");
262 res = a_ads1110_iic_write(handle, &buf[2], 1);
265 handle->
debug_print(
"ads1110: write config failed.\n");
298 res = a_ads1110_iic_read(handle, buf, 3);
301 handle->
debug_print(
"ads1110: read config failed.\n");
335 res = a_ads1110_iic_read(handle, buf, 3);
338 handle->
debug_print(
"ads1110: read config failed.\n");
344 res = a_ads1110_iic_write(handle, &buf[2], 1);
347 handle->
debug_print(
"ads1110: write config failed.\n");
380 res = a_ads1110_iic_read(handle, buf, 3);
383 handle->
debug_print(
"ads1110: read config failed.\n");
409 handle->
iic_addr = (uint8_t)(addr_pin);
466 res = a_ads1110_iic_read(handle, buf, 3);
469 handle->
debug_print(
"ads1110: read config failed.\n");
476 res = a_ads1110_iic_write(handle, &buf[2], 1);
479 handle->
debug_print(
"ads1110: write config failed.\n");
487 res = a_ads1110_iic_read(handle, buf, 3);
490 handle->
debug_print(
"ads1110: read config failed.\n");
494 if ((buf[2] & (1 << 7)) == 0)
506 *raw = (int16_t)(((uint16_t)buf[0] << 8) | buf[1]);
507 rate = (buf[2] >> 2) & 0x03;
527 *v = (float)(*raw) / (2048.0f * (float)(n)) * 2.048f;
531 *v = (float)(*raw) / (8192.0f * (float)(n)) * 2.048f;
535 *v = (float)(*raw) / (16384.0f * (float)(n)) * 2.048f;
539 *v = (float)(*raw) / (32768.0f * (float)(n)) * 2.048f;
575 res = a_ads1110_iic_read(handle, buf, 3);
578 handle->
debug_print(
"ads1110: read config failed.\n");
582 *raw = (int16_t)(((uint16_t)buf[0] << 8) | buf[1]);
583 rate = (buf[2] >> 2) & 0x03;
603 *v = (float)(*raw) / (2048.0f * (float)(n)) * 2.048f;
607 *v = (float)(*raw) / (8192.0f * (float)(n)) * 2.048f;
611 *v = (float)(*raw) / (16384.0f * (float)(n)) * 2.048f;
615 *v = (float)(*raw) / (32768.0f * (float)(n)) * 2.048f;
645 res = a_ads1110_iic_read(handle, buf, 3);
648 handle->
debug_print(
"ads1110: read config failed.\n");
653 res = a_ads1110_iic_write(handle, &buf[2], 1);
656 handle->
debug_print(
"ads1110: write config failed.\n");
688 res = a_ads1110_iic_read(handle, buf, 3);
691 handle->
debug_print(
"ads1110: read config failed.\n");
697 res = a_ads1110_iic_write(handle, &buf[2], 1);
700 handle->
debug_print(
"ads1110: write config failed.\n");
731 return a_ads1110_iic_write(handle, buf, len);
757 return a_ads1110_iic_read(handle, buf, len);
#define SUPPLY_VOLTAGE_MAX
#define MANUFACTURER_NAME
#define SUPPLY_VOLTAGE_MIN
#define CHIP_NAME
chip information definition
driver ads1110 header file
uint8_t ads1110_set_rate(ads1110_handle_t *handle, ads1110_rate_t rate)
set the sample rate
uint8_t ads1110_single_read(ads1110_handle_t *handle, int16_t *raw, float *v)
read data from the chip once
uint8_t ads1110_deinit(ads1110_handle_t *handle)
close the chip
uint8_t ads1110_set_addr_pin(ads1110_handle_t *handle, ads1110_address_t addr_pin)
set the iic address pin
uint8_t ads1110_info(ads1110_info_t *info)
get chip's information
struct ads1110_handle_s ads1110_handle_t
ads1110 handle structure definition
uint8_t ads1110_stop_continuous_read(ads1110_handle_t *handle)
stop the chip reading
ads1110_rate_t
ads1110 rate enumeration definition
uint8_t ads1110_get_gain(ads1110_handle_t *handle, ads1110_gain_t *gain)
get adc gain
uint8_t ads1110_get_rate(ads1110_handle_t *handle, ads1110_rate_t *rate)
get the sample rate
uint8_t ads1110_init(ads1110_handle_t *handle)
initialize the chip
uint8_t ads1110_continuous_read(ads1110_handle_t *handle, int16_t *raw, float *v)
read data from the chip continuously
ads1110_address_t
ads1110 address enumeration definition
uint8_t ads1110_get_addr_pin(ads1110_handle_t *handle, ads1110_address_t *addr_pin)
get the iic address pin
struct ads1110_info_s ads1110_info_t
ads1110 information structure definition
uint8_t ads1110_set_gain(ads1110_handle_t *handle, ads1110_gain_t gain)
set adc gain
uint8_t ads1110_start_continuous_read(ads1110_handle_t *handle)
start the chip reading
ads1110_gain_t
ads1110 gain enumeration definition
uint8_t ads1110_get_reg(ads1110_handle_t *handle, uint8_t *buf, uint16_t len)
get the chip register
uint8_t ads1110_set_reg(ads1110_handle_t *handle, uint8_t *buf, uint16_t len)
set the chip register
void(* delay_ms)(uint32_t ms)
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
uint8_t(* iic_read_cmd)(uint8_t addr, uint8_t *buf, uint16_t len)
uint8_t(* iic_deinit)(void)
uint8_t(* iic_write_cmd)(uint8_t addr, uint8_t *buf, uint16_t len)
float supply_voltage_max_v
char manufacturer_name[32]
float supply_voltage_min_v