A board support package for the LPC4088 Display Module.

Dependencies:   DM_HttpServer DM_USBHost

Dependents:   lpc4088_displaymodule_emwin lpc4088_displaymodule_demo_sphere sampleGUI sampleEmptyGUI ... more

Fork of DMSupport by EmbeddedArtists AB

Committer:
embeddedartists
Date:
Thu Dec 11 18:23:07 2014 +0000
Revision:
9:a33326afd686
Parent:
5:c77fdb6e3438
Child:
10:1ac4b213f0f7
Updated documentation

Who changed what in which revision?

UserRevisionLine numberNew contents of line
embeddedartists 0:6b68dac0d986 1 /*
embeddedartists 0:6b68dac0d986 2 * Copyright 2014 Embedded Artists AB
embeddedartists 0:6b68dac0d986 3 *
embeddedartists 0:6b68dac0d986 4 * Licensed under the Apache License, Version 2.0 (the "License");
embeddedartists 0:6b68dac0d986 5 * you may not use this file except in compliance with the License.
embeddedartists 0:6b68dac0d986 6 * You may obtain a copy of the License at
embeddedartists 0:6b68dac0d986 7 *
embeddedartists 0:6b68dac0d986 8 * http://www.apache.org/licenses/LICENSE-2.0
embeddedartists 0:6b68dac0d986 9 *
embeddedartists 0:6b68dac0d986 10 * Unless required by applicable law or agreed to in writing, software
embeddedartists 0:6b68dac0d986 11 * distributed under the License is distributed on an "AS IS" BASIS,
embeddedartists 0:6b68dac0d986 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
embeddedartists 0:6b68dac0d986 13 * See the License for the specific language governing permissions and
embeddedartists 0:6b68dac0d986 14 * limitations under the License.
embeddedartists 0:6b68dac0d986 15 */
embeddedartists 0:6b68dac0d986 16
embeddedartists 0:6b68dac0d986 17 #ifndef DMBOARD_H
embeddedartists 0:6b68dac0d986 18 #define DMBOARD_H
embeddedartists 0:6b68dac0d986 19
embeddedartists 0:6b68dac0d986 20 #include "mbed.h"
embeddedartists 0:6b68dac0d986 21 #include "dm_board_config.h"
embeddedartists 2:887c6b45e7fa 22 #include "RtosLog.h"
embeddedartists 0:6b68dac0d986 23
embeddedartists 0:6b68dac0d986 24 #if defined(DM_BOARD_USE_MCI_FS)
embeddedartists 0:6b68dac0d986 25 #include "MCIFileSystem.h"
embeddedartists 0:6b68dac0d986 26 #endif
embeddedartists 0:6b68dac0d986 27 #if defined(DM_BOARD_USE_QSPI_FS)
embeddedartists 3:2fa7755f2cef 28 #include "SPIFI.h"
embeddedartists 0:6b68dac0d986 29 #include "QSPIFileSystem.h"
embeddedartists 0:6b68dac0d986 30 #elif defined(DM_BOARD_USE_QSPI)
embeddedartists 0:6b68dac0d986 31 #include "SPIFI.h"
embeddedartists 0:6b68dac0d986 32 #endif
embeddedartists 0:6b68dac0d986 33 #if defined(DM_BOARD_USE_DISPLAY)
embeddedartists 0:6b68dac0d986 34 #include "Display.h"
embeddedartists 0:6b68dac0d986 35 #endif
embeddedartists 0:6b68dac0d986 36 #if defined(DM_BOARD_USE_TOUCH)
embeddedartists 0:6b68dac0d986 37 #include "TouchPanel.h"
embeddedartists 0:6b68dac0d986 38 #endif
embeddedartists 0:6b68dac0d986 39
embeddedartists 0:6b68dac0d986 40 /**
embeddedartists 0:6b68dac0d986 41 * Example of using the Board class:
embeddedartists 0:6b68dac0d986 42 *
embeddedartists 0:6b68dac0d986 43 * @code
embeddedartists 0:6b68dac0d986 44 * #include "mbed.h"
embeddedartists 0:6b68dac0d986 45 * #include "DMBoard.h"
embeddedartists 0:6b68dac0d986 46 *
embeddedartists 0:6b68dac0d986 47 * int main(void) {
embeddedartists 0:6b68dac0d986 48 * DMBoard* board = &DMBoard::instance();
embeddedartists 0:6b68dac0d986 49 * board->init();
embeddedartists 0:6b68dac0d986 50 * ...
embeddedartists 0:6b68dac0d986 51 * board->setLed(1, true);
embeddedartists 0:6b68dac0d986 52 * }
embeddedartists 0:6b68dac0d986 53 * @endcode
embeddedartists 0:6b68dac0d986 54 */
embeddedartists 0:6b68dac0d986 55 class DMBoard {
embeddedartists 0:6b68dac0d986 56 public:
embeddedartists 2:887c6b45e7fa 57 enum Leds {
embeddedartists 2:887c6b45e7fa 58 Led1,
embeddedartists 2:887c6b45e7fa 59 Led2,
embeddedartists 2:887c6b45e7fa 60 Led3,
embeddedartists 2:887c6b45e7fa 61 Led4,
embeddedartists 0:6b68dac0d986 62 };
embeddedartists 0:6b68dac0d986 63
embeddedartists 0:6b68dac0d986 64 enum BoardError {
embeddedartists 0:6b68dac0d986 65 Ok = 0,
embeddedartists 0:6b68dac0d986 66 MemoryError = 1,
embeddedartists 0:6b68dac0d986 67 SpifiError = 1,
embeddedartists 0:6b68dac0d986 68 DisplayError = 2,
embeddedartists 0:6b68dac0d986 69 TouchError = 3,
embeddedartists 0:6b68dac0d986 70 };
embeddedartists 0:6b68dac0d986 71
embeddedartists 9:a33326afd686 72 /** Get the only instance of the DMBoard
embeddedartists 9:a33326afd686 73 *
embeddedartists 9:a33326afd686 74 * @returns The DMBoard
embeddedartists 9:a33326afd686 75 */
embeddedartists 0:6b68dac0d986 76 static DMBoard& instance()
embeddedartists 0:6b68dac0d986 77 {
embeddedartists 0:6b68dac0d986 78 static DMBoard singleton;
embeddedartists 0:6b68dac0d986 79 return singleton;
embeddedartists 0:6b68dac0d986 80 }
embeddedartists 0:6b68dac0d986 81
embeddedartists 0:6b68dac0d986 82 /** Initializes the wanted features
embeddedartists 0:6b68dac0d986 83 *
embeddedartists 0:6b68dac0d986 84 * @returns
embeddedartists 0:6b68dac0d986 85 * Ok on success
embeddedartists 0:6b68dac0d986 86 * An error code on failure
embeddedartists 0:6b68dac0d986 87 */
embeddedartists 0:6b68dac0d986 88 BoardError init();
embeddedartists 0:6b68dac0d986 89
embeddedartists 9:a33326afd686 90 /** Controls the four LEDs on the Display Module
embeddedartists 9:a33326afd686 91 *
embeddedartists 9:a33326afd686 92 * @param led One of Led1, Led2, Led3 or Led4
embeddedartists 9:a33326afd686 93 * @param on true to turn the LED on regardless of its polarity
embeddedartists 9:a33326afd686 94 */
embeddedartists 2:887c6b45e7fa 95 void setLED(Leds led, bool on);
embeddedartists 5:c77fdb6e3438 96
embeddedartists 5:c77fdb6e3438 97 /** Controls the buzzer
embeddedartists 5:c77fdb6e3438 98 *
embeddedartists 5:c77fdb6e3438 99 * Examples:
embeddedartists 5:c77fdb6e3438 100 * buzzer() turns it off
embeddedartists 5:c77fdb6e3438 101 * buzzer(440) plays an A4 (440Hz) note forever
embeddedartists 5:c77fdb6e3438 102 * buzzer(200, 25) plays a 200Hz tone for 25ms and then turns it off
embeddedartists 5:c77fdb6e3438 103 *
embeddedartists 5:c77fdb6e3438 104 * Note that if duration_ms is >0 this is a blocking call
embeddedartists 5:c77fdb6e3438 105 *
embeddedartists 5:c77fdb6e3438 106 * @param frequency the frequency of the tone (in Hz) or 0 to turn it off
embeddedartists 5:c77fdb6e3438 107 * @param duration_ms the number of milliseconds to play or 0 for forever
embeddedartists 5:c77fdb6e3438 108 */
embeddedartists 5:c77fdb6e3438 109 void buzzer(int frequency=0, int duration_ms=0);
embeddedartists 9:a33326afd686 110
embeddedartists 9:a33326afd686 111 /** Test if the USER button is pressed or not
embeddedartists 9:a33326afd686 112 *
embeddedartists 9:a33326afd686 113 * @returns
embeddedartists 9:a33326afd686 114 * True if the button is pressed, false if not
embeddedartists 9:a33326afd686 115 */
embeddedartists 0:6b68dac0d986 116 bool buttonPressed();
embeddedartists 0:6b68dac0d986 117
embeddedartists 0:6b68dac0d986 118 #if defined(DM_BOARD_USE_TOUCH)
embeddedartists 9:a33326afd686 119 /** Returns the TouchPanel interface
embeddedartists 9:a33326afd686 120 *
embeddedartists 9:a33326afd686 121 * @returns
embeddedartists 9:a33326afd686 122 * The touch panel
embeddedartists 9:a33326afd686 123 */
embeddedartists 0:6b68dac0d986 124 TouchPanel* touchPanel() { return _touch; }
embeddedartists 0:6b68dac0d986 125 #endif
embeddedartists 0:6b68dac0d986 126 #if defined(DM_BOARD_USE_DISPLAY)
embeddedartists 9:a33326afd686 127 /** Returns the Display interface
embeddedartists 9:a33326afd686 128 *
embeddedartists 9:a33326afd686 129 * @returns
embeddedartists 9:a33326afd686 130 * The display
embeddedartists 9:a33326afd686 131 */
embeddedartists 0:6b68dac0d986 132 Display* display() { return &(Display::instance()); }
embeddedartists 0:6b68dac0d986 133
embeddedartists 0:6b68dac0d986 134 friend class Display;
embeddedartists 0:6b68dac0d986 135 #endif
embeddedartists 9:a33326afd686 136 /** Returns the logger interface
embeddedartists 9:a33326afd686 137 *
embeddedartists 9:a33326afd686 138 * @returns
embeddedartists 9:a33326afd686 139 * The logger
embeddedartists 9:a33326afd686 140 */
embeddedartists 2:887c6b45e7fa 141 RtosLog* logger() { return &_logger; }
embeddedartists 0:6b68dac0d986 142
embeddedartists 0:6b68dac0d986 143 private:
embeddedartists 0:6b68dac0d986 144
embeddedartists 0:6b68dac0d986 145 bool _initialized;
embeddedartists 0:6b68dac0d986 146
embeddedartists 0:6b68dac0d986 147 #if defined(DM_BOARD_USE_MCI_FS)
embeddedartists 0:6b68dac0d986 148 MCIFileSystem _mcifs;
embeddedartists 0:6b68dac0d986 149 #endif
embeddedartists 0:6b68dac0d986 150 #if defined(DM_BOARD_USE_QSPI_FS)
embeddedartists 0:6b68dac0d986 151 QSPIFileSystem _qspifs;
embeddedartists 0:6b68dac0d986 152 #endif
embeddedartists 0:6b68dac0d986 153 #if defined(DM_BOARD_USE_TOUCH)
embeddedartists 0:6b68dac0d986 154 TouchPanel* _touch;
embeddedartists 0:6b68dac0d986 155 #endif
embeddedartists 0:6b68dac0d986 156
embeddedartists 0:6b68dac0d986 157 PwmOut _buzzer;
embeddedartists 0:6b68dac0d986 158 DigitalIn _button;
embeddedartists 0:6b68dac0d986 159 DigitalOut _led1;
embeddedartists 0:6b68dac0d986 160 DigitalOut _led2;
embeddedartists 0:6b68dac0d986 161 DigitalOut _led3;
embeddedartists 0:6b68dac0d986 162 DigitalOut _led4;
embeddedartists 0:6b68dac0d986 163
embeddedartists 2:887c6b45e7fa 164 RtosLog _logger;
embeddedartists 2:887c6b45e7fa 165
embeddedartists 0:6b68dac0d986 166 explicit DMBoard();
embeddedartists 0:6b68dac0d986 167 // hide copy constructor
embeddedartists 0:6b68dac0d986 168 DMBoard(const DMBoard&);
embeddedartists 0:6b68dac0d986 169 // hide assign operator
embeddedartists 0:6b68dac0d986 170 DMBoard& operator=(const DMBoard&);
embeddedartists 0:6b68dac0d986 171 ~DMBoard();
embeddedartists 0:6b68dac0d986 172
embeddedartists 0:6b68dac0d986 173 BoardError readConfiguration();
embeddedartists 0:6b68dac0d986 174 #if defined(DM_BOARD_USE_DISPLAY)
embeddedartists 0:6b68dac0d986 175 BoardError readDisplayConfiguration(uint8_t** data, uint32_t* size);
embeddedartists 0:6b68dac0d986 176 #endif
embeddedartists 0:6b68dac0d986 177 };
embeddedartists 0:6b68dac0d986 178
embeddedartists 0:6b68dac0d986 179 #endif