SimpleLink MCU SDK Driver APIs  tidrivers_msp43x_3_01_01_03
SD.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
87 #ifndef ti_drivers_SD__include
88 #define ti_drivers_SD__include
89 
90 #ifdef __cplusplus
91 extern "C" {
92 #endif
93 
94 #include <stdint.h>
95 
112 #define SD_CMD_RESERVED (32)
113 
126 #define SD_STATUS_RESERVED (-32)
127 
141 #define SD_STATUS_SUCCESS (0)
142 
149 #define SD_STATUS_ERROR (-1)
150 
158 #define SD_STATUS_UNDEFINEDCMD (-2)
159 
169 /* Add SD_CMD_<commands> here */
170 
178 typedef enum SD_CardType_ {
179  SD_NOCARD = 0,
180  SD_MMC = 1,
181  SD_SDSC = 2,
182  SD_SDHC = 3
183 } SD_CardType;
184 
188 typedef struct SD_Config_ *SD_Handle;
189 
199 /* SD Parameters */
200 typedef struct SD_Params_ {
201  void *custom;
202 } SD_Params;
203 
208 typedef void (*SD_CloseFxn) (SD_Handle handle);
209 
214 typedef int_fast16_t (*SD_ControlFxn) (SD_Handle handle,
215  uint_fast16_t cmd, void *arg);
216 
221 typedef uint_fast32_t (*SD_getNumSectorsFxn) (SD_Handle handle);
222 
227 typedef uint_fast32_t (*SD_getSectorSizeFxn) (void);
228 
233 typedef void (*SD_InitFxn) (SD_Handle handle);
234 
239 typedef int_fast16_t (*SD_InitializeFxn) (SD_Handle handle);
240 
245 typedef SD_Handle (*SD_OpenFxn) (SD_Handle handle, SD_Params *params);
246 
251 typedef int_fast16_t (*SD_ReadFxn) (SD_Handle handle, void *buf,
252  int_fast32_t sector, uint_fast32_t secCount);
253 
258 typedef int_fast16_t (*SD_WriteFxn) (SD_Handle handle, const void *buf,
259  int_fast32_t sector, uint_fast32_t secCount);
260 
266 typedef struct SD_FxnTable_ {
285 } SD_FxnTable;
286 
298 typedef struct SD_Config_ {
301 
303  void *object;
304 
306  void const *hwAttrs;
307 } SD_Config;
308 
318 extern void SD_close(SD_Handle handle);
319 
358 extern int_fast16_t SD_control(SD_Handle handle, uint_fast16_t cmd, void *arg);
359 
374 extern uint_fast32_t SD_getNumSectors(SD_Handle handle);
375 
387 extern uint_fast32_t SD_getSectorSize(SD_Handle handle);
388 
397 extern void SD_init(void);
398 
404 extern void SD_Params_init(SD_Params *params);
405 
417 extern int_fast16_t SD_initialize(SD_Handle handle);
418 
438 extern SD_Handle SD_open(uint_least8_t index, SD_Params *params);
439 
460 extern int_fast16_t SD_read(SD_Handle handle, void *buf,
461  int_fast32_t sector, uint_fast32_t secCount);
462 
483 extern int_fast16_t SD_write(SD_Handle handle, const void *buf,
484  int_fast32_t sector, uint_fast32_t secCount);
485 
486 #ifdef __cplusplus
487 }
488 #endif
489 
490 #endif /* ti_drivers_SD__include */
int_fast16_t SD_control(SD_Handle handle, uint_fast16_t cmd, void *arg)
Function performs implementation specific features on a given SD_Handle.
SD_ControlFxn controlFxn
Definition: SD.h:270
struct SD_Config_ * SD_Handle
A handle that is returned from a SD_open() call.
Definition: SD.h:188
int_fast16_t(* SD_InitializeFxn)(SD_Handle handle)
A function pointer to a driver specific implementation of SD_initializeFxn().
Definition: SD.h:239
SD Global configuration.
Definition: SD.h:298
uint_fast32_t SD_getSectorSize(SD_Handle handle)
Function to obtain the sector size used to access the SD card.
SD_Handle(* SD_OpenFxn)(SD_Handle handle, SD_Params *params)
A function pointer to a driver specific implementation of SD_OpenFxn().
Definition: SD.h:245
uint_fast32_t SD_getNumSectors(SD_Handle handle)
A function pointer to a driver specific implementation of SD_getNumSectors(). Note: Total Card capaci...
Definition: SD.h:179
SD_CloseFxn closeFxn
Definition: SD.h:268
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().
Definition: SD.h:258
void SD_init(void)
This function initializes the SD driver.
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().
Definition: SD.h:214
SD_WriteFxn writeFxn
Definition: SD.h:284
SD_InitFxn initFxn
Definition: SD.h:276
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().
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().
void SD_close(SD_Handle handle)
Function to close a SD peripheral specified by the SD handle.
SD_getSectorSizeFxn getSectorSizeFxn
Definition: SD.h:274
struct SD_Config_ SD_Config
SD Global configuration.
Definition: SD.h:180
SD_ReadFxn readFxn
Definition: SD.h:282
void(* SD_InitFxn)(SD_Handle handle)
A function pointer to a driver specific implementation of SD_InitFxn().
Definition: SD.h:233
SD_CardType_
SD Card type inserted.
Definition: SD.h:178
void * custom
Definition: SD.h:201
Definition: SD.h:182
SD_InitializeFxn initializeFxn
Definition: SD.h:278
struct SD_Params_ SD_Params
SD Parameters.
uint_fast32_t(* SD_getNumSectorsFxn)(SD_Handle handle)
A function pointer to a driver specific implementation of SD_getNumSectorsFxn().
Definition: SD.h:221
Definition: SD.h:181
SD_getNumSectorsFxn getNumSectorsFxn
Definition: SD.h:272
The definition of a SD function table that contains the required set of functions to control a specif...
Definition: SD.h:266
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().
Definition: SD.h:251
struct SD_FxnTable_ SD_FxnTable
The definition of a SD function table that contains the required set of functions to control a specif...
void const * hwAttrs
Definition: SD.h:306
enum SD_CardType_ SD_CardType
SD Card type inserted.
uint_fast32_t(* SD_getSectorSizeFxn)(void)
A function pointer to a driver specific implementation of SD_getSectorSizeFxn().
Definition: SD.h:227
SD_FxnTable const * fxnTablePtr
Definition: SD.h:300
void SD_Params_init(SD_Params *params)
Function to initialize the SD_Params struct to its defaults.
SD_OpenFxn openFxn
Definition: SD.h:280
SD_Handle SD_open(uint_least8_t index, SD_Params *params)
A function pointer to a driver specific implementation of SD_open().
SD Parameters.
Definition: SD.h:200
void(* SD_CloseFxn)(SD_Handle handle)
A function pointer to a driver specific implementation of SD_CloseFxn().
Definition: SD.h:208
void * object
Definition: SD.h:303
int_fast16_t SD_initialize(SD_Handle handle)
A function pointer to a driver specific implementation of SD_initialize().
Copyright 2016, Texas Instruments Incorporated