Add functions to read and write the RAM byte

This commit is contained in:
Odd Stråbø 2023-08-15 22:11:47 +02:00
parent 10efb46153
commit e85874cccf
2 changed files with 12 additions and 0 deletions

View File

@ -81,6 +81,16 @@ void PCF85063Component::write_time() {
this->write_rtc_();
}
void PCF85063Component::write_nvram(uint8_t data) {
this->pcf85063_.reg.nvram = data;
this->write_bytes(0x03, &this->pcf85063_.raw[0x03], 1);
}
uint8_t PCF85063Component::read_nvram() {
this->read_bytes(0x03, &this->pcf85063_.raw[0x03], 1);
return this->pcf85063_.reg.nvram;
}
bool PCF85063Component::read_rtc_() {
if (!this->read_bytes(0, this->pcf85063_.raw, sizeof(this->pcf85063_.raw))) {
ESP_LOGE(TAG, "Can't read I2C data.");

View File

@ -27,6 +27,8 @@ class PCF85063Component : public time::RealTimeClock, public i2c::I2CDevice {
float get_setup_priority() const override;
void read_time();
void write_time();
void write_nvram(uint8_t);
uint8_t read_nvram();
protected:
bool read_rtc_();