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