8static const char *
const TAG =
"mcp4728";
11 auto err = this->
write(
nullptr, 0);
19 ESP_LOGCONFIG(TAG,
"MCP4728:");
22 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
28 this->update_ =
false;
29 if (this->store_in_eeprom_) {
56 ESP_LOGV(TAG,
"Setting MCP4728 channel %c to %d!", cn, value);
57 reg_[channel].
data = value;
63 for (uint8_t i = 0; i < 4; ++i) {
66 wd[1] = ((uint8_t) reg_[i].
vref << 7) | ((uint8_t) reg_[i].pd << 5) | ((uint8_t) reg_[i].
gain << 4) |
68 wd[2] = reg_[i].
data & 0xFF;
69 err[i] = this->
write(wd,
sizeof(wd));
84 for (uint8_t i = 0; i < 4; i++) {
85 wd[i * 2 + 1] = ((uint8_t) reg_[i].
vref << 7) | ((uint8_t) reg_[i].pd << 5) | ((uint8_t) reg_[i].
gain << 4) |
87 wd[i * 2 + 2] = reg_[i].
data & 0xFF;
89 auto err = this->
write(wd,
sizeof(wd));
94 reg_[channel].
vref = vref;
100 reg_[channel].
pd = pd;
102 this->update_ =
true;
108 this->update_ =
true;
void mark_failed()
Mark this component as failed.
void status_clear_error()
ErrorCode write(const uint8_t *data, size_t len) const
writes an array of bytes to a device using an I2CBus
void set_channel_value_(MCP4728ChannelIdx channel, uint16_t value)
void select_vref_(MCP4728ChannelIdx channel, MCP4728Vref vref)
void select_gain_(MCP4728ChannelIdx channel, MCP4728Gain gain)
void dump_config() override
void select_power_down_(MCP4728ChannelIdx channel, MCP4728PwrDown pd)
ErrorCode
Error codes returned by I2CBus and I2CDevice methods.
@ ERROR_OK
No error found during execution of method.