PDK API Guide for J721E
FATFS.h File Reference

Introduction

FATFS interface for driver.

============================================================================

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


Go to the source code of this file.

Data Structures

struct  FATFS_ConfigParams
 SD Parameters. More...
 
struct  FATFS_DrvFxnTable
 The definition of a SD function table that contains the required set of functions to control a specific SD driver implementation. More...
 
struct  FATFS_HwAttrs
 SDAm57x Hardware attributes. More...
 
struct  FATFS_Object
 SDAm572x Object. More...
 
struct  FATFS_Config
 SD Global configuration. More...
 

Macros

#define FATFS_OK   0
 
#define FATFS_ERR   (-(1))
 
#define FATFS_VOLUME_FULL_ERR   (-(10))
 
#define FATFS_VOLUME_DISK_AVL   (0)
 
#define FATFS_MBR_TABLE   (446)
 
#define FATFS_SZ_PTE   (16)
 
#define FATFS_NUM_OF_PARTITIONS   (4)
 
#define FATFS_MBR_PT_TYPE_OFFSET   (4)
 
#define FATFS_DFLT_VOLUME_PD   (0xf)
 
#define FATFS_DFLT_VOLUME_PT   (0xf)
 
#define FATFS_MOUNT_IMMEDIATE   (1)
 
#define FATFS_MOUNT_LATER   (0)
 
#define FATFS_MEDIA_BOOT_SEC_OFFSET   (21)
 
#define FATFS_JUMP_BOOT_SEC_OFFSET   (0)
 
#define FATFS_BOOT_MEDIA_TYPE_NON_REM   (0xF0)
 
#define FATFS_BOOT_MEDIA_REM_TYPE_MIN   (0xF8)
 
#define FATFS_BOOT_MEDIA_REM_TYPE_MAX   (0xFF)
 
#define FATFS_JUMP_BOOT_SEC_JMP_INS_0   (0xEB)
 
#define FATFS_JUMP_BOOT_SEC_JMP_INS_1   (0xE9)
 

Typedefs

typedef int32_t FATFS_Error
 Return status of FATFS. More...
 
typedef void * FATFS_Handle
 A handle that is returned from a FATFS_open() call. More...
 
typedef void * FATFS_Params
 Parameters that is required for FATFS_open() call. More...
 
typedef void * FATFS_DrvHandle
 A handle that is returned to open driver. More...
 
typedef void * FATFS_DrvParams
 Parameters that is required to open driver. More...
 
typedef FATFS_Error(* FATFS_CloseDrvFxn) (FATFS_DrvHandle drvHandle)
 A function pointer to a driver specific implementation of FATFS_close(). More...
 
typedef FATFS_Error(* FATFS_ControlDrvFxn) (FATFS_DrvHandle drvHandle, uint32_t cmd, void *arg)
 A function pointer to a driver specific implementation of FATFS_control(). More...
 
typedef FATFS_Error(* FATFS_InitDrvFxn) (void)
 A function pointer to a driver specific implementation of FATFS_init(). More...
 
typedef FATFS_Error(* FATFS_OpenDrvFxn) (uint32_t index, FATFS_DrvParams drvParams, FATFS_DrvHandle *drvHandle)
 A function pointer to a driver specific implementation of FATFS_open(). More...
 
typedef FATFS_Error(* FATFS_WriteDrvFxn) (FATFS_DrvHandle drvHandle, uint8_t *buf, uint32_t block, uint32_t numBlks)
 A function pointer to a driver specific implementation of FATFS_transfer(). More...
 
typedef FATFS_Error(* FATFS_ReadDrvFxn) (FATFS_DrvHandle drvHandle, uint8_t *buf, uint32_t block, uint32_t numBlks)
 A function pointer to a driver specific implementation of FATFS_transfer(). More...
 
typedef FATFS_Config FATFSConfigList[((uint32_t) _VOLUMES)+(uint32_t) 1U]
 

Functions

FATFS_Error FATFS_close (FATFS_Handle handle)
 Function to close a SD peripheral specified by the SD handle. More...
 
FATFS_Error FATFS_open (uint32_t index, FATFS_Params params, FATFS_Handle *handle)
 Function to initialize a given SD peripheral specified by the particular index value. The parameter specifies which mode the SD will operate. More...
 
FATFS_Error FATFS_Params_init (FATFS_Params params)
 Function to initialize the FATFS_Params struct to its defaults. More...
 
FATFS_Error FATFS_init (void)
 Function to initializes the FATFS module. More...
 

Variables

FATFS_DrvFxnTable FATFS_drvFxnTable
 

Macro Definition Documentation

◆ FATFS_OK

#define FATFS_OK   0

FATFS return code – Function executed successfully

◆ FATFS_ERR

#define FATFS_ERR   (-(1))

FATFS return code – Function executed failed

◆ FATFS_VOLUME_FULL_ERR

#define FATFS_VOLUME_FULL_ERR   (-(10))

FATFS return code – VolToPart structure is full and no index to add more partitions

◆ FATFS_VOLUME_DISK_AVL

#define FATFS_VOLUME_DISK_AVL   (0)

FATFS status code – VolToPart structure is available to add partitions

◆ FATFS_MBR_TABLE

#define FATFS_MBR_TABLE   (446)

MBR: Partition table offset

◆ FATFS_SZ_PTE

#define FATFS_SZ_PTE   (16)

MBR: Size of a partition table entry

◆ FATFS_NUM_OF_PARTITIONS

#define FATFS_NUM_OF_PARTITIONS   (4)

Number of partitions supported

◆ FATFS_MBR_PT_TYPE_OFFSET

#define FATFS_MBR_PT_TYPE_OFFSET   (4)

Partition Type offset of each partition entry in MBR

◆ FATFS_DFLT_VOLUME_PD

#define FATFS_DFLT_VOLUME_PD   (0xf)

Default value of the VolToPart structure variable: partition disk

◆ FATFS_DFLT_VOLUME_PT

#define FATFS_DFLT_VOLUME_PT   (0xf)

Default value of the VolToPart structure variable: partition number

◆ FATFS_MOUNT_IMMEDIATE

#define FATFS_MOUNT_IMMEDIATE   (1)

Value to mount the partition immediately during f_mount function call

◆ FATFS_MOUNT_LATER

#define FATFS_MOUNT_LATER   (0)

Value to mount the partition later during f_open function call but not during f_mount function call

◆ FATFS_MEDIA_BOOT_SEC_OFFSET

#define FATFS_MEDIA_BOOT_SEC_OFFSET   (21)

Offset of Media field in the BOOT Sector which holds the information of the device is removable or non removable media.

◆ FATFS_JUMP_BOOT_SEC_OFFSET

#define FATFS_JUMP_BOOT_SEC_OFFSET   (0)

Offset of the JUMP instruction field which holds the information of three byte unconditional branch instruction.

◆ FATFS_BOOT_MEDIA_TYPE_NON_REM

#define FATFS_BOOT_MEDIA_TYPE_NON_REM   (0xF0)

Standard value of Media offset in Boot sector for non removable media.

◆ FATFS_BOOT_MEDIA_REM_TYPE_MIN

#define FATFS_BOOT_MEDIA_REM_TYPE_MIN   (0xF8)

Legal minimum value of Media offset in Boot sector for removable media.

◆ FATFS_BOOT_MEDIA_REM_TYPE_MAX

#define FATFS_BOOT_MEDIA_REM_TYPE_MAX   (0xFF)

Legal maximum value of Media offset in Boot sector for removable media.

◆ FATFS_JUMP_BOOT_SEC_JMP_INS_0

#define FATFS_JUMP_BOOT_SEC_JMP_INS_0   (0xEB)

Valid JUMP INstruction code value to jump to bootstrap code.

◆ FATFS_JUMP_BOOT_SEC_JMP_INS_1

#define FATFS_JUMP_BOOT_SEC_JMP_INS_1   (0xE9)

Another Valid JUMP INstruction code value to jump to bootstrap code.

Typedef Documentation

◆ FATFS_Error

typedef int32_t FATFS_Error

Return status of FATFS.

◆ FATFS_Handle

typedef void* FATFS_Handle

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

◆ FATFS_Params

typedef void* FATFS_Params

Parameters that is required for FATFS_open() call.

◆ FATFS_DrvHandle

typedef void* FATFS_DrvHandle

A handle that is returned to open driver.

◆ FATFS_DrvParams

typedef void* FATFS_DrvParams

Parameters that is required to open driver.

◆ FATFS_CloseDrvFxn

typedef FATFS_Error(* FATFS_CloseDrvFxn) (FATFS_DrvHandle drvHandle)

A function pointer to a driver specific implementation of FATFS_close().

◆ FATFS_ControlDrvFxn

typedef FATFS_Error(* FATFS_ControlDrvFxn) (FATFS_DrvHandle drvHandle, uint32_t cmd, void *arg)

A function pointer to a driver specific implementation of FATFS_control().

◆ FATFS_InitDrvFxn

typedef FATFS_Error(* FATFS_InitDrvFxn) (void)

A function pointer to a driver specific implementation of FATFS_init().

◆ FATFS_OpenDrvFxn

typedef FATFS_Error(* FATFS_OpenDrvFxn) (uint32_t index, FATFS_DrvParams drvParams, FATFS_DrvHandle *drvHandle)

A function pointer to a driver specific implementation of FATFS_open().

◆ FATFS_WriteDrvFxn

typedef FATFS_Error(* FATFS_WriteDrvFxn) (FATFS_DrvHandle drvHandle, uint8_t *buf, uint32_t block, uint32_t numBlks)

A function pointer to a driver specific implementation of FATFS_transfer().

◆ FATFS_ReadDrvFxn

typedef FATFS_Error(* FATFS_ReadDrvFxn) (FATFS_DrvHandle drvHandle, uint8_t *buf, uint32_t block, uint32_t numBlks)

A function pointer to a driver specific implementation of FATFS_transfer().

◆ FATFSConfigList

typedef FATFS_Config FATFSConfigList[((uint32_t) _VOLUMES)+(uint32_t) 1U]

Function Documentation

◆ FATFS_close()

FATFS_Error FATFS_close ( FATFS_Handle  handle)

Function to close a SD peripheral specified by the SD handle.

Precondition
FATFS_open() had to be called first.
Parameters
handleA FATFS_Handle returned from FATFS_open
See also
FATFS_open()

◆ FATFS_open()

FATFS_Error FATFS_open ( uint32_t  index,
FATFS_Params  params,
FATFS_Handle handle 
)

Function to initialize a given SD peripheral specified by the particular index value. The parameter specifies which mode the SD will operate.

Precondition
SD controller has been initialized
Parameters
indexLogical peripheral number for the disk indexed into the FATFS_config table
paramsPointer to an parameter block, if NULL it will use default values. All the fields in this structure are RO (read-only).
handleHandle to the FATFS driver which holds the hardware attributes and object filesystem parameters.
Returns
A FATFS_Handle on success or a NULL on an error or if it has been opened already.
See also
FATFS_init()
FATFS_close()

◆ FATFS_Params_init()

FATFS_Error FATFS_Params_init ( FATFS_Params  params)

Function to initialize the FATFS_Params struct to its defaults.

Parameters
paramsAn pointer to FATFS_Params structure for initialization

◆ FATFS_init()

FATFS_Error FATFS_init ( void  )

Function to initializes the FATFS module.

Precondition
The FATFS_config structure must exist and be persistent before this function can be called. This function must also be called before any other FATFS APIs. This function call does not modify any peripheral registers.

Variable Documentation

◆ FATFS_drvFxnTable

FATFS_DrvFxnTable FATFS_drvFxnTable