Basically i glued Peter Drescher and Simon Ford libs in a GraphicsDisplay class, then derived TFT or LCD class (which inherits Protocols class), then the most derived ones (Inits), which are per-display and are the only part needed to be adapted to diff hw.
Dependents: afero_poc15_180216 afero_poc15_180223 afero_poc15_180302 afero_poc15_180403R ... more
Fork of UniGraphic by
UniGraphic for La Suno Version.
To go with La Suno, WatchDog Reset functions were added in ILI9341.
Protocols/SPI8.h@0:75ec1b3cde17, 2015-02-12 (annotated)
- Committer:
- Geremia
- Date:
- Thu Feb 12 22:22:47 2015 +0000
- Revision:
- 0:75ec1b3cde17
- Child:
- 1:ff019d22b275
Initial tests, LCD par and spi ok
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Geremia | 0:75ec1b3cde17 | 1 | #ifndef SPI8_H |
Geremia | 0:75ec1b3cde17 | 2 | #define SPI8_H |
Geremia | 0:75ec1b3cde17 | 3 | |
Geremia | 0:75ec1b3cde17 | 4 | #include "mbed.h" |
Geremia | 0:75ec1b3cde17 | 5 | #include "Protocols.h" |
Geremia | 0:75ec1b3cde17 | 6 | //#include "GraphicsDisplay.h" |
Geremia | 0:75ec1b3cde17 | 7 | |
Geremia | 0:75ec1b3cde17 | 8 | class SPI8 : public Protocols |
Geremia | 0:75ec1b3cde17 | 9 | { |
Geremia | 0:75ec1b3cde17 | 10 | public: |
Geremia | 0:75ec1b3cde17 | 11 | |
Geremia | 0:75ec1b3cde17 | 12 | /** Create an SPI 8bit display interface with 3 control pins |
Geremia | 0:75ec1b3cde17 | 13 | * |
Geremia | 0:75ec1b3cde17 | 14 | * @param SPI mosi |
Geremia | 0:75ec1b3cde17 | 15 | * @param SPI miso |
Geremia | 0:75ec1b3cde17 | 16 | * @param SPI sclk |
Geremia | 0:75ec1b3cde17 | 17 | * @param CS pin connected to CS of display |
Geremia | 0:75ec1b3cde17 | 18 | * @param reset pin connected to RESET of display |
Geremia | 0:75ec1b3cde17 | 19 | * @param DC pin connected to data/command of display |
Geremia | 0:75ec1b3cde17 | 20 | */ |
Geremia | 0:75ec1b3cde17 | 21 | SPI8(PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC); |
Geremia | 0:75ec1b3cde17 | 22 | |
Geremia | 0:75ec1b3cde17 | 23 | protected: |
Geremia | 0:75ec1b3cde17 | 24 | |
Geremia | 0:75ec1b3cde17 | 25 | /** Send command byte to display controller |
Geremia | 0:75ec1b3cde17 | 26 | * |
Geremia | 0:75ec1b3cde17 | 27 | * @param cmd: byte to send |
Geremia | 0:75ec1b3cde17 | 28 | * |
Geremia | 0:75ec1b3cde17 | 29 | */ |
Geremia | 0:75ec1b3cde17 | 30 | virtual void wr_cmd(unsigned char cmd); |
Geremia | 0:75ec1b3cde17 | 31 | |
Geremia | 0:75ec1b3cde17 | 32 | /** Send data byte to display controller |
Geremia | 0:75ec1b3cde17 | 33 | * |
Geremia | 0:75ec1b3cde17 | 34 | * @param data8: byte to send |
Geremia | 0:75ec1b3cde17 | 35 | * |
Geremia | 0:75ec1b3cde17 | 36 | */ |
Geremia | 0:75ec1b3cde17 | 37 | virtual void wr_data8(unsigned char data8); |
Geremia | 0:75ec1b3cde17 | 38 | |
Geremia | 0:75ec1b3cde17 | 39 | /** Send same data byte to display controller multiple times |
Geremia | 0:75ec1b3cde17 | 40 | * |
Geremia | 0:75ec1b3cde17 | 41 | * @param data8: byte to send |
Geremia | 0:75ec1b3cde17 | 42 | * @param count: how many |
Geremia | 0:75ec1b3cde17 | 43 | * |
Geremia | 0:75ec1b3cde17 | 44 | */ |
Geremia | 0:75ec1b3cde17 | 45 | virtual void wr_data8(unsigned char data8, unsigned int count); |
Geremia | 0:75ec1b3cde17 | 46 | |
Geremia | 0:75ec1b3cde17 | 47 | /** Send array of data bytes to display controller |
Geremia | 0:75ec1b3cde17 | 48 | * |
Geremia | 0:75ec1b3cde17 | 49 | * @param data8: unsigned char data array |
Geremia | 0:75ec1b3cde17 | 50 | * @param lenght: lenght of array |
Geremia | 0:75ec1b3cde17 | 51 | * |
Geremia | 0:75ec1b3cde17 | 52 | */ |
Geremia | 0:75ec1b3cde17 | 53 | virtual void wr_data8buf(unsigned char* data8, unsigned int lenght); |
Geremia | 0:75ec1b3cde17 | 54 | |
Geremia | 0:75ec1b3cde17 | 55 | /** HW reset sequence (without display init commands) |
Geremia | 0:75ec1b3cde17 | 56 | */ |
Geremia | 0:75ec1b3cde17 | 57 | virtual void hw_reset(); |
Geremia | 0:75ec1b3cde17 | 58 | |
Geremia | 0:75ec1b3cde17 | 59 | /** Set ChipSelect high or low |
Geremia | 0:75ec1b3cde17 | 60 | * @param enable 0/1 |
Geremia | 0:75ec1b3cde17 | 61 | */ |
Geremia | 0:75ec1b3cde17 | 62 | virtual void BusEnable(bool enable); |
Geremia | 0:75ec1b3cde17 | 63 | |
Geremia | 0:75ec1b3cde17 | 64 | DigitalOut _CS; |
Geremia | 0:75ec1b3cde17 | 65 | |
Geremia | 0:75ec1b3cde17 | 66 | private: |
Geremia | 0:75ec1b3cde17 | 67 | |
Geremia | 0:75ec1b3cde17 | 68 | SPI _spi; |
Geremia | 0:75ec1b3cde17 | 69 | DigitalOut _reset; |
Geremia | 0:75ec1b3cde17 | 70 | DigitalOut _DC; |
Geremia | 0:75ec1b3cde17 | 71 | |
Geremia | 0:75ec1b3cde17 | 72 | }; |
Geremia | 0:75ec1b3cde17 | 73 | #endif |