FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
Loading...
Searching...
No Matches
flash Namespace Reference

Defines API to handle flash memory storage. More...

Classes

class  FlashReader
 Functor reading items from an address in AVR Flash memory (PROGMEM). More...
 

Functions

template<typename T = uint8_t>
T * read_flash (uint16_t address, T *buffer, uint8_t size)
 Read flash memory content at given address into buffer. More...
 
template<typename T >
T & read_flash (uint16_t address, T &item)
 Read flash memory content at given address into item. More...
 
template<typename T >
T & read_flash (const T *address, T &item)
 Read flash memory content at given address into item. More...
 

Detailed Description

Defines API to handle flash memory storage.

Function Documentation

◆ read_flash() [1/3]

template<typename T = uint8_t>
T * flash::read_flash ( uint16_t  address,
T *  buffer,
uint8_t  size 
)

Read flash memory content at given address into buffer.

Note that type T should not have constructors as they will not be properly called by this method.

Template Parameters
Ttype of items contained in buffer
Parameters
addressthe address to read from flash storage
bufferthe array (already allocated by caller) to be copied by flash storage content
sizethe number of items (of type T) to read from flash storage
Returns
a pointer to buffer

Definition at line 50 of file flash.h.

◆ read_flash() [2/3]

template<typename T >
T & flash::read_flash ( uint16_t  address,
T &  item 
)

Read flash memory content at given address into item.

Note that type T should not have constructors as they will not be properly called by this method.

Template Parameters
Ttype of item
Parameters
addressthe address to read from flash storage
itemthe item to read from flash storage
Returns
a reference to read item

Definition at line 67 of file flash.h.

◆ read_flash() [3/3]

template<typename T >
T & flash::read_flash ( const T *  address,
T &  item 
)

Read flash memory content at given address into item.

Note that type T should not have constructors as they will not be properly called by this method. The item should properly be defined in flash storage, as in:

struct Dummy
{
uint16_t a;
uint8_t b;
bool c;
};
const Dummy sample1 PROGMEM = {54321, 123, true};

The address of the item in flash storage can then be directly obtained:

Dummy value;
flash::read_flash(&sample1, value);
T * read_flash(uint16_t address, T *buffer, uint8_t size)
Read flash memory content at given address into buffer.
Definition: flash.h:50
Template Parameters
Ttype of item
Parameters
addressthe address to read from flash storage
itemthe item to read from flash storage
Returns
a reference to read item

Definition at line 100 of file flash.h.