BeRTOS
Data Structures | Defines | Functions
Embedded flash driver
BeRTOS peripherals drivers

Embedded flash for cpu. More...

Data Structures

struct  Flash
 EmbFlash KBlock context structure. More...

Defines

#define flash_init(args...)   PP_CAT(flash_init_, COUNT_PARMS(args)) (args)
 Init function for flash driver.
#define flash_init_2(fls, flags)
 Initialize fls Flash context structure.

Functions

FlashFLASH_CAST (KBlock *fls)
 Convert + ASSERT from generic KBlock to Flash.

Embedded flash error values

#define FLASH_WR_OK   0
 Write ok.
#define FLASH_NOT_ERASED   BV(1)
 Flash memory was not erased before to write it.
#define FLASH_WR_PROTECT   BV(2)
 Write not allowed the flash memory was protected.
#define FLASH_WR_TIMEOUT   BV(3)
 Timeout while writing.
#define FLASH_WR_ERR   BV(4)
 Invalid command and/or a bad keywords.

Flash init flags

#define FLASH_WRITE_ONCE   BV(0)
 Allow only one write per block.
#define FLASH_UNBUFFERED   BV(1)
 Open flash memory disabling page caching, no modification and partial write are allowed.

Detailed Description

Embedded flash for cpu.

This module allows to access in reading and writing to the internal flash memory of the micro. It is a block device, so it must be accessed using the KBlock interface functions (see kblock.h).

Once you have opened the flash for writing, you may want to use kblock_trim() to avoid overwriting data on other flash banks.

Example usage:

 Flash fls;
 flash_init(&fls, 0);
 // enable access only on desired blocks
 // start block = 50, num blocks = 20
 kblock_trim(&fls.blk, 50, 20);
 // ...
 // now write to the flash
 // block number is automatically converted
 kblock_write(&fls.blk, 0, buf, 0, 128);
Author:
Francesco Sacchi <batt@develer.com>
Daniele Basile <asterix@develer.com>

Define Documentation

#define flash_init (   args...)    PP_CAT(flash_init_, COUNT_PARMS(args)) (args)

Init function for flash driver.

This macro cannot fail, so no error conditions are reported.

This macro expands to

Do NOT use the above functions directly, use flash_init() instead. Disable old API if you are not upgrading an existing project.

Definition at line 95 of file flash.h.

#define flash_init_2 (   fls,
  flags 
)
Value:
(flags & FLASH_UNBUFFERED) ? \
                                        flash_hw_initUnbuffered(fls, flags) : flash_hw_init(fls, flags)

Initialize fls Flash context structure.

Parameters:
flsFlash context structure
flagsA combination of flash init flags

Definition at line 158 of file flash.h.