#include "mbed.h" enum command_code { IAPCommand_EEPROM_Write = 61, IAPCommand_EEPROM_Read, }; #define IAP_LOCATION 0x03000200 typedef void (*IAP_call)(unsigned int [], unsigned int []); IAP_call iap_entry = reinterpret_cast<IAP_call>(IAP_LOCATION); unsigned int IAP_command[ 5 ]; unsigned int IAP_result[ 5 ]; int cclk_kHz = SystemCoreClock / 1000; int write_eeprom( uint32_t source_addr, uint32_t target_addr, int size ) { IAP_command[ 0 ] = IAPCommand_EEPROM_Write; IAP_command[ 1 ] = target_addr; // Destination EEPROM address where data bytes are to be written. IAP_command[ 2 ] = (unsigned int)source_addr; // Source RAM address from which data bytes are to be read. This address should be a word boundary. IAP_command[ 3 ] = size; // Number of bytes to be written. Should be 256 | 512 | 1024 | 4096. IAP_command[ 4 ] = cclk_kHz; // CPU Clock Frequency (CCLK) in kHz. iap_entry( IAP_command, IAP_result ); return ( (int)IAP_result[ 0 ] ); } int main () { int num=15; int addrEEPROM = 0x100; while (1) { write_eeprom((uint32_t)&num,add,256); } } |
is add the address of EEPROM? should we enter 0x03000100 or simply 0x100 is passed as EEPROM address?
write_eeprom((uint32_t)&num,add,256);
... and no one can do a better thing than pointing to a useless example