TI-RTOS Drivers  tidrivers_tivac_2_16_00_08
Data Structures | Macros | Typedefs | Functions
SDSPI.h File Reference

Detailed Description

SDSPI driver interface.

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

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

Operation

The SDSPI driver is a driver designed to hook into FatFs. It implements a set of functions that FatFs needs to call to perform basic block data transfers.

A SDSPI driver peripheral implementation doesn't require RTOS protection primitives due to the resource protection provided with FatFs. The only functions that can be called by the application are the standard driver framework functions (_open, _close, etc...).

Once the driver has been opened, the application may used the FatFs APIs or the standard C runtime file I/O calls (fopen, fclose, etc...). Once the driver has been closed, ensure the application does NOT make any file I/O calls.

Opening the driver

SDSPI_Handle handle;
SDSPI_Params params;
params.bitRate = someNewBitRate;
handle = SDSPI_open(someSDSPI_configIndexValue, &params);
if (!handle) {
System_printf("SDSPI did not open");
}

Implementation

This module serves as the main interface for TI-RTOS applications. Its purpose is to redirect the module's APIs to specific peripheral implementations which are specified using a pointer to a SDSPI_FxnTable.

The SDSPI driver interface module is joined (at link time) to a NULL-terminated array of SDSPI_Config data structures named SDSPI_config. SDSPI_config is implemented in the application with each entry being an instance of a SDSPI peripheral. Each entry in SDSPI_config contains a:

Instrumentation

The SDSPI 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 dependency graph for SDSPI.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SDSPI_Params
 SDSPI Parameters. More...
 
struct  SDSPI_FxnTable
 The definition of a SDSPI function table that contains the required set of functions to control a specific SDSPI driver implementation. More...
 
struct  SDSPI_Config
 SDSPI Global configuration. More...
 

Macros

#define SDSPI_CMD_RESERVED   32
 
#define SDSPI_STATUS_RESERVED   -32
 
#define SDSPI_STATUS_SUCCESS   0
 Successful status code returned by SDSPI_control(). More...
 
#define SDSPI_STATUS_ERROR   -1
 Generic error status code returned by SDSPI_control(). More...
 
#define SDSPI_STATUS_UNDEFINEDCMD   -2
 An error status code returned by SDSPI_control() for undefined command codes. More...
 

Typedefs

typedef struct SDSPI_ConfigSDSPI_Handle
 A handle that is returned from a SDSPI_open() call. More...
 
typedef struct SDSPI_Params SDSPI_Params
 SDSPI Parameters. More...
 
typedef void(* SDSPI_InitFxn) (SDSPI_Handle handle)
 A function pointer to a driver specific implementation of SDSPI_init(). More...
 
typedef SDSPI_Handle(* SDSPI_OpenFxn) (SDSPI_Handle handle, unsigned char drv, SDSPI_Params *params)
 A function pointer to a driver specific implementation of SDSPI_open(). More...
 
typedef void(* SDSPI_CloseFxn) (SDSPI_Handle handle)
 A function pointer to a driver specific implementation of SDSPI_close(). More...
 
typedef int(* SDSPI_ControlFxn) (SDSPI_Handle handle, unsigned int cmd, void *arg)
 A function pointer to a driver specific implementation of SDSPI_control(). More...
 
typedef struct SDSPI_FxnTable SDSPI_FxnTable
 The definition of a SDSPI function table that contains the required set of functions to control a specific SDSPI driver implementation. More...
 
typedef struct SDSPI_Config SDSPI_Config
 SDSPI Global configuration. More...
 

Functions

void SDSPI_close (SDSPI_Handle handle)
 Function to close a SDSPI peripheral specified by the SDSPI handle. This function unmounts the file system mounted by SDSPI_open and unregisters the SDSPI driver from BIOS' FatFs module. More...
 
int SDSPI_control (SDSPI_Handle handle, unsigned int cmd, void *arg)
 Function performs implementation specific features on a given SDSPI_Handle. More...
 
void SDSPI_init (void)
 This function initializes the SDSPI driver module. More...
 
SDSPI_Handle SDSPI_open (unsigned int index, unsigned char drv, SDSPI_Params *params)
 This function registers the SDSPI driver with BIOS' FatFs module and mounts the FatFs file system. More...
 
void SDSPI_Params_init (SDSPI_Params *params)
 Function to initialize the SDSPI_Params struct to its defaults. More...
 

Typedef Documentation

typedef struct SDSPI_Config* SDSPI_Handle

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

typedef struct SDSPI_Params SDSPI_Params

SDSPI Parameters.

SDSPI Parameters are used to with the SDSPI_open() call. Default values for these parameters are set using SDSPI_Params_init().

See also
SDSPI_Params_init()
typedef void(* SDSPI_InitFxn) (SDSPI_Handle handle)

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

typedef SDSPI_Handle(* SDSPI_OpenFxn) (SDSPI_Handle handle, unsigned char drv, SDSPI_Params *params)

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

typedef void(* SDSPI_CloseFxn) (SDSPI_Handle handle)

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

typedef int(* SDSPI_ControlFxn) (SDSPI_Handle handle, unsigned int cmd, void *arg)

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

The definition of a SDSPI function table that contains the required set of functions to control a specific SDSPI driver implementation.

typedef struct SDSPI_Config SDSPI_Config

SDSPI Global configuration.

The SDSPI_Config structure contains a set of pointers used to characterize the SDSPI driver implementation.

This structure needs to be defined before calling SDSPI_init() and it must not be changed thereafter.

See also
SDSPI_init()

Function Documentation

void SDSPI_close ( SDSPI_Handle  handle)

Function to close a SDSPI peripheral specified by the SDSPI handle. This function unmounts the file system mounted by SDSPI_open and unregisters the SDSPI driver from BIOS' FatFs module.

Precondition
SDSPI_open() had to be called first.
Parameters
handleA SDSPI handle returned from SDSPI_open
See also
SDSPI_open()
int SDSPI_control ( SDSPI_Handle  handle,
unsigned int  cmd,
void *  arg 
)

Function performs implementation specific features on a given SDSPI_Handle.

Commands for SDSPI_control can originate from SDSPI.h or from implementation specific SDSPI*.h (SDSPICC26XX.h, SDSPITiva.h, etc.. ) files. While commands from SDSPI.h are API portable across driver implementations, not all implementations may support all these commands. Conversely, commands from driver implementation specific SDSPI*.h files add unique driver capabilities but are not API portable across all SDSPI driver implementations.

Commands supported by SDSPI.h follow a SDSPI_CMD_<cmd> naming convention.
Commands supported by SDSPI*.h follow a SDSPI*_CMD_<cmd> naming convention.
Each control command defines arg differently. The types of arg are documented with each command.

See SDSPI_control command codes for command codes.

See SDSPI_control return status codes for status codes.

Precondition
SDSPI_open() has to be called first.
Parameters
handleA SDSPI handle returned from SDSPI_open()
cmdSDSPI.h or SDSPI*.h commands.
argAn optional R/W (read/write) command argument accompanied with cmd
Returns
Implementation specific return codes. Negative values indicate unsuccessful operations.
See also
SDSPI_open()
void SDSPI_init ( void  )

This function initializes the SDSPI driver module.

Precondition
The SDSPI_config structure must exist and be persistent before this function can be called. This function must also be called before any other SDSPI driver APIs. This function call does not modify any peripheral registers.
SDSPI_Handle SDSPI_open ( unsigned int  index,
unsigned char  drv,
SDSPI_Params params 
)

This function registers the SDSPI driver with BIOS' FatFs module and mounts the FatFs file system.

Precondition
SDSPI controller has been initialized using SDSPI_init()
Parameters
indexLogical peripheral number for the SDSPI indexed into the SDSPI_config table
drvDrive number to be associated with the SDSPI FatFs driver
paramsPointer to an parameter block, if NULL it will use default values. All the fields in this structure are RO (read-only).
Returns
A SDSPI_Handle on success or a NULL on an error or if it has been opened already.
See also
SDSPI_init()
SDSPI_close()
void SDSPI_Params_init ( SDSPI_Params params)

Function to initialize the SDSPI_Params struct to its defaults.

Parameters
paramsAn pointer to SDSPI_Params structure for initialization

Defaults values are: bitRate = 12500000 (Hz)

Copyright 2016, Texas Instruments Incorporated