sparkfun / SparkFun_SX1509_Arduino_Library

Arduino library for the SX1509 16-I/O GPIO expander.
44 stars 38 forks source link

Library fails to compile against Arduino Nano ESP32 #29

Open sniper1651 opened 1 month ago

sniper1651 commented 1 month ago

When using V3.0.5 of the library (included using the IDE package manage) compiling a sketch with the SX1509 library using the Arduino Nano ESP32 as the selected board it fails to compile with the following errors:

C:\<PATH>\Arduino\libraries\SX1509_IO_Expander\src/SparkFunSX1509.h:130:70: error: macro "pinMode" passed 3 arguments, but takes just 2
  void pinMode(uint8_t pin, uint8_t inOut, uint8_t initialLevel = HIGH);

C:\<PATH>\Arduino\libraries\SX1509_IO_Expander\src/SparkFunSX1509.h:156:43: error: macro "digitalRead" passed 2 arguments, but takes just 1
  bool digitalRead(uint8_t pin, bool *value);

Changing the board to Arduino Nano or Arduino Nano Every compiles correctly.

sniper1651 commented 1 month ago

I have spent some more time on this, and if I rename the pinMode function to pinMode2 and the digitalRead to digitalRead2 in the .h and .cpp files it compiles and works, so for some reason when compiling under Nano ESP32 it seems to get confused between the native pinMode and the SX1509.pinMode definitions. Yet it compiles without issues under AVR for a Nano or Nano Every.

Could there be an error in the SparkFunSX1509.h file that causes the confusion within the compiler?