|  |  | 
SD driver interface.
============================================================================
The SD header file should be included in an application as follows:
The SD driver is designed to serve as an interface to perform basic transfers directly to the SD card.
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 SD_FxnTable.
The SD driver interface module is joined (at link time) to a NULL-terminated array of SD_Config data structures named SD_config. SD_config is implemented in the application with each entry being an instance of a SD peripheral. Each entry in SD_config contains a:
The SD 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>Go to the source code of this file.
| Data Structures | |
| struct | SD_Params_ | 
| SD Parameters.  More... | |
| struct | SD_FxnTable_ | 
| The definition of a SD function table that contains the required set of functions to control a specific SD driver implementation.  More... | |
| struct | SD_Config_ | 
| SD Global configuration.  More... | |
| Macros | |
| #define | SD_CMD_RESERVED (32) | 
| #define | SD_STATUS_RESERVED (-32) | 
| #define | SD_STATUS_SUCCESS (0) | 
| Successful status code returned by SD_control().  More... | |
| #define | SD_STATUS_ERROR (-1) | 
| Generic error status code returned by SD_control().  More... | |
| #define | SD_STATUS_UNDEFINEDCMD (-2) | 
| An error status code returned by SD_control() for undefined command codes.  More... | |
| Typedefs | |
| typedef enum SD_CardType_ | SD_CardType | 
| SD Card type inserted.  More... | |
| typedef struct SD_Config_ * | SD_Handle | 
| A handle that is returned from a SD_open() call.  More... | |
| typedef struct SD_Params_ | SD_Params | 
| SD Parameters.  More... | |
| typedef void(* | SD_CloseFxn) (SD_Handle handle) | 
| A function pointer to a driver specific implementation of SD_CloseFxn().  More... | |
| typedef int_fast16_t(* | SD_ControlFxn) (SD_Handle handle, uint_fast16_t cmd, void *arg) | 
| A function pointer to a driver specific implementation of SD_controlFxn().  More... | |
| typedef uint_fast32_t(* | SD_getNumSectorsFxn) (SD_Handle handle) | 
| A function pointer to a driver specific implementation of SD_getNumSectorsFxn().  More... | |
| typedef uint_fast32_t(* | SD_getSectorSizeFxn) (SD_Handle handle) | 
| A function pointer to a driver specific implementation of SD_getSectorSizeFxn().  More... | |
| typedef void(* | SD_InitFxn) (SD_Handle handle) | 
| A function pointer to a driver specific implementation of SD_InitFxn().  More... | |
| typedef int_fast16_t(* | SD_InitializeFxn) (SD_Handle handle) | 
| A function pointer to a driver specific implementation of SD_initializeFxn().  More... | |
| typedef SD_Handle(* | SD_OpenFxn) (SD_Handle handle, SD_Params *params) | 
| A function pointer to a driver specific implementation of SD_OpenFxn().  More... | |
| typedef int_fast16_t(* | SD_ReadFxn) (SD_Handle handle, void *buf, int_fast32_t sector, uint_fast32_t secCount) | 
| A function pointer to a driver specific implementation of SD_readFxn().  More... | |
| typedef int_fast16_t(* | SD_WriteFxn) (SD_Handle handle, const void *buf, int_fast32_t sector, uint_fast32_t secCount) | 
| A function pointer to a driver specific implementation of SD_writeFxn().  More... | |
| typedef struct SD_FxnTable_ | SD_FxnTable | 
| The definition of a SD function table that contains the required set of functions to control a specific SD driver implementation.  More... | |
| typedef struct SD_Config_ | SD_Config | 
| SD Global configuration.  More... | |
| Enumerations | |
| enum | SD_CardType_ { SD_NOCARD = 0, SD_MMC = 1, SD_SDSC = 2, SD_SDHC = 3 } | 
| SD Card type inserted.  More... | |
| Functions | |
| void | SD_close (SD_Handle handle) | 
| Function to close a SD peripheral specified by the SD handle.  More... | |
| int_fast16_t | SD_control (SD_Handle handle, uint_fast16_t cmd, void *arg) | 
| Function performs implementation specific features on a given SD_Handle.  More... | |
| uint_fast32_t | SD_getNumSectors (SD_Handle handle) | 
| A function pointer to a driver specific implementation of SD_getNumSectors(). Note: Total Card capacity is the (NumberOfSectors * SectorSize).  More... | |
| uint_fast32_t | SD_getSectorSize (SD_Handle handle) | 
| Function to obtain the sector size used to access the SD card.  More... | |
| void | SD_init (void) | 
| This function initializes the SD driver.  More... | |
| void | SD_Params_init (SD_Params *params) | 
| Function to initialize the SD_Params struct to its defaults.  More... | |
| int_fast16_t | SD_initialize (SD_Handle handle) | 
| A function pointer to a driver specific implementation of SD_initialize().  More... | |
| SD_Handle | SD_open (uint_least8_t index, SD_Params *params) | 
| A function pointer to a driver specific implementation of SD_open().  More... | |
| int_fast16_t | SD_read (SD_Handle handle, void *buf, int_fast32_t sector, uint_fast32_t secCount) | 
| A function pointer to a driver specific implementation of SD_read().  More... | |
| int_fast16_t | SD_write (SD_Handle handle, const void *buf, int_fast32_t sector, uint_fast32_t secCount) | 
| A function pointer to a driver specific implementation of SD_write().  More... | |
| typedef enum SD_CardType_ SD_CardType | 
SD Card type inserted.
| typedef struct SD_Config_* SD_Handle | 
A handle that is returned from a SD_open() call.
| typedef struct SD_Params_ SD_Params | 
SD Parameters.
SD Parameters are used to with the SD_open() call. Default values for these parameters are set using SD_Params_init().
| typedef void(* SD_CloseFxn) (SD_Handle handle) | 
A function pointer to a driver specific implementation of SD_CloseFxn().
| typedef int_fast16_t(* SD_ControlFxn) (SD_Handle handle, uint_fast16_t cmd, void *arg) | 
A function pointer to a driver specific implementation of SD_controlFxn().
| typedef uint_fast32_t(* SD_getNumSectorsFxn) (SD_Handle handle) | 
A function pointer to a driver specific implementation of SD_getNumSectorsFxn().
| typedef uint_fast32_t(* SD_getSectorSizeFxn) (SD_Handle handle) | 
A function pointer to a driver specific implementation of SD_getSectorSizeFxn().
| typedef void(* SD_InitFxn) (SD_Handle handle) | 
A function pointer to a driver specific implementation of SD_InitFxn().
| typedef int_fast16_t(* SD_InitializeFxn) (SD_Handle handle) | 
A function pointer to a driver specific implementation of SD_initializeFxn().
A function pointer to a driver specific implementation of SD_OpenFxn().
| typedef int_fast16_t(* SD_ReadFxn) (SD_Handle handle, void *buf, int_fast32_t sector, uint_fast32_t secCount) | 
A function pointer to a driver specific implementation of SD_readFxn().
| typedef int_fast16_t(* SD_WriteFxn) (SD_Handle handle, const void *buf, int_fast32_t sector, uint_fast32_t secCount) | 
A function pointer to a driver specific implementation of SD_writeFxn().
| typedef struct SD_FxnTable_ SD_FxnTable | 
The definition of a SD function table that contains the required set of functions to control a specific SD driver implementation.
| typedef struct SD_Config_ SD_Config | 
| enum SD_CardType_ | 
| void SD_close | ( | SD_Handle | handle | ) | 
| int_fast16_t SD_control | ( | SD_Handle | handle, | 
| uint_fast16_t | cmd, | ||
| void * | arg | ||
| ) | 
Function performs implementation specific features on a given SD_Handle.
Commands for SD_control can originate from SD.h or from implementation specific SD*.h (SDHostCC32XX.h etc.. ) files. While commands from SD.h are API portable across driver implementations, not all implementations may support all these commands. Conversely, commands from driver implementation specific SD*.h files add unique driver capabilities but are not API portable across all SD driver implementations.
Commands supported by SD.h follow a SD*_CMD naming convention.
Commands supported by SD*.h follow a SD*_CMD naming convention. Each control command defines arg differently. The types of arg are documented with each command.
See SD_control command codes for command codes.
See SD_control return status codes for status codes.
| handle | A SD handle returned from SD_open(). | 
| cmd | SD.h or SD*.h commands. | 
| arg | An optional R/W (read/write) command argument accompanied with cmd. | 
| uint_fast32_t SD_getNumSectors | ( | SD_Handle | handle | ) | 
A function pointer to a driver specific implementation of SD_getNumSectors(). Note: Total Card capacity is the (NumberOfSectors * SectorSize).
| handle | A SD handle returned from SD_open(). | 
| uint_fast32_t SD_getSectorSize | ( | SD_Handle | handle | ) | 
Function to obtain the sector size used to access the SD card.
| handle | A SD handle returned from SD_open(). | 
| void SD_init | ( | void | ) | 
This function initializes the SD driver.
| void SD_Params_init | ( | SD_Params * | params | ) | 
Function to initialize the SD_Params struct to its defaults.
| params | A pointer to SD_Params structure for initialization. | 
| int_fast16_t SD_initialize | ( | SD_Handle | handle | ) | 
A function pointer to a driver specific implementation of SD_initialize().
| handle | A SD handle returned from SD_open(). | 
A function pointer to a driver specific implementation of SD_open().
| index | Logical peripheral number for the SD indexed into the SD_config table. | 
| params | Pointer to a parameter block, if NULL it will use default values. All the fields in this structure are RO (read-only). | 
| int_fast16_t SD_read | ( | SD_Handle | handle, | 
| void * | buf, | ||
| int_fast32_t | sector, | ||
| uint_fast32_t | secCount | ||
| ) | 
A function pointer to a driver specific implementation of SD_read().
| handle | A SD handle returned from SD_open(). | 
| buf | Pointer to a buffer to read data into. | 
| sector | Starting sector on the disk to read from. | 
| secCount | Number of sectors to be read. | 
| int_fast16_t SD_write | ( | SD_Handle | handle, | 
| const void * | buf, | ||
| int_fast32_t | sector, | ||
| uint_fast32_t | secCount | ||
| ) | 
A function pointer to a driver specific implementation of SD_write().
| handle | A SD handle returned from SD_open(). | 
| buf | Pointer to a buffer containing data to write to disk. | 
| sector | Starting sector on the disk to write to. | 
| secCount | Number of sectors to be written. |