Skip to content

Commit

Permalink
SPI: fix bug in csPin data type
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
logicog committed Sep 4, 2023
1 parent 6647a15 commit 1a89fde
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/SpiFirmata.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
struct spi_device_config {
byte deviceIdChannel;
byte csPinOptions;
byte csPin;
char csPin;
boolean packedData;
SPISettings spi_settings;
boolean used;
Expand Down

0 comments on commit 1a89fde

Please sign in to comment.