SDFatFS.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2019, 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 /*!****************************************************************************
33  * @file SDFatFS.h
34  *
35  * @brief File Allocation Table File System (FATFS) Driver
36  *
37  * The SDFatFS header file should be included in an application as follows:
38  * @code
39  * #include <ti/drivers/SDFatFS.h>
40  * #include <ti/drivers/SD.h>
41  * @endcode
42  *
43  * @anchor ti_drivers_SDFatFS_Overview
44  * # Overview #
45  *
46  * The SDFatFS driver is designed to hook into FatFs by implementing a
47  * set of functions that FatFs needs to call to perform basic block data
48  * transfers. This driver makes use of the SD driver for lower level disk IO
49  * operations.
50  *
51  * The only functions that should be called by the application are the
52  * standard driver framework functions (_open, _close, etc...).
53  *
54  * The application may use the FatFs APIs or the standard C
55  * runtime file I/O calls (fopen, fclose, etc...) given that SDFatFS_open has
56  * has been successfully called. After the SDFatFS_close API is called,
57  * ensure the application does NOT make any file I/O calls.
58  *
59  * ## Opening the driver #
60  *
61  * @code
62  * SDFatFS_Handle handle;
63  *
64  * handle = SDFatFS_open(CONFIG_SDFatFS0, driveNum, NULL);
65  * if (handle == NULL) {
66  * //Error opening SDFatFS driver
67  * while (1);
68  * }
69  * @endcode
70  *
71  * # Instrumentation #
72  *
73  * The SDFatFS driver interface produces log statements if
74  * instrumentation is enabled.
75  *
76  * Diagnostics Mask | Log details |
77  * ---------------- | ----------- |
78  * Diags_USER1 | basic operations performed |
79  * Diags_USER2 | detailed operations performed |
80  * ============================================================================
81  */
82 
83 #ifndef ti_drivers_SDFatFS__include
84 #define ti_drivers_SDFatFS__include
85 
86 #include <stdint.h>
87 
88 #include <ti/drivers/SD.h>
89 
90 #include <third_party/fatfs/ff.h>
91 #include <third_party/fatfs/diskio.h>
92 
93 #ifdef __cplusplus
94 extern "C" {
95 #endif
96 
101 typedef struct {
102  uint_fast32_t driveNum;
103  DSTATUS diskState;
104  FATFS filesystem; /* FATFS data object */
107 
119 typedef struct {
123 
124 
129 
140 extern SDFatFS_Handle SDFatFS_open(uint_least8_t idx, uint_least8_t drive);
141 
155 extern void SDFatFS_close(SDFatFS_Handle handle);
156 
160 extern void SDFatFS_init(void);
161 
162 #ifdef __cplusplus
163 }
164 #endif
165 
166 #endif /* ti_drivers_SDFatFS__include */
void SDFatFS_init(void)
SD_Handle sdHandle
Definition: SDFatFS.h:105
SD Global configuration.
Definition: SD.h:317
SDFatFS Global configuration.
Definition: SDFatFS.h:119
SDFatFS_Object * object
Definition: SDFatFS.h:121
SDFatFS_Config * SDFatFS_Handle
A handle that is returned from a SDFatFS_open() call.
Definition: SDFatFS.h:128
DSTATUS diskState
Definition: SDFatFS.h:103
SDFatFS_Handle SDFatFS_open(uint_least8_t idx, uint_least8_t drive)
Function to open a SDFatFS instance on the specified drive.
Secure Digital (SD) Driver.
void SDFatFS_close(SDFatFS_Handle handle)
Function to close a SDFatFS instance specified by the SDFatFS handle.
FATFS filesystem
Definition: SDFatFS.h:104
uint_fast32_t driveNum
Definition: SDFatFS.h:102
SDFatFS Object The application must not access any member variables of this structure! ...
Definition: SDFatFS.h:101
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale