EEPROM in TG-LPC11U35-501
Dependents: mbed_EEPROM USBMSD_step1 USBMSD_step1_5 picossd_step1_2cs
See https://mbed.org/users/yasuyuki/notebook/EEPROM/
EEPROM.cpp
- Committer:
- yasuyuki
- Date:
- 2014-06-26
- Revision:
- 0:25e5bc71e65f
File content as of revision 0:25e5bc71e65f:
//**********************
// EEPROM.cpp for TG-LPC11U35-501
// TG-LPC11U35-501 has 4K EEPROM.
//
// usage:
// EEPROM eeprom;
// char RAM[100]
// eeprom.write(0, RAM, 100);
// eeprom.read(0, RAM, 100);
// eeprom.put(0, 0x00);
// i=eeprom.get(0);
//
// note:
// valid EEPROM address range is between 0 to 4031
// top 64 bytes are reserved
//
// (C)Copyright 2014 All rights reserved by Y.Onodera
// http://einstlab.web.fc2.com
//**********************
#include "EEPROM.h"
int EEPROM::write( unsigned int EEPROM_addr, char *RAM_addr, unsigned int n ) {
command[0] = EEPROM_Write;
command[1] = EEPROM_addr;
command[2] = (unsigned int)RAM_addr;
command[3] = n;
command[4] = cclk_kHz;
iap_entry( command, status );
return ( (int)status[0] );
}
int EEPROM::read( unsigned int EEPROM_addr, char *RAM_addr, unsigned int n ) {
command[0] = EEPROM_Read;
command[1] = EEPROM_addr;
command[2] = (unsigned int)RAM_addr;
command[3] = n;
command[4] = cclk_kHz;
iap_entry( command, status );
return ( (int)status[0] );
}
int EEPROM::put( unsigned int EEPROM_addr, char data ) {
dat[0]=data;
command[0] = EEPROM_Write;
command[1] = EEPROM_addr;
command[2] = (unsigned int)dat;
command[3] = 1;
command[4] = cclk_kHz;
iap_entry( command, status );
return ( (int)status[0] );
}
char EEPROM::get( unsigned int EEPROM_addr ) {
command[0] = EEPROM_Read;
command[1] = EEPROM_addr;
command[2] = (unsigned int)dat;
command[3] = 1;
command[4] = cclk_kHz;
iap_entry( command, status );
return ( dat[0] );
}