acid-drop- Hacking the planet from a LilyGo T-Deck using custom firmware |
git clone git://git.acid.vegas/acid-drop.git |
Log | Files | Refs | Archive | README | LICENSE |
Arduino_SWSPI.h (4117B)
1 /* 2 * start rewrite from: 3 * https://github.com/adafruit/Adafruit-GFX-Library.git 4 */ 5 #ifndef _ARDUINO_SWSPI_H_ 6 #define _ARDUINO_SWSPI_H_ 7 8 #include "Arduino_DataBus.h" 9 10 class Arduino_SWSPI : public Arduino_DataBus 11 { 12 public: 13 Arduino_SWSPI(int8_t dc, int8_t cs, int8_t _sck, int8_t _mosi, int8_t _miso = GFX_NOT_DEFINED); // Constructor 14 15 bool begin(int32_t speed = GFX_NOT_DEFINED, int8_t dataMode = GFX_NOT_DEFINED) override; 16 void beginWrite() override; 17 void endWrite() override; 18 void writeCommand(uint8_t) override; 19 void writeCommand16(uint16_t) override; 20 void write(uint8_t) override; 21 void write16(uint16_t) override; 22 void writeRepeat(uint16_t p, uint32_t len) override; 23 void writePixels(uint16_t *data, uint32_t len) override; 24 25 #if !defined(LITTLE_FOOT_PRINT) 26 void writeBytes(uint8_t *data, uint32_t len) override; 27 void writePattern(uint8_t *data, uint8_t len, uint32_t repeat) override; 28 #endif // !defined(LITTLE_FOOT_PRINT) 29 30 private: 31 INLINE void WRITE9BITCOMMAND(uint8_t c); 32 INLINE void WRITE9BITDATA(uint8_t d); 33 INLINE void WRITE(uint8_t d); 34 INLINE void WRITE16(uint16_t d); 35 INLINE void WRITE9BITREPEAT(uint16_t p, uint32_t len); 36 INLINE void WRITEREPEAT(uint16_t p, uint32_t len); 37 INLINE void DC_HIGH(void); 38 INLINE void DC_LOW(void); 39 INLINE void CS_HIGH(void); 40 INLINE void CS_LOW(void); 41 INLINE void SPI_MOSI_HIGH(void); 42 INLINE void SPI_MOSI_LOW(void); 43 INLINE void SPI_SCK_HIGH(void); 44 INLINE void SPI_SCK_LOW(void); 45 INLINE bool SPI_MISO_READ(void); 46 47 int8_t _dc, _cs; 48 int8_t _sck, _mosi, _miso; 49 50 // CLASS INSTANCE VARIABLES -------------------------------------------- 51 52 // Here be dragons! There's a big union of three structures here -- 53 // one each for hardware SPI, software (bitbang) SPI, and parallel 54 // interfaces. This is to save some memory, since a display's connection 55 // will be only one of these. The order of some things is a little weird 56 // in an attempt to get values to align and pack better in RAM. 57 58 #if defined(USE_FAST_PINIO) 59 #if defined(HAS_PORT_SET_CLR) 60 PORTreg_t _csPortSet; ///< PORT register for chip select SET 61 PORTreg_t _csPortClr; ///< PORT register for chip select CLEAR 62 PORTreg_t _dcPortSet; ///< PORT register for data/command SET 63 PORTreg_t _dcPortClr; ///< PORT register for data/command CLEAR 64 PORTreg_t _mosiPortSet; ///< PORT register for MOSI SET 65 PORTreg_t _mosiPortClr; ///< PORT register for MOSI CLEAR 66 PORTreg_t _sckPortSet; ///< PORT register for SCK SET 67 PORTreg_t _sckPortClr; ///< PORT register for SCK CLEAR 68 #if !defined(KINETISK) 69 ARDUINOGFX_PORT_t _csPinMask; ///< Bitmask for chip select 70 ARDUINOGFX_PORT_t _dcPinMask; ///< Bitmask for data/command 71 ARDUINOGFX_PORT_t _mosiPinMask; ///< Bitmask for MOSI 72 ARDUINOGFX_PORT_t _sckPinMask; ///< Bitmask for SCK 73 #endif // !KINETISK 74 #else // !HAS_PORT_SET_CLR 75 PORTreg_t _mosiPort; ///< PORT register for MOSI 76 PORTreg_t _sckPort; ///< PORT register for SCK 77 PORTreg_t _csPort; ///< PORT register for chip select 78 PORTreg_t _dcPort; ///< PORT register for data/command 79 ARDUINOGFX_PORT_t _csPinMaskSet; ///< Bitmask for chip select SET (OR) 80 ARDUINOGFX_PORT_t _csPinMaskClr; ///< Bitmask for chip select CLEAR (AND) 81 ARDUINOGFX_PORT_t _dcPinMaskSet; ///< Bitmask for data/command SET (OR) 82 ARDUINOGFX_PORT_t _dcPinMaskClr; ///< Bitmask for data/command CLEAR (AND) 83 ARDUINOGFX_PORT_t _mosiPinMaskSet; ///< Bitmask for MOSI SET (OR) 84 ARDUINOGFX_PORT_t _mosiPinMaskClr; ///< Bitmask for MOSI CLEAR (AND) 85 ARDUINOGFX_PORT_t _sckPinMaskSet; ///< Bitmask for SCK SET (OR bitmask) 86 ARDUINOGFX_PORT_t _sckPinMaskClr; ///< Bitmask for SCK CLEAR (AND) 87 #endif // HAS_PORT_SET_CLR 88 PORTreg_t _misoPort; ///< PORT (PIN) register for MISO 89 #if !defined(KINETISK) 90 ARDUINOGFX_PORT_t _misoPinMask; ///< Bitmask for MISO 91 #endif // !KINETISK 92 #endif // defined(USE_FAST_PINIO) 93 }; 94 95 #endif // _ARDUINO_SWSPI_H_