t
Dependencies: DM_FATFileSystem DM_HttpServer DM_USBHost EthernetInterface USBDevice mbed-rpc mbed-rtos
Fork of DMSupport by
Diff: Memory/InternalEEPROM.cpp
- Revision:
- 20:9df19da50290
- Parent:
- 18:e5eb986b2a83
- Child:
- 29:b1ec19000e15
diff -r 2efb6f5f69a4 -r 9df19da50290 Memory/InternalEEPROM.cpp --- a/Memory/InternalEEPROM.cpp Fri Jan 09 11:42:06 2015 +0100 +++ b/Memory/InternalEEPROM.cpp Mon Jan 12 10:33:53 2015 +0100 @@ -146,10 +146,11 @@ LPC_EEPROM->PWRDWN = EEPROM_PWRDWN; } -int InternalEEPROM::read(uint32_t pageAddr, uint32_t pageOffset, uint8_t* data, uint32_t size) +int InternalEEPROM::read(uint32_t addr, uint8_t* data, uint32_t size) { uint32_t numRead = 0; - uint32_t readOffset = (pageOffset & (EEPROM_PAGE_SIZE - 1)); + uint32_t pageAddr = addr/EEPROM_PAGE_SIZE; + uint32_t readOffset = (addr & (EEPROM_PAGE_SIZE - 1)); uint32_t readSize = EEPROM_PAGE_SIZE - readOffset; powerUp(); @@ -173,10 +174,11 @@ return numRead; } -int InternalEEPROM::write(uint32_t pageAddr, uint32_t pageOffset, const uint8_t* data, uint32_t size) +int InternalEEPROM::write(uint32_t addr, const uint8_t* data, uint32_t size) { uint32_t numWritten = 0; - uint32_t writeOffset = (pageOffset & (EEPROM_PAGE_SIZE - 1)); + uint32_t pageAddr = addr/EEPROM_PAGE_SIZE; + uint32_t writeOffset = (addr & (EEPROM_PAGE_SIZE - 1)); uint32_t writeSize = EEPROM_PAGE_SIZE - writeOffset; powerUp(); @@ -201,16 +203,16 @@ return numWritten; } -void InternalEEPROM::erasePage(uint32_t pageAddr) -{ - powerUp(); - - clearInterrupt(EEPROM_INT_ENDOFRW); - setCmd(EEPROM_CMD_32BITS_WRITE); - setAddr(pageAddr, 0); - for (int i = 0; i < EEPROM_PAGE_SIZE; i+=4) { - LPC_EEPROM->WDATA = 0; - waitForInterrupt(EEPROM_INT_ENDOFRW); - } - eraseOrProgramPage(pageAddr); -} +//void InternalEEPROM::erasePage(uint32_t pageAddr) +//{ +// powerUp(); +// +// clearInterrupt(EEPROM_INT_ENDOFRW); +// setCmd(EEPROM_CMD_32BITS_WRITE); +// setAddr(pageAddr, 0); +// for (int i = 0; i < EEPROM_PAGE_SIZE; i+=4) { +// LPC_EEPROM->WDATA = 0; +// waitForInterrupt(EEPROM_INT_ENDOFRW); +// } +// eraseOrProgramPage(pageAddr); +//}