NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
flashfs.c File Reference
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include "drivers/flash_m25p16.h"
#include "flashfs.h"
Include dependency graph for flashfs.c:

Functions

void flashfsEraseCompletely (void)
 
void flashfsEraseRange (uint32_t start, uint32_t end)
 
bool flashfsIsReady (void)
 
uint32_t flashfsGetSize (void)
 
uint32_t flashfsGetWriteBufferSize (void)
 
uint32_t flashfsGetWriteBufferFreeSpace (void)
 
const flashGeometry_tflashfsGetGeometry (void)
 
uint32_t flashfsGetOffset (void)
 
bool flashfsFlushAsync (void)
 
void flashfsFlushSync (void)
 
void flashfsSeekAbs (uint32_t offset)
 
void flashfsSeekRel (int32_t offset)
 
void flashfsWriteByte (uint8_t byte)
 
void flashfsWrite (const uint8_t *data, unsigned int len, bool sync)
 
int flashfsReadAbs (uint32_t address, uint8_t *buffer, unsigned int len)
 
int flashfsIdentifyStartOfFreeSpace (void)
 
bool flashfsIsEOF (void)
 
void flashfsInit (void)
 

Function Documentation

void flashfsEraseCompletely ( void  )

Here is the call graph for this function:

void flashfsEraseRange ( uint32_t  start,
uint32_t  end 
)

Start and end must lie on sector boundaries, or they will be rounded out to sector boundaries such that all the bytes in the range [start...end) are erased.

Here is the call graph for this function:

bool flashfsFlushAsync ( void  )

If the flash is ready to accept writes, flush the buffer to it.

Returns true if all data in the buffer has been flushed to the device, or false if there is still data to be written (call flush again later).

void flashfsFlushSync ( void  )

Wait for the flash to become ready and begin flushing any buffered data to flash.

The flash will still be busy some time after this sync completes, but space will be freed up to accept more writes in the write buffer.

const flashGeometry_t* flashfsGetGeometry ( void  )

Here is the call graph for this function:

uint32_t flashfsGetOffset ( void  )

Get the current offset of the file pointer within the volume.

uint32_t flashfsGetSize ( void  )

Here is the call graph for this function:

uint32_t flashfsGetWriteBufferFreeSpace ( void  )

Get the number of bytes that can currently be written to flashfs without any blocking or data loss.

Here is the call graph for this function:

uint32_t flashfsGetWriteBufferSize ( void  )

Get the size of the largest single write that flashfs could ever accept without blocking or data loss.

int flashfsIdentifyStartOfFreeSpace ( void  )

Find the offset of the start of the free space on the device (or the size of the device if it is full).

Here is the call graph for this function:

void flashfsInit ( void  )

Call after initializing the flash chip in order to set up the filesystem.

Here is the call graph for this function:

bool flashfsIsEOF ( void  )

Returns true if the file pointer is at the end of the device.

Here is the call graph for this function:

bool flashfsIsReady ( void  )

Return true if the flash is not currently occupied with an operation.

Here is the call graph for this function:

int flashfsReadAbs ( uint32_t  address,
uint8_t *  buffer,
unsigned int  len 
)

Read len bytes from the given address into the supplied buffer.

Returns the number of bytes actually read which may be less than that requested.

Here is the call graph for this function:

void flashfsSeekAbs ( uint32_t  offset)

Here is the call graph for this function:

void flashfsSeekRel ( int32_t  offset)

Here is the call graph for this function:

void flashfsWrite ( const uint8_t *  data,
unsigned int  len,
bool  sync 
)

Write the given buffer to the flash either synchronously or asynchronously depending on the 'sync' parameter.

If writing asynchronously, data will be silently discarded if the buffer overflows. If writing synchronously, the routine will block waiting for the flash to become ready so will never drop data.

void flashfsWriteByte ( uint8_t  byte)

Write the given byte asynchronously to the flash. If the buffer overflows, data is silently discarded.

Here is the call graph for this function: