From 3af348fb65a26299963cdf1ea846c13b37e4f728 Mon Sep 17 00:00:00 2001 From: Christian Ambach Date: Wed, 31 Oct 2018 09:44:06 +0100 Subject: [PATCH] Revert "SPI wire interface (experimental)" This reverts commit 00b1faab8358d1575e4567d462a5329201023bc2. --- src/spisend.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/spisend.cpp b/src/spisend.cpp index 6d28f5a8..c778a887 100644 --- a/src/spisend.cpp +++ b/src/spisend.cpp @@ -41,32 +41,34 @@ void spi_loop(void *pvParameters) { void hal_spi_init() { SPI.begin(SCK, MISO, MOSI, SS); } -void hal_spi_trx(uint8_t port, uint8_t *buf, int len, uint8_t is_read) { +void hal_spi_trx(u1_t cmd, u1_t *buf, int len, u1_t is_read) { + u1_t nss = SS; SPISettings settings(1E6, MSBFIRST, SPI_MODE0); SPI.beginTransaction(settings); - digitalWrite(SS, 0); - SPI.transfer(port); + digitalWrite(nss, 0); - for (uint8_t i = 0; i < len; i++) { - uint8_t *p = buf + i; - uint8_t data = is_read ? 0x00 : *p; + SPI.transfer(cmd); + + for (u1_t i = 0; i < len; i++) { + u1_t *p = buf + i; + u1_t data = is_read ? 0x00 : *p; data = SPI.transfer(data); if (is_read) *p = data; } - digitalWrite(SS, 1); + digitalWrite(nss, 1); SPI.endTransaction(); } -void hal_spi_write(uint8_t port, const uint8_t *buf, int len) { - hal_spi_trx(port, (uint8_t *)buf, len, 0); +void hal_spi_write(u1_t cmd, const u1_t *buf, int len) { + hal_spi_trx(cmd, (u1_t *)buf, len, 0); } -void hal_spi_read(uint8_t port, uint8_t *buf, int len) { - hal_spi_trx(port, buf, len, 1); +void hal_spi_read(u1_t cmd, u1_t *buf, int len) { + hal_spi_trx(cmd, buf, len, 1); } #endif // HAS_SPI \ No newline at end of file