ILI9488
ILI9488 copied to clipboard
Pinmasks and ports not defined for esp32
When I compile your example sketch for an arduino uno, it works fine. However when I switch the board type to esp32 dev module, I get a bunch of errors:
C:\Users\Max\Documents\Arduino\sketches\libraries\ILI9488-master\ILI9488.cpp: In member function 'void ILI9488::spiwrite(uint8_t)':
C:\Users\Max\Documents\Arduino\sketches\libraries\ILI9488-master\ILI9488.cpp:115:3: error: 'mosiport' was not declared in this scope
*mosiport |= mosipinmask;
^
C:\Users\Max\Documents\Arduino\sketches\libraries\ILI9488-master\ILI9488.cpp:115:16: error: 'mosipinmask' was not declared in this scope
*mosiport |= mosipinmask;
^
C:\Users\Max\Documents\Arduino\sketches\libraries\ILI9488-master\ILI9488.cpp:118:3: error: 'mosiport' was not declared in this scope
*mosiport &= ~mosipinmask;
^
C:\Users\Max\Documents\Arduino\sketches\libraries\ILI9488-master\ILI9488.cpp:118:16: error: 'mosipinmask' was not declared in this scope
*mosiport &= ~mosipinmask;
^
C:\Users\Max\Documents\Arduino\sketches\libraries\ILI9488-master\ILI9488.cpp:121:8: error: 'clkport' was not declared in this scope
*clkport |= clkpinmask;
^
C:\Users\Max\Documents\Arduino\sketches\libraries\ILI9488-master\ILI9488.cpp:121:20: error: 'clkpinmask' was not declared in this scope
*clkport |= clkpinmask;
^
exit status 1
Error compiling for board ESP32 Dev Module.
Is clkpinmask
some sort of built in thing for a regular arduino?
@maxymoo22 It's defined inside his ILI9488.h and ILI9488.cpp routine.
#if defined(USE_FAST_PINIO) && !defined (_VARIANT_ARDUINO_STM32_)
clkport = portOutputRegister(digitalPinToPort(_sclk));
clkpinmask = digitalPinToBitMask(_sclk);
inside the ILI9488.h
#if defined (__AVR__) || defined(TEENSYDUINO)
uint8_t mySPCR;
volatile uint8_t *mosiport, *clkport, *dcport, *rsport, *csport;
int8_t _cs, _dc, _rst, _mosi, _miso, _sclk;
uint8_t mosipinmask, clkpinmask, cspinmask, dcpinmask;
////This def is for the Arduino.ORG M0!!!
//#elif defined(ARDUINO_SAM_ZERO)
// volatile PORT_OUT_Type *mosiport, *clkport, *dcport, *rsport, *csport;
// int32_t _cs, _dc, _rst, _mosi, _miso, _sclk;
// PORT_OUT_Type mosipinmask, clkpinmask, cspinmask, dcpinmask;
#elif defined (__STM32F1__) || defined (_VARIANT_ARDUINO_STM32_) || defined (STM32F100xE) || defined (STM32F101xE) || defined (STM32F101xG) || defined (STM32F103xE) || defined (STM32F103xG) || defined (STM32F105xC) || defined (STM32F107xC)
uint8_t mySPCR;
volatile uint32_t *mosiport, *clkport, *dcport, *rsport, *csport;
int32_t _cs, _dc, _rst, _mosi, _miso, _sclk;
uint32_t mosipinmask, clkpinmask, cspinmask, dcpinmask;
#elif defined (__arm__)
volatile RwReg *mosiport, *clkport, *dcport, *rsport, *csport;
int32_t _cs, _dc, _rst, _mosi, _miso, _sclk;
uint32_t mosipinmask, clkpinmask, cspinmask, dcpinmask;
#elif defined (ESP8266)
int32_t _cs, _dc, _rst, _mosi, _miso, _sclk;
#else
int8_t _cs, _dc, _rst, _mosi, _miso, _sclk;
#endif
Appears the defines are not setup for esp32 but should fall though correctly and not require clkpinmask . Maybe your defines are not correct?
However, note that issue #5
with ILI9488 in 4 wire SPI mode claims the library crashes using ESP32 so...
So I encountered the same problem today, and here's how I solved it:
In the ILI9488::spiwrite function, there's a line that looks like this...
#if defined(ESP8266) || defined (ARDUINO_ARCH_ARC32)
that needs to be changed to this...
#if defined(ESP8266) || defined (ARDUINO_ARCH_ARC32) || defined(ESP32)
so the compiler chooses the block of code that uses the digitalWrite function instead of the block of code with the pinmasks. The example sketch worked for me once I changed this one line.