UniGraphics Library Fork to support mbed os 6.3 Release for ILI9341

Dependents:   TFT_ILI9341_UniGraphic TFT_ILI9341_os6

Committer:
amouroug
Date:
Thu Oct 08 18:11:03 2020 -0500
Revision:
2:59188908eb60
Parent:
0:bb2bda4f5846
Added GraphicsDisplay GFX API to draw triangle.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
amouroug 0:bb2bda4f5846 1 #ifndef BUS16_H
amouroug 0:bb2bda4f5846 2 #define BUS16_H
amouroug 0:bb2bda4f5846 3
amouroug 0:bb2bda4f5846 4 #include "mbed.h"
amouroug 0:bb2bda4f5846 5 #include "Protocols.h"
amouroug 0:bb2bda4f5846 6 //#include "GraphicsDisplay.h"
amouroug 0:bb2bda4f5846 7
amouroug 0:bb2bda4f5846 8 /** Parallel 16bit interface
amouroug 0:bb2bda4f5846 9 */
amouroug 0:bb2bda4f5846 10 class BUS16 : public Protocols
amouroug 0:bb2bda4f5846 11 {
amouroug 0:bb2bda4f5846 12 public:
amouroug 0:bb2bda4f5846 13
amouroug 0:bb2bda4f5846 14 /** Create a BUS16 display interface with scattered pins and 5 control pins
amouroug 0:bb2bda4f5846 15 *
amouroug 0:bb2bda4f5846 16 * @param buspins array of PinNames to group as Bus
amouroug 0:bb2bda4f5846 17 * @param CS pin connected to CS of display
amouroug 0:bb2bda4f5846 18 * @param reset pin connected to RESET of display
amouroug 0:bb2bda4f5846 19 * @param DC pin connected to data/command of display
amouroug 0:bb2bda4f5846 20 * @param WR pin connected to SDI of display
amouroug 0:bb2bda4f5846 21 * @param RD pin connected to RS of display
amouroug 0:bb2bda4f5846 22 */
amouroug 0:bb2bda4f5846 23 BUS16(PinName* buspins, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD);
amouroug 0:bb2bda4f5846 24
amouroug 0:bb2bda4f5846 25 protected:
amouroug 0:bb2bda4f5846 26
amouroug 0:bb2bda4f5846 27 /** Send 8bit command to display controller
amouroug 0:bb2bda4f5846 28 *
amouroug 0:bb2bda4f5846 29 * @param cmd: byte to send
amouroug 0:bb2bda4f5846 30 *
amouroug 0:bb2bda4f5846 31 */
amouroug 0:bb2bda4f5846 32 virtual void wr_cmd8(unsigned char cmd);
amouroug 0:bb2bda4f5846 33
amouroug 0:bb2bda4f5846 34 /** Send 8bit data to display controller
amouroug 0:bb2bda4f5846 35 *
amouroug 0:bb2bda4f5846 36 * @param data: byte to send
amouroug 0:bb2bda4f5846 37 *
amouroug 0:bb2bda4f5846 38 */
amouroug 0:bb2bda4f5846 39 virtual void wr_data8(unsigned char data);
amouroug 0:bb2bda4f5846 40
amouroug 0:bb2bda4f5846 41 /** Send 2x8bit command to display controller
amouroug 0:bb2bda4f5846 42 *
amouroug 0:bb2bda4f5846 43 * @param cmd: halfword to send
amouroug 0:bb2bda4f5846 44 * @note 2cycles using pins[7:0]
amouroug 0:bb2bda4f5846 45 */
amouroug 0:bb2bda4f5846 46 virtual void wr_cmd16(unsigned short cmd);
amouroug 0:bb2bda4f5846 47
amouroug 0:bb2bda4f5846 48 /** Send 2x8bit data to display controller
amouroug 0:bb2bda4f5846 49 *
amouroug 0:bb2bda4f5846 50 * @param data: halfword to send
amouroug 0:bb2bda4f5846 51 * @note 2cycles using pins[7:0], only gram write cmd uses pins[15:8]
amouroug 0:bb2bda4f5846 52 */
amouroug 0:bb2bda4f5846 53 virtual void wr_data16(unsigned short data);
amouroug 0:bb2bda4f5846 54
amouroug 0:bb2bda4f5846 55 /** Send 16bit pixeldata to display controller
amouroug 0:bb2bda4f5846 56 *
amouroug 0:bb2bda4f5846 57 * @param data: halfword to send
amouroug 0:bb2bda4f5846 58 * @note here using all pins[15:0]
amouroug 0:bb2bda4f5846 59 */
amouroug 0:bb2bda4f5846 60 virtual void wr_gram(unsigned short data);
amouroug 0:bb2bda4f5846 61
amouroug 0:bb2bda4f5846 62 /** Send same 16bit pixeldata to display controller multiple times
amouroug 0:bb2bda4f5846 63 *
amouroug 0:bb2bda4f5846 64 * @param data: halfword to send
amouroug 0:bb2bda4f5846 65 * @param count: how many
amouroug 0:bb2bda4f5846 66 * @note here using all pins[15:0]
amouroug 0:bb2bda4f5846 67 */
amouroug 0:bb2bda4f5846 68 virtual void wr_gram(unsigned short data, unsigned int count);
amouroug 0:bb2bda4f5846 69
amouroug 0:bb2bda4f5846 70 /** Send array of pixeldata shorts to display controller
amouroug 0:bb2bda4f5846 71 *
amouroug 0:bb2bda4f5846 72 * @param data: unsigned short pixeldata array
amouroug 0:bb2bda4f5846 73 * @param lenght: lenght (in shorts)
amouroug 0:bb2bda4f5846 74 * @note here using all pins[15:0]
amouroug 0:bb2bda4f5846 75 */
amouroug 0:bb2bda4f5846 76 virtual void wr_grambuf(unsigned short* data, unsigned int lenght);
amouroug 0:bb2bda4f5846 77
amouroug 0:bb2bda4f5846 78 /** Read 16bit pixeldata from display controller (with dummy cycle)
amouroug 0:bb2bda4f5846 79 *
amouroug 0:bb2bda4f5846 80 * @param convert true/false. Convert 18bit to 16bit, some controllers returns 18bit
amouroug 0:bb2bda4f5846 81 * @returns 16bit color
amouroug 0:bb2bda4f5846 82 */
amouroug 0:bb2bda4f5846 83 virtual unsigned short rd_gram(bool convert);
amouroug 0:bb2bda4f5846 84
amouroug 0:bb2bda4f5846 85 /** Read 4x8bit register data (with dummy cycle)
amouroug 0:bb2bda4f5846 86 * @param reg the register to read
amouroug 0:bb2bda4f5846 87 * @returns data as uint
amouroug 0:bb2bda4f5846 88 *
amouroug 0:bb2bda4f5846 89 */
amouroug 0:bb2bda4f5846 90 virtual unsigned int rd_reg_data32(unsigned char reg);
amouroug 0:bb2bda4f5846 91
amouroug 0:bb2bda4f5846 92 /** Read 3x8bit ExtendedCommands register data
amouroug 0:bb2bda4f5846 93 * @param reg the register to read
amouroug 0:bb2bda4f5846 94 * @returns data as uint
amouroug 0:bb2bda4f5846 95 * @note EXTC regs (0xB0 to 0xFF) are read/write registers, for Parallel mode directly accessible in both directions
amouroug 0:bb2bda4f5846 96 */
amouroug 0:bb2bda4f5846 97 virtual unsigned int rd_extcreg_data32(unsigned char reg, unsigned char SPIreadenablecmd);
amouroug 0:bb2bda4f5846 98
amouroug 0:bb2bda4f5846 99 /** ILI932x specific, does a dummy read cycle, number of bits is protocol dependent
amouroug 0:bb2bda4f5846 100 * for PAR protocols: a signle RD bit toggle
amouroug 0:bb2bda4f5846 101 * for SPI8: 8clocks
amouroug 0:bb2bda4f5846 102 * for SPI16: 16 clocks
amouroug 0:bb2bda4f5846 103 */
amouroug 0:bb2bda4f5846 104 virtual void dummyread ();
amouroug 0:bb2bda4f5846 105
amouroug 0:bb2bda4f5846 106 /** ILI932x specific, select register for a successive write or read
amouroug 0:bb2bda4f5846 107 *
amouroug 0:bb2bda4f5846 108 * @param reg register to be selected
amouroug 0:bb2bda4f5846 109 * @param forread false = a write next (default), true = a read next
amouroug 0:bb2bda4f5846 110 * @note forread only used by SPI protocols
amouroug 0:bb2bda4f5846 111 */
amouroug 0:bb2bda4f5846 112 virtual void reg_select(unsigned char reg, bool forread =false);
amouroug 0:bb2bda4f5846 113
amouroug 0:bb2bda4f5846 114 /** ILI932x specific, write register with data
amouroug 0:bb2bda4f5846 115 *
amouroug 0:bb2bda4f5846 116 * @param reg register to write
amouroug 0:bb2bda4f5846 117 * @param data 16bit data
amouroug 0:bb2bda4f5846 118 */
amouroug 0:bb2bda4f5846 119 virtual void reg_write(unsigned char reg, unsigned short data);
amouroug 0:bb2bda4f5846 120
amouroug 0:bb2bda4f5846 121 /** ILI932x specific, read register
amouroug 0:bb2bda4f5846 122 *
amouroug 0:bb2bda4f5846 123 * @param reg register to be read
amouroug 0:bb2bda4f5846 124 * @returns 16bit register value
amouroug 0:bb2bda4f5846 125 */
amouroug 0:bb2bda4f5846 126 virtual unsigned short reg_read(unsigned char reg);
amouroug 0:bb2bda4f5846 127
amouroug 0:bb2bda4f5846 128 /** HW reset sequence (without display init commands)
amouroug 0:bb2bda4f5846 129 */
amouroug 0:bb2bda4f5846 130 virtual void hw_reset();
amouroug 0:bb2bda4f5846 131
amouroug 0:bb2bda4f5846 132 /** Set ChipSelect high or low
amouroug 0:bb2bda4f5846 133 * @param enable 0/1
amouroug 0:bb2bda4f5846 134 */
amouroug 0:bb2bda4f5846 135 virtual void BusEnable(bool enable);
amouroug 0:bb2bda4f5846 136
amouroug 0:bb2bda4f5846 137
amouroug 0:bb2bda4f5846 138
amouroug 0:bb2bda4f5846 139 private:
amouroug 0:bb2bda4f5846 140
amouroug 0:bb2bda4f5846 141 BusInOut _bus;
amouroug 0:bb2bda4f5846 142 DigitalOut _CS;
amouroug 0:bb2bda4f5846 143 DigitalOut _reset;
amouroug 0:bb2bda4f5846 144 DigitalOut _DC;
amouroug 0:bb2bda4f5846 145 DigitalOut _WR;
amouroug 0:bb2bda4f5846 146 DigitalOut _RD;
amouroug 0:bb2bda4f5846 147
amouroug 0:bb2bda4f5846 148 };
amouroug 0:bb2bda4f5846 149 #endif