adafruit / Adafruit-PCD8544-Nokia-5110-LCD-library

Arduino driver for PC8544, most commonly found in small Nokia 5110's
http://ladyada.net/products/nokia5110/
Other
396 stars 226 forks source link

Teensy 3.0 and above support is needed #55

Closed vamsee227 closed 3 years ago

vamsee227 commented 4 years ago

Error compiling the test code for teensy board Adafruit_PCD8544.cpp: In member function 'void Adafruit_PCD8544::begin(uint8_t, uint8_t)': Adafruit_PCD8544.cpp:287:13: error: cannot convert 'volatile uint8_t {aka volatile unsigned char}' to 'PortReg {aka volatile long unsigned int}' in assignment clkport = portOutputRegister(digitalPinToPort(_sclk)); Adafruit_PCD8544.cpp:289:14: error: cannot convert 'volatile uint8_t {aka volatile unsigned char}' to 'PortReg {aka volatile long unsigned int}' in assignment mosiport = portOutputRegister(digitalPinToPort(_din)); Error compiling for board Teensy 3.2 / 3.1.

vamsee227 commented 4 years ago

It worked after editing the header file (H file). After changing "uint32_t" in these lines

else

typedef volatile uint32_t PortReg; ///< PortReg for other chips typedef uint32_t PortMask; ///< PortMask for other chips

endif

Changed to "uint8_t"

else

typedef volatile uint8_t PortReg; ///< PortReg for other chips typedef uint8_t PortMask; ///< PortMask for other chips

endif

I request you to update the library by providing the support for Teensy 3.0 and above boards

Thanks Vamsee

drak7 commented 4 years ago

By default the example uses software SPI, switching to hardware SPI should fix it.

The port registers on the Teensy 3 are emulated as 8-bit for compatibility with Arduino so we could check for that board and use the 8-bit defines. The actual port registers for the teensy are 32-bit and can be used directly, that would be the better way to handle it. See this teensy forum post and this one for more info.

vamsee227 commented 4 years ago

Okay, thanks.

FerGT50 commented 3 years ago

Same problem here. Applying @vamsee227 corrections worked! An update to the library to automatically account for 32 bit Teensies would be nice indeed!

Like:

if defined(SAM3X8E) || defined(ARDUINO_ARCH_SAMD)

typedef volatile RwReg PortReg; ///< PortReg for SAMD typedef uint32_t PortMask; ///< PortMask for SAMD

elif defined(AVR) || defined (TEENSYDUINO)

typedef volatile uint8_t PortReg; ///< PortReg for AVR typedef uint8_t PortMask; ///< PortMask for AVR

else

typedef volatile uint32_t PortReg; ///< PortReg for other chips typedef uint32_t PortMask; ///< PortMask for other chips

endif

ladyada commented 3 years ago

this should be fixed now with the move to busio!