diff options
| author | jacqueline <me@jacqueline.id.au> | 2025-01-10 02:17:11 +0000 |
|---|---|---|
| committer | cooljqln <cooljqln@noreply.codeberg.org> | 2025-01-10 02:17:11 +0000 |
| commit | 94c30b759192231b8172bbb7d81125c8181261a1 (patch) | |
| tree | 3000ddfd33ddb3598f0f8546b94550bad500ec88 /src/drivers/include | |
| parent | 90118996194d90449e7e7d1fbeb08da587b10642 (diff) | |
| download | tangara-fw-94c30b759192231b8172bbb7d81125c8181261a1.tar.gz | |
Isolate the SD card from the SPI bus when talking to the display (#176)
This should help significantly with https://codeberg.org/cool-tech-zone/tangara-fw/issues/121, which seems to be caused by some SD cards being very picky about being the only SPI device on their bus.
Co-authored-by: ailurux <ailuruxx@gmail.com>
Reviewed-on: https://codeberg.org/cool-tech-zone/tangara-fw/pulls/176
Co-authored-by: jacqueline <me@jacqueline.id.au>
Co-committed-by: jacqueline <me@jacqueline.id.au>
Diffstat (limited to 'src/drivers/include')
| -rw-r--r-- | src/drivers/include/drivers/display.hpp | 2 | ||||
| -rw-r--r-- | src/drivers/include/drivers/gpios.hpp | 22 |
2 files changed, 21 insertions, 3 deletions
diff --git a/src/drivers/include/drivers/display.hpp b/src/drivers/include/drivers/display.hpp index 21ca3e2d..e5001c48 100644 --- a/src/drivers/include/drivers/display.hpp +++ b/src/drivers/include/drivers/display.hpp @@ -65,8 +65,6 @@ class Display { void SendInitialisationSequence(const uint8_t* data); void SendCommandWithData(uint8_t command, const uint8_t* data, size_t length); - void SendCmd(const uint8_t* data, size_t length); - void SendData(const uint8_t* data, size_t length); void SendTransaction(TransactionType type, const uint8_t* data, diff --git a/src/drivers/include/drivers/gpios.hpp b/src/drivers/include/drivers/gpios.hpp index e27a3ade..5010e45f 100644 --- a/src/drivers/include/drivers/gpios.hpp +++ b/src/drivers/include/drivers/gpios.hpp @@ -61,7 +61,7 @@ class IGpios { }; /* Nicer value names for use with kSdMuxSwitch. */ - enum SdController { + enum SdTarget { SD_MUX_ESP = 0, SD_MUX_SAMD = 1, }; @@ -80,6 +80,15 @@ class IGpios { virtual auto Get(Pin) const -> bool = 0; virtual auto IsLocked() const -> bool = 0; + + /* + * Enables or disable the SD mux. When the mux is disabled, the SD card is + * isolated from the rest of the SPI bus. + */ + virtual auto SdMuxEnable(bool en) -> void = 0; + + /* Switches whether the SD card is connected to the ESP32 or SAMD21. */ + virtual auto SdMuxTarget(SdTarget target) -> void = 0; }; class Gpios : public IGpios { @@ -96,6 +105,8 @@ class Gpios : public IGpios { */ auto WriteSync(Pin, bool) -> bool override; + auto ShouldRead() -> bool; + virtual auto WriteBuffered(Pin, bool) -> void; /** @@ -114,6 +125,11 @@ class Gpios : public IGpios { */ auto Read(void) -> bool; + auto SdMuxEnable(bool en) -> void override; + auto SdMuxTarget(SdTarget target) -> void override; + + auto SdMuxTarget() -> SdTarget; + // Not copyable or movable. There should usually only ever be once instance // of this class, and that instance will likely have a static lifetime. Gpios(const Gpios&) = delete; @@ -125,6 +141,10 @@ class Gpios : public IGpios { std::atomic<uint16_t> ports_; std::atomic<uint16_t> inputs_; const bool invert_lock_switch_; + bool has_written_; + + std::mutex mux_mutex_; + bool mux_en_; }; } // namespace drivers |
