LibDriver AD7705
Loading...
Searching...
No Matches
driver_ad7705.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_AD7705_H
38#define DRIVER_AD7705_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
62typedef enum
63{
67
78
89
104
113
128
132typedef struct ad7705_handle_s
133{
134 uint8_t (*gpio_reset_init)(void);
135 uint8_t (*gpio_reset_deinit)(void);
136 uint8_t (*gpio_reset_write)(uint8_t level);
137 uint8_t (*spi_init)(void);
138 uint8_t (*spi_deinit)(void);
139 uint8_t (*spi_write)(uint8_t addr, uint8_t *buf, uint16_t len);
140 uint8_t (*spi_read)(uint8_t addr, uint8_t *buf, uint16_t len);
141 void (*delay_ms)(uint32_t ms);
142 void (*debug_print)(const char *const fmt, ...);
143 uint8_t inited;
144 uint8_t channel;
145 uint8_t standby;
148
164
168
175
182#define DRIVER_AD7705_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
183
190#define DRIVER_AD7705_LINK_SPI_INIT(HANDLE, FUC) (HANDLE)->spi_init = FUC
191
198#define DRIVER_AD7705_LINK_SPI_DEINIT(HANDLE, FUC) (HANDLE)->spi_deinit = FUC
199
206#define DRIVER_AD7705_LINK_SPI_READ(HANDLE, FUC) (HANDLE)->spi_read = FUC
207
214#define DRIVER_AD7705_LINK_SPI_WRITE(HANDLE, FUC) (HANDLE)->spi_write = FUC
215
222#define DRIVER_AD7705_LINK_GPIO_RESET_INIT(HANDLE, FUC) (HANDLE)->gpio_reset_init = FUC
223
230#define DRIVER_AD7705_LINK_GPIO_RESET_DEINIT(HANDLE, FUC) (HANDLE)->gpio_reset_deinit = FUC
231
238#define DRIVER_AD7705_LINK_GPIO_RESET_WRITE(HANDLE, FUC) (HANDLE)->gpio_reset_write = FUC
239
246#define DRIVER_AD7705_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
247
254#define DRIVER_AD7705_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
255
259
266
275uint8_t ad7705_info(ad7705_info_t *info);
276
289uint8_t ad7705_init(ad7705_handle_t *handle);
290
302uint8_t ad7705_deinit(ad7705_handle_t *handle);
303
314uint8_t ad7705_set_reference_voltage(ad7705_handle_t *handle, float voltage);
315
326uint8_t ad7705_get_reference_voltage(ad7705_handle_t *handle, float *voltage);
327
338uint8_t ad7705_set_channel(ad7705_handle_t *handle, ad7705_channel_t channel);
339
350uint8_t ad7705_get_channel(ad7705_handle_t *handle, ad7705_channel_t *channel);
351
365uint8_t ad7705_read(ad7705_handle_t *handle, uint16_t *raw, float *volt);
366
378uint8_t ad7705_get_data_ready(ad7705_handle_t *handle, ad7705_bool_t *enable);
379
390uint8_t ad7705_power_on(ad7705_handle_t *handle);
391
402uint8_t ad7705_power_down(ad7705_handle_t *handle);
403
416
429
442
455
468
481
494
506uint8_t ad7705_get_adc_buffer(ad7705_handle_t *handle, ad7705_bool_t *enable);
507
520
533
546
559
572
584uint8_t ad7705_get_clock_div2(ad7705_handle_t *handle, ad7705_bool_t *enable);
585
597uint8_t ad7705_set_rate(ad7705_handle_t *handle, ad7705_rate_t rate);
598
610uint8_t ad7705_get_rate(ad7705_handle_t *handle, ad7705_rate_t *rate);
611
623uint8_t ad7705_get_data(ad7705_handle_t *handle, uint16_t *data);
624
636uint8_t ad7705_set_test(ad7705_handle_t *handle, uint8_t data);
637
649uint8_t ad7705_get_test(ad7705_handle_t *handle, uint8_t *data);
650
662uint8_t ad7705_set_zero_scale_calibration(ad7705_handle_t *handle, uint32_t calibration);
663
675uint8_t ad7705_get_zero_scale_calibration(ad7705_handle_t *handle, uint32_t *calibration);
676
688uint8_t ad7705_set_full_scale_calibration(ad7705_handle_t *handle, uint32_t calibration);
689
701uint8_t ad7705_get_full_scale_calibration(ad7705_handle_t *handle, uint32_t *calibration);
702
714uint8_t ad7705_operate_sync(ad7705_handle_t *handle);
715
719
726
740uint8_t ad7705_set_reg(ad7705_handle_t *handle, uint8_t addr, uint8_t *buf, uint16_t len);
741
755uint8_t ad7705_get_reg(ad7705_handle_t *handle, uint8_t addr, uint8_t *buf, uint16_t len);
756
760
764
765#ifdef __cplusplus
766}
767#endif
768
769#endif
uint8_t ad7705_set_full_scale_calibration(ad7705_handle_t *handle, uint32_t calibration)
set full scale calibration
uint8_t ad7705_get_adc_polar(ad7705_handle_t *handle, ad7705_adc_polar_t *polar)
get adc polar
uint8_t ad7705_set_master_clock_output_disable(ad7705_handle_t *handle, ad7705_bool_t enable)
enable or disable master clock output disable
ad7705_channel_t
ad7705 channel enumeration definition
ad7705_bool_t
ad7705 bool enumeration definition
uint8_t ad7705_get_channel(ad7705_handle_t *handle, ad7705_channel_t *channel)
get channel
struct ad7705_handle_s ad7705_handle_t
ad7705 handle structure definition
uint8_t ad7705_get_adc_buffer(ad7705_handle_t *handle, ad7705_bool_t *enable)
get adc buffer status
uint8_t ad7705_get_rate(ad7705_handle_t *handle, ad7705_rate_t *rate)
get rate
uint8_t ad7705_get_clock_div2(ad7705_handle_t *handle, ad7705_bool_t *enable)
get clock div2 status
ad7705_adc_mode_t
ad7705 adc mode enumeration definition
uint8_t ad7705_get_adc_gain(ad7705_handle_t *handle, ad7705_adc_gain_t *gain)
get adc gain
uint8_t ad7705_get_test(ad7705_handle_t *handle, uint8_t *data)
get test data
uint8_t ad7705_init(ad7705_handle_t *handle)
initialize the chip
uint8_t ad7705_get_full_scale_calibration(ad7705_handle_t *handle, uint32_t *calibration)
get full scale calibration
uint8_t ad7705_get_adc_mode(ad7705_handle_t *handle, ad7705_adc_mode_t *mode)
get adc mode
uint8_t ad7705_set_adc_buffer(ad7705_handle_t *handle, ad7705_bool_t enable)
enable or disable adc buffer
uint8_t ad7705_get_data(ad7705_handle_t *handle, uint16_t *data)
get data
ad7705_adc_polar_t
ad7705 adc polar enumeration definition
uint8_t ad7705_set_reference_voltage(ad7705_handle_t *handle, float voltage)
set reference voltage
uint8_t ad7705_operate_sync(ad7705_handle_t *handle)
operate sync
uint8_t ad7705_deinit(ad7705_handle_t *handle)
close the chip
uint8_t ad7705_set_adc_gain(ad7705_handle_t *handle, ad7705_adc_gain_t gain)
set adc gain
uint8_t ad7705_set_zero_scale_calibration(ad7705_handle_t *handle, uint32_t calibration)
set zero scale calibration
uint8_t ad7705_set_rate(ad7705_handle_t *handle, ad7705_rate_t rate)
set rate
uint8_t ad7705_get_filter_synchronize(ad7705_handle_t *handle, ad7705_bool_t *enable)
get filter synchronize status
uint8_t ad7705_get_zero_scale_calibration(ad7705_handle_t *handle, uint32_t *calibration)
get zero scale calibration
uint8_t ad7705_get_data_ready(ad7705_handle_t *handle, ad7705_bool_t *enable)
get data ready
uint8_t ad7705_read(ad7705_handle_t *handle, uint16_t *raw, float *volt)
read adc
uint8_t ad7705_get_reference_voltage(ad7705_handle_t *handle, float *voltage)
get reference voltage
ad7705_rate_t
ad7705 rate enumeration definition
uint8_t ad7705_set_clock_div2(ad7705_handle_t *handle, ad7705_bool_t enable)
enable or disable clock div2
uint8_t ad7705_power_down(ad7705_handle_t *handle)
power down
uint8_t ad7705_set_adc_mode(ad7705_handle_t *handle, ad7705_adc_mode_t mode)
set adc mode
uint8_t ad7705_power_on(ad7705_handle_t *handle)
power on
struct ad7705_info_s ad7705_info_t
ad7705 information structure definition
uint8_t ad7705_set_test(ad7705_handle_t *handle, uint8_t data)
set test data
uint8_t ad7705_set_channel(ad7705_handle_t *handle, ad7705_channel_t channel)
set channel
ad7705_adc_gain_t
ad7705 adc gain enumeration definition
uint8_t ad7705_info(ad7705_info_t *info)
get chip's information
uint8_t ad7705_get_master_clock_output_disable(ad7705_handle_t *handle, ad7705_bool_t *enable)
get master clock output disable status
uint8_t ad7705_set_adc_polar(ad7705_handle_t *handle, ad7705_adc_polar_t polar)
set adc polar
uint8_t ad7705_set_filter_synchronize(ad7705_handle_t *handle, ad7705_bool_t enable)
enable or disable filter synchronize
@ AD7705_CHANNEL_AIN2_POSITIVE_AIN2_NEGATIVE
@ AD7705_CHANNEL_AIN1_NEGATIVE_AIN1_NEGATIVE
@ AD7705_CHANNEL_AIN1_POSITIVE_AIN1_NEGATIVE
@ AD7705_CHANNEL_AIN1_NEGATIVE_AIN2_NEGATIVE
@ AD7705_BOOL_FALSE
@ AD7705_BOOL_TRUE
@ AD7705_ADC_MODE_SELF_CALIBRATION
@ AD7705_ADC_MODE_NORMAL
@ AD7705_ADC_MODE_FULL_SCALE_SYSTEM_CALIBRATION
@ AD7705_ADC_MODE_ZERO_SCALE_SYSTEM_CALIBRATION
@ AD7705_ADC_POLAR_UNIPOLAR
@ AD7705_ADC_POLAR_BIPOLAR
@ AD7705_RATE_100HZ
@ AD7705_RATE_250HZ
@ AD7705_RATE_200HZ
@ AD7705_RATE_50HZ
@ AD7705_RATE_20HZ
@ AD7705_RATE_25HZ
@ AD7705_RATE_500HZ
@ AD7705_RATE_60HZ
@ AD7705_ADC_GAIN_128
@ AD7705_ADC_GAIN_4
@ AD7705_ADC_GAIN_1
@ AD7705_ADC_GAIN_2
@ AD7705_ADC_GAIN_8
@ AD7705_ADC_GAIN_32
@ AD7705_ADC_GAIN_16
@ AD7705_ADC_GAIN_64
uint8_t ad7705_set_reg(ad7705_handle_t *handle, uint8_t addr, uint8_t *buf, uint16_t len)
set the chip register
uint8_t ad7705_get_reg(ad7705_handle_t *handle, uint8_t addr, uint8_t *buf, uint16_t len)
get the chip register
ad7705 handle structure definition
uint8_t(* gpio_reset_deinit)(void)
uint8_t(* spi_init)(void)
void(* delay_ms)(uint32_t ms)
void(* debug_print)(const char *const fmt,...)
uint8_t(* spi_deinit)(void)
uint8_t(* gpio_reset_write)(uint8_t level)
uint8_t(* spi_write)(uint8_t addr, uint8_t *buf, uint16_t len)
uint8_t(* gpio_reset_init)(void)
uint8_t(* spi_read)(uint8_t addr, uint8_t *buf, uint16_t len)
ad7705 information structure definition
float supply_voltage_max_v
uint32_t driver_version
char manufacturer_name[32]
float supply_voltage_min_v
char chip_name[32]