1
1
/**
2
2
******************************************************************************
3
- * @file sd_diskio .c
3
+ * @file sd_diskio_template_bspv1 .c
4
4
* @author MCD Application Team
5
- * @version V2.0.2
6
- * @date 10-November-2017
7
- * @brief SD Disk I/O driver
5
+ * @brief SD Disk I/O template driver based on BSP v1 api. This file needs
6
+ * to be renamed and copied into the application project alongside
7
+ * the respective header file
8
8
******************************************************************************
9
9
* @attention
10
10
*
11
- * <h2><center>© Copyright (c) 2017 STMicroelectronics International N.V.
12
- * All rights reserved.</center></h2>
11
+ * Copyright (c) 2017-2019 STMicroelectronics. All rights reserved.
13
12
*
14
- * Redistribution and use in source and binary forms, with or without
15
- * modification, are permitted, provided that the following conditions are met:
16
- *
17
- * 1. Redistribution of source code must retain the above copyright notice,
18
- * this list of conditions and the following disclaimer.
19
- * 2. Redistributions in binary form must reproduce the above copyright notice,
20
- * this list of conditions and the following disclaimer in the documentation
21
- * and/or other materials provided with the distribution.
22
- * 3. Neither the name of STMicroelectronics nor the names of other
23
- * contributors to this software may be used to endorse or promote products
24
- * derived from this software without specific written permission.
25
- * 4. This software, including modifications and/or derivative works of this
26
- * software, must execute solely and exclusively on microcontroller or
27
- * microprocessor devices manufactured by or for STMicroelectronics.
28
- * 5. Redistribution and use of this software other than as permitted under
29
- * this license is void and will automatically terminate your rights under
30
- * this license.
31
- *
32
- * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
33
- * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
34
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
35
- * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
36
- * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
37
- * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
38
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
39
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
40
- * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
41
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
42
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
43
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13
+ * This software component is licensed by ST under BSD 3-Clause license,
14
+ * the "License"; You may not use this file except in compliance with the
15
+ * License. You may obtain a copy of the License at:
16
+ * opensource.org/licenses/BSD-3-Clause
44
17
*
45
18
******************************************************************************
46
- */
47
-
19
+ **/
48
20
/* Includes ------------------------------------------------------------------*/
49
21
#include "ff_gen_drv.h"
50
22
#include "sd_diskio.h"
61
33
#define SD_TIMEOUT 30 * 1000
62
34
#endif
63
35
64
- /* Block Size in Bytes */
65
36
#define SD_DEFAULT_BLOCK_SIZE 512
66
37
67
38
/*
@@ -105,7 +76,6 @@ const Diskio_drvTypeDef SD_Driver =
105
76
/* Private functions ---------------------------------------------------------*/
106
77
static DSTATUS SD_CheckStatus (BYTE lun )
107
78
{
108
- (void )lun ;
109
79
Stat = STA_NOINIT ;
110
80
111
81
if (BSP_SD_GetCardState () == MSD_OK )
@@ -125,6 +95,7 @@ DSTATUS SD_initialize(BYTE lun)
125
95
{
126
96
Stat = STA_NOINIT ;
127
97
#if !defined(DISABLE_SD_INIT )
98
+
128
99
if (BSP_SD_Init () == MSD_OK )
129
100
{
130
101
Stat = SD_CheckStatus (lun );
@@ -156,7 +127,6 @@ DSTATUS SD_status(BYTE lun)
156
127
*/
157
128
DRESULT SD_read (BYTE lun , BYTE * buff , DWORD sector , UINT count )
158
129
{
159
- (void )lun ;
160
130
DRESULT res = RES_ERROR ;
161
131
162
132
if (BSP_SD_ReadBlocks ((uint32_t * )buff ,
@@ -169,6 +139,7 @@ DRESULT SD_read(BYTE lun, BYTE *buff, DWORD sector, UINT count)
169
139
}
170
140
res = RES_OK ;
171
141
}
142
+
172
143
return res ;
173
144
}
174
145
@@ -183,7 +154,6 @@ DRESULT SD_read(BYTE lun, BYTE *buff, DWORD sector, UINT count)
183
154
#if _USE_WRITE == 1
184
155
DRESULT SD_write (BYTE lun , const BYTE * buff , DWORD sector , UINT count )
185
156
{
186
- (void )lun ;
187
157
DRESULT res = RES_ERROR ;
188
158
189
159
if (BSP_SD_WriteBlocks ((uint32_t * )buff ,
@@ -196,6 +166,7 @@ DRESULT SD_write(BYTE lun, const BYTE *buff, DWORD sector, UINT count)
196
166
}
197
167
res = RES_OK ;
198
168
}
169
+
199
170
return res ;
200
171
}
201
172
#endif /* _USE_WRITE == 1 */
@@ -210,9 +181,9 @@ DRESULT SD_write(BYTE lun, const BYTE *buff, DWORD sector, UINT count)
210
181
#if _USE_IOCTL == 1
211
182
DRESULT SD_ioctl (BYTE lun , BYTE cmd , void * buff )
212
183
{
213
- (void )lun ;
214
184
DRESULT res = RES_ERROR ;
215
- SD_CardInfo CardInfo ;
185
+ BSP_SD_CardInfo CardInfo ;
186
+
216
187
if (Stat & STA_NOINIT ) return RES_NOTRDY ;
217
188
218
189
switch (cmd )
@@ -240,7 +211,7 @@ DRESULT SD_ioctl(BYTE lun, BYTE cmd, void *buff)
240
211
case GET_BLOCK_SIZE :
241
212
BSP_SD_GetCardInfo (& CardInfo );
242
213
* (DWORD * )buff = CardInfo .LogBlockSize / SD_DEFAULT_BLOCK_SIZE ;
243
- res = RES_OK ;
214
+ res = RES_OK ;
244
215
break ;
245
216
246
217
default :
0 commit comments