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