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:
Mon Nov 04 14:32:50 2019 +0000
Revision:
42:bbfe299d4a0c
Parent:
37:07659b5d90ce
More updates related to mbed OS 5

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
alindvall 36:92193dc72995 33 #include "Display.h"
alindvall 36:92193dc72995 34 #include "TouchPanel.h"
embeddedartists 20:9df19da50290 35 #if defined(DM_BOARD_USE_REGISTRY)
embeddedartists 20:9df19da50290 36 #include "Registry.h"
embeddedartists 20:9df19da50290 37 #endif
embeddedartists 20:9df19da50290 38
embeddedartists 42:bbfe299d4a0c 39 #if defined(DM_BOARD_USE_USB_HOST) && defined(DM_BOARD_USE_ETHERNET)
embeddedartists 42:bbfe299d4a0c 40 /*
embeddedartists 42:bbfe299d4a0c 41 * It is not possible to use USB Host and Ethernet at the same time due to a
embeddedartists 42:bbfe299d4a0c 42 * conflict in memory areas.
embeddedartists 42:bbfe299d4a0c 43 *
embeddedartists 42:bbfe299d4a0c 44 * In OS 5 memory area AHBSRAM0 is used by the EMAC driver (lpc17_emac.cpp) and
embeddedartists 42:bbfe299d4a0c 45 * AHBSRAM1 is used by LWIP as heap (lwip_sys_arch.c). The USB host
embeddedartists 42:bbfe299d4a0c 46 * implementation is using AHBSRAM1 (USBHALHost.cpp).
embeddedartists 42:bbfe299d4a0c 47 */
embeddedartists 42:bbfe299d4a0c 48 #error "Cannot have both USB Host and Ethernet enabled at the same time. See DMBoard.h"
embeddedartists 42:bbfe299d4a0c 49 #endif
embeddedartists 42:bbfe299d4a0c 50
embeddedartists 0:6b68dac0d986 51
embeddedartists 0:6b68dac0d986 52 /**
embeddedartists 0:6b68dac0d986 53 * Example of using the Board class:
embeddedartists 0:6b68dac0d986 54 *
embeddedartists 0:6b68dac0d986 55 * @code
embeddedartists 0:6b68dac0d986 56 * #include "mbed.h"
embeddedartists 0:6b68dac0d986 57 * #include "DMBoard.h"
embeddedartists 0:6b68dac0d986 58 *
embeddedartists 0:6b68dac0d986 59 * int main(void) {
embeddedartists 0:6b68dac0d986 60 * DMBoard* board = &DMBoard::instance();
embeddedartists 0:6b68dac0d986 61 * board->init();
embeddedartists 0:6b68dac0d986 62 * ...
embeddedartists 0:6b68dac0d986 63 * board->setLed(1, true);
embeddedartists 0:6b68dac0d986 64 * }
embeddedartists 0:6b68dac0d986 65 * @endcode
embeddedartists 0:6b68dac0d986 66 */
embeddedartists 0:6b68dac0d986 67 class DMBoard {
embeddedartists 0:6b68dac0d986 68 public:
embeddedartists 2:887c6b45e7fa 69 enum Leds {
embeddedartists 2:887c6b45e7fa 70 Led1,
embeddedartists 2:887c6b45e7fa 71 Led2,
embeddedartists 2:887c6b45e7fa 72 Led3,
embeddedartists 2:887c6b45e7fa 73 Led4,
embeddedartists 0:6b68dac0d986 74 };
embeddedartists 0:6b68dac0d986 75
embeddedartists 0:6b68dac0d986 76 enum BoardError {
embeddedartists 10:1ac4b213f0f7 77 Ok = 0,
embeddedartists 10:1ac4b213f0f7 78 MemoryError,
embeddedartists 10:1ac4b213f0f7 79 SpifiError,
embeddedartists 10:1ac4b213f0f7 80 DisplayError,
embeddedartists 10:1ac4b213f0f7 81 TouchError,
embeddedartists 10:1ac4b213f0f7 82 BiosInvalidError,
embeddedartists 10:1ac4b213f0f7 83 BiosVersionError,
embeddedartists 17:4ea2509445ac 84 BiosStorageError,
embeddedartists 20:9df19da50290 85 RegistryError,
embeddedartists 0:6b68dac0d986 86 };
embeddedartists 0:6b68dac0d986 87
embeddedartists 9:a33326afd686 88 /** Get the only instance of the DMBoard
embeddedartists 9:a33326afd686 89 *
embeddedartists 9:a33326afd686 90 * @returns The DMBoard
embeddedartists 9:a33326afd686 91 */
embeddedartists 0:6b68dac0d986 92 static DMBoard& instance()
embeddedartists 0:6b68dac0d986 93 {
embeddedartists 0:6b68dac0d986 94 static DMBoard singleton;
embeddedartists 0:6b68dac0d986 95 return singleton;
embeddedartists 0:6b68dac0d986 96 }
embeddedartists 0:6b68dac0d986 97
embeddedartists 0:6b68dac0d986 98 /** Initializes the wanted features
embeddedartists 0:6b68dac0d986 99 *
embeddedartists 0:6b68dac0d986 100 * @returns
embeddedartists 0:6b68dac0d986 101 * Ok on success
embeddedartists 0:6b68dac0d986 102 * An error code on failure
embeddedartists 0:6b68dac0d986 103 */
embeddedartists 0:6b68dac0d986 104 BoardError init();
embeddedartists 0:6b68dac0d986 105
embeddedartists 9:a33326afd686 106 /** Controls the four LEDs on the Display Module
embeddedartists 9:a33326afd686 107 *
embeddedartists 9:a33326afd686 108 * @param led One of Led1, Led2, Led3 or Led4
embeddedartists 9:a33326afd686 109 * @param on true to turn the LED on regardless of its polarity
embeddedartists 9:a33326afd686 110 */
embeddedartists 2:887c6b45e7fa 111 void setLED(Leds led, bool on);
embeddedartists 5:c77fdb6e3438 112
embeddedartists 5:c77fdb6e3438 113 /** Controls the buzzer
embeddedartists 5:c77fdb6e3438 114 *
embeddedartists 5:c77fdb6e3438 115 * Examples:
embeddedartists 5:c77fdb6e3438 116 * buzzer() turns it off
embeddedartists 5:c77fdb6e3438 117 * buzzer(440) plays an A4 (440Hz) note forever
embeddedartists 5:c77fdb6e3438 118 * buzzer(200, 25) plays a 200Hz tone for 25ms and then turns it off
embeddedartists 5:c77fdb6e3438 119 *
embeddedartists 5:c77fdb6e3438 120 * Note that if duration_ms is >0 this is a blocking call
embeddedartists 5:c77fdb6e3438 121 *
embeddedartists 5:c77fdb6e3438 122 * @param frequency the frequency of the tone (in Hz) or 0 to turn it off
embeddedartists 5:c77fdb6e3438 123 * @param duration_ms the number of milliseconds to play or 0 for forever
embeddedartists 5:c77fdb6e3438 124 */
embeddedartists 5:c77fdb6e3438 125 void buzzer(int frequency=0, int duration_ms=0);
embeddedartists 9:a33326afd686 126
embeddedartists 9:a33326afd686 127 /** Test if the USER button is pressed or not
embeddedartists 9:a33326afd686 128 *
embeddedartists 9:a33326afd686 129 * @returns
embeddedartists 9:a33326afd686 130 * True if the button is pressed, false if not
embeddedartists 9:a33326afd686 131 */
embeddedartists 0:6b68dac0d986 132 bool buttonPressed();
embeddedartists 0:6b68dac0d986 133
embeddedartists 9:a33326afd686 134 /** Returns the TouchPanel interface
embeddedartists 9:a33326afd686 135 *
embeddedartists 9:a33326afd686 136 * @returns
embeddedartists 9:a33326afd686 137 * The touch panel
embeddedartists 9:a33326afd686 138 */
embeddedartists 10:1ac4b213f0f7 139 TouchPanel* touchPanel();
embeddedartists 10:1ac4b213f0f7 140
embeddedartists 9:a33326afd686 141 /** Returns the Display interface
embeddedartists 9:a33326afd686 142 *
embeddedartists 9:a33326afd686 143 * @returns
embeddedartists 9:a33326afd686 144 * The display
embeddedartists 9:a33326afd686 145 */
embeddedartists 10:1ac4b213f0f7 146 Display* display();
embeddedartists 0:6b68dac0d986 147
embeddedartists 9:a33326afd686 148 /** Returns the logger interface
embeddedartists 9:a33326afd686 149 *
embeddedartists 9:a33326afd686 150 * @returns
embeddedartists 9:a33326afd686 151 * The logger
embeddedartists 9:a33326afd686 152 */
embeddedartists 2:887c6b45e7fa 153 RtosLog* logger() { return &_logger; }
embeddedartists 0:6b68dac0d986 154
embeddedartists 20:9df19da50290 155 #if defined(DM_BOARD_USE_REGISTRY)
embeddedartists 20:9df19da50290 156 /** Returns the Registry interface
embeddedartists 20:9df19da50290 157 *
embeddedartists 20:9df19da50290 158 * @returns
embeddedartists 20:9df19da50290 159 * The registry
embeddedartists 20:9df19da50290 160 */
embeddedartists 20:9df19da50290 161 Registry* registry() { return &Registry::instance(); }
embeddedartists 20:9df19da50290 162 #endif
alindvall 37:07659b5d90ce 163
alindvall 37:07659b5d90ce 164 #if defined(DM_BOARD_USE_MCI_FS)
alindvall 37:07659b5d90ce 165 /** Returns the MCI File System instance.
alindvall 37:07659b5d90ce 166 *
alindvall 37:07659b5d90ce 167 * Can be used to call e.g. cardInserted().
alindvall 37:07659b5d90ce 168 *
alindvall 37:07659b5d90ce 169 * @returns
alindvall 37:07659b5d90ce 170 * The file system instance
alindvall 37:07659b5d90ce 171 */
alindvall 37:07659b5d90ce 172 MCIFileSystem* getMciFS() { return &_mcifs; }
alindvall 37:07659b5d90ce 173 #else
alindvall 37:07659b5d90ce 174 void* getMciFS() { return NULL; }
alindvall 37:07659b5d90ce 175 #endif
alindvall 37:07659b5d90ce 176 #if defined(DM_BOARD_USE_QSPI_FS)
alindvall 37:07659b5d90ce 177 /** Returns the QSPI File System instance.
alindvall 37:07659b5d90ce 178 *
alindvall 37:07659b5d90ce 179 * Can be used to call e.g. isformatted() and format().
alindvall 37:07659b5d90ce 180 *
alindvall 37:07659b5d90ce 181 * @returns
alindvall 37:07659b5d90ce 182 * The file system instance
alindvall 37:07659b5d90ce 183 */
alindvall 37:07659b5d90ce 184 QSPIFileSystem* getQspiFS() { return &_qspifs; }
alindvall 37:07659b5d90ce 185 #else
alindvall 37:07659b5d90ce 186 void* getQspiFS() { return NULL; }
alindvall 37:07659b5d90ce 187 #endif
alindvall 37:07659b5d90ce 188
embeddedartists 20:9df19da50290 189
embeddedartists 0:6b68dac0d986 190 private:
embeddedartists 0:6b68dac0d986 191
embeddedartists 0:6b68dac0d986 192 bool _initialized;
embeddedartists 0:6b68dac0d986 193
embeddedartists 0:6b68dac0d986 194 #if defined(DM_BOARD_USE_MCI_FS)
embeddedartists 0:6b68dac0d986 195 MCIFileSystem _mcifs;
embeddedartists 42:bbfe299d4a0c 196 FATFileSystem _mciFatFs;
embeddedartists 0:6b68dac0d986 197 #endif
embeddedartists 0:6b68dac0d986 198 #if defined(DM_BOARD_USE_QSPI_FS)
embeddedartists 0:6b68dac0d986 199 QSPIFileSystem _qspifs;
embeddedartists 0:6b68dac0d986 200 #endif
embeddedartists 0:6b68dac0d986 201
embeddedartists 0:6b68dac0d986 202 PwmOut _buzzer;
embeddedartists 0:6b68dac0d986 203 DigitalIn _button;
embeddedartists 0:6b68dac0d986 204 DigitalOut _led1;
embeddedartists 0:6b68dac0d986 205 DigitalOut _led2;
embeddedartists 0:6b68dac0d986 206 DigitalOut _led3;
embeddedartists 0:6b68dac0d986 207 DigitalOut _led4;
embeddedartists 0:6b68dac0d986 208
embeddedartists 2:887c6b45e7fa 209 RtosLog _logger;
embeddedartists 2:887c6b45e7fa 210
embeddedartists 0:6b68dac0d986 211 explicit DMBoard();
embeddedartists 0:6b68dac0d986 212 // hide copy constructor
embeddedartists 0:6b68dac0d986 213 DMBoard(const DMBoard&);
embeddedartists 0:6b68dac0d986 214 // hide assign operator
embeddedartists 0:6b68dac0d986 215 DMBoard& operator=(const DMBoard&);
embeddedartists 0:6b68dac0d986 216 ~DMBoard();
embeddedartists 0:6b68dac0d986 217 };
embeddedartists 0:6b68dac0d986 218
embeddedartists 0:6b68dac0d986 219 #endif