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 mbed-src
Fork of DMSupport by
Diff: DMBoard.h
- Revision:
- 0:6b68dac0d986
- Child:
- 2:887c6b45e7fa
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/DMBoard.h Fri Nov 21 11:42:51 2014 +0000
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2014 Embedded Artists AB
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMBOARD_H
+#define DMBOARD_H
+
+#include "mbed.h"
+#include "dm_board_config.h"
+
+#if defined(DM_BOARD_USE_MCI_FS)
+ #include "MCIFileSystem.h"
+#endif
+#if defined(DM_BOARD_USE_QSPI_FS)
+ #include "QSPIFileSystem.h"
+#elif defined(DM_BOARD_USE_QSPI)
+ #include "SPIFI.h"
+#endif
+#if defined(DM_BOARD_USE_DISPLAY)
+ #include "Display.h"
+#endif
+#if defined(DM_BOARD_USE_TOUCH)
+ #include "TouchPanel.h"
+#endif
+
+/**
+ * Example of using the Board class:
+ *
+ * @code
+ * #include "mbed.h"
+ * #include "DMBoard.h"
+ *
+ * int main(void) {
+ * DMBoard* board = &DMBoard::instance();
+ * board->init();
+ * ...
+ * board->setLed(1, true);
+ * }
+ * @endcode
+ */
+class DMBoard {
+public:
+ enum Constants {
+ NumLEDs = 4,
+ };
+
+ enum BoardError {
+ Ok = 0,
+ MemoryError = 1,
+ SpifiError = 1,
+ DisplayError = 2,
+ TouchError = 3,
+ };
+
+ static DMBoard& instance()
+ {
+ static DMBoard singleton;
+ return singleton;
+ }
+
+
+ /** Initializes the wanted features
+ *
+ * @returns
+ * Ok on success
+ * An error code on failure
+ */
+ BoardError init();
+
+ void setLED(int led, bool on);
+ void buzzer(float value);
+ bool buttonPressed();
+
+#if defined(DM_BOARD_USE_TOUCH)
+ TouchPanel* touchPanel() { return _touch; }
+#endif
+#if defined(DM_BOARD_USE_DISPLAY)
+ Display* display() { return &(Display::instance()); }
+
+ friend class Display;
+#endif
+
+private:
+
+ bool _initialized;
+
+#if defined(DM_BOARD_USE_MCI_FS)
+ MCIFileSystem _mcifs;
+#endif
+#if defined(DM_BOARD_USE_QSPI_FS)
+ QSPIFileSystem _qspifs;
+#endif
+#if defined(DM_BOARD_USE_TOUCH)
+ TouchPanel* _touch;
+#endif
+
+ PwmOut _buzzer;
+ DigitalIn _button;
+ DigitalOut _led1;
+ DigitalOut _led2;
+ DigitalOut _led3;
+ DigitalOut _led4;
+
+ explicit DMBoard();
+ // hide copy constructor
+ DMBoard(const DMBoard&);
+ // hide assign operator
+ DMBoard& operator=(const DMBoard&);
+ ~DMBoard();
+
+ BoardError readConfiguration();
+#if defined(DM_BOARD_USE_DISPLAY)
+ BoardError readDisplayConfiguration(uint8_t** data, uint32_t* size);
+#endif
+};
+
+#endif
+
