summaryrefslogtreecommitdiff
path: root/src/drivers/samd.cpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-01-10 20:32:01 +1100
committerjacqueline <me@jacqueline.id.au>2024-01-10 20:34:36 +1100
commit55bde70b9651b411ac0135bd4704f5b6972ea799 (patch)
tree520e502d62dabab2511a6032c1b29d86d1b1cb55 /src/drivers/samd.cpp
parent1b2d791a05954fd161376e3ddce0d44f74fcc6c0 (diff)
downloadtangara-fw-55bde70b9651b411ac0135bd4704f5b6972ea799.tar.gz
add accurate esp and samd versions + expose this info to lua
Diffstat (limited to 'src/drivers/samd.cpp')
-rw-r--r--src/drivers/samd.cpp10
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_;
}