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