Subdirectory provided by Embedded Artists
Dependencies: DM_FATFileSystem DM_HttpServer DM_USBHost EthernetInterface USBDevice mbed-rpc mbed-rtos mbed-src
Dependents: lpc4088_displaymodule_hello_world_Sept_2018
Fork of DMSupport by
Memory/InternalEEPROM.h
- Committer:
- embeddedartists
- Date:
- 2015-01-12
- Revision:
- 20:9df19da50290
- Parent:
- 17:4ea2509445ac
- Child:
- 34:fc366bab393f
File content as of revision 20:9df19da50290:
/* * 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 INTERNAL_EEPROM_H #define INTERNAL_EEPROM_H #include "mbed.h" /** * Internal EEPROM Driver */ class InternalEEPROM { public: enum Constants { EEPROM_MEMORY_SIZE = 4032, EEPROM_PAGE_SIZE = 64, EEPROM_NUM_PAGES = EEPROM_MEMORY_SIZE/EEPROM_PAGE_SIZE, }; InternalEEPROM(); ~InternalEEPROM(); /** Initializes the EEPROM * * @returns * Ok on success * An error code on failure */ void init(); void powerDown(); int read(uint32_t addr, uint8_t* data, uint32_t size); int write(uint32_t addr, const uint8_t* data, uint32_t size); /** Returns the size (in bytes) of the internal EEPROM * * @returns * The size in bytes */ uint32_t memorySize() { return EEPROM_MEMORY_SIZE; } /** Returns the size of a page (in bytes) of the internal EEPROM * * @returns * The page size in bytes */ //uint32_t pageSize() { return EEPROM_PAGE_SIZE; } /** Returns the number of pages in the internal EEPROM * * @returns * The number of pages */ //uint32_t numPages() { return EEPROM_NUM_PAGES; } private: bool _initialized; void powerUp(); void clearInterrupt(uint32_t mask); void waitForInterrupt(uint32_t mask); void setAddr(uint32_t pageAddr, uint32_t pageOffset); void setCmd(uint32_t cmd); void readPage(uint32_t pageAddr, uint32_t pageOffset, uint8_t* buf, uint32_t size); void writePage(uint32_t pageAddr, uint32_t pageOffset, const uint8_t* buf, uint32_t size); void eraseOrProgramPage(uint32_t pageAddr); }; #endif