FF_READ_BLOCKS

From FullFAT
Jump to: navigation, search

FullFAT defines a driver model for data I/O. This is the specification for the READ function.

When FullFAT is initialised, these "driver" functions are registered using the FF_RegisterBlkDevice() function. This is a unique feature to FullFAT allowing many different instances of FullFAT to use different block-device drivers.

Prototype

typedef FF_T_SINT32 (*FF_READ_BLOCKS)	(FF_T_UINT8 *pBuffer, FF_T_UINT32 SectorAddress, FF_T_UINT32 Count, void *pParam);
// e.g.
 
FF_T_SINT32 fnRead(FF_T_UINT8 *buffer, FF_T_UINT32 SectorAddress, FF_T_UINT16 Count, void *pParam);

Back to API

Example

Creating a FullFAT device driver is very straight-forward. FullFAT needs 2 functions, one to read from a block device (hard drive, Memory card, and any kind of mass storage device). The other function is to write to the device.

The official definition of each driver function looks as follows:

#include "ff_types.h" // FullFAT FF_T_ Datatype definitions
#include "ff_ioman.h" // Defines the Error Codes we can return.
 
FF_T_SINT32 fnRead(FF_T_UINT8 *buffer, FF_T_UINT32 SectorAddress, FF_T_UINT16 Count, void *pParam) {
    // The code here should fill buffer, with Count number of sectors (beginning with the sector
    // specified by SectorAddress [in LBA format]).
    // 
    // pParam is a pointer or sizeof(void*) sized value. (32-bit on a pc). It is provided
    // provided when FF_RegisterBlkDevice() is called. 
    // 
    // This would usually be a handle to a lower-level driver, if required.
}

Optionally you may return the following error codes, to handle particular behaviours:

(defined in ff_ioman.h)

Back to API

See Also






Back to API

Personal tools