LOGGER  Logger
Data Logging using ESP8266
Macros | Functions
flashservices.cpp File Reference
#include <arduino.h>
#include <SPI.h>
#include <SD.h>
#include "flashservices.h"
#include "basetype.h"
#include "error.h"
#include "huzzahpins.h"

Macros

#define flashservicesEdit   1
 version of this module
 
#define DATA_FILE_NAME   ((char *)"datalog.bin")
 
#define SD_CARD_CHECKS   0
 Set to 1 to include card checking code.
 

Functions

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

Detailed Description

Services to read and write NAND flash parts.

Author
Michael Newman

Macro Definition Documentation

#define DATA_FILE_NAME   ((char *)"datalog.bin")

Name of the log file $$$Passing a string constant to the SD.exists subroutine gives a deprecated warning about converting a string constant to (char *). The explicit conversion here hides the warning. There may be issues on some platforms with passing a pointer to constant data to routines that expect pointers to the (char *) type.

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
EXTERNDEF void flashservicesDump ( )

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

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