From 1a89fde123e2acd63c57acfdb0b01d3dd1a1d0e1 Mon Sep 17 00:00:00 2001 From: Birger Koblitz Date: Mon, 4 Sep 2023 11:15:52 +0200 Subject: [PATCH] SPI: fix bug in csPin data type The data type of the csPin member of spi_device_config was wrong. The field will be set to -1 if no pin is set or manual cs-pin control is used. Then the comparisons with -1 in the code will not work as expected, see https://stackoverflow.com/questions/36770376/comparing-unsigned-char-to-a-negative-number So we use "char" instead of "byte" and the code behaves as expected. --- src/SpiFirmata.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SpiFirmata.h b/src/SpiFirmata.h index f405d04..9300d09 100644 --- a/src/SpiFirmata.h +++ b/src/SpiFirmata.h @@ -40,7 +40,7 @@ struct spi_device_config { byte deviceIdChannel; byte csPinOptions; - byte csPin; + char csPin; boolean packedData; SPISettings spi_settings; boolean used;