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/PAR16.h@20:14daa48ffd4c, 2015-03-23 (annotated)
- Committer:
- Geremia
- Date:
- Mon Mar 23 14:08:04 2015 +0000
- Revision:
- 20:14daa48ffd4c
- Parent:
- 11:b842b8e332cb
- Child:
- 25:daacdcf34e52
Add ILI 9320/9325/9328 custom TFT932x class, parallel/spi 8/16bit, with orientation, scroll, pixelread, fastwindow.; Par8 and 16 tested, SPI not at all, needs checking if the CS toggle is necessary (see SPI8.cpp SPI16.cpp).
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Geremia | 4:12ba0ecc2c1f | 1 | #ifndef PAR16_H |
Geremia | 4:12ba0ecc2c1f | 2 | #define PAR16_H |
Geremia | 4:12ba0ecc2c1f | 3 | |
Geremia | 4:12ba0ecc2c1f | 4 | #include "mbed.h" |
Geremia | 4:12ba0ecc2c1f | 5 | #include "Protocols.h" |
Geremia | 4:12ba0ecc2c1f | 6 | //#include "GraphicsDisplay.h" |
Geremia | 4:12ba0ecc2c1f | 7 | |
Geremia | 6:8356d48a07db | 8 | /** Parallel 16bit interface |
Geremia | 6:8356d48a07db | 9 | */ |
Geremia | 4:12ba0ecc2c1f | 10 | class PAR16 : public Protocols |
Geremia | 4:12ba0ecc2c1f | 11 | { |
Geremia | 4:12ba0ecc2c1f | 12 | public: |
Geremia | 4:12ba0ecc2c1f | 13 | |
Geremia | 4:12ba0ecc2c1f | 14 | /** Create a PAR16 display interface with a GPIO port and 5 control pins |
Geremia | 4:12ba0ecc2c1f | 15 | * |
Geremia | 4:12ba0ecc2c1f | 16 | * @param port GPIO port to use |
Geremia | 4:12ba0ecc2c1f | 17 | * @param CS pin connected to CS of display |
Geremia | 4:12ba0ecc2c1f | 18 | * @param reset pin connected to RESET of display |
Geremia | 4:12ba0ecc2c1f | 19 | * @param DC pin connected to data/command of display |
Geremia | 4:12ba0ecc2c1f | 20 | * @param WR pin connected to SDI of display |
Geremia | 4:12ba0ecc2c1f | 21 | * @param RD pin connected to RS of display |
Geremia | 4:12ba0ecc2c1f | 22 | */ |
Geremia | 4:12ba0ecc2c1f | 23 | PAR16(PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD); |
Geremia | 4:12ba0ecc2c1f | 24 | |
Geremia | 4:12ba0ecc2c1f | 25 | protected: |
Geremia | 4:12ba0ecc2c1f | 26 | |
Geremia | 4:12ba0ecc2c1f | 27 | /** Send 8bit command to display controller |
Geremia | 4:12ba0ecc2c1f | 28 | * |
Geremia | 4:12ba0ecc2c1f | 29 | * @param cmd: byte to send |
Geremia | 4:12ba0ecc2c1f | 30 | * |
Geremia | 4:12ba0ecc2c1f | 31 | */ |
Geremia | 4:12ba0ecc2c1f | 32 | virtual void wr_cmd8(unsigned char cmd); |
Geremia | 4:12ba0ecc2c1f | 33 | |
Geremia | 4:12ba0ecc2c1f | 34 | /** Send 8bit data to display controller |
Geremia | 4:12ba0ecc2c1f | 35 | * |
Geremia | 4:12ba0ecc2c1f | 36 | * @param data: byte to send |
Geremia | 4:12ba0ecc2c1f | 37 | * |
Geremia | 4:12ba0ecc2c1f | 38 | */ |
Geremia | 4:12ba0ecc2c1f | 39 | virtual void wr_data8(unsigned char data); |
Geremia | 4:12ba0ecc2c1f | 40 | |
Geremia | 4:12ba0ecc2c1f | 41 | /** Send 2x8bit command to display controller |
Geremia | 4:12ba0ecc2c1f | 42 | * |
Geremia | 4:12ba0ecc2c1f | 43 | * @param cmd: halfword to send |
Geremia | 4:12ba0ecc2c1f | 44 | * @note 2cycles using pins[7:0] |
Geremia | 4:12ba0ecc2c1f | 45 | */ |
Geremia | 4:12ba0ecc2c1f | 46 | virtual void wr_cmd16(unsigned short cmd); |
Geremia | 4:12ba0ecc2c1f | 47 | |
Geremia | 4:12ba0ecc2c1f | 48 | /** Send 2x8bit data to display controller |
Geremia | 4:12ba0ecc2c1f | 49 | * |
Geremia | 4:12ba0ecc2c1f | 50 | * @param data: halfword to send |
Geremia | 4:12ba0ecc2c1f | 51 | * @note 2cycles using pins[7:0], only gram write cmd uses pins[15:8] |
Geremia | 4:12ba0ecc2c1f | 52 | */ |
Geremia | 4:12ba0ecc2c1f | 53 | virtual void wr_data16(unsigned short data); |
Geremia | 4:12ba0ecc2c1f | 54 | |
Geremia | 4:12ba0ecc2c1f | 55 | /** Send 16bit pixeldata to display controller |
Geremia | 4:12ba0ecc2c1f | 56 | * |
Geremia | 4:12ba0ecc2c1f | 57 | * @param data: halfword to send |
Geremia | 4:12ba0ecc2c1f | 58 | * @note here using all pins[15:0] |
Geremia | 4:12ba0ecc2c1f | 59 | */ |
Geremia | 4:12ba0ecc2c1f | 60 | virtual void wr_gram(unsigned short data); |
Geremia | 4:12ba0ecc2c1f | 61 | |
Geremia | 4:12ba0ecc2c1f | 62 | /** Send same 16bit pixeldata to display controller multiple times |
Geremia | 4:12ba0ecc2c1f | 63 | * |
Geremia | 4:12ba0ecc2c1f | 64 | * @param data: halfword to send |
Geremia | 4:12ba0ecc2c1f | 65 | * @param count: how many |
Geremia | 4:12ba0ecc2c1f | 66 | * @note here using all pins[15:0] |
Geremia | 4:12ba0ecc2c1f | 67 | */ |
Geremia | 4:12ba0ecc2c1f | 68 | virtual void wr_gram(unsigned short data, unsigned int count); |
Geremia | 4:12ba0ecc2c1f | 69 | |
Geremia | 4:12ba0ecc2c1f | 70 | /** Send array of pixeldata shorts to display controller |
Geremia | 4:12ba0ecc2c1f | 71 | * |
Geremia | 4:12ba0ecc2c1f | 72 | * @param data: unsigned short pixeldata array |
Geremia | 4:12ba0ecc2c1f | 73 | * @param lenght: lenght (in shorts) |
Geremia | 4:12ba0ecc2c1f | 74 | * @note here using all pins[15:0] |
Geremia | 4:12ba0ecc2c1f | 75 | */ |
Geremia | 4:12ba0ecc2c1f | 76 | virtual void wr_grambuf(unsigned short* data, unsigned int lenght); |
Geremia | 4:12ba0ecc2c1f | 77 | |
Geremia | 5:b222a9461d6b | 78 | /** Read 16bit pixeldata from display controller (with dummy cycle) |
Geremia | 5:b222a9461d6b | 79 | * |
Geremia | 11:b842b8e332cb | 80 | * @param convert true/false. Convert 18bit to 16bit, some controllers returns 18bit |
Geremia | 5:b222a9461d6b | 81 | * @returns 16bit color |
Geremia | 5:b222a9461d6b | 82 | */ |
Geremia | 11:b842b8e332cb | 83 | virtual unsigned short rd_gram(bool convert); |
Geremia | 5:b222a9461d6b | 84 | |
Geremia | 7:bb0383b91104 | 85 | /** Read 4x8bit register data (with dummy cycle) |
Geremia | 7:bb0383b91104 | 86 | * @param reg the register to read |
Geremia | 7:bb0383b91104 | 87 | * @returns data as uint |
Geremia | 7:bb0383b91104 | 88 | * |
Geremia | 7:bb0383b91104 | 89 | */ |
Geremia | 7:bb0383b91104 | 90 | virtual unsigned int rd_reg_data32(unsigned char reg); |
Geremia | 7:bb0383b91104 | 91 | |
Geremia | 7:bb0383b91104 | 92 | /** Read 3x8bit ExtendedCommands register data |
Geremia | 7:bb0383b91104 | 93 | * @param reg the register to read |
Geremia | 7:bb0383b91104 | 94 | * @returns data as uint |
Geremia | 7:bb0383b91104 | 95 | * @note EXTC regs (0xB0 to 0xFF) are read/write registers, for Parallel mode directly accessible in both directions |
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 | 20:14daa48ffd4c | 99 | /** ILI932x specific, does a dummy read cycle, number of bits is protocol dependent |
Geremia | 20:14daa48ffd4c | 100 | * for PAR protocols: a signle RD bit toggle |
Geremia | 20:14daa48ffd4c | 101 | * for SPI8: 8clocks |
Geremia | 20:14daa48ffd4c | 102 | * for SPI16: 16 clocks |
Geremia | 20:14daa48ffd4c | 103 | */ |
Geremia | 20:14daa48ffd4c | 104 | virtual void dummyread (); |
Geremia | 20:14daa48ffd4c | 105 | |
Geremia | 20:14daa48ffd4c | 106 | /** ILI932x specific, select register for a successive write or read |
Geremia | 20:14daa48ffd4c | 107 | * |
Geremia | 20:14daa48ffd4c | 108 | * @param reg register to be selected |
Geremia | 20:14daa48ffd4c | 109 | * @param forread false = a write next (default), true = a read next |
Geremia | 20:14daa48ffd4c | 110 | * @note forread only used by SPI protocols |
Geremia | 20:14daa48ffd4c | 111 | */ |
Geremia | 20:14daa48ffd4c | 112 | virtual void reg_select(unsigned char reg, bool forread =false); |
Geremia | 20:14daa48ffd4c | 113 | |
Geremia | 20:14daa48ffd4c | 114 | /** ILI932x specific, write register with data |
Geremia | 20:14daa48ffd4c | 115 | * |
Geremia | 20:14daa48ffd4c | 116 | * @param reg register to write |
Geremia | 20:14daa48ffd4c | 117 | * @param data 16bit data |
Geremia | 20:14daa48ffd4c | 118 | */ |
Geremia | 20:14daa48ffd4c | 119 | virtual void reg_write(unsigned char reg, unsigned short data); |
Geremia | 20:14daa48ffd4c | 120 | |
Geremia | 20:14daa48ffd4c | 121 | /** ILI932x specific, read register |
Geremia | 20:14daa48ffd4c | 122 | * |
Geremia | 20:14daa48ffd4c | 123 | * @param reg register to be read |
Geremia | 20:14daa48ffd4c | 124 | * @returns 16bit register value |
Geremia | 20:14daa48ffd4c | 125 | */ |
Geremia | 20:14daa48ffd4c | 126 | virtual unsigned short reg_read(unsigned char reg); |
Geremia | 20:14daa48ffd4c | 127 | |
Geremia | 4:12ba0ecc2c1f | 128 | /** HW reset sequence (without display init commands) |
Geremia | 4:12ba0ecc2c1f | 129 | */ |
Geremia | 4:12ba0ecc2c1f | 130 | virtual void hw_reset(); |
Geremia | 4:12ba0ecc2c1f | 131 | |
Geremia | 4:12ba0ecc2c1f | 132 | /** Set ChipSelect high or low |
Geremia | 4:12ba0ecc2c1f | 133 | * @param enable 0/1 |
Geremia | 4:12ba0ecc2c1f | 134 | */ |
Geremia | 4:12ba0ecc2c1f | 135 | virtual void BusEnable(bool enable); |
Geremia | 4:12ba0ecc2c1f | 136 | |
Geremia | 4:12ba0ecc2c1f | 137 | |
Geremia | 4:12ba0ecc2c1f | 138 | |
Geremia | 4:12ba0ecc2c1f | 139 | private: |
Geremia | 4:12ba0ecc2c1f | 140 | |
Geremia | 4:12ba0ecc2c1f | 141 | PortInOut _port; |
Geremia | 4:12ba0ecc2c1f | 142 | DigitalOut _CS; |
Geremia | 4:12ba0ecc2c1f | 143 | DigitalOut _reset; |
Geremia | 4:12ba0ecc2c1f | 144 | DigitalOut _DC; |
Geremia | 4:12ba0ecc2c1f | 145 | DigitalOut _WR; |
Geremia | 4:12ba0ecc2c1f | 146 | DigitalOut _RD; |
Geremia | 4:12ba0ecc2c1f | 147 | |
Geremia | 4:12ba0ecc2c1f | 148 | }; |
Geremia | 4:12ba0ecc2c1f | 149 | #endif |