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