150 for (i=0; i<times; i++)
163 for (j=0; j<len; j++)
182 for (i=0; i<times; i++)
195 for (j=0; j<len; j++)
214 for (i=0; i<times; i++)
227 for (j=0; j<len; j++)
246 for (i=0; i<times; i++)
259 for (j=0; j<len; j++)
301 for (i=0; i<times; i++)
304 res =
pcf8591_read(&gs_handle, (int16_t *)&raw, (
float *)&adc);
328 for (i=0; i<times; i++)
331 res =
pcf8591_read(&gs_handle, (int16_t *)&raw, (
float *)&adc);
355 for (i=0; i<times; i++)
358 res =
pcf8591_read(&gs_handle, (int16_t *)&raw, (
float *)&adc);
382 for (i=0; i<times; i++)
385 res =
pcf8591_read(&gs_handle, (int16_t *)&raw, (
float *)&adc);
400 for (i=0; i<times; i++)
402 adc = (float)(rand() % 3300) / 1000.0f;
driver pcf8591 read write test header file
uint8_t pcf8591_dac_convert_to_register(pcf8591_handle_t *handle, float dac, uint8_t *reg)
convert a dac value to a register raw data
struct pcf8591_info_s pcf8591_info_t
pcf8591 information structure definition
uint8_t pcf8591_read(pcf8591_handle_t *handle, int16_t *raw, float *adc)
read data from the chip
uint8_t pcf8591_info(pcf8591_info_t *info)
get chip's information
uint8_t pcf8591_set_addr_pin(pcf8591_handle_t *handle, pcf8591_address_t addr_pin)
set the address pin
uint8_t pcf8591_write(pcf8591_handle_t *handle, uint8_t data)
write to the dac
uint8_t pcf8591_init(pcf8591_handle_t *handle)
initialize the chip
uint8_t pcf8591_multiple_read(pcf8591_handle_t *handle, int16_t *raw, float *adc, uint8_t *len)
read the multiple channel data from the chip
uint8_t pcf8591_set_mode(pcf8591_handle_t *handle, pcf8591_mode_t mode)
set the adc mode
uint8_t pcf8591_set_reference_voltage(pcf8591_handle_t *handle, float ref_voltage)
set the adc reference voltage
uint8_t pcf8591_set_channel(pcf8591_handle_t *handle, pcf8591_channel_t channel)
set the adc channel
pcf8591_address_t
pcf8591 address enumeration definition
uint8_t pcf8591_deinit(pcf8591_handle_t *handle)
close the chip
struct pcf8591_handle_s pcf8591_handle_t
pcf8591 handle structure definition
uint8_t pcf8591_set_auto_increment(pcf8591_handle_t *handle, pcf8591_bool_t enable)
set the adc auto increment read mode
@ PCF8591_MODE_AIN0_AIN1_AND_ANI2_AIN3
@ PCF8591_MODE_AIN012_AIN3
@ PCF8591_MODE_AIN0123_GND
@ PCF8591_MODE_AIN0_GND_AND_AIN1_GND_AND_AIN2_AIN3
uint8_t pcf8591_interface_iic_init(void)
interface iic bus init
void pcf8591_interface_delay_ms(uint32_t ms)
interface delay ms
void pcf8591_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t pcf8591_interface_iic_write_cmd(uint8_t addr, uint8_t *buf, uint16_t len)
interface iic bus write command
uint8_t pcf8591_interface_iic_deinit(void)
interface iic bus deinit
uint8_t pcf8591_interface_iic_read_cmd(uint8_t addr, uint8_t *buf, uint16_t len)
interface iic bus read command
#define DRIVER_PCF8591_LINK_IIC_READ_COMMAND(HANDLE, FUC)
link iic_read_cmd function
#define DRIVER_PCF8591_LINK_INIT(HANDLE, STRUCTURE)
initialize pcf8591_handle_t structure
#define DRIVER_PCF8591_LINK_IIC_INIT(HANDLE, FUC)
link iic_init function
#define DRIVER_PCF8591_LINK_DEBUG_PRINT(HANDLE, FUC)
link debug_print function
#define DRIVER_PCF8591_LINK_DELAY_MS(HANDLE, FUC)
link delay_ms function
#define DRIVER_PCF8591_LINK_IIC_WRITE_COMMAND(HANDLE, FUC)
link iic_write_cmd function
#define DRIVER_PCF8591_LINK_IIC_DEINIT(HANDLE, FUC)
link iic_deinit function
uint8_t pcf8591_read_write_test(pcf8591_address_t addr, uint32_t times)
read write test
float supply_voltage_max_v
char manufacturer_name[32]
float supply_voltage_min_v