t
Dependencies: DM_FATFileSystem DM_HttpServer DM_USBHost EthernetInterface USBDevice mbed-rpc mbed-rtos
Fork of DMSupport by
DMBoard.h@0:6b68dac0d986, 2014-11-21 (annotated)
- Committer:
- embeddedartists
- Date:
- Fri Nov 21 11:42:51 2014 +0000
- Revision:
- 0:6b68dac0d986
- Child:
- 2:887c6b45e7fa
First version
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 | 0:6b68dac0d986 | 22 | |
embeddedartists | 0:6b68dac0d986 | 23 | #if defined(DM_BOARD_USE_MCI_FS) |
embeddedartists | 0:6b68dac0d986 | 24 | #include "MCIFileSystem.h" |
embeddedartists | 0:6b68dac0d986 | 25 | #endif |
embeddedartists | 0:6b68dac0d986 | 26 | #if defined(DM_BOARD_USE_QSPI_FS) |
embeddedartists | 0:6b68dac0d986 | 27 | #include "QSPIFileSystem.h" |
embeddedartists | 0:6b68dac0d986 | 28 | #elif defined(DM_BOARD_USE_QSPI) |
embeddedartists | 0:6b68dac0d986 | 29 | #include "SPIFI.h" |
embeddedartists | 0:6b68dac0d986 | 30 | #endif |
embeddedartists | 0:6b68dac0d986 | 31 | #if defined(DM_BOARD_USE_DISPLAY) |
embeddedartists | 0:6b68dac0d986 | 32 | #include "Display.h" |
embeddedartists | 0:6b68dac0d986 | 33 | #endif |
embeddedartists | 0:6b68dac0d986 | 34 | #if defined(DM_BOARD_USE_TOUCH) |
embeddedartists | 0:6b68dac0d986 | 35 | #include "TouchPanel.h" |
embeddedartists | 0:6b68dac0d986 | 36 | #endif |
embeddedartists | 0:6b68dac0d986 | 37 | |
embeddedartists | 0:6b68dac0d986 | 38 | /** |
embeddedartists | 0:6b68dac0d986 | 39 | * Example of using the Board class: |
embeddedartists | 0:6b68dac0d986 | 40 | * |
embeddedartists | 0:6b68dac0d986 | 41 | * @code |
embeddedartists | 0:6b68dac0d986 | 42 | * #include "mbed.h" |
embeddedartists | 0:6b68dac0d986 | 43 | * #include "DMBoard.h" |
embeddedartists | 0:6b68dac0d986 | 44 | * |
embeddedartists | 0:6b68dac0d986 | 45 | * int main(void) { |
embeddedartists | 0:6b68dac0d986 | 46 | * DMBoard* board = &DMBoard::instance(); |
embeddedartists | 0:6b68dac0d986 | 47 | * board->init(); |
embeddedartists | 0:6b68dac0d986 | 48 | * ... |
embeddedartists | 0:6b68dac0d986 | 49 | * board->setLed(1, true); |
embeddedartists | 0:6b68dac0d986 | 50 | * } |
embeddedartists | 0:6b68dac0d986 | 51 | * @endcode |
embeddedartists | 0:6b68dac0d986 | 52 | */ |
embeddedartists | 0:6b68dac0d986 | 53 | class DMBoard { |
embeddedartists | 0:6b68dac0d986 | 54 | public: |
embeddedartists | 0:6b68dac0d986 | 55 | enum Constants { |
embeddedartists | 0:6b68dac0d986 | 56 | NumLEDs = 4, |
embeddedartists | 0:6b68dac0d986 | 57 | }; |
embeddedartists | 0:6b68dac0d986 | 58 | |
embeddedartists | 0:6b68dac0d986 | 59 | enum BoardError { |
embeddedartists | 0:6b68dac0d986 | 60 | Ok = 0, |
embeddedartists | 0:6b68dac0d986 | 61 | MemoryError = 1, |
embeddedartists | 0:6b68dac0d986 | 62 | SpifiError = 1, |
embeddedartists | 0:6b68dac0d986 | 63 | DisplayError = 2, |
embeddedartists | 0:6b68dac0d986 | 64 | TouchError = 3, |
embeddedartists | 0:6b68dac0d986 | 65 | }; |
embeddedartists | 0:6b68dac0d986 | 66 | |
embeddedartists | 0:6b68dac0d986 | 67 | static DMBoard& instance() |
embeddedartists | 0:6b68dac0d986 | 68 | { |
embeddedartists | 0:6b68dac0d986 | 69 | static DMBoard singleton; |
embeddedartists | 0:6b68dac0d986 | 70 | return singleton; |
embeddedartists | 0:6b68dac0d986 | 71 | } |
embeddedartists | 0:6b68dac0d986 | 72 | |
embeddedartists | 0:6b68dac0d986 | 73 | |
embeddedartists | 0:6b68dac0d986 | 74 | /** Initializes the wanted features |
embeddedartists | 0:6b68dac0d986 | 75 | * |
embeddedartists | 0:6b68dac0d986 | 76 | * @returns |
embeddedartists | 0:6b68dac0d986 | 77 | * Ok on success |
embeddedartists | 0:6b68dac0d986 | 78 | * An error code on failure |
embeddedartists | 0:6b68dac0d986 | 79 | */ |
embeddedartists | 0:6b68dac0d986 | 80 | BoardError init(); |
embeddedartists | 0:6b68dac0d986 | 81 | |
embeddedartists | 0:6b68dac0d986 | 82 | void setLED(int led, bool on); |
embeddedartists | 0:6b68dac0d986 | 83 | void buzzer(float value); |
embeddedartists | 0:6b68dac0d986 | 84 | bool buttonPressed(); |
embeddedartists | 0:6b68dac0d986 | 85 | |
embeddedartists | 0:6b68dac0d986 | 86 | #if defined(DM_BOARD_USE_TOUCH) |
embeddedartists | 0:6b68dac0d986 | 87 | TouchPanel* touchPanel() { return _touch; } |
embeddedartists | 0:6b68dac0d986 | 88 | #endif |
embeddedartists | 0:6b68dac0d986 | 89 | #if defined(DM_BOARD_USE_DISPLAY) |
embeddedartists | 0:6b68dac0d986 | 90 | Display* display() { return &(Display::instance()); } |
embeddedartists | 0:6b68dac0d986 | 91 | |
embeddedartists | 0:6b68dac0d986 | 92 | friend class Display; |
embeddedartists | 0:6b68dac0d986 | 93 | #endif |
embeddedartists | 0:6b68dac0d986 | 94 | |
embeddedartists | 0:6b68dac0d986 | 95 | private: |
embeddedartists | 0:6b68dac0d986 | 96 | |
embeddedartists | 0:6b68dac0d986 | 97 | bool _initialized; |
embeddedartists | 0:6b68dac0d986 | 98 | |
embeddedartists | 0:6b68dac0d986 | 99 | #if defined(DM_BOARD_USE_MCI_FS) |
embeddedartists | 0:6b68dac0d986 | 100 | MCIFileSystem _mcifs; |
embeddedartists | 0:6b68dac0d986 | 101 | #endif |
embeddedartists | 0:6b68dac0d986 | 102 | #if defined(DM_BOARD_USE_QSPI_FS) |
embeddedartists | 0:6b68dac0d986 | 103 | QSPIFileSystem _qspifs; |
embeddedartists | 0:6b68dac0d986 | 104 | #endif |
embeddedartists | 0:6b68dac0d986 | 105 | #if defined(DM_BOARD_USE_TOUCH) |
embeddedartists | 0:6b68dac0d986 | 106 | TouchPanel* _touch; |
embeddedartists | 0:6b68dac0d986 | 107 | #endif |
embeddedartists | 0:6b68dac0d986 | 108 | |
embeddedartists | 0:6b68dac0d986 | 109 | PwmOut _buzzer; |
embeddedartists | 0:6b68dac0d986 | 110 | DigitalIn _button; |
embeddedartists | 0:6b68dac0d986 | 111 | DigitalOut _led1; |
embeddedartists | 0:6b68dac0d986 | 112 | DigitalOut _led2; |
embeddedartists | 0:6b68dac0d986 | 113 | DigitalOut _led3; |
embeddedartists | 0:6b68dac0d986 | 114 | DigitalOut _led4; |
embeddedartists | 0:6b68dac0d986 | 115 | |
embeddedartists | 0:6b68dac0d986 | 116 | explicit DMBoard(); |
embeddedartists | 0:6b68dac0d986 | 117 | // hide copy constructor |
embeddedartists | 0:6b68dac0d986 | 118 | DMBoard(const DMBoard&); |
embeddedartists | 0:6b68dac0d986 | 119 | // hide assign operator |
embeddedartists | 0:6b68dac0d986 | 120 | DMBoard& operator=(const DMBoard&); |
embeddedartists | 0:6b68dac0d986 | 121 | ~DMBoard(); |
embeddedartists | 0:6b68dac0d986 | 122 | |
embeddedartists | 0:6b68dac0d986 | 123 | BoardError readConfiguration(); |
embeddedartists | 0:6b68dac0d986 | 124 | #if defined(DM_BOARD_USE_DISPLAY) |
embeddedartists | 0:6b68dac0d986 | 125 | BoardError readDisplayConfiguration(uint8_t** data, uint32_t* size); |
embeddedartists | 0:6b68dac0d986 | 126 | #endif |
embeddedartists | 0:6b68dac0d986 | 127 | }; |
embeddedartists | 0:6b68dac0d986 | 128 | |
embeddedartists | 0:6b68dac0d986 | 129 | #endif |
embeddedartists | 0:6b68dac0d986 | 130 |