LibDriver ADS1110
Loading...
Searching...
No Matches
driver_ads1110_shot.c
Go to the documentation of this file.
1
36
37#include "driver_ads1110_shot.h"
38
39static ads1110_handle_t gs_handle;
40
50{
51 uint8_t res;
52
53 /* link interface function */
61
62 /* set addr pin */
63 res = ads1110_set_addr_pin(&gs_handle, addr);
64 if (res != 0)
65 {
66 ads1110_interface_debug_print("ads1110: set addr failed.\n");
67
68 return 1;
69 }
70
71 /* ads1110 init */
72 res = ads1110_init(&gs_handle);
73 if (res != 0)
74 {
75 ads1110_interface_debug_print("ads1110: init failed.\n");
76
77 return 1;
78 }
79
80 /* set default rate */
82 if (res != 0)
83 {
84 ads1110_interface_debug_print("ads1110: set rate failed.\n");
85 (void)ads1110_deinit(&gs_handle);
86
87 return 1;
88 }
89
90 /* set default gain */
92 if (res != 0)
93 {
94 ads1110_interface_debug_print("ads1110: set compare failed.\n");
95 (void)ads1110_deinit(&gs_handle);
96
97 return 1;
98 }
99
100 return 0;
101}
102
111uint8_t ads1110_shot_read(float *s)
112{
113 int16_t raw;
114
115 /* read data */
116 if (ads1110_single_read(&gs_handle, (int16_t *)&raw, s) != 0)
117 {
118 return 1;
119 }
120
121 return 0;
122}
123
132{
133 uint8_t res;
134
135 /* deinit ads1110 */
136 res = ads1110_deinit(&gs_handle);
137 if (res != 0)
138 {
139 return 1;
140 }
141
142 return 0;
143}
driver ads1110 shot 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
struct ads1110_handle_s ads1110_handle_t
ads1110 handle structure definition
uint8_t ads1110_init(ads1110_handle_t *handle)
initialize the chip
ads1110_address_t
ads1110 address enumeration definition
uint8_t ads1110_set_gain(ads1110_handle_t *handle, ads1110_gain_t gain)
set adc gain
#define ADS1110_SHOT_DEFAULT_RATE
ads1110 shot example default definition
uint8_t ads1110_shot_init(ads1110_address_t addr)
shot example init
uint8_t ads1110_shot_deinit(void)
shot example deinit
#define ADS1110_SHOT_DEFAULT_GAIN
uint8_t ads1110_shot_read(float *s)
shot example read
uint8_t ads1110_interface_iic_read_cmd(uint8_t addr, uint8_t *buf, uint16_t len)
interface iic bus read command
uint8_t ads1110_interface_iic_init(void)
interface iic bus init
uint8_t ads1110_interface_iic_deinit(void)
interface iic bus deinit
void ads1110_interface_delay_ms(uint32_t ms)
interface delay ms
void ads1110_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t ads1110_interface_write_cmd(uint8_t addr, uint8_t *buf, uint16_t len)
interface iic bus write command