LibDriver ADS1110
Loading...
Searching...
No Matches
driver_ads1110.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_ADS1110_H
38#define DRIVER_ADS1110_H
39
40#include <stdio.h>
41#include <stdint.h>
42#include <string.h>
43
44#ifdef __cplusplus
45extern "C"{
46#endif
47
53
58
73
77typedef enum
78{
84
95
99typedef struct ads1110_handle_s
100{
101 uint8_t iic_addr;
102 uint8_t (*iic_init)(void);
103 uint8_t (*iic_deinit)(void);
104 uint8_t (*iic_read_cmd)(uint8_t addr, uint8_t *buf, uint16_t len);
105 uint8_t (*iic_write_cmd)(uint8_t addr, uint8_t *buf, uint16_t len);
106 void (*delay_ms)(uint32_t ms);
107 void (*debug_print)(const char *const fmt, ...);
108 uint8_t inited;
110
126
130
137
144#define DRIVER_ADS1110_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
145
152#define DRIVER_ADS1110_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
153
160#define DRIVER_ADS1110_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
161
168#define DRIVER_ADS1110_LINK_IIC_READ_COMMAND(HANDLE, FUC) (HANDLE)->iic_read_cmd = FUC
169
176#define DRIVER_ADS1110_LINK_IIC_WRITE_COMMAND(HANDLE, FUC) (HANDLE)->iic_write_cmd = FUC
177
184#define DRIVER_ADS1110_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
185
192#define DRIVER_ADS1110_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
193
197
204
213uint8_t ads1110_info(ads1110_info_t *info);
214
226
238
249uint8_t ads1110_init(ads1110_handle_t *handle);
250
262uint8_t ads1110_deinit(ads1110_handle_t *handle);
263
276uint8_t ads1110_single_read(ads1110_handle_t *handle, int16_t *raw, float *v);
277
291uint8_t ads1110_continuous_read(ads1110_handle_t *handle,int16_t *raw, float *v);
292
304
316
329
341uint8_t ads1110_get_rate(ads1110_handle_t *handle, ads1110_rate_t *rate);
342
355
367uint8_t ads1110_get_gain(ads1110_handle_t *handle, ads1110_gain_t *gain);
368
372
379
392uint8_t ads1110_set_reg(ads1110_handle_t *handle, uint8_t *buf, uint16_t len);
393
406uint8_t ads1110_get_reg(ads1110_handle_t *handle, uint8_t *buf, uint16_t len);
407
411
415
416#ifdef __cplusplus
417}
418#endif
419
420#endif
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
@ ADS1110_RATE_15SPS
@ ADS1110_RATE_60SPS
@ ADS1110_RATE_240SPS
@ ADS1110_RATE_30SPS
@ ADS1110_ADDRESS7
@ ADS1110_ADDRESS1
@ ADS1110_ADDRESS6
@ ADS1110_ADDRESS2
@ ADS1110_ADDRESS5
@ ADS1110_ADDRESS4
@ ADS1110_ADDRESS0
@ ADS1110_ADDRESS3
@ ADS1110_GAIN_8
@ ADS1110_GAIN_1
@ ADS1110_GAIN_2
@ ADS1110_GAIN_4
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
ads1110 handle structure definition
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)
ads1110 information structure definition
uint32_t driver_version
char manufacturer_name[32]