diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-08-18 15:40:24 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-08-18 15:40:24 +1000 |
| commit | cad70605401e8fa30811e8c68a0cc5c014438942 (patch) | |
| tree | 42307c27b01ce80b1e9038dea6dca2d4aa94eae1 /src/drivers/include | |
| parent | 697ec3c5843c66253f73572c26b9b4885680d56c (diff) | |
| download | tangara-fw-cad70605401e8fa30811e8c68a0cc5c014438942.tar.gz | |
Add interrupts for samd changes
Diffstat (limited to 'src/drivers/include')
| -rw-r--r-- | src/drivers/include/gpios.hpp | 5 | ||||
| -rw-r--r-- | src/drivers/include/samd.hpp | 22 |
2 files changed, 22 insertions, 5 deletions
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<uint16_t> ports_; std::atomic<uint16_t> 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 <optional> +#include "freertos/FreeRTOS.h" +#include "freertos/semphr.h" + namespace drivers { class Samd { @@ -32,7 +35,8 @@ class Samd { kFullCharge, }; - auto ReadChargeStatus() -> std::optional<ChargeStatus>; + auto GetChargeStatus() -> std::optional<ChargeStatus>; + 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<ChargeStatus> charge_status_; + UsbStatus usb_status_; + + static SemaphoreHandle_t sReadPending; }; } // namespace drivers |
