From 97bbed87d2a752387a7d51e6b001a415755dcec6 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Wed, 6 Dec 2023 18:35:08 -0600 Subject: [PATCH 1/2] Add functional SPI implementation for arduino_default --- src/lgfx/v1/platforms/arduino_default/common.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/lgfx/v1/platforms/arduino_default/common.cpp b/src/lgfx/v1/platforms/arduino_default/common.cpp index e1298196..9e1eccf8 100644 --- a/src/lgfx/v1/platforms/arduino_default/common.cpp +++ b/src/lgfx/v1/platforms/arduino_default/common.cpp @@ -67,12 +67,15 @@ namespace lgfx /// unimplemented. namespace spi { - cpp::result init(int spi_host, int spi_sclk, int spi_miso, int spi_mosi) { return cpp::fail(error_t::unknown_err); } + cpp::result init(int spi_host, int spi_sclk, int spi_miso, int spi_mosi) { cpp::result res = {}; return res; } void release(int spi_host) {} - void beginTransaction(int spi_host, uint32_t freq, int spi_mode) {} - void endTransaction(int spi_host) {} + void beginTransaction(int spi_host, uint32_t freq, int spi_mode) { + SPISettings setting(freq, MSBFIRST, SPI_MODE0); + SPI.beginTransaction(setting); + } + void endTransaction(int spi_host) {SPI.endTransaction();} void writeBytes(int spi_host, const uint8_t* data, size_t length) {} - void readBytes(int spi_host, uint8_t* data, size_t length) {} + void readBytes(int spi_host, uint8_t* data, size_t length) {SPI.transfer(data, length);} } //---------------------------------------------------------------------------- From 8cbc5a93bc5b10d0704a6ed2343818a5e2d1424f Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Wed, 6 Dec 2023 21:30:07 -0600 Subject: [PATCH 2/2] Add missed readBytes() in arduino_default common.cpp --- src/lgfx/v1/platforms/arduino_default/common.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lgfx/v1/platforms/arduino_default/common.cpp b/src/lgfx/v1/platforms/arduino_default/common.cpp index 9e1eccf8..c222d126 100644 --- a/src/lgfx/v1/platforms/arduino_default/common.cpp +++ b/src/lgfx/v1/platforms/arduino_default/common.cpp @@ -90,6 +90,7 @@ namespace lgfx cpp::result endTransaction(int i2c_port) { return cpp::fail(error_t::unknown_err); } cpp::result writeBytes(int i2c_port, const uint8_t *data, size_t length) { return cpp::fail(error_t::unknown_err); } cpp::result readBytes(int i2c_port, uint8_t *data, size_t length) { return cpp::fail(error_t::unknown_err); } + cpp::result readBytes(int i2c_port, uint8_t *data, size_t length, bool last_nack) { return cpp::fail(error_t::unknown_err); } //--------