t

Dependencies:   DM_FATFileSystem DM_HttpServer DM_USBHost EthernetInterface USBDevice mbed-rpc mbed-rtos

Fork of DMSupport by Embedded Artists

Committer:
embeddedartists
Date:
Wed Jan 07 14:02:39 2015 +0100
Revision:
17:4ea2509445ac
Parent:
0:6b68dac0d986
Child:
20:9df19da50290
Moved BIOS from internal to external EEPROM

Who changed what in which revision?

UserRevisionLine numberNew 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 INTERNAL_EEPROM_H
embeddedartists 0:6b68dac0d986 18 #define INTERNAL_EEPROM_H
embeddedartists 0:6b68dac0d986 19
embeddedartists 0:6b68dac0d986 20 #include "mbed.h"
embeddedartists 0:6b68dac0d986 21
embeddedartists 0:6b68dac0d986 22 /**
embeddedartists 17:4ea2509445ac 23 * Internal EEPROM Driver
embeddedartists 0:6b68dac0d986 24 */
embeddedartists 0:6b68dac0d986 25 class InternalEEPROM {
embeddedartists 0:6b68dac0d986 26 public:
embeddedartists 0:6b68dac0d986 27
embeddedartists 0:6b68dac0d986 28 enum Constants {
embeddedartists 0:6b68dac0d986 29 EEPROM_MEMORY_SIZE = 4032,
embeddedartists 0:6b68dac0d986 30 EEPROM_PAGE_SIZE = 64,
embeddedartists 0:6b68dac0d986 31 EEPROM_NUM_PAGES = EEPROM_MEMORY_SIZE/EEPROM_PAGE_SIZE,
embeddedartists 0:6b68dac0d986 32 };
embeddedartists 0:6b68dac0d986 33
embeddedartists 0:6b68dac0d986 34 InternalEEPROM();
embeddedartists 0:6b68dac0d986 35 ~InternalEEPROM();
embeddedartists 0:6b68dac0d986 36
embeddedartists 17:4ea2509445ac 37 /** Initializes the EEPROM
embeddedartists 0:6b68dac0d986 38 *
embeddedartists 0:6b68dac0d986 39 * @returns
embeddedartists 0:6b68dac0d986 40 * Ok on success
embeddedartists 0:6b68dac0d986 41 * An error code on failure
embeddedartists 0:6b68dac0d986 42 */
embeddedartists 0:6b68dac0d986 43 void init();
embeddedartists 0:6b68dac0d986 44
embeddedartists 0:6b68dac0d986 45 void powerDown();
embeddedartists 0:6b68dac0d986 46
embeddedartists 0:6b68dac0d986 47 int read(uint32_t pageAddr, uint32_t pageOffset, uint8_t* data, uint32_t size);
embeddedartists 0:6b68dac0d986 48 int write(uint32_t pageAddr, uint32_t pageOffset, const uint8_t* data, uint32_t size);
embeddedartists 0:6b68dac0d986 49 void erasePage(uint32_t pageAddr);
embeddedartists 0:6b68dac0d986 50
embeddedartists 0:6b68dac0d986 51 /** Returns the size (in bytes) of the internal EEPROM
embeddedartists 0:6b68dac0d986 52 *
embeddedartists 0:6b68dac0d986 53 * @returns
embeddedartists 0:6b68dac0d986 54 * The size in bytes
embeddedartists 0:6b68dac0d986 55 */
embeddedartists 0:6b68dac0d986 56 uint32_t memorySize() { return EEPROM_MEMORY_SIZE; }
embeddedartists 0:6b68dac0d986 57
embeddedartists 0:6b68dac0d986 58 /** Returns the size of a page (in bytes) of the internal EEPROM
embeddedartists 0:6b68dac0d986 59 *
embeddedartists 0:6b68dac0d986 60 * @returns
embeddedartists 0:6b68dac0d986 61 * The page size in bytes
embeddedartists 0:6b68dac0d986 62 */
embeddedartists 0:6b68dac0d986 63 uint32_t pageSize() { return EEPROM_PAGE_SIZE; }
embeddedartists 0:6b68dac0d986 64
embeddedartists 0:6b68dac0d986 65 /** Returns the number of pages in the internal EEPROM
embeddedartists 0:6b68dac0d986 66 *
embeddedartists 0:6b68dac0d986 67 * @returns
embeddedartists 0:6b68dac0d986 68 * The number of pages
embeddedartists 0:6b68dac0d986 69 */
embeddedartists 0:6b68dac0d986 70 uint32_t numPages() { return EEPROM_NUM_PAGES; }
embeddedartists 0:6b68dac0d986 71
embeddedartists 0:6b68dac0d986 72 private:
embeddedartists 0:6b68dac0d986 73
embeddedartists 0:6b68dac0d986 74 bool _initialized;
embeddedartists 0:6b68dac0d986 75
embeddedartists 0:6b68dac0d986 76 void powerUp();
embeddedartists 0:6b68dac0d986 77 void clearInterrupt(uint32_t mask);
embeddedartists 0:6b68dac0d986 78 void waitForInterrupt(uint32_t mask);
embeddedartists 0:6b68dac0d986 79 void setAddr(uint32_t pageAddr, uint32_t pageOffset);
embeddedartists 0:6b68dac0d986 80 void setCmd(uint32_t cmd);
embeddedartists 0:6b68dac0d986 81 void readPage(uint32_t pageAddr, uint32_t pageOffset, uint8_t* buf, uint32_t size);
embeddedartists 0:6b68dac0d986 82 void writePage(uint32_t pageAddr, uint32_t pageOffset, const uint8_t* buf, uint32_t size);
embeddedartists 0:6b68dac0d986 83 void eraseOrProgramPage(uint32_t pageAddr);
embeddedartists 0:6b68dac0d986 84 };
embeddedartists 0:6b68dac0d986 85
embeddedartists 0:6b68dac0d986 86 #endif