43#define CHIP_NAME "Analog Devices AD7705"
44#define MANUFACTURER_NAME "Analog Devices"
45#define SUPPLY_VOLTAGE_MIN 2.7f
46#define SUPPLY_VOLTAGE_MAX 5.25f
47#define MAX_CURRENT 1.3f
48#define TEMPERATURE_MIN -20.0f
49#define TEMPERATURE_MAX 85.0f
50#define DRIVER_VERSION 1000
55#define AD7705_REG_COMMUNICATION 0x00
56#define AD7705_REG_SETUP 0x01
57#define AD7705_REG_CLOCK 0x02
58#define AD7705_REG_DATA 0x03
59#define AD7705_REG_TEST 0x04
60#define AD7705_REG_NO_OPERATION 0x05
61#define AD7705_REG_OFFSET 0x06
62#define AD7705_REG_GAIN 0x07
75static uint8_t a_ad7705_read(
ad7705_handle_t *handle, uint8_t addr, uint8_t *buf, uint16_t len)
79 command = ((addr & 0x7) << 4) | (1 << 3) |
81 if (handle->
spi_read(command, buf, len) != 0)
100static uint8_t a_ad7705_write(
ad7705_handle_t *handle, uint8_t addr, uint8_t *buf, uint16_t len)
104 command = ((addr & 0x7) << 4) |
106 if (handle->
spi_write(command, buf, len) != 0)
135 handle->
channel = (uint8_t)channel;
193 handle->
debug_print(
"ad7705: power down failed.\n");
265 handle->
debug_print(
"ad7705: read setup failed.\n");
274 handle->
debug_print(
"ad7705: write setup failed.\n");
310 handle->
debug_print(
"ad7705: read setup failed.\n");
347 handle->
debug_print(
"ad7705: read setup failed.\n");
356 handle->
debug_print(
"ad7705: write setup failed.\n");
392 handle->
debug_print(
"ad7705: read setup failed.\n");
429 handle->
debug_print(
"ad7705: read setup failed.\n");
438 handle->
debug_print(
"ad7705: write setup failed.\n");
474 handle->
debug_print(
"ad7705: read setup failed.\n");
511 handle->
debug_print(
"ad7705: read setup failed.\n");
520 handle->
debug_print(
"ad7705: write setup failed.\n");
556 handle->
debug_print(
"ad7705: read setup failed.\n");
593 handle->
debug_print(
"ad7705: read setup failed.\n");
598 prev |= (!enable) << 0;
602 handle->
debug_print(
"ad7705: write setup failed.\n");
638 handle->
debug_print(
"ad7705: read setup failed.\n");
675 handle->
debug_print(
"ad7705: read clock failed.\n");
685 handle->
debug_print(
"ad7705: write clock failed.\n");
721 handle->
debug_print(
"ad7705: read clock failed.\n");
758 handle->
debug_print(
"ad7705: read clock failed.\n");
768 handle->
debug_print(
"ad7705: write clock failed.\n");
804 handle->
debug_print(
"ad7705: read clock failed.\n");
841 handle->
debug_print(
"ad7705: read clock failed.\n");
851 handle->
debug_print(
"ad7705: write clock failed.\n");
887 handle->
debug_print(
"ad7705: read clock failed.\n");
924 handle->
debug_print(
"ad7705: read data failed.\n");
928 *data = (uint16_t)((((uint16_t)buf[0]) << 8) | buf[1]);
963 handle->
debug_print(
"ad7705: write test failed.\n");
998 handle->
debug_print(
"ad7705: read test failed.\n");
1031 buf[0] = (calibration >> 16) & 0xFF;
1032 buf[1] = (calibration >> 8) & 0xFF;
1033 buf[2] = (calibration >> 0) & 0xFF;
1037 handle->
debug_print(
"ad7705: write offset failed.\n");
1073 handle->
debug_print(
"ad7705: read offset failed.\n");
1077 *calibration = (uint32_t)((uint32_t)buf[0] << 16) |
1078 (uint32_t)((uint32_t)buf[1] << 8) |
1079 (uint32_t)((uint32_t)buf[2] << 0);
1109 buf[0] = (calibration >> 16) & 0xFF;
1110 buf[1] = (calibration >> 8) & 0xFF;
1111 buf[2] = (calibration >> 0) & 0xFF;
1115 handle->
debug_print(
"ad7705: write gain failed.\n");
1151 handle->
debug_print(
"ad7705: read gain failed.\n");
1155 *calibration = (uint32_t)((uint32_t)buf[0] << 16) |
1156 (uint32_t)((uint32_t)buf[1] << 8) |
1157 (uint32_t)((uint32_t)buf[2] << 0);
1242 handle->
debug_print(
"ad7705: read communication failed.\n");
1285 handle->
debug_print(
"ad7705: read setup failed.\n");
1289 polar = (prev >> 2) & 0x01;
1290 gain = (prev >> 3) & 0x07;
1293 while (timeout != 0)
1298 handle->
debug_print(
"ad7705: read communication failed.\n");
1302 if (((prev >> 7) & 0x01) == 0)
1319 handle->
debug_print(
"ad7705: read data failed.\n");
1325 *raw = (uint16_t)((((uint16_t)buf[0]) << 8) | buf[1]);
1327 (float)powf(2.0f, (
float)(gain));
1331 *raw = (uint16_t)((((uint16_t)buf[0]) << 8) | buf[1]);
1332 *volt = ((float)(*raw) - 32768.0f) / 32768.0f *
1367 while (timeout != 0)
1372 handle->
debug_print(
"ad7705: read communication failed.\n");
1376 if (((prev >> 7) & 0x01) == 0)
1419 handle->
debug_print(
"ad7705: gpio_reset_init is null.\n");
1425 handle->
debug_print(
"ad7705: gpio_reset_deinit is null.\n");
1431 handle->
debug_print(
"ad7705: gpio_reset_write is null.\n");
1437 handle->
debug_print(
"ad7705: spi_init is null.\n");
1443 handle->
debug_print(
"ad7705: spi_deinit is null.\n");
1449 handle->
debug_print(
"ad7705: spi_read is null.\n");
1455 handle->
debug_print(
"ad7705: spi_write is null.\n");
1461 handle->
debug_print(
"ad7705: delay_ms is null.\n");
1468 handle->
debug_print(
"ad7705: gpio reset init failed.\n");
1474 handle->
debug_print(
"ad7705: spi init failed.\n");
1483 handle->
debug_print(
"ad7705: gpio reset write failed.\n");
1493 handle->
debug_print(
"ad7705: gpio reset write failed.\n");
1503 handle->
debug_print(
"ad7705: gpio reset write failed.\n");
1515 handle->
debug_print(
"ad7705: power on failed.\n");
1555 handle->
debug_print(
"ad7705: power down failed.\n");
1563 handle->
debug_print(
"ad7705: spi deinit failed.\n");
1596 if (a_ad7705_write(handle, addr, buf, len) != 0)
1628 if (a_ad7705_read(handle, addr, buf, len) != 0)
#define AD7705_REG_NO_OPERATION
#define SUPPLY_VOLTAGE_MAX
#define AD7705_REG_OFFSET
#define AD7705_REG_COMMUNICATION
chip register definition
#define MANUFACTURER_NAME
#define SUPPLY_VOLTAGE_MIN
#define CHIP_NAME
chip information definition
driver ad7705 header file
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
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
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)
float supply_voltage_max_v
char manufacturer_name[32]
float supply_voltage_min_v