From 37872ede01961c59a47cb55022f570328f00111e Mon Sep 17 00:00:00 2001 From: "David J. Fiddes" Date: Thu, 7 Nov 2019 11:54:56 +0000 Subject: [PATCH 1/3] SPI: Fix discarded-qalifiers warning when compiling with all warnings This fixes an error introduced with changeset b847f41 which tightened the use of const for read-only data. The helper funtion __transferBytes also requires the const qualifier on outgoing data. Without this change a warning is displayed when compiling with the Arduino IDE set to display "All" compiler warnings. Tests: - Build an ESP32 SPI sketch that uses static const data to send to an SPI device using the SPI.transferBytes() API --- cores/esp32/esp32-hal-spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/esp32/esp32-hal-spi.c b/cores/esp32/esp32-hal-spi.c index 9dfe34cb8e0..73c6f791391 100644 --- a/cores/esp32/esp32-hal-spi.c +++ b/cores/esp32/esp32-hal-spi.c @@ -630,7 +630,7 @@ uint32_t spiTransferLong(spi_t * spi, uint32_t data) return data; } -void __spiTransferBytes(spi_t * spi, uint8_t * data, uint8_t * out, uint32_t bytes) +void __spiTransferBytes(spi_t * spi, const uint8_t * data, uint8_t * out, uint32_t bytes) { if(!spi) { return; From 42b8ca9f6f7b99d7dd3e01179793e6e0f9c0cf50 Mon Sep 17 00:00:00 2001 From: "David J. Fiddes" Date: Mon, 11 Nov 2019 16:28:04 +0000 Subject: [PATCH 2/3] SPI:Ensure all local functions are marked static This audits all functions in the esp32-hal-xpi.c module and ensures that any functions entirely local to the module are marked as static. Tests: - Build with Arduino set to show all warnings and ensure none are displayed --- cores/esp32/esp32-hal-spi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cores/esp32/esp32-hal-spi.c b/cores/esp32/esp32-hal-spi.c index 73c6f791391..1e191859c01 100644 --- a/cores/esp32/esp32-hal-spi.c +++ b/cores/esp32/esp32-hal-spi.c @@ -532,7 +532,7 @@ uint8_t spiTransferByte(spi_t * spi, uint8_t data) return data; } -uint32_t __spiTranslate24(uint32_t data) +static uint32_t __spiTranslate24(uint32_t data) { union { uint32_t l; @@ -542,7 +542,7 @@ uint32_t __spiTranslate24(uint32_t data) return out.b[2] | (out.b[1] << 8) | (out.b[0] << 16); } -uint32_t __spiTranslate32(uint32_t data) +static uint32_t __spiTranslate32(uint32_t data) { union { uint32_t l; @@ -630,7 +630,7 @@ uint32_t spiTransferLong(spi_t * spi, uint32_t data) return data; } -void __spiTransferBytes(spi_t * spi, const uint8_t * data, uint8_t * out, uint32_t bytes) +static void __spiTransferBytes(spi_t * spi, const uint8_t * data, uint8_t * out, uint32_t bytes) { if(!spi) { return; From ad73f57c26c888a9e0e278244dbe3e4d8f7336df Mon Sep 17 00:00:00 2001 From: "David J. Fiddes" Date: Mon, 11 Nov 2019 16:32:57 +0000 Subject: [PATCH 3/3] SPI: Remove unused local __spiTranslate24 function This removes the __spiTranslate24() function which is unused. --- cores/esp32/esp32-hal-spi.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/cores/esp32/esp32-hal-spi.c b/cores/esp32/esp32-hal-spi.c index 1e191859c01..cf302cac88f 100644 --- a/cores/esp32/esp32-hal-spi.c +++ b/cores/esp32/esp32-hal-spi.c @@ -532,16 +532,6 @@ uint8_t spiTransferByte(spi_t * spi, uint8_t data) return data; } -static uint32_t __spiTranslate24(uint32_t data) -{ - union { - uint32_t l; - uint8_t b[4]; - } out; - out.l = data; - return out.b[2] | (out.b[1] << 8) | (out.b[0] << 16); -} - static uint32_t __spiTranslate32(uint32_t data) { union {