This is library for storing data array in internal flash memory of MCU LPC1768. The flash data is empty every time we download program to MCU so it can be used in project where we don't have acces to file system like mbed development board uses.

Dependencies:   IAP

Dependents:   Flash_Example

Embed: (wiki syntax)

« Back to documentation index

Flash Class Reference

Flash Class Reference

This is simple library for storing data to flash memory and reading it. More...

#include <Flash.h>

Public Member Functions

 Flash ()
 Constructor.
void writeFlash (char data[MEM_SIZE])
 Function recevies data array wich is stored in flash memory.
void readFlash (char *data)
 Function returning data to pointer to array of size 256 wich is stored in flash memory.

Detailed Description

This is simple library for storing data to flash memory and reading it.

This allows us to have retain data without having to have external flash chip. This class uses NXP LPC1768 internal flash memory which give us 256B of flash size.

Author: TVZ Mechatronics Team

Example of use:

 #include "mbed.h"
 #include "Flash.h"

 BusOut display(LED1, LED2, LED3, LED4);
 InterruptIn cntUp(p5);
 Timer debounceUp;
 Flash flash;

 char retainData[MEM_SIZE];
 uint8_t counter;

 void countUp(void) {
    if (debounceUp.read_ms() > 500) {
        if (counter > 15)
            counter = 0;
        else
            counter++;
            
        retainData[0] = counter;
        flash.writeFlash(retainData);
        
        debounceUp.reset();
    }
 }
 
 int main() {
    cntUp.rise(&countUp);
    debounceUp.start();

    flash.readFlash(retainData);
    counter = retainData[0];

    while(1) {
        display = counter;
    }
 }

Definition at line 58 of file Flash.h.


Constructor & Destructor Documentation

Flash (  )

Constructor.

Definition at line 3 of file Flash.cpp.


Member Function Documentation

void readFlash ( char *  data )

Function returning data to pointer to array of size 256 wich is stored in flash memory.

Definition at line 26 of file Flash.cpp.

void writeFlash ( char  data[MEM_SIZE] )

Function recevies data array wich is stored in flash memory.

Definition at line 7 of file Flash.cpp.