RobTillaart / MCP23S17

Arduino library for SPI based MCP23S17 16 channel port expander
MIT License
27 stars 11 forks source link

Compilation for Arduino Nano 33 BLE fails #6

Closed electrickery closed 2 years ago

electrickery commented 2 years ago

When I compile for the Arduino Nano 33 BLE (an ARM derived Arduino), compilations fails. The logging doesn't even mention my code, but fails on the MCP23S17 library. When I explicitly cast to the PinStatus-type, like "::digitalWrite(dao, ((PinStatus)(val & mask)));", compilation succeeds. Haven't tested the result yet, as other troubles bricked my Arduino. This is with Arduino IDE 1.8.19.

.../libraries/MCP23S17/MCP23S17.cpp: In member function 'uint8_t MCP23S17::swSPI_transfer(uint8_t)': .../libraries/MCP23S17/MCP23S17.cpp:652:30: error: invalid conversion from 'int' to 'PinStatus' [-fpermissive] ::digitalWrite(dao, (val & mask));


In file included from .../.arduino15/packages/arduino/hardware/mbed_nano/3.0.1/variants/ARDUINO_NANO33BLE/pinmode_arduino.h:23:0,
                 from .../.arduino15/packages/arduino/hardware/mbed_nano/3.0.1/cores/arduino/Arduino.h:26,
                 from .../ArduinoSketchbook/libraries/MCP23S17/MCP23S17.cpp:16:
.../.arduino15/packages/arduino/hardware/mbed_nano/3.0.1/cores/arduino/api/Common.h:96:6: note:   initializing argument 2 of 'void digitalWrite(pin_size_t, PinStatus)'
 void digitalWrite(pin_size_t pinNumber, PinStatus status);
      ^~~~~~~~~~~~
exit status 1
Error compiling for board Arduino Nano 33 BLE.
RobTillaart commented 2 years ago

Thanks for opening this issue, I did not test this library with the NANO33 as far as I recall. I have no hardware nearby so I will try to recreate the problem without.

Q: does the problem also occur with one of the examples?

RobTillaart commented 2 years ago

Used the MCP23S17_digitalWrite.ino example

RobTillaart commented 2 years ago

Found the problem, created a develop branch with solution.

RobTillaart commented 2 years ago

@electrickery Can you please verify?

electrickery commented 2 years ago

@RobTillaart: I can confirm it compiles for the NANO 33 BLE. Testing code is not yet possible, as both my NANO33 BLE's are bricked for a unknown, unrelated reason (bug in upload routines?).

RobTillaart commented 2 years ago

Ok i will merge things tomorrow.

Not an expert on NANO33, is it only your code that fails to upload or even a minimal blink led sketch?