Darren Ulrich / UniGraphic

Dependents:   Bicycl_Computer_NUCLEO-F411RE Bicycl_Computer_NUCLEO-L476RG

Fork of UniGraphic by GraphicsDisplay

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SPI8.h Source File

SPI8.h

00001 #ifndef SPI8_H
00002 #define SPI8_H
00003 
00004 #include "mbed.h"
00005 #include "Protocols.h "
00006 //#include "GraphicsDisplay.h"
00007 
00008 /** SPI 8bit interface
00009 */
00010 class SPI8 : public Protocols
00011 {
00012  public:
00013 
00014     /** Create an SPI 8bit display interface with 3 control pins
00015     *
00016     * @param SPI mosi
00017     * @param SPI miso
00018     * @param SPI sclk
00019     * @param CS pin connected to CS of display
00020     * @param reset pin connected to RESET of display
00021     * @param DC pin connected to data/command of display
00022     */ 
00023     SPI8(int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC);
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     */   
00045     virtual void wr_cmd16(unsigned short cmd);
00046     
00047     /** Send 2x8bit data to display controller 
00048     *
00049     * @param data: halfword to send   
00050     *
00051     */   
00052     virtual void wr_data16(unsigned short data);
00053     
00054     /** Send 16bit pixeldata to display controller 
00055     *
00056     * @param data: halfword to send   
00057     *
00058     */   
00059     virtual void wr_gram(unsigned short data);
00060     
00061     /** Send same 16bit pixeldata to display controller multiple times
00062     *
00063     * @param data: halfword to send
00064     * @param count: how many
00065     *
00066     */   
00067     virtual void wr_gram(unsigned short data, unsigned int count);
00068     
00069     /** Send array of pixeldata shorts to display controller
00070     *
00071     * @param data: unsigned short pixeldata array
00072     * @param lenght: lenght (in shorts)
00073     *
00074     */   
00075     virtual void wr_grambuf(unsigned short* data, unsigned int lenght);
00076     
00077     /** Read 16bit pixeldata from display controller (with dummy cycle)
00078     *
00079     * @param convert true/false. Convert 18bit to 16bit, some controllers returns 18bit
00080     * @returns 16bit color
00081     */ 
00082     virtual unsigned short rd_gram(bool convert);
00083     
00084     /** Read 4x8bit register data (with dummy cycle)
00085     * @param reg the register to read
00086     * @returns data as uint
00087     * 
00088     */ 
00089     virtual unsigned int rd_reg_data32(unsigned char reg);
00090     
00091     /** Read 3x8bit ExtendedCommands register data
00092     * @param reg the register to read
00093     * @param SPIreadenablecmd vendor/device specific cmd to read EXTC registers
00094     * @returns data as uint
00095     * @note EXTC regs (0xB0 to 0xFF) are read/write registers but needs special cmd to be read in SPI mode
00096     */ 
00097     virtual unsigned int rd_extcreg_data32(unsigned char reg, unsigned char SPIreadenablecmd);
00098     
00099     /** HW reset sequence (without display init commands)   
00100     */
00101     virtual void hw_reset();
00102     
00103     /** Set ChipSelect high or low
00104     * @param enable 0/1   
00105     */
00106     virtual void BusEnable(bool enable);
00107         
00108         virtual void fastWrite(int data);
00109         virtual void clearRX( void ) ;
00110   
00111     DigitalOut _CS;
00112 
00113 private:
00114 
00115     SPI _spi;
00116     DigitalOut _reset;
00117     DigitalOut _DC;
00118   
00119 };
00120 #endif