Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: DM_FATFileSystem DM_HttpServer DM_USBHost EthernetInterface USBDevice mbed-rpc mbed-rtos
Fork of DMSupport by
DMBoard.h
00001 /* 00002 * Copyright 2014 Embedded Artists AB 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef DMBOARD_H 00018 #define DMBOARD_H 00019 00020 #include "mbed.h" 00021 #include "dm_board_config.h" 00022 #include "RtosLog.h" 00023 00024 #if defined(DM_BOARD_USE_MCI_FS) 00025 #include "MCIFileSystem.h" 00026 #endif 00027 #if defined(DM_BOARD_USE_QSPI_FS) 00028 #include "SPIFI.h" 00029 #include "QSPIFileSystem.h" 00030 #elif defined(DM_BOARD_USE_QSPI) 00031 #include "SPIFI.h" 00032 #endif 00033 #include "Display.h" 00034 #include "TouchPanel.h" 00035 #if defined(DM_BOARD_USE_REGISTRY) 00036 #include "Registry.h" 00037 #endif 00038 00039 00040 /** 00041 * Example of using the Board class: 00042 * 00043 * @code 00044 * #include "mbed.h" 00045 * #include "DMBoard.h" 00046 * 00047 * int main(void) { 00048 * DMBoard* board = &DMBoard::instance(); 00049 * board->init(); 00050 * ... 00051 * board->setLed(1, true); 00052 * } 00053 * @endcode 00054 */ 00055 class DMBoard { 00056 public: 00057 enum Leds { 00058 Led1, 00059 Led2, 00060 Led3, 00061 Led4, 00062 }; 00063 00064 enum BoardError { 00065 Ok = 0, 00066 MemoryError, 00067 SpifiError, 00068 DisplayError, 00069 TouchError, 00070 BiosInvalidError, 00071 BiosVersionError, 00072 BiosStorageError, 00073 RegistryError, 00074 }; 00075 00076 /** Get the only instance of the DMBoard 00077 * 00078 * @returns The DMBoard 00079 */ 00080 static DMBoard& instance() 00081 { 00082 static DMBoard singleton; 00083 return singleton; 00084 } 00085 00086 /** Initializes the wanted features 00087 * 00088 * @returns 00089 * Ok on success 00090 * An error code on failure 00091 */ 00092 BoardError init(); 00093 00094 /** Controls the four LEDs on the Display Module 00095 * 00096 * @param led One of Led1, Led2, Led3 or Led4 00097 * @param on true to turn the LED on regardless of its polarity 00098 */ 00099 void setLED(Leds led, bool on); 00100 00101 /** Controls the buzzer 00102 * 00103 * Examples: 00104 * buzzer() turns it off 00105 * buzzer(440) plays an A4 (440Hz) note forever 00106 * buzzer(200, 25) plays a 200Hz tone for 25ms and then turns it off 00107 * 00108 * Note that if duration_ms is >0 this is a blocking call 00109 * 00110 * @param frequency the frequency of the tone (in Hz) or 0 to turn it off 00111 * @param duration_ms the number of milliseconds to play or 0 for forever 00112 */ 00113 void buzzer(int frequency=0, int duration_ms=0); 00114 00115 /** Test if the USER button is pressed or not 00116 * 00117 * @returns 00118 * True if the button is pressed, false if not 00119 */ 00120 bool buttonPressed(); 00121 00122 /** Returns the TouchPanel interface 00123 * 00124 * @returns 00125 * The touch panel 00126 */ 00127 TouchPanel* touchPanel(); 00128 00129 /** Returns the Display interface 00130 * 00131 * @returns 00132 * The display 00133 */ 00134 Display* display(); 00135 00136 /** Returns the logger interface 00137 * 00138 * @returns 00139 * The logger 00140 */ 00141 RtosLog* logger() { return &_logger; } 00142 00143 #if defined(DM_BOARD_USE_REGISTRY) 00144 /** Returns the Registry interface 00145 * 00146 * @returns 00147 * The registry 00148 */ 00149 Registry* registry() { return &Registry::instance(); } 00150 #endif 00151 00152 #if defined(DM_BOARD_USE_MCI_FS) 00153 /** Returns the MCI File System instance. 00154 * 00155 * Can be used to call e.g. cardInserted(). 00156 * 00157 * @returns 00158 * The file system instance 00159 */ 00160 MCIFileSystem* getMciFS() { return &_mcifs; } 00161 #else 00162 void* getMciFS() { return NULL; } 00163 #endif 00164 #if defined(DM_BOARD_USE_QSPI_FS) 00165 /** Returns the QSPI File System instance. 00166 * 00167 * Can be used to call e.g. isformatted() and format(). 00168 * 00169 * @returns 00170 * The file system instance 00171 */ 00172 QSPIFileSystem* getQspiFS() { return &_qspifs; } 00173 #else 00174 void* getQspiFS() { return NULL; } 00175 #endif 00176 00177 00178 private: 00179 00180 bool _initialized; 00181 00182 #if defined(DM_BOARD_USE_MCI_FS) 00183 MCIFileSystem _mcifs; 00184 #endif 00185 #if defined(DM_BOARD_USE_QSPI_FS) 00186 QSPIFileSystem _qspifs; 00187 #endif 00188 00189 PwmOut _buzzer; 00190 DigitalIn _button; 00191 DigitalOut _led1; 00192 DigitalOut _led2; 00193 DigitalOut _led3; 00194 DigitalOut _led4; 00195 00196 RtosLog _logger; 00197 00198 explicit DMBoard(); 00199 // hide copy constructor 00200 DMBoard(const DMBoard&); 00201 // hide assign operator 00202 DMBoard& operator=(const DMBoard&); 00203 ~DMBoard(); 00204 }; 00205 00206 #endif
Generated on Tue Jul 12 2022 21:29:01 by
