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:
Wed Dec 10 08:25:17 2014 +0000
Revision:
5:c77fdb6e3438
Parent:
3:2fa7755f2cef
Child:
9:a33326afd686
Minor changes in DMBoard

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 0:6b68dac0d986 72 static DMBoard& instance()
embeddedartists 0:6b68dac0d986 73 {
embeddedartists 0:6b68dac0d986 74 static DMBoard singleton;
embeddedartists 0:6b68dac0d986 75 return singleton;
embeddedartists 0:6b68dac0d986 76 }
embeddedartists 0:6b68dac0d986 77
embeddedartists 0:6b68dac0d986 78
embeddedartists 0:6b68dac0d986 79 /** Initializes the wanted features
embeddedartists 0:6b68dac0d986 80 *
embeddedartists 0:6b68dac0d986 81 * @returns
embeddedartists 0:6b68dac0d986 82 * Ok on success
embeddedartists 0:6b68dac0d986 83 * An error code on failure
embeddedartists 0:6b68dac0d986 84 */
embeddedartists 0:6b68dac0d986 85 BoardError init();
embeddedartists 0:6b68dac0d986 86
embeddedartists 2:887c6b45e7fa 87 void setLED(Leds led, bool on);
embeddedartists 5:c77fdb6e3438 88
embeddedartists 5:c77fdb6e3438 89 /** Controls the buzzer
embeddedartists 5:c77fdb6e3438 90 *
embeddedartists 5:c77fdb6e3438 91 * Examples:
embeddedartists 5:c77fdb6e3438 92 * buzzer() turns it off
embeddedartists 5:c77fdb6e3438 93 * buzzer(440) plays an A4 (440Hz) note forever
embeddedartists 5:c77fdb6e3438 94 * buzzer(200, 25) plays a 200Hz tone for 25ms and then turns it off
embeddedartists 5:c77fdb6e3438 95 *
embeddedartists 5:c77fdb6e3438 96 * Note that if duration_ms is >0 this is a blocking call
embeddedartists 5:c77fdb6e3438 97 *
embeddedartists 5:c77fdb6e3438 98 * @param frequency the frequency of the tone (in Hz) or 0 to turn it off
embeddedartists 5:c77fdb6e3438 99 * @param duration_ms the number of milliseconds to play or 0 for forever
embeddedartists 5:c77fdb6e3438 100 */
embeddedartists 5:c77fdb6e3438 101 void buzzer(int frequency=0, int duration_ms=0);
embeddedartists 0:6b68dac0d986 102 bool buttonPressed();
embeddedartists 0:6b68dac0d986 103
embeddedartists 0:6b68dac0d986 104 #if defined(DM_BOARD_USE_TOUCH)
embeddedartists 0:6b68dac0d986 105 TouchPanel* touchPanel() { return _touch; }
embeddedartists 0:6b68dac0d986 106 #endif
embeddedartists 0:6b68dac0d986 107 #if defined(DM_BOARD_USE_DISPLAY)
embeddedartists 0:6b68dac0d986 108 Display* display() { return &(Display::instance()); }
embeddedartists 0:6b68dac0d986 109
embeddedartists 0:6b68dac0d986 110 friend class Display;
embeddedartists 0:6b68dac0d986 111 #endif
embeddedartists 2:887c6b45e7fa 112 RtosLog* logger() { return &_logger; }
embeddedartists 0:6b68dac0d986 113
embeddedartists 0:6b68dac0d986 114 private:
embeddedartists 0:6b68dac0d986 115
embeddedartists 0:6b68dac0d986 116 bool _initialized;
embeddedartists 0:6b68dac0d986 117
embeddedartists 0:6b68dac0d986 118 #if defined(DM_BOARD_USE_MCI_FS)
embeddedartists 0:6b68dac0d986 119 MCIFileSystem _mcifs;
embeddedartists 0:6b68dac0d986 120 #endif
embeddedartists 0:6b68dac0d986 121 #if defined(DM_BOARD_USE_QSPI_FS)
embeddedartists 0:6b68dac0d986 122 QSPIFileSystem _qspifs;
embeddedartists 0:6b68dac0d986 123 #endif
embeddedartists 0:6b68dac0d986 124 #if defined(DM_BOARD_USE_TOUCH)
embeddedartists 0:6b68dac0d986 125 TouchPanel* _touch;
embeddedartists 0:6b68dac0d986 126 #endif
embeddedartists 0:6b68dac0d986 127
embeddedartists 0:6b68dac0d986 128 PwmOut _buzzer;
embeddedartists 0:6b68dac0d986 129 DigitalIn _button;
embeddedartists 0:6b68dac0d986 130 DigitalOut _led1;
embeddedartists 0:6b68dac0d986 131 DigitalOut _led2;
embeddedartists 0:6b68dac0d986 132 DigitalOut _led3;
embeddedartists 0:6b68dac0d986 133 DigitalOut _led4;
embeddedartists 0:6b68dac0d986 134
embeddedartists 2:887c6b45e7fa 135 RtosLog _logger;
embeddedartists 2:887c6b45e7fa 136
embeddedartists 0:6b68dac0d986 137 explicit DMBoard();
embeddedartists 0:6b68dac0d986 138 // hide copy constructor
embeddedartists 0:6b68dac0d986 139 DMBoard(const DMBoard&);
embeddedartists 0:6b68dac0d986 140 // hide assign operator
embeddedartists 0:6b68dac0d986 141 DMBoard& operator=(const DMBoard&);
embeddedartists 0:6b68dac0d986 142 ~DMBoard();
embeddedartists 0:6b68dac0d986 143
embeddedartists 0:6b68dac0d986 144 BoardError readConfiguration();
embeddedartists 0:6b68dac0d986 145 #if defined(DM_BOARD_USE_DISPLAY)
embeddedartists 0:6b68dac0d986 146 BoardError readDisplayConfiguration(uint8_t** data, uint32_t* size);
embeddedartists 0:6b68dac0d986 147 #endif
embeddedartists 0:6b68dac0d986 148 };
embeddedartists 0:6b68dac0d986 149
embeddedartists 0:6b68dac0d986 150 #endif
embeddedartists 0:6b68dac0d986 151