Skip to content

Commit

Permalink
Fixes for WICED Feather hardware SPI
Browse files Browse the repository at this point in the history
  • Loading branch information
PaintYourDragon committed Nov 17, 2018
1 parent 8822904 commit 9bdc390
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 23 deletions.
6 changes: 0 additions & 6 deletions Adafruit_SPITFT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ Adafruit_SPITFT::Adafruit_SPITFT(uint16_t w, uint16_t h,
#endif
}

#if !defined(ARDUINO_STM32_FEATHER) // No SPIClass on WICED (yet?)
/**************************************************************************/
/*!
@brief Instantiate Adafruit SPI display driver with hardware SPI
Expand Down Expand Up @@ -172,7 +171,6 @@ Adafruit_SPITFT::Adafruit_SPITFT(uint16_t w, uint16_t h, SPIClass *spiClass,
}
#endif
}
#endif // !ARDUINO_STM32_FEATHER

/**************************************************************************/
/*!
Expand Down Expand Up @@ -225,11 +223,7 @@ void Adafruit_SPITFT::initSPI(uint32_t freq) {
/**************************************************************************/
uint8_t Adafruit_SPITFT::spiRead() {
if(_sclk < 0){
#if defined(ARDUINO_STM32_FEATHER)
return 0; // TODO
#else
return HSPI_READ();
#endif
}
if(_miso < 0){
return 0;
Expand Down
5 changes: 1 addition & 4 deletions Adafruit_SPITFT.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#elif defined(ARDUINO_STM32_FEATHER)
typedef volatile uint32 RwReg;
#undef USE_FAST_PINIO
typedef class HardwareSPI SPIClass;
#elif defined(__OPENCR__) || defined (__OPENCM904__)
#undef USE_FAST_PINIO
#elif defined(ARDUINO_FEATHER52) || defined(__arm__)
Expand All @@ -38,10 +39,8 @@ class Adafruit_SPITFT : public Adafruit_GFX {

public:
Adafruit_SPITFT(uint16_t w, uint16_t h, int8_t _CS, int8_t _DC, int8_t _MOSI, int8_t _SCLK, int8_t _RST = -1, int8_t _MISO = -1);
#if !defined(ARDUINO_STM32_FEATHER) // No SPIClass on WICED (yet?)
Adafruit_SPITFT(uint16_t w, uint16_t h, int8_t _CS, int8_t _DC, int8_t _RST = -1);
Adafruit_SPITFT(uint16_t w, uint16_t h, SPIClass *spiClass, int8_t _CS, int8_t _DC, int8_t _RST = -1);
#endif
virtual void begin(uint32_t freq) = 0; ///< Virtual begin() function to set SPI frequency, must be overridden in subclass. @param freq Maximum SPI hardware clock speed

void initSPI(uint32_t freq);
Expand Down Expand Up @@ -91,9 +90,7 @@ class Adafruit_SPITFT : public Adafruit_GFX {
uint16_t color565(uint8_t r, uint8_t g, uint8_t b);

protected:
#if !defined(ARDUINO_STM32_FEATHER)
SPIClass *_spi; ///< The SPI device we want to use (set in constructor)
#endif
uint32_t _freq; ///< SPI clock frequency (for hardware SPI)
#if defined (__AVR__) || defined(TEENSYDUINO) || defined (ESP8266) || defined (ESP32)
int8_t _cs, _dc, _rst, _sclk, _mosi, _miso;
Expand Down
12 changes: 0 additions & 12 deletions Adafruit_SPITFT_Macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ static inline uint8_t _avr_spi_read(void) {
}
#define HSPI_WRITE(b) {SPDR = (b); while(!(SPSR & _BV(SPIF)));}
#define HSPI_READ() _avr_spi_read()
#elif defined(ARDUINO_STM32_FEATHER) // No SPIClass on WICED (yet?)
#define HSPI_WRITE(b) SSPI_WRITE(b)
#define HSPI_READ() HSPI_WRITE(0)
#else
#define HSPI_WRITE(b) _spi->transfer((uint8_t)(b))
#define HSPI_READ() HSPI_WRITE(0)
Expand All @@ -109,20 +106,11 @@ static inline uint8_t _avr_spi_read(void) {
#define HSPI_WRITE_PIXELS(c,l) for(uint32_t i=0; i<(l); i+=2){ HSPI_WRITE(((uint8_t*)(c))[i+1]); HSPI_WRITE(((uint8_t*)(c))[i]); }
#endif

#if defined(ARDUINO_STM32_FEATHER) // No SPIClass on WICED (yet?)
#define SPI_BEGIN()
#define SPI_BEGIN_TRANSACTION()
#define SPI_END_TRANSACTION()
#define SPI_WRITE16(s) SSPI_WRITE16(s);
#define SPI_WRITE32(l) SSPI_WRITE32(l);
#define SPI_WRITE_PIXELS(c,l) SSPI_WRITE_PIXELS(c,l);
#else
#define SPI_BEGIN() if(_sclk < 0){_spi->begin();}
#define SPI_BEGIN_TRANSACTION() if(_sclk < 0){HSPI_BEGIN_TRANSACTION();}
#define SPI_END_TRANSACTION() if(_sclk < 0){HSPI_END_TRANSACTION();}
#define SPI_WRITE16(s) if(_sclk < 0){HSPI_WRITE16(s);}else{SSPI_WRITE16(s);}
#define SPI_WRITE32(l) if(_sclk < 0){HSPI_WRITE32(l);}else{SSPI_WRITE32(l);}
#define SPI_WRITE_PIXELS(c,l) if(_sclk < 0){HSPI_WRITE_PIXELS(c,l);}else{SSPI_WRITE_PIXELS(c,l);}
#endif

#endif // _ADAFRUIT_SPITFT_MACROS
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Adafruit GFX Library
version=1.3.2
version=1.3.3
author=Adafruit
maintainer=Adafruit <info@adafruit.com>
sentence=Adafruit GFX graphics core library, this is the 'core' class that all our other graphics libraries derive from.
Expand Down

0 comments on commit 9bdc390

Please sign in to comment.