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_mbedSPI.h (1863B)
1 /* 2 * start rewrite from: 3 * https://github.com/arduino/ArduinoCore-mbed/blob/master/libraries/SPI/SPI.cpp 4 */ 5 #ifdef ARDUINO_ARCH_NRF52840 6 7 #ifndef _ARDUINO_MBEDSPI_H_ 8 #define _ARDUINO_MBEDSPI_H_ 9 10 #include <SPI.h> 11 #if !defined(ARDUINO_AS_MBED_LIBRARY) 12 #include "drivers/SPIMaster.h" 13 #else 14 #include "drivers/SPI.h" 15 #endif 16 17 #include "Arduino_DataBus.h" 18 19 #define SPI_MAX_PIXELS_AT_ONCE 32 20 21 class Arduino_mbedSPI : public Arduino_DataBus 22 { 23 public: 24 Arduino_mbedSPI(int8_t dc, int8_t cs = GFX_NOT_DEFINED); // Constructor 25 26 bool begin(int32_t speed = GFX_NOT_DEFINED, int8_t dataMode = GFX_NOT_DEFINED) override; 27 void beginWrite() override; 28 void endWrite() override; 29 void writeCommand(uint8_t) override; 30 void writeCommand16(uint16_t) override; 31 void write(uint8_t) override; 32 void write16(uint16_t) override; 33 void writeRepeat(uint16_t p, uint32_t len) override; 34 void writePixels(uint16_t *data, uint32_t len) override; 35 36 void writeC8D8(uint8_t c, uint8_t d) override; 37 void writeC8D16(uint8_t c, uint16_t d) override; 38 void writeC8D16D16(uint8_t c, uint16_t d1, uint16_t d2) override; 39 void writeBytes(uint8_t *data, uint32_t len) override; 40 void writePattern(uint8_t *data, uint8_t len, uint32_t repeat) override; 41 42 private: 43 INLINE void WRITE(uint8_t d); 44 INLINE void WRITE16(uint16_t d); 45 INLINE void WRITEBUF(uint8_t *buf, size_t count); 46 INLINE void DC_HIGH(void); 47 INLINE void DC_LOW(void); 48 INLINE void CS_HIGH(void); 49 INLINE void CS_LOW(void); 50 51 int8_t _dc, _cs; 52 mbed::SPI *_dev; 53 PORTreg_t _csPortSet; 54 PORTreg_t _csPortClr; 55 PORTreg_t _dcPortSet; 56 PORTreg_t _dcPortClr; 57 ARDUINOGFX_PORT_t _dcPinMask; 58 ARDUINOGFX_PORT_t _csPinMask; 59 60 union 61 { 62 uint8_t _buffer[SPI_MAX_PIXELS_AT_ONCE * 2]; 63 uint16_t _buffer16[SPI_MAX_PIXELS_AT_ONCE]; 64 }; 65 }; 66 67 #endif // _ARDUINO_MBEDSPI_H_ 68 69 #endif // #ifdef ARDUINO_ARCH_NRF52840