UniGraphics Library Fork to support mbed os 6.3 Release for ILI9341

Dependents:   TFT_ILI9341_UniGraphic TFT_ILI9341_os6

Committer:
amouroug
Date:
Tue Oct 06 05:07:55 2020 +0000
Revision:
0:bb2bda4f5846
Unigraphics Library Fork to support mbed-os 6.3 for ILI9341;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
amouroug 0:bb2bda4f5846 1 #ifndef I2C_bus_H
amouroug 0:bb2bda4f5846 2 #define I2C_bus_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 /** I2C interface
amouroug 0:bb2bda4f5846 8 */
amouroug 0:bb2bda4f5846 9 class I2C_bus : public Protocols
amouroug 0:bb2bda4f5846 10 {
amouroug 0:bb2bda4f5846 11 public:
amouroug 0:bb2bda4f5846 12
amouroug 0:bb2bda4f5846 13 /** Create an I2C display interface
amouroug 0:bb2bda4f5846 14 *
amouroug 0:bb2bda4f5846 15 * @param I2C frquency
amouroug 0:bb2bda4f5846 16 * @param I2C address
amouroug 0:bb2bda4f5846 17 * @param I2C pin sda
amouroug 0:bb2bda4f5846 18 * @param I2C pin scl
amouroug 0:bb2bda4f5846 19 */
amouroug 0:bb2bda4f5846 20 I2C_bus(int Hz, int address,PinName sda, PinName scl);
amouroug 0:bb2bda4f5846 21
amouroug 0:bb2bda4f5846 22 protected:
amouroug 0:bb2bda4f5846 23
amouroug 0:bb2bda4f5846 24 /** Send 8bit command to display controller
amouroug 0:bb2bda4f5846 25 *
amouroug 0:bb2bda4f5846 26 * @param cmd: byte to send
amouroug 0:bb2bda4f5846 27 *
amouroug 0:bb2bda4f5846 28 */
amouroug 0:bb2bda4f5846 29 virtual void wr_cmd8(unsigned char cmd);
amouroug 0:bb2bda4f5846 30
amouroug 0:bb2bda4f5846 31 /** Send 8bit data to display controller
amouroug 0:bb2bda4f5846 32 *
amouroug 0:bb2bda4f5846 33 * @param data: byte to send
amouroug 0:bb2bda4f5846 34 *
amouroug 0:bb2bda4f5846 35 */
amouroug 0:bb2bda4f5846 36 virtual void wr_data8(unsigned char data);
amouroug 0:bb2bda4f5846 37
amouroug 0:bb2bda4f5846 38 /** Send 2x8bit command to display controller
amouroug 0:bb2bda4f5846 39 *
amouroug 0:bb2bda4f5846 40 * @param cmd: halfword to send
amouroug 0:bb2bda4f5846 41 * @note in SPI_16 mode a single 16bit transfer will be done
amouroug 0:bb2bda4f5846 42 */
amouroug 0:bb2bda4f5846 43 virtual void wr_cmd16(unsigned short cmd);
amouroug 0:bb2bda4f5846 44
amouroug 0:bb2bda4f5846 45 /** Send 2x8bit data to display controller
amouroug 0:bb2bda4f5846 46 *
amouroug 0:bb2bda4f5846 47 * @param data: halfword to send
amouroug 0:bb2bda4f5846 48 * @note in SPI_16 mode a single 16bit transfer will be done
amouroug 0:bb2bda4f5846 49 */
amouroug 0:bb2bda4f5846 50 virtual void wr_data16(unsigned short data);
amouroug 0:bb2bda4f5846 51
amouroug 0:bb2bda4f5846 52 /** Send 16bit pixeldata to display controller
amouroug 0:bb2bda4f5846 53 *
amouroug 0:bb2bda4f5846 54 * @param data: halfword to send
amouroug 0:bb2bda4f5846 55 *
amouroug 0:bb2bda4f5846 56 */
amouroug 0:bb2bda4f5846 57 virtual void wr_gram(unsigned short data);
amouroug 0:bb2bda4f5846 58
amouroug 0:bb2bda4f5846 59 /** Send same 16bit pixeldata to display controller multiple times
amouroug 0:bb2bda4f5846 60 *
amouroug 0:bb2bda4f5846 61 * @param data: halfword to send
amouroug 0:bb2bda4f5846 62 * @param count: how many
amouroug 0:bb2bda4f5846 63 *
amouroug 0:bb2bda4f5846 64 */
amouroug 0:bb2bda4f5846 65 virtual void wr_gram(unsigned short data, unsigned int count);
amouroug 0:bb2bda4f5846 66
amouroug 0:bb2bda4f5846 67 /** Send array of pixeldata shorts to display controller
amouroug 0:bb2bda4f5846 68 *
amouroug 0:bb2bda4f5846 69 * @param data: unsigned short pixeldata array
amouroug 0:bb2bda4f5846 70 * @param lenght: lenght (in shorts)
amouroug 0:bb2bda4f5846 71 *
amouroug 0:bb2bda4f5846 72 */
amouroug 0:bb2bda4f5846 73 virtual void wr_grambuf(unsigned short* data, unsigned int lenght);
amouroug 0:bb2bda4f5846 74
amouroug 0:bb2bda4f5846 75 /** Read 16bit pixeldata from display controller (with dummy cycle)
amouroug 0:bb2bda4f5846 76 *
amouroug 0:bb2bda4f5846 77 * @param convert true/false. Convert 18bit to 16bit, some controllers returns 18bit
amouroug 0:bb2bda4f5846 78 * @returns 16bit color
amouroug 0:bb2bda4f5846 79 */
amouroug 0:bb2bda4f5846 80 virtual unsigned short rd_gram(bool convert);
amouroug 0:bb2bda4f5846 81
amouroug 0:bb2bda4f5846 82 /** Read 4x8bit register data (
amouroug 0:bb2bda4f5846 83 * reading from display ia I2C is not implemented in most controllers !
amouroug 0:bb2bda4f5846 84 *
amouroug 0:bb2bda4f5846 85 */
amouroug 0:bb2bda4f5846 86 virtual unsigned int rd_reg_data32(unsigned char reg);
amouroug 0:bb2bda4f5846 87
amouroug 0:bb2bda4f5846 88 /** Read 3x8bit ExtendedCommands register data
amouroug 0:bb2bda4f5846 89 * reading from display ia I2C is not implemented in most controllers !
amouroug 0:bb2bda4f5846 90 */
amouroug 0:bb2bda4f5846 91 virtual unsigned int rd_extcreg_data32(unsigned char reg, unsigned char SPIreadenablecmd);
amouroug 0:bb2bda4f5846 92
amouroug 0:bb2bda4f5846 93 /** ILI932x specific, does a dummy read cycle, number of bits is protocol dependent
amouroug 0:bb2bda4f5846 94 * reading from display ia I2C is not implemented in most controllers !
amouroug 0:bb2bda4f5846 95 */
amouroug 0:bb2bda4f5846 96 virtual void dummyread ();
amouroug 0:bb2bda4f5846 97
amouroug 0:bb2bda4f5846 98 /** ILI932x specific, select register for a successive write or read
amouroug 0:bb2bda4f5846 99 *
amouroug 0:bb2bda4f5846 100 * reading from display ia I2C is not implemented in most controllers !
amouroug 0:bb2bda4f5846 101 */
amouroug 0:bb2bda4f5846 102 virtual void reg_select(unsigned char reg, bool forread =false);
amouroug 0:bb2bda4f5846 103
amouroug 0:bb2bda4f5846 104 /** ILI932x specific, write register with data
amouroug 0:bb2bda4f5846 105 *
amouroug 0:bb2bda4f5846 106 * @param reg register to write
amouroug 0:bb2bda4f5846 107 * @param data 16bit data
amouroug 0:bb2bda4f5846 108 * not implemented for I2C !
amouroug 0:bb2bda4f5846 109 */
amouroug 0:bb2bda4f5846 110 virtual void reg_write(unsigned char reg, unsigned short data);
amouroug 0:bb2bda4f5846 111
amouroug 0:bb2bda4f5846 112 /** ILI932x specific, read register
amouroug 0:bb2bda4f5846 113 *
amouroug 0:bb2bda4f5846 114 * @param reg register to be read
amouroug 0:bb2bda4f5846 115 * @returns 16bit register value
amouroug 0:bb2bda4f5846 116 * not implemented for I2C !
amouroug 0:bb2bda4f5846 117 */
amouroug 0:bb2bda4f5846 118 virtual unsigned short reg_read(unsigned char reg);
amouroug 0:bb2bda4f5846 119
amouroug 0:bb2bda4f5846 120 /** HW reset sequence (without display init commands)
amouroug 0:bb2bda4f5846 121 * most I2C displays have no reset signal !
amouroug 0:bb2bda4f5846 122 */
amouroug 0:bb2bda4f5846 123 virtual void hw_reset();
amouroug 0:bb2bda4f5846 124
amouroug 0:bb2bda4f5846 125 /** Set ChipSelect high or low
amouroug 0:bb2bda4f5846 126 * @param enable 0/1
amouroug 0:bb2bda4f5846 127 * not implemented for I2C !
amouroug 0:bb2bda4f5846 128 */
amouroug 0:bb2bda4f5846 129 virtual void BusEnable(bool enable);
amouroug 0:bb2bda4f5846 130
amouroug 0:bb2bda4f5846 131 private:
amouroug 0:bb2bda4f5846 132
amouroug 0:bb2bda4f5846 133 I2C _i2c;
amouroug 0:bb2bda4f5846 134 int _address;
amouroug 0:bb2bda4f5846 135
amouroug 0:bb2bda4f5846 136 };
amouroug 0:bb2bda4f5846 137
amouroug 0:bb2bda4f5846 138
amouroug 0:bb2bda4f5846 139 #endif