44#define CHIP_NAME "Microchip MCP4725"
45#define MANUFACTURER_NAME "Microchip"
46#define SUPPLY_VOLTAGE_MIN 2.7f
47#define SUPPLY_VOLTAGE_MAX 5.5f
48#define MAX_CURRENT 0.4f
49#define TEMPERATURE_MIN -40.0f
50#define TEMPERATURE_MAX 125.0f
51#define DRIVER_VERSION 2000
75 handle->
debug_print(
"mcp4725: iic_init is null.\n");
81 handle->
debug_print(
"mcp4725: iic_deinit is null.\n");
87 handle->
debug_print(
"mcp4725: iic_read_cmd is null.\n");
93 handle->
debug_print(
"mcp4725: iic_write_cmd is null.\n");
99 handle->
debug_print(
"mcp4725: delay_ms is null.\n");
106 handle->
debug_print(
"mcp4725: iic init failed.\n");
138 handle->
debug_print(
"mcp4725: iic deinit failed.\n");
163 handle->
iic_addr = (uint8_t)((0x60 | addr_pin) << 1);
184 if (((handle->
iic_addr >> 1) & ~0x60) != 0)
217 handle->
mode = (uint8_t)mode;
384 *value = (uint16_t)(((uint16_t)buf[1]) << 8 | buf[2]);
385 *value = (*value) >> 4;
391 *value = (uint16_t)((uint16_t)(buf[3] & 0x0F) << 8 | buf[4]);
397 handle->
debug_print(
"mcp4725: mode is invalid.\n");
427 value = value & 0xFFF;
430 buf[0] = (uint8_t)((value >> 8) & 0xFF);
431 buf[0] = (uint8_t)(buf[0] | (handle->
power_mode << 4));
432 buf[1] = (uint8_t)(value & 0xFF);
433 buf[2] = (uint8_t)((value >> 8) & 0xFF);
434 buf[2] = (uint8_t)(buf[2] | (handle->
power_mode << 4));
435 buf[3] = (uint8_t)(value & 0xFF);
441 buf[0] = (uint8_t)(0x03 << 5);
442 buf[0] = (uint8_t)(buf[0] | (handle->
power_mode << 1));
444 buf[1] = (uint8_t)((value >> 8) & 0xFF);
445 buf[2] = (uint8_t)(value & 0xFF);
446 buf[3] = (uint8_t)(0x03 << 5);
447 buf[3] = (uint8_t)(buf[3] | (handle->
power_mode << 1));
449 buf[4] = (uint8_t)((value >> 8) & 0xFF);
450 buf[5] = (uint8_t)(value & 0xFF);
456 handle->
debug_print(
"mcp4725: mode is invalid.\n");
487 handle->
debug_print(
"mcp4725: reference voltage can't be zero.\n");
491 *reg = (uint16_t)(s * 4096.0000000f / handle->
ref_voltage);
519 *s = (float)(reg) * handle->
ref_voltage / 4096.00000000f;
#define SUPPLY_VOLTAGE_MAX
#define MANUFACTURER_NAME
#define SUPPLY_VOLTAGE_MIN
#define CHIP_NAME
chip information definition
driver mcp4725 header file
struct mcp4725_handle_s mcp4725_handle_t
mcp4725 handle structure definition
uint8_t mcp4725_get_reference_voltage(mcp4725_handle_t *handle, float *ref_voltage)
get the chip reference voltage
mcp4725_power_down_mode_t
mcp4725 power down enumeration definition
uint8_t mcp4725_convert_to_data(mcp4725_handle_t *handle, uint16_t reg, float *s)
convert the register data to the dac value
uint8_t mcp4725_deinit(mcp4725_handle_t *handle)
close the chip
uint8_t mcp4725_info(mcp4725_info_t *info)
get chip's information
uint8_t mcp4725_read(mcp4725_handle_t *handle, uint16_t *value)
read the dac value
uint8_t mcp4725_set_power_mode(mcp4725_handle_t *handle, mcp4725_power_down_mode_t mode)
set the chip power mode
uint8_t mcp4725_get_power_mode(mcp4725_handle_t *handle, mcp4725_power_down_mode_t *mode)
get the chip power mode
mcp4725_address_t
mcp4725 address enumeration definition
struct mcp4725_info_s mcp4725_info_t
mcp4725 information structure definition
uint8_t mcp4725_write(mcp4725_handle_t *handle, uint16_t value)
write the dac value
uint8_t mcp4725_convert_to_register(mcp4725_handle_t *handle, float s, uint16_t *reg)
convert the dac value to the register data
uint8_t mcp4725_get_addr_pin(mcp4725_handle_t *handle, mcp4725_address_t *addr_pin)
get the chip address pin
uint8_t mcp4725_init(mcp4725_handle_t *handle)
initialize the chip
uint8_t mcp4725_set_reference_voltage(mcp4725_handle_t *handle, float ref_voltage)
set the chip reference voltage
uint8_t mcp4725_set_mode(mcp4725_handle_t *handle, mcp4725_mode_t mode)
set the chip mode
mcp4725_mode_t
mcp4725 mode enumeration definition
uint8_t mcp4725_get_mode(mcp4725_handle_t *handle, mcp4725_mode_t *mode)
get the chip mode
uint8_t mcp4725_set_addr_pin(mcp4725_handle_t *handle, mcp4725_address_t addr_pin)
set the chip address pin
uint8_t mcp4725_set_reg(mcp4725_handle_t *handle, uint8_t *buf, uint16_t len)
set the chip register
uint8_t mcp4725_get_reg(mcp4725_handle_t *handle, uint8_t *buf, uint16_t len)
get the chip register
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)
float supply_voltage_max_v
char manufacturer_name[32]
float supply_voltage_min_v