9 static const char *
const TAG =
"dac7678";
11 static const uint8_t DAC7678_REG_INPUT_N = 0x00;
12 static const uint8_t DAC7678_REG_SELECT_UPDATE_N = 0x10;
13 static const uint8_t DAC7678_REG_WRITE_N_UPDATE_ALL = 0x20;
14 static const uint8_t DAC7678_REG_WRITE_N_UPDATE_N = 0x30;
15 static const uint8_t DAC7678_REG_POWER = 0x40;
16 static const uint8_t DAC7678_REG_CLEAR_CODE = 0x50;
17 static const uint8_t DAC7678_REG_LDAC = 0x60;
18 static const uint8_t DAC7678_REG_SOFTWARE_RESET = 0x70;
19 static const uint8_t DAC7678_REG_INTERNAL_REF_0 = 0x80;
20 static const uint8_t DAC7678_REG_INTERNAL_REF_1 = 0x90;
23 ESP_LOGCONFIG(TAG,
"Setting up DAC7678OutputComponent...");
25 ESP_LOGV(TAG,
"Resetting device...");
28 if (!this->
write_byte_16(DAC7678_REG_SOFTWARE_RESET, 0x0000)) {
29 ESP_LOGE(TAG,
"Reset failed");
33 ESP_LOGV(TAG,
"Reset succeeded");
40 if (!this->
write_byte_16(DAC7678_REG_INTERNAL_REF_0, 1 << 4)) {
41 ESP_LOGE(TAG,
"Set internal reference failed");
45 ESP_LOGV(TAG,
"Internal reference enabled");
52 ESP_LOGE(TAG,
"Setting up DAC7678 failed!");
54 ESP_LOGCONFIG(TAG,
"DAC7678 initialised");
63 ESP_LOGV(TAG,
"Registered channel: %01u", channel->
channel_);
68 ESP_LOGV(TAG,
"Channel %01u: input_reg=%04u ", channel, value);
70 if (!this->
write_byte_16(DAC7678_REG_WRITE_N_UPDATE_N | channel, value << 4)) {
80 const float input_rounded = roundf(state * this->full_scale_);
81 auto input =
static_cast<uint16_t
>(input_rounded);
82 this->parent_->set_channel_value_(this->channel_, input);
uint16_t dac_input_reg_[8]
void write_state(float state) override
void status_set_warning(const char *message="unspecified")
void set_parent(T *parent)
Set the parent of this object.
void status_clear_warning()
void set_channel_value_(uint8_t channel, uint16_t value)
virtual void mark_failed()
Mark this component as failed.
void dump_config() override
Implementation of SPI Controller mode.
void register_channel(DAC7678Channel *channel)
void IRAM_ATTR HOT delayMicroseconds(uint32_t us)
bool write_byte_16(uint8_t a_register, uint16_t data)