Skip to content

Commit 9915bd3

Browse files
committed
chore: update to stm32_mw_fatfs v2.1.4
FatFs R0.12C modified by ST Signed-off-by: Frederic Pillon <[email protected]>
1 parent ae903ad commit 9915bd3

File tree

15 files changed

+325
-359
lines changed

15 files changed

+325
-359
lines changed

src/diskio.c

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,46 +10,6 @@
1010
/* storage control modules to the FatFs module with a defined API. */
1111
/*-----------------------------------------------------------------------*/
1212

13-
/**
14-
******************************************************************************
15-
*
16-
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics International N.V.
17-
* All rights reserved.</center></h2>
18-
*
19-
* Redistribution and use in source and binary forms, with or without
20-
* modification, are permitted, provided that the following conditions are met:
21-
*
22-
* 1. Redistribution of source code must retain the above copyright notice,
23-
* this list of conditions and the following disclaimer.
24-
* 2. Redistributions in binary form must reproduce the above copyright notice,
25-
* this list of conditions and the following disclaimer in the documentation
26-
* and/or other materials provided with the distribution.
27-
* 3. Neither the name of STMicroelectronics nor the names of other
28-
* contributors to this software may be used to endorse or promote products
29-
* derived from this software without specific written permission.
30-
* 4. This software, including modifications and/or derivative works of this
31-
* software, must execute solely and exclusively on microcontroller or
32-
* microprocessor devices manufactured by or for STMicroelectronics.
33-
* 5. Redistribution and use of this software other than as permitted under
34-
* this license is void and will automatically terminate your rights under
35-
* this license.
36-
*
37-
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
38-
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
39-
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
40-
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
41-
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
42-
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
43-
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
44-
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
45-
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
46-
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
47-
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
48-
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49-
*
50-
******************************************************************************
51-
*/
52-
5313
/* Includes ------------------------------------------------------------------*/
5414
#include "diskio.h"
5515
#include "ff_gen_drv.h"

src/drivers/sd_diskio.c

Lines changed: 16 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,22 @@
11
/**
22
******************************************************************************
3-
* @file sd_diskio.c
3+
* @file sd_diskio_template_bspv1.c
44
* @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
88
******************************************************************************
99
* @attention
1010
*
11-
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics International N.V.
12-
* All rights reserved.</center></h2>
11+
* Copyright (c) 2017-2019 STMicroelectronics. All rights reserved.
1312
*
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
4417
*
4518
******************************************************************************
46-
*/
47-
19+
**/
4820
/* Includes ------------------------------------------------------------------*/
4921
#include "ff_gen_drv.h"
5022
#include "sd_diskio.h"
@@ -61,7 +33,6 @@
6133
#define SD_TIMEOUT 30 * 1000
6234
#endif
6335

64-
/* Block Size in Bytes */
6536
#define SD_DEFAULT_BLOCK_SIZE 512
6637

6738
/*
@@ -105,7 +76,6 @@ const Diskio_drvTypeDef SD_Driver =
10576
/* Private functions ---------------------------------------------------------*/
10677
static DSTATUS SD_CheckStatus(BYTE lun)
10778
{
108-
(void)lun;
10979
Stat = STA_NOINIT;
11080

11181
if(BSP_SD_GetCardState() == MSD_OK)
@@ -125,6 +95,7 @@ DSTATUS SD_initialize(BYTE lun)
12595
{
12696
Stat = STA_NOINIT;
12797
#if !defined(DISABLE_SD_INIT)
98+
12899
if(BSP_SD_Init() == MSD_OK)
129100
{
130101
Stat = SD_CheckStatus(lun);
@@ -156,7 +127,6 @@ DSTATUS SD_status(BYTE lun)
156127
*/
157128
DRESULT SD_read(BYTE lun, BYTE *buff, DWORD sector, UINT count)
158129
{
159-
(void)lun;
160130
DRESULT res = RES_ERROR;
161131

162132
if(BSP_SD_ReadBlocks((uint32_t*)buff,
@@ -169,6 +139,7 @@ DRESULT SD_read(BYTE lun, BYTE *buff, DWORD sector, UINT count)
169139
}
170140
res = RES_OK;
171141
}
142+
172143
return res;
173144
}
174145

@@ -183,7 +154,6 @@ DRESULT SD_read(BYTE lun, BYTE *buff, DWORD sector, UINT count)
183154
#if _USE_WRITE == 1
184155
DRESULT SD_write(BYTE lun, const BYTE *buff, DWORD sector, UINT count)
185156
{
186-
(void)lun;
187157
DRESULT res = RES_ERROR;
188158

189159
if(BSP_SD_WriteBlocks((uint32_t*)buff,
@@ -196,6 +166,7 @@ DRESULT SD_write(BYTE lun, const BYTE *buff, DWORD sector, UINT count)
196166
}
197167
res = RES_OK;
198168
}
169+
199170
return res;
200171
}
201172
#endif /* _USE_WRITE == 1 */
@@ -210,9 +181,9 @@ DRESULT SD_write(BYTE lun, const BYTE *buff, DWORD sector, UINT count)
210181
#if _USE_IOCTL == 1
211182
DRESULT SD_ioctl(BYTE lun, BYTE cmd, void *buff)
212183
{
213-
(void)lun;
214184
DRESULT res = RES_ERROR;
215-
SD_CardInfo CardInfo;
185+
BSP_SD_CardInfo CardInfo;
186+
216187
if (Stat & STA_NOINIT) return RES_NOTRDY;
217188

218189
switch (cmd)
@@ -240,7 +211,7 @@ DRESULT SD_ioctl(BYTE lun, BYTE cmd, void *buff)
240211
case GET_BLOCK_SIZE :
241212
BSP_SD_GetCardInfo(&CardInfo);
242213
*(DWORD*)buff = CardInfo.LogBlockSize / SD_DEFAULT_BLOCK_SIZE;
243-
res = RES_OK;
214+
res = RES_OK;
244215
break;
245216

246217
default:

src/drivers/sd_diskio.h

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,27 @@
11
/**
22
******************************************************************************
3-
* @file sd_diskio.h
3+
* @file sd_diskio_tempalte.h
44
* @author MCD Application Team
5-
* @version V2.0.2
6-
* @date 10-November-2017
7-
* @brief Header for sd_diskio.c module.
5+
* @brief Header for sd_diskio_template.c module.This file needs to be
6+
customized then copied under the application project
87
******************************************************************************
98
* @attention
109
*
11-
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics International N.V.
12-
* All rights reserved.</center></h2>
10+
* Copyright (c) 2017 STMicroelectronics. All rights reserved.
1311
*
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.
12+
* This software component is licensed by ST under BSD 3-Clause license,
13+
* the "License"; You may not use this file except in compliance with the
14+
* License. You may obtain a copy of the License at:
15+
* opensource.org/licenses/BSD-3-Clause
4416
*
4517
******************************************************************************
46-
*/
47-
18+
**/
4819
/* Define to prevent recursive inclusion -------------------------------------*/
4920
#ifndef __SD_DISKIO_H
5021
#define __SD_DISKIO_H
5122

5223
/* Includes ------------------------------------------------------------------*/
24+
#include "stm32xxxxx_{eval}{discovery}_sd.h"
5325
/* Exported types ------------------------------------------------------------*/
5426
/* Exported constants --------------------------------------------------------*/
5527
/* Exported functions ------------------------------------------------------- */

src/ff.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3218,16 +3218,27 @@ FRESULT validate ( /* Returns FR_OK or FR_INVALID_OBJECT */
32183218
FATFS** fs /* Pointer to pointer to the owner file system object to return */
32193219
)
32203220
{
3221-
FRESULT res;
3221+
FRESULT res = FR_INVALID_OBJECT;
32223222

3223-
if (!obj || !obj->fs || !obj->fs->fs_type || obj->fs->id != obj->id || (disk_status(obj->fs->drv) & STA_NOINIT)) {
3224-
*fs = 0;
3225-
res = FR_INVALID_OBJECT; /* The object is invalid */
3226-
} else {
3227-
*fs = obj->fs; /* Owner file sytem object */
3228-
ENTER_FF(obj->fs); /* Lock file system */
3229-
res = FR_OK; /* Valid object */
3223+
3224+
if (obj && obj->fs && obj->fs->fs_type && obj->id == obj->fs->id) { /* Test if the object is valid */
3225+
#if _FS_REENTRANT
3226+
if (lock_fs(obj->fs)) { /* Obtain the filesystem object */
3227+
if (!(disk_status(obj->fs->drv) & STA_NOINIT)) { /* Test if the phsical drive is kept initialized */
3228+
res = FR_OK;
3229+
} else {
3230+
unlock_fs(obj->fs, FR_OK);
3231+
}
3232+
} else {
3233+
res = FR_TIMEOUT;
3234+
}
3235+
#else
3236+
if (!(disk_status(obj->fs->drv) & STA_NOINIT)) { /* Test if the phsical drive is kept initialized */
3237+
res = FR_OK;
3238+
}
3239+
#endif
32303240
}
3241+
*fs = (res == FR_OK) ? obj->fs : 0; /* Corresponding filesystem object */
32313242
return res;
32323243
}
32333244

src/ff_gen_drv.c

Lines changed: 7 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,19 @@
22
******************************************************************************
33
* @file ff_gen_drv.c
44
* @author MCD Application Team
5-
* @version V2.0.2
6-
* @date 10-November-2017
75
* @brief FatFs generic low level driver.
8-
******************************************************************************
6+
*****************************************************************************
97
* @attention
108
*
11-
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics International N.V.
12-
* All rights reserved.</center></h2>
13-
*
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.
9+
* Copyright (c) 2017 STMicroelectronics. All rights reserved.
3110
*
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.
11+
* This software component is licensed by ST under BSD 3-Clause license,
12+
* the "License"; You may not use this file except in compliance with the
13+
* License. You may obtain a copy of the License at:
14+
* opensource.org/licenses/BSD-3-Clause
4415
*
4516
******************************************************************************
46-
*/
47-
17+
**/
4818
/* Includes ------------------------------------------------------------------*/
4919
#include "ff_gen_drv.h"
5020

@@ -109,7 +79,6 @@ uint8_t FATFS_LinkDriver(const Diskio_drvTypeDef *drv, char *path)
10979
*/
11080
uint8_t FATFS_UnLinkDriverEx(char *path, uint8_t lun)
11181
{
112-
(void)lun;
11382
uint8_t DiskNum = 0;
11483
uint8_t ret = 1;
11584

0 commit comments

Comments
 (0)