Programa de ejemplo para leer y escribir en la flash de la FRDMKL25Z los datos se escriben y lee del arreglo "data[]"

Dependencies:   FreescaleIAP mbed

Committer:
tony63
Date:
Tue Dec 12 07:52:22 2017 +0000
Revision:
0:e8a8f8351b80
Programa de ejemplo para leer y escribir en la flash de la FRDMKL25Z; los datos se escriben y lee del arreglo "data[]"

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tony63 0:e8a8f8351b80 1 /*
tony63 0:e8a8f8351b80 2 Programa de ejemplo para leer y escribir en la flash de la FRDMKL25Z
tony63 0:e8a8f8351b80 3 los datos se escriben y lee del arreglo "data[]"
tony63 0:e8a8f8351b80 4
tony63 0:e8a8f8351b80 5 */
tony63 0:e8a8f8351b80 6 #include "mbed.h"
tony63 0:e8a8f8351b80 7 #include "FreescaleIAP.h"
tony63 0:e8a8f8351b80 8 Serial pc(USBTX, USBRX);
tony63 0:e8a8f8351b80 9
tony63 0:e8a8f8351b80 10 int main() {
tony63 0:e8a8f8351b80 11 int address = flash_size() - SECTOR_SIZE; //Write in last sector
tony63 0:e8a8f8351b80 12
tony63 0:e8a8f8351b80 13 int *data = (int*)address;
tony63 0:e8a8f8351b80 14 pc.printf("Starting\r\n");
tony63 0:e8a8f8351b80 15 erase_sector(address);
tony63 0:e8a8f8351b80 16 int numbers[10] = {0, 1, 10, 100, 1000, 10000, 1000000, 10000000, 100000000, 1000000000};
tony63 0:e8a8f8351b80 17 program_flash(address, (char*)&numbers, 40); //10 integers of 4 bytes each: 40 bytes length
tony63 0:e8a8f8351b80 18 pc.printf("Resulting flash: \r\n");
tony63 0:e8a8f8351b80 19 for (int i = 0; i<10; i++)
tony63 0:e8a8f8351b80 20 pc.printf("%d\r\n", data[i]);
tony63 0:e8a8f8351b80 21
tony63 0:e8a8f8351b80 22 pc.printf("Done\r\n\n");
tony63 0:e8a8f8351b80 23
tony63 0:e8a8f8351b80 24
tony63 0:e8a8f8351b80 25 while (true) {
tony63 0:e8a8f8351b80 26 }
tony63 0:e8a8f8351b80 27 }