This is the final version of Mini Gateway for Automation and Security desgined for Renesas GR Peach Design Contest

Dependencies:   GR-PEACH_video GraphicsFramework HTTPServer R_BSP mbed-rpc mbed-rtos Socket lwip-eth lwip-sys lwip FATFileSystem

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Protocols.h Source File

Protocols.h

Go to the documentation of this file.
00001  /* mbed UniGraphic library - Abstract protocol class
00002  * Copyright (c) 2015 Giuliano Dianda
00003  * Released under the MIT License: http://mbed.org/license/mit
00004  */
00005  
00006 /** @file Protocols.h
00007 */
00008 #ifndef Protocols_H
00009 #define Protocols_H
00010 
00011 #include "mbed.h"
00012 
00013 #define RGB24to16(r,g,b)  (((r&0xF8)<<8)|((g&0xFC)<<3)|((b&0xF8)>>3)) //5 red | 6 green | 5 blue
00014 #define BGR2RGB(color) (((color&0x1F)<<11) | (color&0x7E0) | ((color&0xF800)>>11))
00015 
00016 #define FLIP_NONE   0
00017 #define FLIP_X      1
00018 #define FLIP_Y      2
00019 
00020 //#define USE_CS
00021 
00022 /** Protocol types
00023 */
00024 #include "platform.h"
00025 
00026 #if DEVICE_PORTINOUT
00027 enum proto_t {
00028     PAR_8   /**< Parallel 8bit, port pins 0 to 7 */
00029     ,PAR_16 /**< Parallel 16bit, port pins 0 to 15 */
00030     ,BUS_8   /**< Parallel 8bit, scattered pins */
00031     ,BUS_16   /**< Parallel 16bit, scattered pins */
00032     ,SPI_8  /**< SPI 8bit */
00033     ,SPI_16 /**< SPI 16bit */
00034 };
00035 #else 
00036 enum proto_t {
00037     BUS_8   /**< Parallel 8bit, scattered pins */
00038     ,BUS_16   /**< Parallel 16bit, scattered pins */
00039     ,SPI_8  /**< SPI 8bit */
00040     ,SPI_16 /**< SPI 16bit */
00041 };
00042 #endif
00043 
00044 
00045 /** Abstract interface class for spi and parallel protocols
00046 */
00047 class Protocols
00048 {
00049  public:
00050     
00051     /** Send 8bit command to display controller 
00052     *
00053     * @param cmd: byte to send  
00054     *
00055     */   
00056     virtual void wr_cmd8(unsigned char cmd) = 0;
00057     
00058     /** Send 8bit data to display controller 
00059     *
00060     * @param data: byte to send   
00061     *
00062     */   
00063     virtual void wr_data8(unsigned char data) = 0;
00064     
00065     /** Send 2x8bit command to display controller 
00066     *
00067     * @param cmd: halfword to send  
00068     *
00069     */   
00070     virtual void wr_cmd16(unsigned short cmd) = 0;
00071     
00072     /** Send 2x8bit data to display controller 
00073     *
00074     * @param data: halfword to send   
00075     *
00076     */   
00077     virtual void wr_data16(unsigned short data) = 0;
00078     
00079     /** Send 16bit pixeldata to display controller 
00080     *
00081     * @param data: halfword to send   
00082     *
00083     */   
00084     virtual void wr_gram(unsigned short data) = 0;
00085     
00086     /** Send same 16bit pixeldata to display controller multiple times
00087     *
00088     * @param data: halfword to send
00089     * @param count: how many
00090     *
00091     */   
00092     virtual void wr_gram(unsigned short data, unsigned int count) = 0;
00093     
00094     /** Send array of pixeldata shorts to display controller
00095     *
00096     * @param data: unsigned short pixeldata array
00097     * @param lenght: lenght (in shorts)
00098     *
00099     */   
00100     virtual void wr_grambuf(unsigned short* data, unsigned int lenght) = 0;
00101     
00102     /** Read 16bit pixeldata from display controller (with dummy cycle)
00103     *
00104     * @param convert true/false. Convert 18bit to 16bit, some controllers returns 18bit
00105     * @returns 16bit color
00106     */ 
00107     virtual unsigned short rd_gram(bool convert) = 0;
00108     
00109     /** Read 4x8bit register data (with dummy cycle)
00110     * @param reg the register to read
00111     * @returns data as uint
00112     * 
00113     */ 
00114     virtual unsigned int rd_reg_data32(unsigned char reg) = 0;
00115     
00116     /** Read 3x8bit ExtendedCommands register data
00117     * @param reg the register to read
00118     * @param SPIreadenablecmd vendor/device specific cmd to read EXTC registers
00119     * @returns data as uint
00120     * @note EXTC regs (0xB0 to 0xFF) are read/write registers but needs special cmd to be read in SPI mode
00121     */ 
00122     virtual unsigned int rd_extcreg_data32(unsigned char reg, unsigned char SPIreadenablecmd) = 0;
00123     
00124     /** ILI932x specific, does a dummy read cycle, number of bits is protocol dependent
00125     * for PAR protocols: a signle RD bit toggle
00126     * for SPI8: 8clocks
00127     * for SPI16: 16 clocks
00128     */   
00129     virtual void dummyread () = 0;
00130     
00131     /** ILI932x specific, select register for a successive write or read
00132     *
00133     * @param reg register to be selected
00134     * @param forread false = a write next (default), true = a read next
00135     * @note forread only used by SPI protocols
00136     */   
00137     virtual void reg_select(unsigned char reg, bool forread =false) = 0;
00138     
00139     /** ILI932x specific, write register with data
00140     *
00141     * @param reg register to write
00142     * @param data 16bit data
00143     */   
00144     virtual void reg_write(unsigned char reg, unsigned short data) = 0;
00145     
00146     /** ILI932x specific, read register
00147     *
00148     * @param reg register to be read
00149     * @returns 16bit register value
00150     */ 
00151     virtual unsigned short reg_read(unsigned char reg) = 0;
00152     
00153     /** HW reset sequence (without display init commands)   
00154     */
00155     virtual void hw_reset() = 0;
00156     
00157     /** Set ChipSelect high or low
00158     * @param enable 0/1   
00159     */
00160     virtual void BusEnable(bool enable) = 0;
00161 
00162 };
00163 #endif