t

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

Fork of DMSupport by Embedded Artists

Committer:
embeddedartists
Date:
Mon Jan 12 10:33:53 2015 +0100
Revision:
20:9df19da50290
Parent:
17:4ea2509445ac
Child:
34:fc366bab393f
- Added first version of a simple Registry
- Simplified interface to internal 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 20:9df19da50290 47 int read(uint32_t addr, uint8_t* data, uint32_t size);
embeddedartists 20:9df19da50290 48 int write(uint32_t addr, const uint8_t* data, uint32_t size);
embeddedartists 0:6b68dac0d986 49
embeddedartists 0:6b68dac0d986 50 /** Returns the size (in bytes) of the internal EEPROM
embeddedartists 0:6b68dac0d986 51 *
embeddedartists 0:6b68dac0d986 52 * @returns
embeddedartists 0:6b68dac0d986 53 * The size in bytes
embeddedartists 0:6b68dac0d986 54 */
embeddedartists 0:6b68dac0d986 55 uint32_t memorySize() { return EEPROM_MEMORY_SIZE; }
embeddedartists 0:6b68dac0d986 56
embeddedartists 0:6b68dac0d986 57 /** Returns the size of a page (in bytes) of the internal EEPROM
embeddedartists 0:6b68dac0d986 58 *
embeddedartists 0:6b68dac0d986 59 * @returns
embeddedartists 0:6b68dac0d986 60 * The page size in bytes
embeddedartists 0:6b68dac0d986 61 */
embeddedartists 20:9df19da50290 62 //uint32_t pageSize() { return EEPROM_PAGE_SIZE; }
embeddedartists 0:6b68dac0d986 63
embeddedartists 0:6b68dac0d986 64 /** Returns the number of pages in the internal EEPROM
embeddedartists 0:6b68dac0d986 65 *
embeddedartists 0:6b68dac0d986 66 * @returns
embeddedartists 0:6b68dac0d986 67 * The number of pages
embeddedartists 0:6b68dac0d986 68 */
embeddedartists 20:9df19da50290 69 //uint32_t numPages() { return EEPROM_NUM_PAGES; }
embeddedartists 0:6b68dac0d986 70
embeddedartists 0:6b68dac0d986 71 private:
embeddedartists 0:6b68dac0d986 72
embeddedartists 0:6b68dac0d986 73 bool _initialized;
embeddedartists 0:6b68dac0d986 74
embeddedartists 0:6b68dac0d986 75 void powerUp();
embeddedartists 0:6b68dac0d986 76 void clearInterrupt(uint32_t mask);
embeddedartists 0:6b68dac0d986 77 void waitForInterrupt(uint32_t mask);
embeddedartists 0:6b68dac0d986 78 void setAddr(uint32_t pageAddr, uint32_t pageOffset);
embeddedartists 0:6b68dac0d986 79 void setCmd(uint32_t cmd);
embeddedartists 0:6b68dac0d986 80 void readPage(uint32_t pageAddr, uint32_t pageOffset, uint8_t* buf, uint32_t size);
embeddedartists 0:6b68dac0d986 81 void writePage(uint32_t pageAddr, uint32_t pageOffset, const uint8_t* buf, uint32_t size);
embeddedartists 0:6b68dac0d986 82 void eraseOrProgramPage(uint32_t pageAddr);
embeddedartists 0:6b68dac0d986 83 };
embeddedartists 0:6b68dac0d986 84
embeddedartists 0:6b68dac0d986 85 #endif