.
Protocols/SPI8.h@11:b842b8e332cb, 2015-02-20 (annotated)
- Committer:
- Geremia
- Date:
- Fri Feb 20 21:32:25 2015 +0000
- Revision:
- 11:b842b8e332cb
- Parent:
- 7:bb0383b91104
- Child:
- 20:14daa48ffd4c
added auto_gram_read_format() to TFt inits. Even if write is set to 16bit RGB color, for some controllers the read cmd outputs 18bit BGR. Now that function will autodetect and set internal flags accordingly, so pixelread() is always correct.
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 | 6:8356d48a07db | 8 | /** SPI 8bit interface |
Geremia | 6:8356d48a07db | 9 | */ |
Geremia | 0:75ec1b3cde17 | 10 | class SPI8 : public Protocols |
Geremia | 0:75ec1b3cde17 | 11 | { |
Geremia | 0:75ec1b3cde17 | 12 | public: |
Geremia | 0:75ec1b3cde17 | 13 | |
Geremia | 0:75ec1b3cde17 | 14 | /** Create an SPI 8bit display interface with 3 control pins |
Geremia | 0:75ec1b3cde17 | 15 | * |
Geremia | 0:75ec1b3cde17 | 16 | * @param SPI mosi |
Geremia | 0:75ec1b3cde17 | 17 | * @param SPI miso |
Geremia | 0:75ec1b3cde17 | 18 | * @param SPI sclk |
Geremia | 0:75ec1b3cde17 | 19 | * @param CS pin connected to CS of display |
Geremia | 0:75ec1b3cde17 | 20 | * @param reset pin connected to RESET of display |
Geremia | 0:75ec1b3cde17 | 21 | * @param DC pin connected to data/command of display |
Geremia | 0:75ec1b3cde17 | 22 | */ |
Geremia | 1:ff019d22b275 | 23 | SPI8(int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC); |
Geremia | 0:75ec1b3cde17 | 24 | |
Geremia | 0:75ec1b3cde17 | 25 | protected: |
Geremia | 0:75ec1b3cde17 | 26 | |
Geremia | 1:ff019d22b275 | 27 | /** Send 8bit command to display controller |
Geremia | 0:75ec1b3cde17 | 28 | * |
Geremia | 0:75ec1b3cde17 | 29 | * @param cmd: byte to send |
Geremia | 0:75ec1b3cde17 | 30 | * |
Geremia | 0:75ec1b3cde17 | 31 | */ |
Geremia | 1:ff019d22b275 | 32 | virtual void wr_cmd8(unsigned char cmd); |
Geremia | 0:75ec1b3cde17 | 33 | |
Geremia | 1:ff019d22b275 | 34 | /** Send 8bit data to display controller |
Geremia | 0:75ec1b3cde17 | 35 | * |
Geremia | 1:ff019d22b275 | 36 | * @param data: byte to send |
Geremia | 0:75ec1b3cde17 | 37 | * |
Geremia | 0:75ec1b3cde17 | 38 | */ |
Geremia | 1:ff019d22b275 | 39 | virtual void wr_data8(unsigned char data); |
Geremia | 0:75ec1b3cde17 | 40 | |
Geremia | 4:12ba0ecc2c1f | 41 | /** Send 2x8bit command to display controller |
Geremia | 1:ff019d22b275 | 42 | * |
Geremia | 1:ff019d22b275 | 43 | * @param cmd: halfword to send |
Geremia | 1:ff019d22b275 | 44 | */ |
Geremia | 1:ff019d22b275 | 45 | virtual void wr_cmd16(unsigned short cmd); |
Geremia | 1:ff019d22b275 | 46 | |
Geremia | 4:12ba0ecc2c1f | 47 | /** Send 2x8bit data to display controller |
Geremia | 1:ff019d22b275 | 48 | * |
Geremia | 1:ff019d22b275 | 49 | * @param data: halfword to send |
Geremia | 1:ff019d22b275 | 50 | * |
Geremia | 1:ff019d22b275 | 51 | */ |
Geremia | 1:ff019d22b275 | 52 | virtual void wr_data16(unsigned short data); |
Geremia | 1:ff019d22b275 | 53 | |
Geremia | 4:12ba0ecc2c1f | 54 | /** Send 16bit pixeldata to display controller |
Geremia | 4:12ba0ecc2c1f | 55 | * |
Geremia | 4:12ba0ecc2c1f | 56 | * @param data: halfword to send |
Geremia | 4:12ba0ecc2c1f | 57 | * |
Geremia | 4:12ba0ecc2c1f | 58 | */ |
Geremia | 4:12ba0ecc2c1f | 59 | virtual void wr_gram(unsigned short data); |
Geremia | 4:12ba0ecc2c1f | 60 | |
Geremia | 4:12ba0ecc2c1f | 61 | /** Send same 16bit pixeldata to display controller multiple times |
Geremia | 1:ff019d22b275 | 62 | * |
Geremia | 1:ff019d22b275 | 63 | * @param data: halfword to send |
Geremia | 1:ff019d22b275 | 64 | * @param count: how many |
Geremia | 1:ff019d22b275 | 65 | * |
Geremia | 1:ff019d22b275 | 66 | */ |
Geremia | 4:12ba0ecc2c1f | 67 | virtual void wr_gram(unsigned short data, unsigned int count); |
Geremia | 1:ff019d22b275 | 68 | |
Geremia | 4:12ba0ecc2c1f | 69 | /** Send array of pixeldata shorts to display controller |
Geremia | 1:ff019d22b275 | 70 | * |
Geremia | 4:12ba0ecc2c1f | 71 | * @param data: unsigned short pixeldata array |
Geremia | 1:ff019d22b275 | 72 | * @param lenght: lenght (in shorts) |
Geremia | 1:ff019d22b275 | 73 | * |
Geremia | 1:ff019d22b275 | 74 | */ |
Geremia | 4:12ba0ecc2c1f | 75 | virtual void wr_grambuf(unsigned short* data, unsigned int lenght); |
Geremia | 0:75ec1b3cde17 | 76 | |
Geremia | 5:b222a9461d6b | 77 | /** Read 16bit pixeldata from display controller (with dummy cycle) |
Geremia | 5:b222a9461d6b | 78 | * |
Geremia | 11:b842b8e332cb | 79 | * @param convert true/false. Convert 18bit to 16bit, some controllers returns 18bit |
Geremia | 5:b222a9461d6b | 80 | * @returns 16bit color |
Geremia | 5:b222a9461d6b | 81 | */ |
Geremia | 11:b842b8e332cb | 82 | virtual unsigned short rd_gram(bool convert); |
Geremia | 5:b222a9461d6b | 83 | |
Geremia | 7:bb0383b91104 | 84 | /** Read 4x8bit register data (with dummy cycle) |
Geremia | 7:bb0383b91104 | 85 | * @param reg the register to read |
Geremia | 7:bb0383b91104 | 86 | * @returns data as uint |
Geremia | 7:bb0383b91104 | 87 | * |
Geremia | 7:bb0383b91104 | 88 | */ |
Geremia | 7:bb0383b91104 | 89 | virtual unsigned int rd_reg_data32(unsigned char reg); |
Geremia | 7:bb0383b91104 | 90 | |
Geremia | 7:bb0383b91104 | 91 | /** Read 3x8bit ExtendedCommands register data |
Geremia | 7:bb0383b91104 | 92 | * @param reg the register to read |
Geremia | 7:bb0383b91104 | 93 | * @param SPIreadenablecmd vendor/device specific cmd to read EXTC registers |
Geremia | 7:bb0383b91104 | 94 | * @returns data as uint |
Geremia | 7:bb0383b91104 | 95 | * @note EXTC regs (0xB0 to 0xFF) are read/write registers but needs special cmd to be read in SPI mode |
Geremia | 7:bb0383b91104 | 96 | */ |
Geremia | 7:bb0383b91104 | 97 | virtual unsigned int rd_extcreg_data32(unsigned char reg, unsigned char SPIreadenablecmd); |
Geremia | 7:bb0383b91104 | 98 | |
Geremia | 0:75ec1b3cde17 | 99 | /** HW reset sequence (without display init commands) |
Geremia | 0:75ec1b3cde17 | 100 | */ |
Geremia | 0:75ec1b3cde17 | 101 | virtual void hw_reset(); |
Geremia | 0:75ec1b3cde17 | 102 | |
Geremia | 0:75ec1b3cde17 | 103 | /** Set ChipSelect high or low |
Geremia | 0:75ec1b3cde17 | 104 | * @param enable 0/1 |
Geremia | 0:75ec1b3cde17 | 105 | */ |
Geremia | 0:75ec1b3cde17 | 106 | virtual void BusEnable(bool enable); |
Geremia | 0:75ec1b3cde17 | 107 | |
Geremia | 0:75ec1b3cde17 | 108 | DigitalOut _CS; |
Geremia | 0:75ec1b3cde17 | 109 | |
Geremia | 0:75ec1b3cde17 | 110 | private: |
Geremia | 0:75ec1b3cde17 | 111 | |
Geremia | 0:75ec1b3cde17 | 112 | SPI _spi; |
Geremia | 0:75ec1b3cde17 | 113 | DigitalOut _reset; |
Geremia | 0:75ec1b3cde17 | 114 | DigitalOut _DC; |
Geremia | 0:75ec1b3cde17 | 115 | |
Geremia | 0:75ec1b3cde17 | 116 | }; |
Geremia | 0:75ec1b3cde17 | 117 | #endif |