Skip to content

Commit 8822904

Browse files
Some incomplete WICED work; not bumping version # yet
1 parent 33158b3 commit 8822904

File tree

3 files changed

+41
-15
lines changed

3 files changed

+41
-15
lines changed

Adafruit_SPITFT.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@
3232
*
3333
*/
3434

35-
// NOT A CHANCE of this stuff working on ATtiny, No SPIClass on WICED (yet?)
36-
#if (!defined(__AVR_ATtiny85__) && !defined(ARDUINO_STM32_FEATHER))
35+
#if !defined(__AVR_ATtiny85__) // NOT A CHANCE of this stuff working on ATtiny
3736

3837
#include "Adafruit_SPITFT.h"
39-
#include "pins_arduino.h"
40-
#ifndef RASPI
38+
#if !defined(ARDUINO_STM32_FEATHER)
39+
#include "pins_arduino.h"
40+
#endif
41+
#if !defined(ARDUINO_STM32_FEATHER) && !defined(RASPI)
4142
#include "wiring_private.h"
4243
#endif
4344
#include <limits.h>
@@ -112,6 +113,7 @@ Adafruit_SPITFT::Adafruit_SPITFT(uint16_t w, uint16_t h,
112113
#endif
113114
}
114115

116+
#if !defined(ARDUINO_STM32_FEATHER) // No SPIClass on WICED (yet?)
115117
/**************************************************************************/
116118
/*!
117119
@brief Instantiate Adafruit SPI display driver with hardware SPI
@@ -170,6 +172,7 @@ Adafruit_SPITFT::Adafruit_SPITFT(uint16_t w, uint16_t h, SPIClass *spiClass,
170172
}
171173
#endif
172174
}
175+
#endif // !ARDUINO_STM32_FEATHER
173176

174177
/**************************************************************************/
175178
/*!
@@ -216,13 +219,17 @@ void Adafruit_SPITFT::initSPI(uint32_t freq) {
216219

217220
/**************************************************************************/
218221
/*!
219-
@brief Read one byte from SPI interface (hardware or software
222+
@brief Read one byte from SPI interface (hardware or software)
220223
@returns One byte, MSB order
221224
*/
222225
/**************************************************************************/
223226
uint8_t Adafruit_SPITFT::spiRead() {
224227
if(_sclk < 0){
228+
#if defined(ARDUINO_STM32_FEATHER)
229+
return 0; // TODO
230+
#else
225231
return HSPI_READ();
232+
#endif
226233
}
227234
if(_miso < 0){
228235
return 0;
@@ -241,7 +248,7 @@ uint8_t Adafruit_SPITFT::spiRead() {
241248

242249
/**************************************************************************/
243250
/*!
244-
@brief Write one byte to SPI interface (hardware or software
251+
@brief Write one byte to SPI interface (hardware or software)
245252
@param b One byte to send, MSB order
246253
*/
247254
/**************************************************************************/
@@ -569,4 +576,4 @@ void Adafruit_SPITFT::drawRGBBitmap(int16_t x, int16_t y,
569576
endWrite();
570577
}
571578

572-
#endif // !__AVR_ATtiny85__ && !ARDUINO_STM32_FEATHER
579+
#endif // !__AVR_ATtiny85__

Adafruit_SPITFT.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef _ADAFRUIT_SPITFT_
22
#define _ADAFRUIT_SPITFT_
33

4+
#if !defined(__AVR_ATtiny85__) // NOT A CHANCE of this stuff working on ATtiny
5+
46
#if ARDUINO >= 100
57
#include "Arduino.h"
68
#include "Print.h"
@@ -36,9 +38,10 @@ class Adafruit_SPITFT : public Adafruit_GFX {
3638

3739
public:
3840
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);
41+
#if !defined(ARDUINO_STM32_FEATHER) // No SPIClass on WICED (yet?)
3942
Adafruit_SPITFT(uint16_t w, uint16_t h, int8_t _CS, int8_t _DC, int8_t _RST = -1);
4043
Adafruit_SPITFT(uint16_t w, uint16_t h, SPIClass *spiClass, int8_t _CS, int8_t _DC, int8_t _RST = -1);
41-
44+
#endif
4245
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
4346

4447
void initSPI(uint32_t freq);
@@ -88,7 +91,9 @@ class Adafruit_SPITFT : public Adafruit_GFX {
8891
uint16_t color565(uint8_t r, uint8_t g, uint8_t b);
8992

9093
protected:
94+
#if !defined(ARDUINO_STM32_FEATHER)
9195
SPIClass *_spi; ///< The SPI device we want to use (set in constructor)
96+
#endif
9297
uint32_t _freq; ///< SPI clock frequency (for hardware SPI)
9398
#if defined (__AVR__) || defined(TEENSYDUINO) || defined (ESP8266) || defined (ESP32)
9499
int8_t _cs, _dc, _rst, _sclk, _mosi, _miso;
@@ -124,4 +129,6 @@ class Adafruit_SPITFT : public Adafruit_GFX {
124129
int16_t _ystart = 0; ///< Many displays don't have pixels starting at (0,0) of the internal framebuffer, this is the y offset from 0 to align
125130
};
126131

127-
#endif
132+
#endif // !__AVR_ATtiny85__
133+
134+
#endif // !_ADAFRUIT_SPITFT_

Adafruit_SPITFT_Macros.h

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ static inline uint8_t _avr_spi_read(void) {
9797
}
9898
#define HSPI_WRITE(b) {SPDR = (b); while(!(SPSR & _BV(SPIF)));}
9999
#define HSPI_READ() _avr_spi_read()
100+
#elif defined(ARDUINO_STM32_FEATHER) // No SPIClass on WICED (yet?)
101+
#define HSPI_WRITE(b) SSPI_WRITE(b)
102+
#define HSPI_READ() HSPI_WRITE(0)
100103
#else
101104
#define HSPI_WRITE(b) _spi->transfer((uint8_t)(b))
102105
#define HSPI_READ() HSPI_WRITE(0)
@@ -106,11 +109,20 @@ static inline uint8_t _avr_spi_read(void) {
106109
#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]); }
107110
#endif
108111

109-
#define SPI_BEGIN() if(_sclk < 0){_spi->begin();}
110-
#define SPI_BEGIN_TRANSACTION() if(_sclk < 0){HSPI_BEGIN_TRANSACTION();}
111-
#define SPI_END_TRANSACTION() if(_sclk < 0){HSPI_END_TRANSACTION();}
112-
#define SPI_WRITE16(s) if(_sclk < 0){HSPI_WRITE16(s);}else{SSPI_WRITE16(s);}
113-
#define SPI_WRITE32(l) if(_sclk < 0){HSPI_WRITE32(l);}else{SSPI_WRITE32(l);}
114-
#define SPI_WRITE_PIXELS(c,l) if(_sclk < 0){HSPI_WRITE_PIXELS(c,l);}else{SSPI_WRITE_PIXELS(c,l);}
112+
#if defined(ARDUINO_STM32_FEATHER) // No SPIClass on WICED (yet?)
113+
#define SPI_BEGIN()
114+
#define SPI_BEGIN_TRANSACTION()
115+
#define SPI_END_TRANSACTION()
116+
#define SPI_WRITE16(s) SSPI_WRITE16(s);
117+
#define SPI_WRITE32(l) SSPI_WRITE32(l);
118+
#define SPI_WRITE_PIXELS(c,l) SSPI_WRITE_PIXELS(c,l);
119+
#else
120+
#define SPI_BEGIN() if(_sclk < 0){_spi->begin();}
121+
#define SPI_BEGIN_TRANSACTION() if(_sclk < 0){HSPI_BEGIN_TRANSACTION();}
122+
#define SPI_END_TRANSACTION() if(_sclk < 0){HSPI_END_TRANSACTION();}
123+
#define SPI_WRITE16(s) if(_sclk < 0){HSPI_WRITE16(s);}else{SSPI_WRITE16(s);}
124+
#define SPI_WRITE32(l) if(_sclk < 0){HSPI_WRITE32(l);}else{SSPI_WRITE32(l);}
125+
#define SPI_WRITE_PIXELS(c,l) if(_sclk < 0){HSPI_WRITE_PIXELS(c,l);}else{SSPI_WRITE_PIXELS(c,l);}
126+
#endif
115127

116128
#endif // _ADAFRUIT_SPITFT_MACROS

0 commit comments

Comments
 (0)