38#ifndef DRIVER_PCF8591_H
39#define DRIVER_PCF8591_H
156#define DRIVER_PCF8591_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
164#define DRIVER_PCF8591_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
172#define DRIVER_PCF8591_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
180#define DRIVER_PCF8591_LINK_IIC_READ_COMMAND(HANDLE, FUC) (HANDLE)->iic_read_cmd = FUC
188#define DRIVER_PCF8591_LINK_IIC_WRITE_COMMAND(HANDLE, FUC) (HANDLE)->iic_write_cmd = FUC
196#define DRIVER_PCF8591_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
204#define DRIVER_PCF8591_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
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_get_channel(pcf8591_handle_t *handle, pcf8591_channel_t *channel)
get the adc channel
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
pcf8591_mode_t
pcf8591 mode definition
uint8_t pcf8591_get_auto_increment(pcf8591_handle_t *handle, pcf8591_bool_t *enable)
get the adc auto increment read mode
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
pcf8591_bool_t
pcf8591 bool enumeration definition
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
uint8_t pcf8591_get_addr_pin(pcf8591_handle_t *handle, pcf8591_address_t *addr_pin)
get the address pin
pcf8591_address_t
pcf8591 address enumeration definition
uint8_t pcf8591_get_mode(pcf8591_handle_t *handle, pcf8591_mode_t *mode)
get the adc mode
uint8_t pcf8591_get_reference_voltage(pcf8591_handle_t *handle, float *ref_voltage)
get the adc reference voltage
uint8_t pcf8591_deinit(pcf8591_handle_t *handle)
close the chip
struct pcf8591_handle_s pcf8591_handle_t
pcf8591 handle structure definition
pcf8591_channel_t
pcf8591 channel 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_get_reg(pcf8591_handle_t *handle, uint8_t *buf, uint16_t len)
get the chip register
uint8_t pcf8591_set_reg(pcf8591_handle_t *handle, uint8_t *buf, uint16_t len)
set the chip register
pcf8591 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)
pcf8591 information structure definition
float supply_voltage_max_v
char manufacturer_name[32]
float supply_voltage_min_v