Subdirectory provided by Embedded Artists

Dependencies:   DM_FATFileSystem DM_HttpServer DM_USBHost EthernetInterface USBDevice mbed-rpc mbed-rtos mbed-src

Dependents:   lpc4088_displaymodule_hello_world_Sept_2018

Fork of DMSupport by Embedded Artists

Committer:
jmitc91516
Date:
Thu Oct 04 08:30:19 2018 +0000
Revision:
41:ac490f69398f
Parent:
37:07659b5d90ce
To demonstrate a problem with the dm_board_config.h file - the project will not build if it is in its normal place in the root directory, but builds OK if I copy it to the DMSupport subdirectory.

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 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 10:1ac4b213f0f7 65 Ok = 0,
embeddedartists 10:1ac4b213f0f7 66 MemoryError,
embeddedartists 10:1ac4b213f0f7 67 SpifiError,
embeddedartists 10:1ac4b213f0f7 68 DisplayError,
embeddedartists 10:1ac4b213f0f7 69 TouchError,
embeddedartists 10:1ac4b213f0f7 70 BiosInvalidError,
embeddedartists 10:1ac4b213f0f7 71 BiosVersionError,
embeddedartists 17:4ea2509445ac 72 BiosStorageError,
embeddedartists 20:9df19da50290 73 RegistryError,
embeddedartists 0:6b68dac0d986 74 };
embeddedartists 0:6b68dac0d986 75
embeddedartists 9:a33326afd686 76 /** Get the only instance of the DMBoard
embeddedartists 9:a33326afd686 77 *
embeddedartists 9:a33326afd686 78 * @returns The DMBoard
embeddedartists 9:a33326afd686 79 */
embeddedartists 0:6b68dac0d986 80 static DMBoard& instance()
embeddedartists 0:6b68dac0d986 81 {
embeddedartists 0:6b68dac0d986 82 static DMBoard singleton;
embeddedartists 0:6b68dac0d986 83 return singleton;
embeddedartists 0:6b68dac0d986 84 }
embeddedartists 0:6b68dac0d986 85
embeddedartists 0:6b68dac0d986 86 /** Initializes the wanted features
embeddedartists 0:6b68dac0d986 87 *
embeddedartists 0:6b68dac0d986 88 * @returns
embeddedartists 0:6b68dac0d986 89 * Ok on success
embeddedartists 0:6b68dac0d986 90 * An error code on failure
embeddedartists 0:6b68dac0d986 91 */
embeddedartists 0:6b68dac0d986 92 BoardError init();
embeddedartists 0:6b68dac0d986 93
embeddedartists 9:a33326afd686 94 /** Controls the four LEDs on the Display Module
embeddedartists 9:a33326afd686 95 *
embeddedartists 9:a33326afd686 96 * @param led One of Led1, Led2, Led3 or Led4
embeddedartists 9:a33326afd686 97 * @param on true to turn the LED on regardless of its polarity
embeddedartists 9:a33326afd686 98 */
embeddedartists 2:887c6b45e7fa 99 void setLED(Leds led, bool on);
embeddedartists 5:c77fdb6e3438 100
embeddedartists 5:c77fdb6e3438 101 /** Controls the buzzer
embeddedartists 5:c77fdb6e3438 102 *
embeddedartists 5:c77fdb6e3438 103 * Examples:
embeddedartists 5:c77fdb6e3438 104 * buzzer() turns it off
embeddedartists 5:c77fdb6e3438 105 * buzzer(440) plays an A4 (440Hz) note forever
embeddedartists 5:c77fdb6e3438 106 * buzzer(200, 25) plays a 200Hz tone for 25ms and then turns it off
embeddedartists 5:c77fdb6e3438 107 *
embeddedartists 5:c77fdb6e3438 108 * Note that if duration_ms is >0 this is a blocking call
embeddedartists 5:c77fdb6e3438 109 *
embeddedartists 5:c77fdb6e3438 110 * @param frequency the frequency of the tone (in Hz) or 0 to turn it off
embeddedartists 5:c77fdb6e3438 111 * @param duration_ms the number of milliseconds to play or 0 for forever
embeddedartists 5:c77fdb6e3438 112 */
embeddedartists 5:c77fdb6e3438 113 void buzzer(int frequency=0, int duration_ms=0);
embeddedartists 9:a33326afd686 114
embeddedartists 9:a33326afd686 115 /** Test if the USER button is pressed or not
embeddedartists 9:a33326afd686 116 *
embeddedartists 9:a33326afd686 117 * @returns
embeddedartists 9:a33326afd686 118 * True if the button is pressed, false if not
embeddedartists 9:a33326afd686 119 */
embeddedartists 0:6b68dac0d986 120 bool buttonPressed();
embeddedartists 0:6b68dac0d986 121
embeddedartists 9:a33326afd686 122 /** Returns the TouchPanel interface
embeddedartists 9:a33326afd686 123 *
embeddedartists 9:a33326afd686 124 * @returns
embeddedartists 9:a33326afd686 125 * The touch panel
embeddedartists 9:a33326afd686 126 */
embeddedartists 10:1ac4b213f0f7 127 TouchPanel* touchPanel();
embeddedartists 10:1ac4b213f0f7 128
embeddedartists 9:a33326afd686 129 /** Returns the Display interface
embeddedartists 9:a33326afd686 130 *
embeddedartists 9:a33326afd686 131 * @returns
embeddedartists 9:a33326afd686 132 * The display
embeddedartists 9:a33326afd686 133 */
embeddedartists 10:1ac4b213f0f7 134 Display* display();
embeddedartists 0:6b68dac0d986 135
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 20:9df19da50290 143 #if defined(DM_BOARD_USE_REGISTRY)
embeddedartists 20:9df19da50290 144 /** Returns the Registry interface
embeddedartists 20:9df19da50290 145 *
embeddedartists 20:9df19da50290 146 * @returns
embeddedartists 20:9df19da50290 147 * The registry
embeddedartists 20:9df19da50290 148 */
embeddedartists 20:9df19da50290 149 Registry* registry() { return &Registry::instance(); }
embeddedartists 20:9df19da50290 150 #endif
alindvall 37:07659b5d90ce 151
alindvall 37:07659b5d90ce 152 #if defined(DM_BOARD_USE_MCI_FS)
alindvall 37:07659b5d90ce 153 /** Returns the MCI File System instance.
alindvall 37:07659b5d90ce 154 *
alindvall 37:07659b5d90ce 155 * Can be used to call e.g. cardInserted().
alindvall 37:07659b5d90ce 156 *
alindvall 37:07659b5d90ce 157 * @returns
alindvall 37:07659b5d90ce 158 * The file system instance
alindvall 37:07659b5d90ce 159 */
alindvall 37:07659b5d90ce 160 MCIFileSystem* getMciFS() { return &_mcifs; }
alindvall 37:07659b5d90ce 161 #else
alindvall 37:07659b5d90ce 162 void* getMciFS() { return NULL; }
alindvall 37:07659b5d90ce 163 #endif
alindvall 37:07659b5d90ce 164 #if defined(DM_BOARD_USE_QSPI_FS)
alindvall 37:07659b5d90ce 165 /** Returns the QSPI File System instance.
alindvall 37:07659b5d90ce 166 *
alindvall 37:07659b5d90ce 167 * Can be used to call e.g. isformatted() and format().
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 QSPIFileSystem* getQspiFS() { return &_qspifs; }
alindvall 37:07659b5d90ce 173 #else
alindvall 37:07659b5d90ce 174 void* getQspiFS() { return NULL; }
alindvall 37:07659b5d90ce 175 #endif
alindvall 37:07659b5d90ce 176
embeddedartists 20:9df19da50290 177
embeddedartists 0:6b68dac0d986 178 private:
embeddedartists 0:6b68dac0d986 179
embeddedartists 0:6b68dac0d986 180 bool _initialized;
embeddedartists 0:6b68dac0d986 181
embeddedartists 0:6b68dac0d986 182 #if defined(DM_BOARD_USE_MCI_FS)
embeddedartists 0:6b68dac0d986 183 MCIFileSystem _mcifs;
embeddedartists 0:6b68dac0d986 184 #endif
embeddedartists 0:6b68dac0d986 185 #if defined(DM_BOARD_USE_QSPI_FS)
embeddedartists 0:6b68dac0d986 186 QSPIFileSystem _qspifs;
embeddedartists 0:6b68dac0d986 187 #endif
embeddedartists 0:6b68dac0d986 188
embeddedartists 0:6b68dac0d986 189 PwmOut _buzzer;
embeddedartists 0:6b68dac0d986 190 DigitalIn _button;
embeddedartists 0:6b68dac0d986 191 DigitalOut _led1;
embeddedartists 0:6b68dac0d986 192 DigitalOut _led2;
embeddedartists 0:6b68dac0d986 193 DigitalOut _led3;
embeddedartists 0:6b68dac0d986 194 DigitalOut _led4;
embeddedartists 0:6b68dac0d986 195
embeddedartists 2:887c6b45e7fa 196 RtosLog _logger;
embeddedartists 2:887c6b45e7fa 197
embeddedartists 0:6b68dac0d986 198 explicit DMBoard();
embeddedartists 0:6b68dac0d986 199 // hide copy constructor
embeddedartists 0:6b68dac0d986 200 DMBoard(const DMBoard&);
embeddedartists 0:6b68dac0d986 201 // hide assign operator
embeddedartists 0:6b68dac0d986 202 DMBoard& operator=(const DMBoard&);
embeddedartists 0:6b68dac0d986 203 ~DMBoard();
embeddedartists 0:6b68dac0d986 204 };
embeddedartists 0:6b68dac0d986 205
embeddedartists 0:6b68dac0d986 206 #endif