LOGGER  Logger
Data Logging using ESP8266
Functions
flashservices.h File Reference

Services to read and write flash memory parts. More...

Go to the source code of this file.

Functions

void flashInit ()
 < version of this include file More...
 
void flashServicesLoop ()
 
bool flashReadBytes (uint32_t address, uint32_t numBytes, void *pBuffer)
 Blocking model routines. More...
 
void flashEraseAll ()
 erase all data
 
void flashDatabaseExists ()
 
uint32_t flashGetDatabaseSize ()
 
bool flashWriteBytes (uint32_t offset, uint32_t numBytes, void *pBuffer)
 
void flashCardInfo ()
 Report the state of the flash card and info about its content.
 
void flashservicesDump ()
 

Detailed Description

Services to read and write flash memory parts.

Author
Michael Newman
Date
24January2016

Services that isolate a user of a flash part from the details of how to read or write the data stored in that memory. The services are structured around NAND flash style operation. The user of the these services is expected to understand that the part must be erased before it can be written correctly. These services are optimized around the expectation that the part will typically be written once.

A typical flash part of this type is the S25FL512S. ??? Learn what SD cards use and if their memory is similar to the S25.

Function Documentation

void flashDatabaseExists ( )

Test if the database file is present

uint32_t flashGetDatabaseSize ( )

Get the size of the database, this is the number of bytes written so far.

void flashInit ( )

< version of this include file

Routines common to the blocking and non-blocking model. Configure the flash services and pins associated with the flash part. This must be called once at system startup. It can be called as many times as desired. Calling it after an error might succeed in fixing the error, but, it is more likely that a reset of the part will fix the error (

See also
flashSetReset).
bool flashReadBytes ( uint32_t  address,
uint32_t  numBytes,
void *  pBuffer 
)

Blocking model routines.

Read data from the flash memory.

Read flash memory. Block until the read is complete. If an operation is in progress when this is called the system will return false to indicate a failure to start the read.

Parameters
addressBase address of block to read
numBytesnumber of bytes to read
pBufferpointer to where to put the result
Returns
true if the read completed, false if the flash system is busy or on errors
void flashservicesDump ( )

Report simple information about the flash memory system. This is a subset of the flashCardInfo information

void flashServicesLoop ( )

Call this periodically from a non-interrupt context. Performs user level management of the flash and activities associated with the flash. Once a flash operation begins further transitions among the FlashStatus_t states will occur as a consequence of this call.

???consider changing to a blocking model and eliminating this call.

bool flashWriteBytes ( uint32_t  offset,
uint32_t  numBytes,
void *  pBuffer 
)

Write bytes at a particular location in the database. Normal usage will only write at the end of the database. This allows modeling the database as a file which is appended to. The database also expects to be a write once structure.

Parameters
offsetlocation in the database of the first byte to write
numBytesnumber of bytes to write
pBufferpointer to where to get the bytes