Basically i glued Peter Drescher and Simon Ford libs in a GraphicsDisplay class, then derived TFT or LCD class (which inherits Protocols class), then the most derived ones (Inits), which are per-display and are the only part needed to be adapted to diff hw.

Fork of UniGraphic by GraphicsDisplay

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers BUS16.h Source File

BUS16.h

00001 #ifndef BUS16_H
00002 #define BUS16_H
00003 
00004 #include "mbed.h"
00005 #include "Protocols.h "
00006 //#include "GraphicsDisplay.h"
00007 
00008 /** Parallel 16bit interface
00009 */
00010 class BUS16 : public Protocols
00011 {
00012  public:
00013 
00014     /** Create a BUS16 display interface with scattered pins and 5 control pins
00015     *
00016     * @param buspins array of PinNames to group as Bus
00017     * @param CS pin connected to CS of display
00018     * @param reset pin connected to RESET of display
00019     * @param DC pin connected to data/command of display
00020     * @param WR pin connected to SDI of display
00021     * @param RD pin connected to RS of display 
00022     */ 
00023     BUS16(PinName* buspins, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD);
00024 
00025 protected:
00026   
00027     /** Send 8bit command to display controller 
00028     *
00029     * @param cmd: byte to send  
00030     *
00031     */   
00032     virtual void wr_cmd8(unsigned char cmd);
00033     
00034     /** Send 8bit data to display controller 
00035     *
00036     * @param data: byte to send   
00037     *
00038     */   
00039     virtual void wr_data8(unsigned char data);
00040     
00041     /** Send 2x8bit command to display controller 
00042     *
00043     * @param cmd: halfword to send  
00044     * @note 2cycles using pins[7:0]
00045     */   
00046     virtual void wr_cmd16(unsigned short cmd);
00047     
00048     /** Send 2x8bit data to display controller 
00049     *
00050     * @param data: halfword to send   
00051     * @note 2cycles using pins[7:0], only gram write cmd uses pins[15:8]
00052     */   
00053     virtual void wr_data16(unsigned short data);
00054     
00055     /** Send 16bit pixeldata to display controller 
00056     *
00057     * @param data: halfword to send   
00058     * @note here using all pins[15:0]
00059     */   
00060     virtual void wr_gram(unsigned short data);
00061     
00062     /** Send same 16bit pixeldata to display controller multiple times
00063     *
00064     * @param data: halfword to send
00065     * @param count: how many
00066     * @note here using all pins[15:0]
00067     */   
00068     virtual void wr_gram(unsigned short data, unsigned int count);
00069     
00070     /** Send array of pixeldata shorts to display controller
00071     *
00072     * @param data: unsigned short pixeldata array
00073     * @param lenght: lenght (in shorts)
00074     * @note here using all pins[15:0]
00075     */   
00076     virtual void wr_grambuf(unsigned short* data, unsigned int lenght);
00077     
00078     /** Read 16bit pixeldata from display controller (with dummy cycle)
00079     *
00080     * @param convert true/false. Convert 18bit to 16bit, some controllers returns 18bit
00081     * @returns 16bit color
00082     */ 
00083     virtual unsigned short rd_gram(bool convert);
00084     
00085     /** Read 4x8bit register data (with dummy cycle)
00086     * @param reg the register to read
00087     * @returns data as uint
00088     * 
00089     */ 
00090     virtual unsigned int rd_reg_data32(unsigned char reg);
00091     
00092     /** Read 3x8bit ExtendedCommands register data
00093     * @param reg the register to read
00094     * @returns data as uint
00095     * @note EXTC regs (0xB0 to 0xFF) are read/write registers, for Parallel mode directly accessible in both directions
00096     */ 
00097     virtual unsigned int rd_extcreg_data32(unsigned char reg, unsigned char SPIreadenablecmd);
00098     
00099     /** ILI932x specific, does a dummy read cycle, number of bits is protocol dependent
00100     * for PAR protocols: a signle RD bit toggle
00101     * for SPI8: 8clocks
00102     * for SPI16: 16 clocks
00103     */   
00104     virtual void dummyread ();
00105     
00106     /** ILI932x specific, select register for a successive write or read
00107     *
00108     * @param reg register to be selected
00109     * @param forread false = a write next (default), true = a read next
00110     * @note forread only used by SPI protocols
00111     */   
00112     virtual void reg_select(unsigned char reg, bool forread =false);
00113     
00114     /** ILI932x specific, write register with data
00115     *
00116     * @param reg register to write
00117     * @param data 16bit data
00118     */   
00119     virtual void reg_write(unsigned char reg, unsigned short data);
00120     
00121     /** ILI932x specific, read register
00122     *
00123     * @param reg register to be read
00124     * @returns 16bit register value
00125     */ 
00126     virtual unsigned short reg_read(unsigned char reg);
00127     
00128     /** HW reset sequence (without display init commands)   
00129     */
00130     virtual void hw_reset();
00131     
00132     /** Set ChipSelect high or low
00133     * @param enable 0/1   
00134     */
00135     virtual void BusEnable(bool enable);
00136   
00137    
00138 
00139 private:
00140 
00141     BusInOut _bus;
00142     DigitalOut _CS; 
00143     DigitalOut _reset;
00144     DigitalOut _DC;
00145     DigitalOut _WR;
00146     DigitalOut _RD;
00147   
00148 };
00149 #endif