Some incomplete WICED work; not bumping version # yet

This commit is contained in:
Phillip Burgess 2018-11-15 19:14:23 -08:00
parent 33158b3986
commit 882290442a
3 changed files with 41 additions and 15 deletions

View File

@ -32,12 +32,13 @@
*
*/
// NOT A CHANCE of this stuff working on ATtiny, No SPIClass on WICED (yet?)
#if (!defined(__AVR_ATtiny85__) && !defined(ARDUINO_STM32_FEATHER))
#if !defined(__AVR_ATtiny85__) // NOT A CHANCE of this stuff working on ATtiny
#include "Adafruit_SPITFT.h"
#if !defined(ARDUINO_STM32_FEATHER)
#include "pins_arduino.h"
#ifndef RASPI
#endif
#if !defined(ARDUINO_STM32_FEATHER) && !defined(RASPI)
#include "wiring_private.h"
#endif
#include <limits.h>
@ -112,6 +113,7 @@ 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
@ -170,6 +172,7 @@ Adafruit_SPITFT::Adafruit_SPITFT(uint16_t w, uint16_t h, SPIClass *spiClass,
}
#endif
}
#endif // !ARDUINO_STM32_FEATHER
/**************************************************************************/
/*!
@ -216,13 +219,17 @@ void Adafruit_SPITFT::initSPI(uint32_t freq) {
/**************************************************************************/
/*!
@brief Read one byte from SPI interface (hardware or software
@brief Read one byte from SPI interface (hardware or software)
@returns One byte, MSB order
*/
/**************************************************************************/
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;
@ -241,7 +248,7 @@ uint8_t Adafruit_SPITFT::spiRead() {
/**************************************************************************/
/*!
@brief Write one byte to SPI interface (hardware or software
@brief Write one byte to SPI interface (hardware or software)
@param b One byte to send, MSB order
*/
/**************************************************************************/
@ -569,4 +576,4 @@ void Adafruit_SPITFT::drawRGBBitmap(int16_t x, int16_t y,
endWrite();
}
#endif // !__AVR_ATtiny85__ && !ARDUINO_STM32_FEATHER
#endif // !__AVR_ATtiny85__

View File

@ -1,6 +1,8 @@
#ifndef _ADAFRUIT_SPITFT_
#define _ADAFRUIT_SPITFT_
#if !defined(__AVR_ATtiny85__) // NOT A CHANCE of this stuff working on ATtiny
#if ARDUINO >= 100
#include "Arduino.h"
#include "Print.h"
@ -36,9 +38,10 @@ 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);
@ -88,7 +91,9 @@ 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;
@ -124,4 +129,6 @@ class Adafruit_SPITFT : public Adafruit_GFX {
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
};
#endif
#endif // !__AVR_ATtiny85__
#endif // !_ADAFRUIT_SPITFT_

View File

@ -97,6 +97,9 @@ 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)
@ -106,11 +109,20 @@ 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