TVZ Mechatronics Team / Mbed 2 deprecated Flash_Example

Dependencies:   Flash mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "Flash.h"
00003 
00004 BusOut display(LED1, LED2, LED3, LED4);
00005 InterruptIn cntUp(p5);
00006 Timer debounceUp;
00007 Flash flash;
00008 
00009 char retainData[MEM_SIZE];
00010 uint8_t counter;
00011 
00012 void countUp(void) {
00013     if (debounceUp.read_ms() > 500) {
00014         
00015         if (counter > 15)
00016             counter = 0;
00017         else
00018             counter++;
00019             
00020         retainData[0] = counter;
00021         flash.writeFlash(retainData);
00022         
00023         debounceUp.reset();
00024     }
00025 }
00026 
00027 int main() {
00028     cntUp.rise(&countUp);
00029     debounceUp.start();
00030     
00031     flash.readFlash(retainData);
00032     counter = retainData[0];
00033     
00034     while(1) {
00035         display = counter;
00036     }
00037 }