From cad70605401e8fa30811e8c68a0cc5c014438942 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Fri, 18 Aug 2023 15:40:24 +1000 Subject: Add interrupts for samd changes --- src/drivers/include/gpios.hpp | 5 ++--- src/drivers/include/samd.hpp | 22 ++++++++++++++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) (limited to 'src/drivers/include') diff --git a/src/drivers/include/gpios.hpp b/src/drivers/include/gpios.hpp index 5ac475bf..fe330e3b 100644 --- a/src/drivers/include/gpios.hpp +++ b/src/drivers/include/gpios.hpp @@ -107,8 +107,7 @@ class Gpios : public IGpios { */ auto Read(void) -> bool; - auto InstallReadPendingISR() -> void; - auto IsReadPending() -> SemaphoreHandle_t { return read_pending_; } + static auto CreateReadPending() -> SemaphoreHandle_t; // Not copyable or movable. There should usually only ever be once instance // of this class, and that instance will likely have a static lifetime. @@ -121,7 +120,7 @@ class Gpios : public IGpios { std::atomic ports_; std::atomic inputs_; - SemaphoreHandle_t read_pending_; + static SemaphoreHandle_t sReadPending; }; } // namespace drivers diff --git a/src/drivers/include/samd.hpp b/src/drivers/include/samd.hpp index 1560b590..4a31a577 100644 --- a/src/drivers/include/samd.hpp +++ b/src/drivers/include/samd.hpp @@ -8,6 +8,9 @@ #include +#include "freertos/FreeRTOS.h" +#include "freertos/semphr.h" + namespace drivers { class Samd { @@ -32,7 +35,8 @@ class Samd { kFullCharge, }; - auto ReadChargeStatus() -> std::optional; + auto GetChargeStatus() -> std::optional; + auto UpdateChargeStatus() -> void; enum class UsbStatus { // There is no compatible usb host attached. @@ -44,9 +48,23 @@ class Samd { kAttachedMounted, }; - auto ReadUsbStatus() -> UsbStatus; + auto GetUsbStatus() -> UsbStatus; + auto UpdateUsbStatus() -> void; auto ResetToFlashSamd() -> void; + + static auto CreateReadPending() -> SemaphoreHandle_t; + + // Not copyable or movable. There should usually only ever be once instance + // of this class, and that instance will likely have a static lifetime. + Samd(const Samd&) = delete; + Samd& operator=(const Samd&) = delete; + + private: + std::optional charge_status_; + UsbStatus usb_status_; + + static SemaphoreHandle_t sReadPending; }; } // namespace drivers -- cgit v1.2.3