Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Bicycl_Computer_NUCLEO-F411RE Bicycl_Computer_NUCLEO-L476RG
Fork of UniGraphic by
Protocols.h
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 USE_CS 00017 00018 /** Protocol types 00019 */ 00020 enum proto_t { 00021 PAR_8 /**< Parallel 8bit, pins 0 to 7 */ 00022 ,PAR_16 /**< Parallel 16bit, pins 0 to 15 */ 00023 ,SPI_8 /**< SPI 8bit */ 00024 ,SPI_16 /**< SPI 16bit */ 00025 }; 00026 00027 00028 /** Abstract interface class for spi and parallel protocols 00029 */ 00030 class Protocols 00031 { 00032 public: 00033 00034 /** Send 8bit command to display controller 00035 * 00036 * @param cmd: byte to send 00037 * 00038 */ 00039 virtual void wr_cmd8(unsigned char cmd) = 0; 00040 00041 /** Send 8bit data to display controller 00042 * 00043 * @param data: byte to send 00044 * 00045 */ 00046 virtual void wr_data8(unsigned char data) = 0; 00047 00048 /** Send 2x8bit command to display controller 00049 * 00050 * @param cmd: halfword to send 00051 * 00052 */ 00053 virtual void wr_cmd16(unsigned short cmd) = 0; 00054 00055 /** Send 2x8bit data to display controller 00056 * 00057 * @param data: halfword to send 00058 * 00059 */ 00060 virtual void wr_data16(unsigned short data) = 0; 00061 00062 /** Send 16bit pixeldata to display controller 00063 * 00064 * @param data: halfword to send 00065 * 00066 */ 00067 virtual void wr_gram(unsigned short data) = 0; 00068 00069 /** Send same 16bit pixeldata to display controller multiple times 00070 * 00071 * @param data: halfword to send 00072 * @param count: how many 00073 * 00074 */ 00075 virtual void wr_gram(unsigned short data, unsigned int count) = 0; 00076 00077 /** Send array of pixeldata shorts to display controller 00078 * 00079 * @param data: unsigned short pixeldata array 00080 * @param lenght: lenght (in shorts) 00081 * 00082 */ 00083 virtual void wr_grambuf(unsigned short* data, unsigned int lenght) = 0; 00084 00085 /** Read 16bit pixeldata from display controller (with dummy cycle) 00086 * 00087 * @param convert true/false. Convert 18bit to 16bit, some controllers returns 18bit 00088 * @returns 16bit color 00089 */ 00090 virtual unsigned short rd_gram(bool convert) = 0; 00091 00092 /** Read 4x8bit register data (with dummy cycle) 00093 * @param reg the register to read 00094 * @returns data as uint 00095 * 00096 */ 00097 virtual unsigned int rd_reg_data32(unsigned char reg) = 0; 00098 00099 /** Read 3x8bit ExtendedCommands register data 00100 * @param reg the register to read 00101 * @param SPIreadenablecmd vendor/device specific cmd to read EXTC registers 00102 * @returns data as uint 00103 * @note EXTC regs (0xB0 to 0xFF) are read/write registers but needs special cmd to be read in SPI mode 00104 */ 00105 virtual unsigned int rd_extcreg_data32(unsigned char reg, unsigned char SPIreadenablecmd) = 0; 00106 00107 /** HW reset sequence (without display init commands) 00108 */ 00109 virtual void hw_reset() = 0; 00110 00111 /** Set ChipSelect high or low 00112 * @param enable 0/1 00113 */ 00114 virtual void BusEnable(bool enable) = 0; 00115 00116 }; 00117 #endif
Generated on Wed Jul 13 2022 20:11:30 by
