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.cpp
- Revision:
- 22:1a58a518435c
- Parent:
- 20:9df19da50290
- Child:
- 33:8a0a99d54bf8
--- a/DMBoard.cpp Mon Jan 12 10:37:57 2015 +0100
+++ b/DMBoard.cpp Fri Jan 16 11:13:39 2015 +0100
@@ -16,12 +16,12 @@
#include "mbed.h"
#include "DMBoard.h"
-#include "BiosEEPROM.h"
-#include "bios.h"
-#include "crc.h"
#if defined(DM_BOARD_USE_DISPLAY)
- #include "BiosDisplayAndTouch.h"
+ #include "BiosDisplay.h"
+#endif
+#if defined(DM_BOARD_USE_TOUCH)
+ #include "BiosTouch.h"
#endif
#if defined(DM_BOARD_ENABLE_MEASSURING_PINS)
@@ -58,16 +58,6 @@
static DevNull null("null");
#endif
-/*
- * Make sure that we reserve at least this amount of RAM for future
- * expansion of the BIOS. This prevents the user from squeezing out
- * the last drop of available RAM in his application.
- */
-#define BIOS_RESERVED_CHUNK 0x1000
-#define BIOS_MAX_SIZE 0x100000
-#ifndef MAX
- #define MAX(__a, __b) (((__a)>(__b))?(__a):(__b))
-#endif
/******************************************************************************
* Local variables
@@ -79,7 +69,6 @@
DMBoard::DMBoard() :
_initialized(false),
- _conf(NULL), _confSize(0),
#if defined(DM_BOARD_USE_MCI_FS)
_mcifs("mci", P4_16),
#endif
@@ -97,83 +86,8 @@
DMBoard::~DMBoard()
{
- if (_conf != NULL) {
- free(_conf);
- _conf = NULL;
- _confSize = 0;
- }
}
-#if defined(DM_BOARD_USE_DISPLAY)
-DMBoard::BoardError DMBoard::readDisplayConfiguration(uint8_t** data, uint32_t* size)
-{
- BoardError err = Ok;
- BiosEEPROM eeprom;
- file_header_t fh;
-
- if (_conf != NULL) {
- *data = _conf;
- *size = _confSize;
- return Ok;
- }
- do {
- if (!eeprom.read(0, (char*)&fh, sizeof(file_header_t))) {
- err = BiosStorageError;
- break;
- }
-
- if (fh.magic != BIOS_MAGIC) {
- err = BiosInvalidError;
- break;
- }
-
- if (fh.version != BIOS_VER) {
- err = BiosVersionError;
- break;
- }
-
- if ((fh.headerSize + fh.size) > BIOS_MAX_SIZE) {
- err = BiosInvalidError;
- break;
- }
-
- _confSize = fh.headerSize + fh.size;
- _conf = (uint8_t*)malloc(MAX(_confSize,BIOS_RESERVED_CHUNK));
- if (_conf == NULL) {
- _confSize = 0;
- err = MemoryError;
- break;
- }
-
- if (!eeprom.read(0, (char*)_conf, _confSize)) {
- err = BiosStorageError;
- break;
- }
-
- uint32_t crc = crc_Buffer((uint32_t*)(&_conf[fh.headerSize]), fh.size/4);
- if (crc != fh.crc) {
- err = BiosInvalidError;
- break;
- }
-
- // Bios header has been verified and seems ok
- *data = _conf;
- *size = _confSize;
- err = Ok;
- } while (false);
-
- if (err != Ok) {
- if (_conf != NULL) {
- free(_conf);
- _conf = NULL;
- _confSize = 0;
- }
- }
-
- return err;
-}
-#endif
-
/******************************************************************************
* Public Functions
*****************************************************************************/
@@ -219,14 +133,14 @@
#endif
#if defined(DM_BOARD_USE_DISPLAY)
- if (BiosDisplayAndTouch::instance().initDisplay() != Display::DisplayError_Ok) {
+ if (BiosDisplay::instance().init() != Display::DisplayError_Ok) {
err = DisplayError;
break;
}
#endif
#if defined(DM_BOARD_USE_TOUCH)
- if (BiosDisplayAndTouch::instance().initTouchController() != TouchPanel::TouchError_Ok) {
+ if (BiosTouch::instance().init() != TouchPanel::TouchError_Ok) {
err = TouchError;
break;
}
@@ -281,11 +195,11 @@
return _button.read() == 0;
}
-#if defined(DM_BOARD_USE_DISPLAY)
+#if defined(DM_BOARD_USE_TOUCH)
TouchPanel* DMBoard::touchPanel()
{
- if (BiosDisplayAndTouch::instance().isTouchSupported()) {
- return &BiosDisplayAndTouch::instance();
+ if (BiosTouch::instance().isTouchSupported()) {
+ return &BiosTouch::instance();
}
return NULL;
}
@@ -294,6 +208,6 @@
#if defined(DM_BOARD_USE_DISPLAY)
Display* DMBoard::display()
{
- return &BiosDisplayAndTouch::instance();
+ return &BiosDisplay::instance();
}
#endif
