Dependencies: DM_FATFileSystem EthernetInterface HTTPClient mbed-rtos mbed-src
Fork of DMSupport by
DMBoard.h@2:887c6b45e7fa, 2014-12-02 (annotated)
- Committer:
- embeddedartists
- Date:
- Tue Dec 02 15:21:18 2014 +0000
- Revision:
- 2:887c6b45e7fa
- Parent:
- 0:6b68dac0d986
- Child:
- 3:2fa7755f2cef
Added RTOS-safe logger (RtosLog). Switched USBHost library so that it works in an RTOS setting. Modified the FAT file system to work in an RTOS setting.
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 | 0:6b68dac0d986 | 28 | #include "QSPIFileSystem.h" |
embeddedartists | 0:6b68dac0d986 | 29 | #elif defined(DM_BOARD_USE_QSPI) |
embeddedartists | 0:6b68dac0d986 | 30 | #include "SPIFI.h" |
embeddedartists | 0:6b68dac0d986 | 31 | #endif |
embeddedartists | 0:6b68dac0d986 | 32 | #if defined(DM_BOARD_USE_DISPLAY) |
embeddedartists | 0:6b68dac0d986 | 33 | #include "Display.h" |
embeddedartists | 0:6b68dac0d986 | 34 | #endif |
embeddedartists | 0:6b68dac0d986 | 35 | #if defined(DM_BOARD_USE_TOUCH) |
embeddedartists | 0:6b68dac0d986 | 36 | #include "TouchPanel.h" |
embeddedartists | 0:6b68dac0d986 | 37 | #endif |
embeddedartists | 0:6b68dac0d986 | 38 | |
embeddedartists | 0:6b68dac0d986 | 39 | /** |
embeddedartists | 0:6b68dac0d986 | 40 | * Example of using the Board class: |
embeddedartists | 0:6b68dac0d986 | 41 | * |
embeddedartists | 0:6b68dac0d986 | 42 | * @code |
embeddedartists | 0:6b68dac0d986 | 43 | * #include "mbed.h" |
embeddedartists | 0:6b68dac0d986 | 44 | * #include "DMBoard.h" |
embeddedartists | 0:6b68dac0d986 | 45 | * |
embeddedartists | 0:6b68dac0d986 | 46 | * int main(void) { |
embeddedartists | 0:6b68dac0d986 | 47 | * DMBoard* board = &DMBoard::instance(); |
embeddedartists | 0:6b68dac0d986 | 48 | * board->init(); |
embeddedartists | 0:6b68dac0d986 | 49 | * ... |
embeddedartists | 0:6b68dac0d986 | 50 | * board->setLed(1, true); |
embeddedartists | 0:6b68dac0d986 | 51 | * } |
embeddedartists | 0:6b68dac0d986 | 52 | * @endcode |
embeddedartists | 0:6b68dac0d986 | 53 | */ |
embeddedartists | 0:6b68dac0d986 | 54 | class DMBoard { |
embeddedartists | 0:6b68dac0d986 | 55 | public: |
embeddedartists | 2:887c6b45e7fa | 56 | enum Leds { |
embeddedartists | 2:887c6b45e7fa | 57 | Led1, |
embeddedartists | 2:887c6b45e7fa | 58 | Led2, |
embeddedartists | 2:887c6b45e7fa | 59 | Led3, |
embeddedartists | 2:887c6b45e7fa | 60 | Led4, |
embeddedartists | 0:6b68dac0d986 | 61 | }; |
embeddedartists | 0:6b68dac0d986 | 62 | |
embeddedartists | 0:6b68dac0d986 | 63 | enum BoardError { |
embeddedartists | 0:6b68dac0d986 | 64 | Ok = 0, |
embeddedartists | 0:6b68dac0d986 | 65 | MemoryError = 1, |
embeddedartists | 0:6b68dac0d986 | 66 | SpifiError = 1, |
embeddedartists | 0:6b68dac0d986 | 67 | DisplayError = 2, |
embeddedartists | 0:6b68dac0d986 | 68 | TouchError = 3, |
embeddedartists | 0:6b68dac0d986 | 69 | }; |
embeddedartists | 0:6b68dac0d986 | 70 | |
embeddedartists | 0:6b68dac0d986 | 71 | static DMBoard& instance() |
embeddedartists | 0:6b68dac0d986 | 72 | { |
embeddedartists | 0:6b68dac0d986 | 73 | static DMBoard singleton; |
embeddedartists | 0:6b68dac0d986 | 74 | return singleton; |
embeddedartists | 0:6b68dac0d986 | 75 | } |
embeddedartists | 0:6b68dac0d986 | 76 | |
embeddedartists | 0:6b68dac0d986 | 77 | |
embeddedartists | 0:6b68dac0d986 | 78 | /** Initializes the wanted features |
embeddedartists | 0:6b68dac0d986 | 79 | * |
embeddedartists | 0:6b68dac0d986 | 80 | * @returns |
embeddedartists | 0:6b68dac0d986 | 81 | * Ok on success |
embeddedartists | 0:6b68dac0d986 | 82 | * An error code on failure |
embeddedartists | 0:6b68dac0d986 | 83 | */ |
embeddedartists | 0:6b68dac0d986 | 84 | BoardError init(); |
embeddedartists | 0:6b68dac0d986 | 85 | |
embeddedartists | 2:887c6b45e7fa | 86 | void setLED(Leds led, bool on); |
embeddedartists | 0:6b68dac0d986 | 87 | void buzzer(float value); |
embeddedartists | 0:6b68dac0d986 | 88 | bool buttonPressed(); |
embeddedartists | 0:6b68dac0d986 | 89 | |
embeddedartists | 0:6b68dac0d986 | 90 | #if defined(DM_BOARD_USE_TOUCH) |
embeddedartists | 0:6b68dac0d986 | 91 | TouchPanel* touchPanel() { return _touch; } |
embeddedartists | 0:6b68dac0d986 | 92 | #endif |
embeddedartists | 0:6b68dac0d986 | 93 | #if defined(DM_BOARD_USE_DISPLAY) |
embeddedartists | 0:6b68dac0d986 | 94 | Display* display() { return &(Display::instance()); } |
embeddedartists | 0:6b68dac0d986 | 95 | |
embeddedartists | 0:6b68dac0d986 | 96 | friend class Display; |
embeddedartists | 0:6b68dac0d986 | 97 | #endif |
embeddedartists | 2:887c6b45e7fa | 98 | RtosLog* logger() { return &_logger; } |
embeddedartists | 0:6b68dac0d986 | 99 | |
embeddedartists | 0:6b68dac0d986 | 100 | private: |
embeddedartists | 0:6b68dac0d986 | 101 | |
embeddedartists | 0:6b68dac0d986 | 102 | bool _initialized; |
embeddedartists | 0:6b68dac0d986 | 103 | |
embeddedartists | 0:6b68dac0d986 | 104 | #if defined(DM_BOARD_USE_MCI_FS) |
embeddedartists | 0:6b68dac0d986 | 105 | MCIFileSystem _mcifs; |
embeddedartists | 0:6b68dac0d986 | 106 | #endif |
embeddedartists | 0:6b68dac0d986 | 107 | #if defined(DM_BOARD_USE_QSPI_FS) |
embeddedartists | 0:6b68dac0d986 | 108 | QSPIFileSystem _qspifs; |
embeddedartists | 0:6b68dac0d986 | 109 | #endif |
embeddedartists | 0:6b68dac0d986 | 110 | #if defined(DM_BOARD_USE_TOUCH) |
embeddedartists | 0:6b68dac0d986 | 111 | TouchPanel* _touch; |
embeddedartists | 0:6b68dac0d986 | 112 | #endif |
embeddedartists | 0:6b68dac0d986 | 113 | |
embeddedartists | 0:6b68dac0d986 | 114 | PwmOut _buzzer; |
embeddedartists | 0:6b68dac0d986 | 115 | DigitalIn _button; |
embeddedartists | 0:6b68dac0d986 | 116 | DigitalOut _led1; |
embeddedartists | 0:6b68dac0d986 | 117 | DigitalOut _led2; |
embeddedartists | 0:6b68dac0d986 | 118 | DigitalOut _led3; |
embeddedartists | 0:6b68dac0d986 | 119 | DigitalOut _led4; |
embeddedartists | 0:6b68dac0d986 | 120 | |
embeddedartists | 2:887c6b45e7fa | 121 | RtosLog _logger; |
embeddedartists | 2:887c6b45e7fa | 122 | |
embeddedartists | 0:6b68dac0d986 | 123 | explicit DMBoard(); |
embeddedartists | 0:6b68dac0d986 | 124 | // hide copy constructor |
embeddedartists | 0:6b68dac0d986 | 125 | DMBoard(const DMBoard&); |
embeddedartists | 0:6b68dac0d986 | 126 | // hide assign operator |
embeddedartists | 0:6b68dac0d986 | 127 | DMBoard& operator=(const DMBoard&); |
embeddedartists | 0:6b68dac0d986 | 128 | ~DMBoard(); |
embeddedartists | 0:6b68dac0d986 | 129 | |
embeddedartists | 0:6b68dac0d986 | 130 | BoardError readConfiguration(); |
embeddedartists | 0:6b68dac0d986 | 131 | #if defined(DM_BOARD_USE_DISPLAY) |
embeddedartists | 0:6b68dac0d986 | 132 | BoardError readDisplayConfiguration(uint8_t** data, uint32_t* size); |
embeddedartists | 0:6b68dac0d986 | 133 | #endif |
embeddedartists | 0:6b68dac0d986 | 134 | }; |
embeddedartists | 0:6b68dac0d986 | 135 | |
embeddedartists | 0:6b68dac0d986 | 136 | #endif |
embeddedartists | 0:6b68dac0d986 | 137 |