From b320a6a863cf1c10dc79254af41f573730935564 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Thu, 18 May 2023 18:17:14 +1000 Subject: Add basic samd class --- src/drivers/include/samd.hpp | 46 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/drivers/include/samd.hpp (limited to 'src/drivers/include') 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 + +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; + + 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 -- cgit v1.2.3