diff options
Diffstat (limited to 'src/drivers/samd.cpp')
| -rw-r--r-- | src/drivers/samd.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/drivers/samd.cpp b/src/drivers/samd.cpp index cf3b9c18..f12a18de 100644 --- a/src/drivers/samd.cpp +++ b/src/drivers/samd.cpp @@ -8,6 +8,7 @@ #include <cstdint> #include <optional> +#include <string> #include "esp_err.h" #include "esp_log.h" @@ -37,23 +38,26 @@ Samd::Samd() { // Being able to interface with the SAMD properly is critical. To ensure we // will be able to, we begin by checking the I2C protocol version is // compatible, and throw if it's not. - uint8_t raw_res = 0; I2CTransaction transaction; transaction.start() .write_addr(kAddress, I2C_MASTER_WRITE) .write_ack(Registers::kSamdFirmwareVersion) .start() .write_addr(kAddress, I2C_MASTER_READ) - .read(&raw_res, I2C_MASTER_NACK) + .read(&version_, I2C_MASTER_NACK) .stop(); ESP_ERROR_CHECK(transaction.Execute(1)); - ESP_LOGI(kTag, "samd firmware rev: %u", raw_res); + ESP_LOGI(kTag, "samd firmware rev: %u", version_); UpdateChargeStatus(); UpdateUsbStatus(); } Samd::~Samd() {} +auto Samd::Version() -> std::string { + return std::to_string(version_); +} + auto Samd::GetChargeStatus() -> std::optional<ChargeStatus> { return charge_status_; } |
