The wait in mci_WaitForEvent will delay all card transactions.
Fork of EALib by
LcdController.h
00001 00002 #ifndef LCDCONTROLLER_H 00003 #define LCDCONTROLLER_H 00004 00005 /** 00006 * A LCD controller interface 00007 * 00008 * @code 00009 * #include "mbed.h" 00010 * #include "LcdController.h" 00011 * 00012 * LcdController::Config innolux( 00013 * 45, 00014 * 17, 00015 * 2, 00016 * 800, 00017 * 22, 00018 * 22, 00019 * 2, 00020 * 480, 00021 * false, 00022 * false, 00023 * true, 00024 * true, 00025 * true, 00026 * LcdController::Bpp_16_565, 00027 * 36000000, 00028 * LcdController::Tft, 00029 * false); 00030 * 00031 * int main(void) { 00032 * LcdController lcd; 00033 * 00034 * lcd.open(&innolux); 00035 * lcd.setFrameBuffer(frameBuffer); 00036 * lcd.setPower(true); 00037 * 00038 * // draw on the frame buffer 00039 * ... 00040 * } 00041 * @endcode 00042 */ 00043 class LcdController { 00044 public: 00045 00046 enum LcdPanel { 00047 Tft = 0, // standard TFT 00048 AdTft, // advanced TFT 00049 HrTft, // highly reflective TFT 00050 Mono_4Bit, // 4-bit mono 00051 Mono_8Bit, // 8-bit mono 00052 ColorStn // Color STN 00053 }; 00054 00055 enum BitsPerPixel { 00056 Bpp_1 = 0, 00057 Bpp_2, 00058 Bpp_4, 00059 Bpp_8, 00060 Bpp_16, 00061 Bpp_24, 00062 Bpp_16_565, 00063 Bpp_12_444 00064 }; 00065 00066 /** 00067 * LCD configuration 00068 */ 00069 class Config { 00070 public: 00071 00072 /** Create an empty LCD configuration object 00073 * 00074 */ 00075 Config() { 00076 } 00077 00078 /** Create a LCD configuration object with specified values 00079 * 00080 * @param horizontalBackPorch Horizontal back porch in clocks 00081 * @param horizontalFrontPorch Horizontal front porch in clocks 00082 * @param hsync HSYNC pulse width in clocks 00083 * @param width width of display in pixels 00084 * @param verticalBackPorch vertical back porch in clocks 00085 * @param verticalFrontPorch vertical front porch in clocks 00086 * @param vsync VSYNC pulse width in clocks 00087 * @param height height of display in pixels 00088 * @param invertOutputEnable true to invert output enable 00089 * @param invertPanelClock true to invert panel clock 00090 * @param invertHsync true to invert HSYNC 00091 * @param invertVsync true to invert VSYNC 00092 * @param acBias AC bias frequency in clocks 00093 * @param bpp bits per pixel 00094 * @param optimalClock optimal clock rate (Hz) 00095 * @param panelType LCD panel type 00096 * @param dualPanel true if it is a dual panel display 00097 */ 00098 Config(int horizontalBackPorch, 00099 int horizontalFrontPorch, 00100 int hsync, 00101 int width, 00102 int verticalBackPorch, 00103 int verticalFrontPorch, 00104 int vsync, 00105 int height, 00106 bool invertOutputEnable, 00107 bool invertPanelClock, 00108 bool invertHsync, 00109 bool invertVsync, 00110 int acBias, 00111 BitsPerPixel bpp, 00112 int optimalClock, 00113 LcdPanel panelType, 00114 bool dualPanel) { 00115 00116 this->horizontalBackPorch = horizontalBackPorch; 00117 this->horizontalFrontPorch = horizontalFrontPorch; 00118 this->hsync = hsync; 00119 this->width = width; 00120 this->verticalBackPorch = verticalBackPorch; 00121 this->verticalFrontPorch = verticalFrontPorch; 00122 this->vsync = vsync; 00123 this->height = height; 00124 this->invertOutputEnable = invertOutputEnable; 00125 this->invertPanelClock = invertPanelClock; 00126 this->invertHsync = invertHsync; 00127 this->invertVsync = invertVsync; 00128 this->acBias = acBias; 00129 this->bpp = bpp; 00130 this->optimalClock = optimalClock; 00131 this->panelType = panelType; 00132 this->dualPanel = dualPanel; 00133 } 00134 00135 int horizontalBackPorch; 00136 int horizontalFrontPorch; 00137 int hsync; 00138 int width; 00139 int verticalBackPorch; 00140 int verticalFrontPorch; 00141 int vsync; 00142 int height; 00143 bool invertOutputEnable; 00144 bool invertPanelClock; 00145 bool invertHsync; 00146 bool invertVsync; 00147 int acBias; 00148 BitsPerPixel bpp; 00149 int optimalClock; 00150 LcdPanel panelType; 00151 bool dualPanel; 00152 }; 00153 00154 /** Create a LCD controller interface 00155 * 00156 */ 00157 LcdController(); 00158 00159 /** Open and initialize the LCD controller with the given LCD configuration 00160 * 00161 * @param cfg LCD configuration 00162 * 00163 * @returns 00164 * 0 on success 00165 * 1 on failure 00166 */ 00167 int open(LcdController::Config* cfg); 00168 00169 /** Close the LCD controller 00170 * 00171 * @returns 00172 * 0 on success 00173 * 1 on failure 00174 */ 00175 int close(); 00176 00177 /** Set and activate the address of the frame buffer to use. 00178 * 00179 * It is the content of the frame buffer that is shown on the 00180 * display. All the drawing on the frame buffer can be done 00181 * 'offline' and whenever it should be shown this function 00182 * can be called with the address of the offline frame buffer. 00183 * 00184 * @param address Memory address of the frame buffer 00185 * 00186 * @returns 00187 * 0 on success 00188 * 1 on failure 00189 */ 00190 int setFrameBuffer(uint32_t address); 00191 00192 /** Turn on/off the power to the display. 00193 * 00194 * @param on true to turn on, false to turn off 00195 * 00196 * @returns 00197 * 0 on success 00198 * 1 on failure 00199 */ 00200 int setPower(bool on); 00201 00202 00203 private: 00204 00205 bool _opened; 00206 static bool _lcdControllerUsed; 00207 00208 void init(LcdController::Config* cfg); 00209 void pinConfig(); 00210 uint32_t getClockDivisor(int clock); 00211 }; 00212 00213 #endif 00214 00215
Generated on Tue Jul 12 2022 15:13:41 by 1.7.2