The wait in mci_WaitForEvent will delay all card transactions.

Dependencies:   FATFileSystem

Fork of EALib by EmbeddedArtists AB

Committer:
embeddedartists
Date:
Thu Sep 26 06:37:02 2013 +0000
Revision:
0:0fdadbc3d852
Child:
4:b32cf4ef45c5
First version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
embeddedartists 0:0fdadbc3d852 1
embeddedartists 0:0fdadbc3d852 2 #ifndef EALCDBOARD_H
embeddedartists 0:0fdadbc3d852 3 #define EALCDBOARD_H
embeddedartists 0:0fdadbc3d852 4
embeddedartists 0:0fdadbc3d852 5 #include "LcdController.h"
embeddedartists 0:0fdadbc3d852 6
embeddedartists 0:0fdadbc3d852 7 /** An interface to Embedded Artists LCD Boards
embeddedartists 0:0fdadbc3d852 8 *
embeddedartists 0:0fdadbc3d852 9 */
embeddedartists 0:0fdadbc3d852 10 class EaLcdBoard {
embeddedartists 0:0fdadbc3d852 11 public:
embeddedartists 0:0fdadbc3d852 12
embeddedartists 0:0fdadbc3d852 13 enum Result {
embeddedartists 0:0fdadbc3d852 14 Ok = 0,
embeddedartists 0:0fdadbc3d852 15 InvalidCommandString,
embeddedartists 0:0fdadbc3d852 16 InvalidArgument,
embeddedartists 0:0fdadbc3d852 17 InvalidStorage,
embeddedartists 0:0fdadbc3d852 18 BufferTooSmall,
embeddedartists 0:0fdadbc3d852 19 VersionNotSupported,
embeddedartists 0:0fdadbc3d852 20 LcdAccessError
embeddedartists 0:0fdadbc3d852 21 };
embeddedartists 0:0fdadbc3d852 22
embeddedartists 0:0fdadbc3d852 23 enum Constants {
embeddedartists 0:0fdadbc3d852 24 NameBufferSize = 30
embeddedartists 0:0fdadbc3d852 25 };
embeddedartists 0:0fdadbc3d852 26
embeddedartists 0:0fdadbc3d852 27 /** Create an interface to an Embedded Artists LCD Board
embeddedartists 0:0fdadbc3d852 28 *
embeddedartists 0:0fdadbc3d852 29 * @param sda I2C data line pin
embeddedartists 0:0fdadbc3d852 30 * @param scl I2C clock line pin
embeddedartists 0:0fdadbc3d852 31 */
embeddedartists 0:0fdadbc3d852 32 EaLcdBoard(PinName sda, PinName scl);
embeddedartists 0:0fdadbc3d852 33
embeddedartists 0:0fdadbc3d852 34 /** Open the interface and start initialization.
embeddedartists 0:0fdadbc3d852 35 *
embeddedartists 0:0fdadbc3d852 36 * @param cfg initialize with a given LCD configuration. If this argument is
embeddedartists 0:0fdadbc3d852 37 * NULL the LCD configuration will be retrieved from persistent
embeddedartists 0:0fdadbc3d852 38 * storage on the LCD Board.
embeddedartists 0:0fdadbc3d852 39 * @param initSeq the initialization string. If this argument is NULL the
embeddedartists 0:0fdadbc3d852 40 * initialization string will be retrieved from persistent
embeddedartists 0:0fdadbc3d852 41 * storage on the LCD Board.
embeddedartists 0:0fdadbc3d852 42 *
embeddedartists 0:0fdadbc3d852 43 * @returns the result of the operation
embeddedartists 0:0fdadbc3d852 44 */
embeddedartists 0:0fdadbc3d852 45 Result open(LcdController::Config* cfg, char* initSeq);
embeddedartists 0:0fdadbc3d852 46
embeddedartists 0:0fdadbc3d852 47 /** Close the interface
embeddedartists 0:0fdadbc3d852 48 *
embeddedartists 0:0fdadbc3d852 49 * @returns the result of the operation
embeddedartists 0:0fdadbc3d852 50 */
embeddedartists 0:0fdadbc3d852 51 Result close();
embeddedartists 0:0fdadbc3d852 52
embeddedartists 0:0fdadbc3d852 53 /** Set and activate the address of the frame buffer to use.
embeddedartists 0:0fdadbc3d852 54 *
embeddedartists 0:0fdadbc3d852 55 * It is the content of the frame buffer that is shown on the
embeddedartists 0:0fdadbc3d852 56 * display. All the drawing on the frame buffer can be done
embeddedartists 0:0fdadbc3d852 57 * 'offline' and whenever it should be shown this function
embeddedartists 0:0fdadbc3d852 58 * can be called with the address of the offline frame buffer.
embeddedartists 0:0fdadbc3d852 59 *
embeddedartists 0:0fdadbc3d852 60 * @param address Memory address of the frame buffer
embeddedartists 0:0fdadbc3d852 61 *
embeddedartists 0:0fdadbc3d852 62 * @returns the result of the operation
embeddedartists 0:0fdadbc3d852 63 */
embeddedartists 0:0fdadbc3d852 64 Result setFrameBuffer(uint32_t address);
embeddedartists 0:0fdadbc3d852 65
embeddedartists 0:0fdadbc3d852 66 /** Get the LCD configuration stored in persistent storage on the LCD Board
embeddedartists 0:0fdadbc3d852 67 *
embeddedartists 0:0fdadbc3d852 68 * @param cfg pointer to a configuration object. Parameters are copied to
embeddedartists 0:0fdadbc3d852 69 * this object.
embeddedartists 0:0fdadbc3d852 70 *
embeddedartists 0:0fdadbc3d852 71 * @returns the result of the operation
embeddedartists 0:0fdadbc3d852 72 */
embeddedartists 0:0fdadbc3d852 73 Result getLcdConfig(LcdController::Config* cfg);
embeddedartists 0:0fdadbc3d852 74
embeddedartists 0:0fdadbc3d852 75 /** Get the display name stored in persistent storage on the LCD Board
embeddedartists 0:0fdadbc3d852 76 *
embeddedartists 0:0fdadbc3d852 77 * @param buf buffer to which the name will be copied
embeddedartists 0:0fdadbc3d852 78 * @param len size of the buffer in bytes
embeddedartists 0:0fdadbc3d852 79 *
embeddedartists 0:0fdadbc3d852 80 * @returns the result of the operation
embeddedartists 0:0fdadbc3d852 81 */
embeddedartists 0:0fdadbc3d852 82 Result getDisplayName(char* buf, int len);
embeddedartists 0:0fdadbc3d852 83
embeddedartists 0:0fdadbc3d852 84 /** Get the display manufacturer stored in persistent storage on the
embeddedartists 0:0fdadbc3d852 85 * LCD Board
embeddedartists 0:0fdadbc3d852 86 *
embeddedartists 0:0fdadbc3d852 87 * @param buf buffer to which the name will be copied
embeddedartists 0:0fdadbc3d852 88 * @param len size of the buffer in bytes
embeddedartists 0:0fdadbc3d852 89 *
embeddedartists 0:0fdadbc3d852 90 * @returns the result of the operation
embeddedartists 0:0fdadbc3d852 91 */
embeddedartists 0:0fdadbc3d852 92 Result getDisplayMfg(char* buf, int len);
embeddedartists 0:0fdadbc3d852 93
embeddedartists 0:0fdadbc3d852 94 /** Get the initialization sequence stored in persistent storage on the
embeddedartists 0:0fdadbc3d852 95 * LCD Board
embeddedartists 0:0fdadbc3d852 96 *
embeddedartists 0:0fdadbc3d852 97 * @param buf buffer to which the string will be copied
embeddedartists 0:0fdadbc3d852 98 * @param len size of the buffer in bytes
embeddedartists 0:0fdadbc3d852 99 *
embeddedartists 0:0fdadbc3d852 100 * @returns the result of the operation
embeddedartists 0:0fdadbc3d852 101 */
embeddedartists 0:0fdadbc3d852 102 Result getInitSeq(char* buf, int len);
embeddedartists 0:0fdadbc3d852 103
embeddedartists 0:0fdadbc3d852 104 /** Get the power down sequence stored in persistent storage on the
embeddedartists 0:0fdadbc3d852 105 * LCD Board
embeddedartists 0:0fdadbc3d852 106 *
embeddedartists 0:0fdadbc3d852 107 * @param buf buffer to which the string will be copied
embeddedartists 0:0fdadbc3d852 108 * @param len size of the buffer in bytes
embeddedartists 0:0fdadbc3d852 109 *
embeddedartists 0:0fdadbc3d852 110 * @returns the result of the operation
embeddedartists 0:0fdadbc3d852 111 */
embeddedartists 0:0fdadbc3d852 112 Result getPowerDownSeq(char* buf, int len);
embeddedartists 0:0fdadbc3d852 113
embeddedartists 0:0fdadbc3d852 114
embeddedartists 0:0fdadbc3d852 115 private:
embeddedartists 0:0fdadbc3d852 116
embeddedartists 0:0fdadbc3d852 117 typedef struct {
embeddedartists 0:0fdadbc3d852 118 uint32_t magic; // magic number
embeddedartists 0:0fdadbc3d852 119 uint8_t lcd_name[NameBufferSize]; // LCD name
embeddedartists 0:0fdadbc3d852 120 uint8_t lcd_mfg[NameBufferSize]; // manufacturer name
embeddedartists 0:0fdadbc3d852 121 uint16_t lcdParamOff; // offset to LCD parameters
embeddedartists 0:0fdadbc3d852 122 uint16_t initOff; // offset to init sequence string
embeddedartists 0:0fdadbc3d852 123 uint16_t pdOff; // offset to power down sequence string
embeddedartists 0:0fdadbc3d852 124 uint16_t tsOff; // offset to touch parameters
embeddedartists 0:0fdadbc3d852 125 uint16_t end; // end offset
embeddedartists 0:0fdadbc3d852 126 } store_t;
embeddedartists 0:0fdadbc3d852 127
embeddedartists 0:0fdadbc3d852 128 Result getStore(store_t* store);
embeddedartists 0:0fdadbc3d852 129
embeddedartists 0:0fdadbc3d852 130 int eepromRead(uint8_t* buf, uint16_t offset, uint16_t len);
embeddedartists 0:0fdadbc3d852 131 int eepromWrite(uint8_t* buf, uint16_t offset, uint16_t len);
embeddedartists 0:0fdadbc3d852 132
embeddedartists 0:0fdadbc3d852 133 Result parseInitString(char* str, LcdController::Config* cfg);
embeddedartists 0:0fdadbc3d852 134 Result checkVersion(char* v, uint32_t len);
embeddedartists 0:0fdadbc3d852 135 Result execDelay(char* del, uint32_t len);
embeddedartists 0:0fdadbc3d852 136 Result execSeqCtrl(char* cmd, uint32_t len);
embeddedartists 0:0fdadbc3d852 137
embeddedartists 0:0fdadbc3d852 138 void setLsStates(uint16_t states, uint8_t* ls, uint8_t mode);
embeddedartists 0:0fdadbc3d852 139 void setLeds(void);
embeddedartists 0:0fdadbc3d852 140 void pca9532_setLeds (uint16_t ledOnMask, uint16_t ledOffMask);
embeddedartists 0:0fdadbc3d852 141 void pca9532_setBlink0Period(uint8_t period);
embeddedartists 0:0fdadbc3d852 142 void pca9532_setBlink0Duty(uint8_t duty);
embeddedartists 0:0fdadbc3d852 143 void pca9532_setBlink0Leds(uint16_t ledMask);
embeddedartists 0:0fdadbc3d852 144
embeddedartists 0:0fdadbc3d852 145 void set3V3Signal(bool enabled);
embeddedartists 0:0fdadbc3d852 146 void set5VSignal(bool enabled);
embeddedartists 0:0fdadbc3d852 147 void setDisplayEnableSignal(bool enabled);
embeddedartists 0:0fdadbc3d852 148 void setBacklightContrast(uint32_t value);
embeddedartists 0:0fdadbc3d852 149
embeddedartists 0:0fdadbc3d852 150 I2C _i2c;
embeddedartists 0:0fdadbc3d852 151 LcdController::Config _cfg;
embeddedartists 0:0fdadbc3d852 152 LcdController lcdCtrl;
embeddedartists 0:0fdadbc3d852 153 uint16_t _blink0Shadow;
embeddedartists 0:0fdadbc3d852 154 uint16_t _blink1Shadow;
embeddedartists 0:0fdadbc3d852 155 uint16_t _ledStateShadow;
embeddedartists 0:0fdadbc3d852 156 bool _lcdPwrOn;
embeddedartists 0:0fdadbc3d852 157 };
embeddedartists 0:0fdadbc3d852 158
embeddedartists 0:0fdadbc3d852 159 #endif
embeddedartists 0:0fdadbc3d852 160
embeddedartists 0:0fdadbc3d852 161