Data Structures | Typedefs | Functions
SDFatFS.h File Reference

Detailed Description

File Allocation Table File System (FATFS) Driver.

The SDFatFS header file should be included in an application as follows:


The SDFatFS driver is designed to hook into FatFs by implementing a set of functions that FatFs needs to call to perform basic block data transfers. This driver makes use of the SD driver for lower level disk IO operations.

The only functions that should be called by the application are the standard driver framework functions (_open, _close, etc...).

The application may use the FatFs APIs or the standard C runtime file I/O calls (fopen, fclose, etc...) given that SDFatFS_open has has been successfully called. After the SDFatFS_close API is called, ensure the application does NOT make any file I/O calls.

Opening the driver

handle = SDFatFS_open(CONFIG_SDFatFS0, driveNum, NULL);
if (handle == NULL) {
//Error opening SDFatFS driver
while (1);


The SDFatFS driver interface produces log statements if instrumentation is enabled.

Diagnostics Mask Log details
Diags_USER1 basic operations performed
Diags_USER2 detailed operations performed


#include <stdint.h>
#include <ti/drivers/SD.h>
#include <third_party/fatfs/ff.h>
#include <third_party/fatfs/diskio.h>
Include dependency graph for SDFatFS.h:

Go to the source code of this file.

Data Structures

struct  SDFatFS_Object
 SDFatFS Object The application must not access any member variables of this structure! More...
struct  SDFatFS_Config
 SDFatFS Global configuration. More...


typedef SDFatFS_ConfigSDFatFS_Handle
 A handle that is returned from a SDFatFS_open() call. More...


SDFatFS_Handle SDFatFS_open (uint_least8_t idx, uint_least8_t drive)
 Function to open a SDFatFS instance on the specified drive. More...
void SDFatFS_close (SDFatFS_Handle handle)
 Function to close a SDFatFS instance specified by the SDFatFS handle. More...
void SDFatFS_init (void)

Typedef Documentation

§ SDFatFS_Handle

A handle that is returned from a SDFatFS_open() call.

Function Documentation

§ SDFatFS_open()

SDFatFS_Handle SDFatFS_open ( uint_least8_t  idx,
uint_least8_t  drive 

Function to open a SDFatFS instance on the specified drive.

Function to mount the FatFs filesystem and register the SDFatFS disk I/O functions with the FatFS module.

idxLogical peripheral number indexed into the HWAttrs table.
driveDrive Number

§ SDFatFS_close()

void SDFatFS_close ( SDFatFS_Handle  handle)

Function to close a SDFatFS instance specified by the SDFatFS handle.

This function unmounts the file system mounted by SDFatFS_open() and unregisters the SDFatFS driver from the FatFs module.

SDFatFS_open() had to be called first.
handleA SDFatFS_Handle returned from SDFatFS_open()
See also

§ SDFatFS_init()

void SDFatFS_init ( void  )

Function to initialize a SDFatFS instance

© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale