Contiki 3.x
Macros | Functions
flash.h File Reference

 App for easy usage of additional flash memory
More...

#include <nvm.h>

Go to the source code of this file.

Macros

#define flash_stack_read(dest, offset, numBytes)   flash_getVar(dest, FLASH_STACK + (offset), numBytes)
 Read data from stack. More...
 

Functions

void flash_init ()
 Initialize or clear random access blocks. More...
 
nvmErr_t flash_getVar (void *dest, flash_addr_t address, uint32_t numBytes)
 Read data from flash memory. More...
 
nvmErr_t flash_setVar (void *src, flash_addr_t address, uint32_t numBytes)
 Write data to flash memory. More...
 
nvmErr_t flash_cmp (void *src, flash_addr_t address, uint32_t numBytes)
 Compares data from RAM with flash memory. More...
 
void flash_stack_init ()
 Stack initialisation. More...
 
nvmErr_t flash_stack_push (uint8_t *src, uint32_t numBytes)
 Push data to stack. More...
 
uint32_t flash_stack_size ()
 Stacksize. More...
 

Detailed Description

 App for easy usage of additional flash memory

Purposes of the different flash blocks 1 : 0x18000 - 0x18FFF : Random access block 1.1 2 : 0x19000 - 0x19FFF : Random access block 1.2 3 : 0x1A000 - 0x1AFFF : Random access block 2.1 4 : 0x1B000 - 0x1BFFF : Random access block 2.2 5 : 0x1C000 - 0x1CFFF : Stack without pop function 6 : 0x1D000 - 0x1DFFF : Read only 7 : 0x1E000 - 0x1EFFF : Read only 8 : 0x1F000 - 0x1FFFF : System reserved

This app only allows write access to blocks 1 - 5 and read access to blocks 1 - 7.

To use the stack in block 5 you need: flash_stack_init, flash_stack_push, flash_stack_size, flash_stack_read.

To use the random access blocks 1.x and 2.x you need: flash_init, flash_getVar, flash_setVar, flash_cmp.

Blocks 1.x and 2.x are accessible with adresses 0x0001 - 0x0FFF and 0x1001 - 0x1FFF.

To be able to write to flash memory, its required to delete it first, but its only possible to delete a full block. So this app copies the data of a block, changing the requested data. Copying a block needs time. So when you only use the first N bytes, you can set FLASH_CONF_B1=N and FLASH_CONF_B2=N in your makefile to optimize speed.

You can find an example in examples/econotag-flash-test.

Author
Lars Schmertmann Small.nosp@m.Lars.nosp@m.@t-on.nosp@m.line.nosp@m..de

Definition in file flash.h.

Macro Definition Documentation

#define flash_stack_read (   dest,
  offset,
  numBytes 
)    flash_getVar(dest, FLASH_STACK + (offset), numBytes)

Read data from stack.

Reads data from stack (without removing it) and stores it into RAM.

Parameters
destMemory area to store the data
offsetPosition in stack to read from
numBytesNumber of bytes to read
Returns
gNvmErrNoError_c (0) if read was successfull

Definition at line 176 of file flash.h.

Function Documentation

nvmErr_t flash_cmp ( void *  src,
flash_addr_t  address,
uint32_t  numBytes 
)

Compares data from RAM with flash memory.

Compares data from RAM with flash memory. Valid addresses are 0x18000 - 0x1EFFF. Addresses 0x0 - 0x1FFF will be mapped to 0x18000 - 0x1BFFF.

Parameters
srcMemory area with data to compare
addressArea in flash memory
numBytesNumber of bytes to compare
Returns
0 if data is matching

Definition at line 163 of file flash.c.

nvmErr_t flash_getVar ( void *  dest,
flash_addr_t  address,
uint32_t  numBytes 
)

Read data from flash memory.

Reads data from flash memory and stores it into RAM. You can read the flash area 0x18000 - 0x1EFFF. Addresses 0x0000 - 0x1FFF will be mapped to 0x18000 - 0x1BFFF.

Parameters
destMemory area to store the data
addressArea in flash memory to read from
numBytesNumber of bytes to read
Returns
gNvmErrNoError_c (0) if read was successfull

Definition at line 92 of file flash.c.

void flash_init ( )

Initialize or clear random access blocks.

To use the random access blocks, you need to call this function first. You can also use it to delete all data in this blocks.

Definition at line 69 of file flash.c.

nvmErr_t flash_setVar ( void *  src,
flash_addr_t  address,
uint32_t  numBytes 
)

Write data to flash memory.

Writes data to flash memory. Valid addresses are 0x0001 - 0x0FFF and 0x1001 - 0x1FFF -> Mapped to 0x18000 - 0x1BFFF.

Parameters
srcMemory area with data to store in flash memory
addressArea in flash memory to write
numBytesNumber of bytes to write
Returns
gNvmErrNoError_c (0) if write was successfull

Definition at line 110 of file flash.c.

void flash_stack_init ( )

Stack initialisation.

Clears and initializes the stack.

Definition at line 174 of file flash.c.

nvmErr_t flash_stack_push ( uint8_t *  src,
uint32_t  numBytes 
)

Push data to stack.

Pushes numBytes from src to stack into flash memory.

Parameters
srcMemory area with data to store in flash memory
numBytesNumber of bytes to write
Returns
gNvmErrNoError_c (0) if push was successfull

Definition at line 180 of file flash.c.

uint32_t flash_stack_size ( )

Stacksize.

Returns the size of data in stack

Returns
Number of bytes in stack

Definition at line 191 of file flash.c.