From a5c631593e7e859fe0fb9f1b2de289bdb37cbf7a Mon Sep 17 00:00:00 2001 From: howard-wa9axq <75182246+howard-wa9axq@users.noreply.github.com> Date: Sat, 28 Nov 2020 14:15:01 -0600 Subject: [PATCH 1/8] Update Adafruit_SPIDevice.cpp The SPI.cpp that the STM32 project uses does not have a transfer method with both a buffer and a length. Changes to this file uses a transfer method that just needs a single 8 bit character. --- Adafruit_SPIDevice.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Adafruit_SPIDevice.cpp b/Adafruit_SPIDevice.cpp index d5ecdc9..e952bf7 100644 --- a/Adafruit_SPIDevice.cpp +++ b/Adafruit_SPIDevice.cpp @@ -116,7 +116,8 @@ void Adafruit_SPIDevice::transfer(uint8_t *buffer, size_t len) { #ifdef SPARK _spi->transfer(buffer, buffer, len, NULL); #else - _spi->transfer(buffer, len); + for(i = 0; i < len; i++ ) + _spi->transfer(buffer[i]); #endif return; From 197d21ad2a669e31aadb656d5851e33943e28ab0 Mon Sep 17 00:00:00 2001 From: howard-wa9axq <75182246+howard-wa9axq@users.noreply.github.com> Date: Sat, 28 Nov 2020 15:05:52 -0600 Subject: [PATCH 2/8] Update Adafruit_SPIDevice.cpp Added code to define 'i'. --- Adafruit_SPIDevice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Adafruit_SPIDevice.cpp b/Adafruit_SPIDevice.cpp index e952bf7..5e554bd 100644 --- a/Adafruit_SPIDevice.cpp +++ b/Adafruit_SPIDevice.cpp @@ -116,7 +116,7 @@ void Adafruit_SPIDevice::transfer(uint8_t *buffer, size_t len) { #ifdef SPARK _spi->transfer(buffer, buffer, len, NULL); #else - for(i = 0; i < len; i++ ) + for(size_t i = 0; i < len; i++ ) _spi->transfer(buffer[i]); #endif From 0787a7dd4de864dfb799fbeece76e530e24d9efb Mon Sep 17 00:00:00 2001 From: howard-wa9axq <75182246+howard-wa9axq@users.noreply.github.com> Date: Sat, 28 Nov 2020 15:21:54 -0600 Subject: [PATCH 3/8] Update Adafruit_SPIDevice.cpp Adjusted syntax of added 'for' statement --- Adafruit_SPIDevice.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Adafruit_SPIDevice.cpp b/Adafruit_SPIDevice.cpp index 5e554bd..52425ed 100644 --- a/Adafruit_SPIDevice.cpp +++ b/Adafruit_SPIDevice.cpp @@ -116,8 +116,9 @@ void Adafruit_SPIDevice::transfer(uint8_t *buffer, size_t len) { #ifdef SPARK _spi->transfer(buffer, buffer, len, NULL); #else - for(size_t i = 0; i < len; i++ ) + for (size_t i = 0; i < len; i++) { _spi->transfer(buffer[i]); + } #endif return; From 40ccbb3739fd334695f906aa0b580097dcee50b7 Mon Sep 17 00:00:00 2001 From: howard-wa9axq <75182246+howard-wa9axq@users.noreply.github.com> Date: Sat, 28 Nov 2020 16:16:58 -0600 Subject: [PATCH 4/8] Update Adafruit_SPIDevice.cpp --- Adafruit_SPIDevice.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Adafruit_SPIDevice.cpp b/Adafruit_SPIDevice.cpp index 52425ed..6bdf301 100644 --- a/Adafruit_SPIDevice.cpp +++ b/Adafruit_SPIDevice.cpp @@ -115,10 +115,12 @@ void Adafruit_SPIDevice::transfer(uint8_t *buffer, size_t len) { #ifdef SPARK _spi->transfer(buffer, buffer, len, NULL); -#else +#elsif STM32 for (size_t i = 0; i < len; i++) { _spi->transfer(buffer[i]); } +#else + _spi->transfer(buffer, len); #endif return; From 02b702fc41653201d93942dbc4fd719732555146 Mon Sep 17 00:00:00 2001 From: howard-wa9axq <75182246+howard-wa9axq@users.noreply.github.com> Date: Sat, 28 Nov 2020 16:43:05 -0600 Subject: [PATCH 5/8] Update Adafruit_SPIDevice.cpp Changing #ifdef construct to make STM32 a special case. --- Adafruit_SPIDevice.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Adafruit_SPIDevice.cpp b/Adafruit_SPIDevice.cpp index 6bdf301..5f42145 100644 --- a/Adafruit_SPIDevice.cpp +++ b/Adafruit_SPIDevice.cpp @@ -115,12 +115,14 @@ void Adafruit_SPIDevice::transfer(uint8_t *buffer, size_t len) { #ifdef SPARK _spi->transfer(buffer, buffer, len, NULL); -#elsif STM32 +#else +#ifdef STM32 for (size_t i = 0; i < len; i++) { _spi->transfer(buffer[i]); } #else - _spi->transfer(buffer, len); + _spi->transfer(buffer, len); +#endif #endif return; From b8e11f14f167367025d8ee20010ee6e70533f50c Mon Sep 17 00:00:00 2001 From: howard-wa9axq <75182246+howard-wa9axq@users.noreply.github.com> Date: Sat, 28 Nov 2020 18:22:48 -0600 Subject: [PATCH 6/8] Updated #if #elif structure. Update #if #elif structure to avoid nested #ifdef's --- Adafruit_SPIDevice.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Adafruit_SPIDevice.cpp b/Adafruit_SPIDevice.cpp index 5f42145..cc2c58c 100644 --- a/Adafruit_SPIDevice.cpp +++ b/Adafruit_SPIDevice.cpp @@ -113,17 +113,16 @@ void Adafruit_SPIDevice::transfer(uint8_t *buffer, size_t len) { if (_spi) { // hardware SPI is easy -#ifdef SPARK +#if defined(SPARK) _spi->transfer(buffer, buffer, len, NULL); -#else -#ifdef STM32 +#elif defined(STM32) for (size_t i = 0; i < len; i++) { _spi->transfer(buffer[i]); } #else _spi->transfer(buffer, len); #endif -#endif + return; } From ed828a27f704b707cd3137a9e2a1f398512e4fd5 Mon Sep 17 00:00:00 2001 From: howard-wa9axq <75182246+howard-wa9axq@users.noreply.github.com> Date: Sat, 28 Nov 2020 18:37:05 -0600 Subject: [PATCH 7/8] Removed extra blank line --- Adafruit_SPIDevice.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Adafruit_SPIDevice.cpp b/Adafruit_SPIDevice.cpp index cc2c58c..1b19804 100644 --- a/Adafruit_SPIDevice.cpp +++ b/Adafruit_SPIDevice.cpp @@ -122,9 +122,7 @@ void Adafruit_SPIDevice::transfer(uint8_t *buffer, size_t len) { #else _spi->transfer(buffer, len); #endif - - - return; + return; } uint8_t startbit; From 074a8a9323960f15d78c4f8cb0ea3772cb039922 Mon Sep 17 00:00:00 2001 From: howard-wa9axq <75182246+howard-wa9axq@users.noreply.github.com> Date: Sat, 28 Nov 2020 19:13:19 -0600 Subject: [PATCH 8/8] Update Adafruit_SPIDevice.cpp --- Adafruit_SPIDevice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Adafruit_SPIDevice.cpp b/Adafruit_SPIDevice.cpp index 1b19804..1b6b3bf 100644 --- a/Adafruit_SPIDevice.cpp +++ b/Adafruit_SPIDevice.cpp @@ -122,7 +122,7 @@ void Adafruit_SPIDevice::transfer(uint8_t *buffer, size_t len) { #else _spi->transfer(buffer, len); #endif - return; + return; } uint8_t startbit;