nvm-write.c
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include <mc1322x.h>
00037 #include <board.h>
00038
00039 #include "tests.h"
00040 #include "config.h"
00041
00042 void main(void) {
00043 nvmType_t type=0;
00044 nvmErr_t err;
00045 uint32_t buf[WRITE_NBYTES/4];
00046 uint32_t i;
00047
00048 uart_init(INC, MOD, SAMP);
00049
00050 print_welcome("nvm-write");
00051
00052 vreg_init();
00053
00054 putstr("Detecting internal nvm\n\r");
00055
00056 err = nvm_detect(gNvmInternalInterface_c, &type);
00057
00058 putstr("nvm_detect returned: 0x");
00059 put_hex(err);
00060 putstr(" type is: 0x");
00061 put_hex32(type);
00062 putstr("\n\r");
00063
00064
00065 buf[0] = WRITEVAL0;
00066 buf[1] = WRITEVAL1;
00067
00068 err = nvm_erase(gNvmInternalInterface_c, type, 0x40000000);
00069 putstr("nvm_erase returned: 0x");
00070 put_hex(err);
00071 putstr("\n\r");
00072
00073 err = nvm_write(gNvmInternalInterface_c, type, (uint8_t *)buf, WRITE_ADDR, WRITE_NBYTES);
00074 putstr("nvm_write returned: 0x");
00075 put_hex(err);
00076 putstr("\n\r");
00077 putstr("writing\n\r");
00078 for(i=0; i<WRITE_NBYTES/4; i++) {
00079 putstr("0x");
00080 put_hex32(buf[i]);
00081 putstr("\n\r");
00082 buf[i] = 0x00000000;
00083 }
00084
00085 err = nvm_read(gNvmInternalInterface_c, type, (uint8_t *)buf, WRITE_ADDR, WRITE_NBYTES);
00086 putstr("nvm_read returned: 0x");
00087 put_hex(err);
00088 putstr("\n\r");
00089 putstr("reading\n\r");
00090 for(i=0; i<WRITE_NBYTES/4; i++) {
00091 putstr("0x");
00092 put_hex32(buf[i]);
00093 putstr("\n\r");
00094 }
00095
00096
00097 while(1) {continue;};
00098 }
00099