The friendly Operating System for the Internet of Things

Low-level flash page interface. More...

Detailed Description

Files

file  flashpage.h
 Low-level flash page peripheral driver interface.
 

Macros

#define CPU_FLASH_BASE   (0)
 Per default, we expect the internal flash to start at address 0.
 

Enumerations

enum  { FLASHPAGE_OK = 0, FLASHPAGE_NOMATCH = -1 }
 Make sure the page size and the number of pages is defined. More...
 

Functions

static void * flashpage_addr (int page)
 Translate the given page number into the page's starting address. More...
 
static int flashpage_page (void *addr)
 Translate the given address into the corresponding page number. More...
 
void flashpage_write (int page, void *data)
 Write the given page with the given data. More...
 
void flashpage_read (int page, void *data)
 Read the given page into the given memory location. More...
 
int flashpage_verify (int page, void *data)
 Verify the given page against the given data. More...
 
int flashpage_write_and_verify (int page, void *data)
 Write the given page and verify the results. More...
 

Enumeration Type Documentation

anonymous enum

Return values used in this interface

Enumerator
FLASHPAGE_OK 

everything succeeded

FLASHPAGE_NOMATCH 

page differs from target data

Definition at line 64 of file flashpage.h.

Function Documentation

static void* flashpage_addr ( int  page)
inlinestatic
Note
The given page MUST be valid, otherwise the returned address points to an undefined memory location!
Parameters
[in]pagepage number to get the address of
Returns
starting memory address of the given page

Definition at line 79 of file flashpage.h.

static int flashpage_page ( void *  addr)
inlinestatic

The given address can be any address inside a page.

Note
The given address MUST be a valid flash address!
Parameters
[in]addraddress inside the targeted page
Returns
page containing the given address

Definition at line 95 of file flashpage.h.

void flashpage_read ( int  page,
void *  data 
)
Parameters
[in]pagepage to read
[out]datamemory to write the page to, MUST be FLASHPAGE_SIZE byte
int flashpage_verify ( int  page,
void *  data 
)
Parameters
[in]pagepage to verify
[in]datadata to compare page against, MUST be FLASHPAGE_SIZE byte of data
Returns
FLASHPAGE_OK if data in the page is identical to data
FLASHPAGE_NOMATCH if data and page content diverge
void flashpage_write ( int  page,
void *  data 
)
Parameters
[in]pagepage to write
[in]datadata to write to the page, MUST be FLASHPAGE_SIZE byte. Set to NULL for page erase only.
int flashpage_write_and_verify ( int  page,
void *  data 
)

This is a convenience function wrapping flashpage_write and flashpage_verify.

Parameters
[in]pagepage to write
[in]datadata to write to the page, MUST be FLASHPAGE_SIZE byte.
Returns
FLASHPAGE_OK on success
FLASHPAGE_NOMATCH if data and page content diverge