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
DMBoard.h@36:92193dc72995, 2015-03-20 (annotated)
- Committer:
- alindvall
- Date:
- Fri Mar 20 14:44:06 2015 +0000
- Revision:
- 36:92193dc72995
- Parent:
- 22:1a58a518435c
- Child:
- 37:07659b5d90ce
Modified DMBoard interface to always have the touchPanel() and display() functions even if the touch/display has been disabled in dm_board_config.h to allow e.g. AppTouchCalibration to compile (even if it will never be used it must still compile)
Who changed what in which revision?
User | Revision | Line number | New 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 |
embeddedartists | 20:9df19da50290 | 151 | |
embeddedartists | 0:6b68dac0d986 | 152 | private: |
embeddedartists | 0:6b68dac0d986 | 153 | |
embeddedartists | 0:6b68dac0d986 | 154 | bool _initialized; |
embeddedartists | 0:6b68dac0d986 | 155 | |
embeddedartists | 0:6b68dac0d986 | 156 | #if defined(DM_BOARD_USE_MCI_FS) |
embeddedartists | 0:6b68dac0d986 | 157 | MCIFileSystem _mcifs; |
embeddedartists | 0:6b68dac0d986 | 158 | #endif |
embeddedartists | 0:6b68dac0d986 | 159 | #if defined(DM_BOARD_USE_QSPI_FS) |
embeddedartists | 0:6b68dac0d986 | 160 | QSPIFileSystem _qspifs; |
embeddedartists | 0:6b68dac0d986 | 161 | #endif |
embeddedartists | 0:6b68dac0d986 | 162 | |
embeddedartists | 0:6b68dac0d986 | 163 | PwmOut _buzzer; |
embeddedartists | 0:6b68dac0d986 | 164 | DigitalIn _button; |
embeddedartists | 0:6b68dac0d986 | 165 | DigitalOut _led1; |
embeddedartists | 0:6b68dac0d986 | 166 | DigitalOut _led2; |
embeddedartists | 0:6b68dac0d986 | 167 | DigitalOut _led3; |
embeddedartists | 0:6b68dac0d986 | 168 | DigitalOut _led4; |
embeddedartists | 0:6b68dac0d986 | 169 | |
embeddedartists | 2:887c6b45e7fa | 170 | RtosLog _logger; |
embeddedartists | 2:887c6b45e7fa | 171 | |
embeddedartists | 0:6b68dac0d986 | 172 | explicit DMBoard(); |
embeddedartists | 0:6b68dac0d986 | 173 | // hide copy constructor |
embeddedartists | 0:6b68dac0d986 | 174 | DMBoard(const DMBoard&); |
embeddedartists | 0:6b68dac0d986 | 175 | // hide assign operator |
embeddedartists | 0:6b68dac0d986 | 176 | DMBoard& operator=(const DMBoard&); |
embeddedartists | 0:6b68dac0d986 | 177 | ~DMBoard(); |
embeddedartists | 0:6b68dac0d986 | 178 | }; |
embeddedartists | 0:6b68dac0d986 | 179 | |
embeddedartists | 0:6b68dac0d986 | 180 | #endif |