summaryrefslogtreecommitdiff
path: root/src/drivers/include
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-05-18 18:17:14 +1000
committerjacqueline <me@jacqueline.id.au>2023-05-18 18:17:14 +1000
commitb320a6a863cf1c10dc79254af41f573730935564 (patch)
tree00e0624eb34b5347dcf14bde26d708ffb216f834 /src/drivers/include
parentd71f726c42963d55809605b4dc4144970ca0f230 (diff)
downloadtangara-fw-b320a6a863cf1c10dc79254af41f573730935564.tar.gz
Add basic samd class
Diffstat (limited to 'src/drivers/include')
-rw-r--r--src/drivers/include/samd.hpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/drivers/include/samd.hpp b/src/drivers/include/samd.hpp
new file mode 100644
index 00000000..4ba5877c
--- /dev/null
+++ b/src/drivers/include/samd.hpp
@@ -0,0 +1,46 @@
+#pragma once
+
+#include <optional>
+
+namespace drivers {
+
+class Samd {
+ public:
+ Samd();
+ ~Samd();
+
+ enum class ChargeStatus {
+ // There is no battery plugged into the device.
+ kNoBattery,
+ // The battery is discharging, and the current voltage level is very low.
+ kBatteryCritical,
+ // The battery is discharging.
+ kDischarging,
+ // The battery is charging over a low-current USB connection
+ kChargingRegular,
+ // The battery is charging over a high-current USB connection
+ kChargingFast,
+ // The battery is full charged, and we are still plugged in.
+ kFullCharge,
+ };
+
+ auto ReadChargeStatus() -> std::optional<ChargeStatus>;
+
+ enum class UsbMscStatus {
+ // There is no compatible usb host attached.
+ kDetached,
+ // There is a compatible usb host attached, but USB MSC is not currently
+ // in use by the SAMD.
+ kAttachedIdle,
+ // The SAMD is currently exposing the SD card via USB MSC.
+ kAttachedMounted,
+ };
+
+ auto WriteAllowUsbMsc(bool is_allowed) -> void;
+ auto ReadUsbMscStatus() -> UsbMscStatus;
+
+ auto ReadFlashingEnabled() -> bool;
+ auto WriteFlashingEnabled(bool) -> void;
+};
+
+} // namespace drivers