The wait in mci_WaitForEvent will delay all card transactions.

Dependencies:   FATFileSystem

Fork of EALib by EmbeddedArtists AB

Committer:
dreschpe
Date:
Sun Dec 15 21:58:56 2013 +0000
Revision:
9:da373a015d07
Parent:
0:0fdadbc3d852
the wait in mci_WaitForEvent will delay all card transactions.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
embeddedartists 0:0fdadbc3d852 1
embeddedartists 0:0fdadbc3d852 2 #ifndef LCDCONTROLLER_H
embeddedartists 0:0fdadbc3d852 3 #define LCDCONTROLLER_H
embeddedartists 0:0fdadbc3d852 4
embeddedartists 0:0fdadbc3d852 5 /**
embeddedartists 0:0fdadbc3d852 6 * A LCD controller interface
embeddedartists 0:0fdadbc3d852 7 *
embeddedartists 0:0fdadbc3d852 8 * @code
embeddedartists 0:0fdadbc3d852 9 * #include "mbed.h"
embeddedartists 0:0fdadbc3d852 10 * #include "LcdController.h"
embeddedartists 0:0fdadbc3d852 11 *
embeddedartists 0:0fdadbc3d852 12 * LcdController::Config innolux(
embeddedartists 0:0fdadbc3d852 13 * 45,
embeddedartists 0:0fdadbc3d852 14 * 17,
embeddedartists 0:0fdadbc3d852 15 * 2,
embeddedartists 0:0fdadbc3d852 16 * 800,
embeddedartists 0:0fdadbc3d852 17 * 22,
embeddedartists 0:0fdadbc3d852 18 * 22,
embeddedartists 0:0fdadbc3d852 19 * 2,
embeddedartists 0:0fdadbc3d852 20 * 480,
embeddedartists 0:0fdadbc3d852 21 * false,
embeddedartists 0:0fdadbc3d852 22 * false,
embeddedartists 0:0fdadbc3d852 23 * true,
embeddedartists 0:0fdadbc3d852 24 * true,
embeddedartists 0:0fdadbc3d852 25 * true,
embeddedartists 0:0fdadbc3d852 26 * LcdController::Bpp_16_565,
embeddedartists 0:0fdadbc3d852 27 * 36000000,
embeddedartists 0:0fdadbc3d852 28 * LcdController::Tft,
embeddedartists 0:0fdadbc3d852 29 * false);
embeddedartists 0:0fdadbc3d852 30 *
embeddedartists 0:0fdadbc3d852 31 * int main(void) {
embeddedartists 0:0fdadbc3d852 32 * LcdController lcd;
embeddedartists 0:0fdadbc3d852 33 *
embeddedartists 0:0fdadbc3d852 34 * lcd.open(&innolux);
embeddedartists 0:0fdadbc3d852 35 * lcd.setFrameBuffer(frameBuffer);
embeddedartists 0:0fdadbc3d852 36 * lcd.setPower(true);
embeddedartists 0:0fdadbc3d852 37 *
embeddedartists 0:0fdadbc3d852 38 * // draw on the frame buffer
embeddedartists 0:0fdadbc3d852 39 * ...
embeddedartists 0:0fdadbc3d852 40 * }
embeddedartists 0:0fdadbc3d852 41 * @endcode
embeddedartists 0:0fdadbc3d852 42 */
embeddedartists 0:0fdadbc3d852 43 class LcdController {
embeddedartists 0:0fdadbc3d852 44 public:
embeddedartists 0:0fdadbc3d852 45
embeddedartists 0:0fdadbc3d852 46 enum LcdPanel {
embeddedartists 0:0fdadbc3d852 47 Tft = 0, // standard TFT
embeddedartists 0:0fdadbc3d852 48 AdTft, // advanced TFT
embeddedartists 0:0fdadbc3d852 49 HrTft, // highly reflective TFT
embeddedartists 0:0fdadbc3d852 50 Mono_4Bit, // 4-bit mono
embeddedartists 0:0fdadbc3d852 51 Mono_8Bit, // 8-bit mono
embeddedartists 0:0fdadbc3d852 52 ColorStn // Color STN
embeddedartists 0:0fdadbc3d852 53 };
embeddedartists 0:0fdadbc3d852 54
embeddedartists 0:0fdadbc3d852 55 enum BitsPerPixel {
embeddedartists 0:0fdadbc3d852 56 Bpp_1 = 0,
embeddedartists 0:0fdadbc3d852 57 Bpp_2,
embeddedartists 0:0fdadbc3d852 58 Bpp_4,
embeddedartists 0:0fdadbc3d852 59 Bpp_8,
embeddedartists 0:0fdadbc3d852 60 Bpp_16,
embeddedartists 0:0fdadbc3d852 61 Bpp_24,
embeddedartists 0:0fdadbc3d852 62 Bpp_16_565,
embeddedartists 0:0fdadbc3d852 63 Bpp_12_444
embeddedartists 0:0fdadbc3d852 64 };
embeddedartists 0:0fdadbc3d852 65
embeddedartists 0:0fdadbc3d852 66 /**
embeddedartists 0:0fdadbc3d852 67 * LCD configuration
embeddedartists 0:0fdadbc3d852 68 */
embeddedartists 0:0fdadbc3d852 69 class Config {
embeddedartists 0:0fdadbc3d852 70 public:
embeddedartists 0:0fdadbc3d852 71
embeddedartists 0:0fdadbc3d852 72 /** Create an empty LCD configuration object
embeddedartists 0:0fdadbc3d852 73 *
embeddedartists 0:0fdadbc3d852 74 */
embeddedartists 0:0fdadbc3d852 75 Config() {
embeddedartists 0:0fdadbc3d852 76 }
embeddedartists 0:0fdadbc3d852 77
embeddedartists 0:0fdadbc3d852 78 /** Create a LCD configuration object with specified values
embeddedartists 0:0fdadbc3d852 79 *
embeddedartists 0:0fdadbc3d852 80 * @param horizontalBackPorch Horizontal back porch in clocks
embeddedartists 0:0fdadbc3d852 81 * @param horizontalFrontPorch Horizontal front porch in clocks
embeddedartists 0:0fdadbc3d852 82 * @param hsync HSYNC pulse width in clocks
embeddedartists 0:0fdadbc3d852 83 * @param width width of display in pixels
embeddedartists 0:0fdadbc3d852 84 * @param verticalBackPorch vertical back porch in clocks
embeddedartists 0:0fdadbc3d852 85 * @param verticalFrontPorch vertical front porch in clocks
embeddedartists 0:0fdadbc3d852 86 * @param vsync VSYNC pulse width in clocks
embeddedartists 0:0fdadbc3d852 87 * @param height height of display in pixels
embeddedartists 0:0fdadbc3d852 88 * @param invertOutputEnable true to invert output enable
embeddedartists 0:0fdadbc3d852 89 * @param invertPanelClock true to invert panel clock
embeddedartists 0:0fdadbc3d852 90 * @param invertHsync true to invert HSYNC
embeddedartists 0:0fdadbc3d852 91 * @param invertVsync true to invert VSYNC
embeddedartists 0:0fdadbc3d852 92 * @param acBias AC bias frequency in clocks
embeddedartists 0:0fdadbc3d852 93 * @param bpp bits per pixel
embeddedartists 0:0fdadbc3d852 94 * @param optimalClock optimal clock rate (Hz)
embeddedartists 0:0fdadbc3d852 95 * @param panelType LCD panel type
embeddedartists 0:0fdadbc3d852 96 * @param dualPanel true if it is a dual panel display
embeddedartists 0:0fdadbc3d852 97 */
embeddedartists 0:0fdadbc3d852 98 Config(int horizontalBackPorch,
embeddedartists 0:0fdadbc3d852 99 int horizontalFrontPorch,
embeddedartists 0:0fdadbc3d852 100 int hsync,
embeddedartists 0:0fdadbc3d852 101 int width,
embeddedartists 0:0fdadbc3d852 102 int verticalBackPorch,
embeddedartists 0:0fdadbc3d852 103 int verticalFrontPorch,
embeddedartists 0:0fdadbc3d852 104 int vsync,
embeddedartists 0:0fdadbc3d852 105 int height,
embeddedartists 0:0fdadbc3d852 106 bool invertOutputEnable,
embeddedartists 0:0fdadbc3d852 107 bool invertPanelClock,
embeddedartists 0:0fdadbc3d852 108 bool invertHsync,
embeddedartists 0:0fdadbc3d852 109 bool invertVsync,
embeddedartists 0:0fdadbc3d852 110 int acBias,
embeddedartists 0:0fdadbc3d852 111 BitsPerPixel bpp,
embeddedartists 0:0fdadbc3d852 112 int optimalClock,
embeddedartists 0:0fdadbc3d852 113 LcdPanel panelType,
embeddedartists 0:0fdadbc3d852 114 bool dualPanel) {
embeddedartists 0:0fdadbc3d852 115
embeddedartists 0:0fdadbc3d852 116 this->horizontalBackPorch = horizontalBackPorch;
embeddedartists 0:0fdadbc3d852 117 this->horizontalFrontPorch = horizontalFrontPorch;
embeddedartists 0:0fdadbc3d852 118 this->hsync = hsync;
embeddedartists 0:0fdadbc3d852 119 this->width = width;
embeddedartists 0:0fdadbc3d852 120 this->verticalBackPorch = verticalBackPorch;
embeddedartists 0:0fdadbc3d852 121 this->verticalFrontPorch = verticalFrontPorch;
embeddedartists 0:0fdadbc3d852 122 this->vsync = vsync;
embeddedartists 0:0fdadbc3d852 123 this->height = height;
embeddedartists 0:0fdadbc3d852 124 this->invertOutputEnable = invertOutputEnable;
embeddedartists 0:0fdadbc3d852 125 this->invertPanelClock = invertPanelClock;
embeddedartists 0:0fdadbc3d852 126 this->invertHsync = invertHsync;
embeddedartists 0:0fdadbc3d852 127 this->invertVsync = invertVsync;
embeddedartists 0:0fdadbc3d852 128 this->acBias = acBias;
embeddedartists 0:0fdadbc3d852 129 this->bpp = bpp;
embeddedartists 0:0fdadbc3d852 130 this->optimalClock = optimalClock;
embeddedartists 0:0fdadbc3d852 131 this->panelType = panelType;
embeddedartists 0:0fdadbc3d852 132 this->dualPanel = dualPanel;
embeddedartists 0:0fdadbc3d852 133 }
embeddedartists 0:0fdadbc3d852 134
embeddedartists 0:0fdadbc3d852 135 int horizontalBackPorch;
embeddedartists 0:0fdadbc3d852 136 int horizontalFrontPorch;
embeddedartists 0:0fdadbc3d852 137 int hsync;
embeddedartists 0:0fdadbc3d852 138 int width;
embeddedartists 0:0fdadbc3d852 139 int verticalBackPorch;
embeddedartists 0:0fdadbc3d852 140 int verticalFrontPorch;
embeddedartists 0:0fdadbc3d852 141 int vsync;
embeddedartists 0:0fdadbc3d852 142 int height;
embeddedartists 0:0fdadbc3d852 143 bool invertOutputEnable;
embeddedartists 0:0fdadbc3d852 144 bool invertPanelClock;
embeddedartists 0:0fdadbc3d852 145 bool invertHsync;
embeddedartists 0:0fdadbc3d852 146 bool invertVsync;
embeddedartists 0:0fdadbc3d852 147 int acBias;
embeddedartists 0:0fdadbc3d852 148 BitsPerPixel bpp;
embeddedartists 0:0fdadbc3d852 149 int optimalClock;
embeddedartists 0:0fdadbc3d852 150 LcdPanel panelType;
embeddedartists 0:0fdadbc3d852 151 bool dualPanel;
embeddedartists 0:0fdadbc3d852 152 };
embeddedartists 0:0fdadbc3d852 153
embeddedartists 0:0fdadbc3d852 154 /** Create a LCD controller interface
embeddedartists 0:0fdadbc3d852 155 *
embeddedartists 0:0fdadbc3d852 156 */
embeddedartists 0:0fdadbc3d852 157 LcdController();
embeddedartists 0:0fdadbc3d852 158
embeddedartists 0:0fdadbc3d852 159 /** Open and initialize the LCD controller with the given LCD configuration
embeddedartists 0:0fdadbc3d852 160 *
embeddedartists 0:0fdadbc3d852 161 * @param cfg LCD configuration
embeddedartists 0:0fdadbc3d852 162 *
embeddedartists 0:0fdadbc3d852 163 * @returns
embeddedartists 0:0fdadbc3d852 164 * 0 on success
embeddedartists 0:0fdadbc3d852 165 * 1 on failure
embeddedartists 0:0fdadbc3d852 166 */
embeddedartists 0:0fdadbc3d852 167 int open(LcdController::Config* cfg);
embeddedartists 0:0fdadbc3d852 168
embeddedartists 0:0fdadbc3d852 169 /** Close the LCD controller
embeddedartists 0:0fdadbc3d852 170 *
embeddedartists 0:0fdadbc3d852 171 * @returns
embeddedartists 0:0fdadbc3d852 172 * 0 on success
embeddedartists 0:0fdadbc3d852 173 * 1 on failure
embeddedartists 0:0fdadbc3d852 174 */
embeddedartists 0:0fdadbc3d852 175 int close();
embeddedartists 0:0fdadbc3d852 176
embeddedartists 0:0fdadbc3d852 177 /** Set and activate the address of the frame buffer to use.
embeddedartists 0:0fdadbc3d852 178 *
embeddedartists 0:0fdadbc3d852 179 * It is the content of the frame buffer that is shown on the
embeddedartists 0:0fdadbc3d852 180 * display. All the drawing on the frame buffer can be done
embeddedartists 0:0fdadbc3d852 181 * 'offline' and whenever it should be shown this function
embeddedartists 0:0fdadbc3d852 182 * can be called with the address of the offline frame buffer.
embeddedartists 0:0fdadbc3d852 183 *
embeddedartists 0:0fdadbc3d852 184 * @param address Memory address of the frame buffer
embeddedartists 0:0fdadbc3d852 185 *
embeddedartists 0:0fdadbc3d852 186 * @returns
embeddedartists 0:0fdadbc3d852 187 * 0 on success
embeddedartists 0:0fdadbc3d852 188 * 1 on failure
embeddedartists 0:0fdadbc3d852 189 */
embeddedartists 0:0fdadbc3d852 190 int setFrameBuffer(uint32_t address);
embeddedartists 0:0fdadbc3d852 191
embeddedartists 0:0fdadbc3d852 192 /** Turn on/off the power to the display.
embeddedartists 0:0fdadbc3d852 193 *
embeddedartists 0:0fdadbc3d852 194 * @param on true to turn on, false to turn off
embeddedartists 0:0fdadbc3d852 195 *
embeddedartists 0:0fdadbc3d852 196 * @returns
embeddedartists 0:0fdadbc3d852 197 * 0 on success
embeddedartists 0:0fdadbc3d852 198 * 1 on failure
embeddedartists 0:0fdadbc3d852 199 */
embeddedartists 0:0fdadbc3d852 200 int setPower(bool on);
embeddedartists 0:0fdadbc3d852 201
embeddedartists 0:0fdadbc3d852 202
embeddedartists 0:0fdadbc3d852 203 private:
embeddedartists 0:0fdadbc3d852 204
embeddedartists 0:0fdadbc3d852 205 bool _opened;
embeddedartists 0:0fdadbc3d852 206 static bool _lcdControllerUsed;
embeddedartists 0:0fdadbc3d852 207
embeddedartists 0:0fdadbc3d852 208 void init(LcdController::Config* cfg);
embeddedartists 0:0fdadbc3d852 209 void pinConfig();
embeddedartists 0:0fdadbc3d852 210 uint32_t getClockDivisor(int clock);
embeddedartists 0:0fdadbc3d852 211 };
embeddedartists 0:0fdadbc3d852 212
embeddedartists 0:0fdadbc3d852 213 #endif
embeddedartists 0:0fdadbc3d852 214
embeddedartists 0:0fdadbc3d852 215