Skip to content

Commit 31e87b4

Browse files
authored
Merge pull request #13 from fpistm/R0.15
chore: update to stm32_mw_fatfs v4.0.0
2 parents bf405ba + a654c74 commit 31e87b4

26 files changed

+19741
-33820
lines changed

LICENSE.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright (c) 2015, ChaN, all right reserved.
2+
# Copyright (c) 2019 STMicroelectronics.
3+
4+
Redistribution and use in source and binary forms, with or without modification,
5+
are permitted provided that the following conditions are met:
6+
7+
1. Redistributions of source code must retain the above copyright notice, this
8+
list of conditions and the following disclaimer.
9+
10+
2. Redistributions in binary form must reproduce the above copyright notice,
11+
this list of conditions and the following disclaimer in the documentation and/or
12+
other materials provided with the distribution.
13+
14+
3. Neither the name of the copyright holder nor the names of its contributors
15+
may be used to endorse or promote products derived from this software without
16+
specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
22+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Licence.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

ffsystem/ffsystem_baremetal.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
******************************************************************************
3+
* @file ffsystem_baremetal.c
4+
* @author MCD Application Team
5+
* @brief ffsystem baremetal functions implementation
6+
******************************************************************************
7+
* @attention
8+
*
9+
* Copyright (C) 2018, ChaN, all right reserved
10+
* Copyright (c) 2023 STMicroelectronics
11+
  *
12+
  * This software is licensed under terms that can be found in the LICENSE file
13+
  * in the root directory of this software component.
14+
  * If no LICENSE file comes with this software, it is provided AS-IS.
15+
*
16+
******************************************************************************
17+
*/
18+
19+
/* Includes -------------------------------------------------------------*/
20+
#include "ff.h"
21+
#include <stdlib.h>
22+
23+
#if FF_FS_REENTRANT
24+
#error "The flag FF_FS_REENTRANT should be set to 0"
25+
#endif
26+
27+
/* Dynamic memory allocation */
28+
#if FF_USE_LFN == 3
29+
30+
/*------------------------------------------------------------------------*/
31+
/* Allocate a memory block */
32+
/*------------------------------------------------------------------------*/
33+
34+
void* ff_memalloc ( /* Returns pointer to the allocated memory block (null if not enough core) */
35+
UINT msize /* Number of bytes to allocate */
36+
)
37+
{
38+
return malloc((size_t)msize); /* Allocate a new memory block */
39+
}
40+
41+
42+
void ff_memfree (
43+
void* mblock /* Pointer to the memory block to free (no effect if null) */
44+
)
45+
{
46+
free(mblock); /* Free the memory block */
47+
}
48+
49+
#endif

ffsystem/ffsystem_cmsis_os.c

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
/**
2+
******************************************************************************
3+
* @file ffsystem_cmsis_os.c
4+
* @author MCD Application Team
5+
* @brief ffsystem cmsis_os functions implementation
6+
******************************************************************************
7+
* @attention
8+
*
9+
* Copyright (C) 2018, ChaN, all right reserved
10+
* Copyright (c) 2023 STMicroelectronics
11+
  *
12+
  * This software is licensed under terms that can be found in the LICENSE file
13+
  * in the root directory of this software component.
14+
  * If no LICENSE file comes with this software, it is provided AS-IS.
15+
*
16+
******************************************************************************
17+
*/
18+
19+
/* Includes -------------------------------------------------------------*/
20+
#include "ff.h"
21+
22+
#if FF_USE_LFN == 3
23+
#include "FreeRTOS.h"
24+
#endif
25+
26+
#if FF_FS_REENTRANT
27+
#include "cmsis_os2.h"
28+
#endif
29+
30+
/* Dynamic memory allocation */
31+
#if FF_USE_LFN == 3
32+
33+
/*------------------------------------------------------------------------*/
34+
/* Allocate/Free a Memory Block */
35+
/*------------------------------------------------------------------------*/
36+
37+
void* ff_memalloc ( /* Returns pointer to the allocated memory block (null if not enough core) */
38+
UINT msize /* Number of bytes to allocate */
39+
)
40+
{
41+
return (void *) pvPortMalloc((size_t)msize); /* Allocate a new memory block */
42+
}
43+
44+
45+
/*------------------------------------------------------------------------*/
46+
/* Free a memory block */
47+
/*------------------------------------------------------------------------*/
48+
49+
void ff_memfree (
50+
void* mblock /* Pointer to the memory block to free (no effect if null) */
51+
)
52+
{
53+
vPortFree(mblock); /* Free the memory block */
54+
}
55+
56+
#endif
57+
58+
59+
/* Mutal exclusion */
60+
#if FF_FS_REENTRANT
61+
62+
/* Definition table of Mutex */
63+
static osMutexId_t Mutex[FF_VOLUMES + 1]; /* Table of mutex ID */
64+
65+
/*------------------------------------------------------------------------*/
66+
/* Create a Mutex */
67+
/*------------------------------------------------------------------------*/
68+
/* This function is called in f_mount function to create a new mutex
69+
/ or semaphore for the volume. When a 0 is returned, the f_mount function
70+
/ fails with FR_INT_ERR.
71+
*/
72+
73+
int ff_mutex_create ( /* Returns 1:Function succeeded or 0:Could not create the mutex */
74+
int vol /* Mutex ID: Volume mutex (0 to FF_VOLUMES - 1) or system mutex (FF_VOLUMES) */
75+
)
76+
{
77+
int ret;
78+
const osMutexAttr_t attr = {
79+
"FatFsMutex",
80+
osMutexRecursive,
81+
NULL,
82+
0U
83+
};
84+
85+
Mutex[vol] = osMutexNew(&attr);
86+
if (Mutex[vol] != NULL)
87+
{
88+
ret = 1;
89+
}
90+
else
91+
{
92+
ret = 0;
93+
}
94+
95+
return ret;
96+
}
97+
98+
99+
/*------------------------------------------------------------------------*/
100+
/* Delete a Mutex */
101+
/*------------------------------------------------------------------------*/
102+
/* This function is called in f_mount function to delete a mutex or
103+
/ semaphore of the volume created with ff_mutex_create function.
104+
*/
105+
106+
void ff_mutex_delete ( /* Returns 1:Function succeeded or 0:Could not delete due to an error */
107+
int vol /* Mutex ID: Volume mutex (0 to FF_VOLUMES - 1) or system mutex (FF_VOLUMES) */
108+
)
109+
{
110+
osMutexDelete(Mutex[vol]);
111+
}
112+
113+
114+
/*------------------------------------------------------------------------*/
115+
/* Request a Grant to Access the Volume */
116+
/*------------------------------------------------------------------------*/
117+
/* This function is called on enter file functions to lock the volume.
118+
/ When a 0 is returned, the file function fails with FR_TIMEOUT.
119+
*/
120+
121+
int ff_mutex_take ( /* Returns 1:Succeeded or 0:Timeout */
122+
int vol /* Mutex ID: Volume mutex (0 to FF_VOLUMES - 1) or system mutex (FF_VOLUMES) */
123+
)
124+
{
125+
int ret;
126+
127+
if(osMutexAcquire(Mutex[vol], FF_FS_TIMEOUT) == osOK)
128+
{
129+
ret = 1;
130+
}
131+
else
132+
{
133+
ret = 0;
134+
}
135+
136+
return ret;
137+
}
138+
139+
/*------------------------------------------------------------------------*/
140+
/* Release a Grant to Access the Volume */
141+
/*------------------------------------------------------------------------*/
142+
/* This function is called on leave file functions to unlock the volume.
143+
*/
144+
145+
void ff_mutex_give (
146+
int vol /* Mutex ID: Volume mutex (0 to FF_VOLUMES - 1) or system mutex (FF_VOLUMES) */
147+
)
148+
{
149+
osMutexRelease(Mutex[vol]);
150+
}
151+
#endif

ffsystem/ffsystem_template.c

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/*------------------------------------------------------------------------*/
2+
/* A Sample Code of User Provided OS Dependent Functions for FatFs */
3+
/*------------------------------------------------------------------------*/
4+
5+
#include "ff.h"
6+
7+
8+
#if FF_USE_LFN == 3 /* Use dynamic memory allocation */
9+
10+
/*------------------------------------------------------------------------*/
11+
/* Allocate/Free a Memory Block */
12+
/*------------------------------------------------------------------------*/
13+
14+
15+
void* ff_memalloc ( /* Returns pointer to the allocated memory block (null if not enough core) */
16+
UINT msize /* Number of bytes to allocate */
17+
)
18+
{
19+
void* mem_ptr = NULL; /* Memory block to be allocated */
20+
21+
return mem_ptr;
22+
}
23+
24+
25+
void ff_memfree (
26+
void* mblock /* Pointer to the memory block to free (no effect if null) */
27+
)
28+
{
29+
free(mblock); /* Free the memory block */
30+
}
31+
32+
#endif
33+
34+
35+
36+
37+
#if FF_FS_REENTRANT /* Mutal exclusion */
38+
/*------------------------------------------------------------------------*/
39+
/* Create a Mutex */
40+
/*------------------------------------------------------------------------*/
41+
/* This function is called in f_mount function to create a new mutex
42+
/ or semaphore for the volume. When a 0 is returned, the f_mount function
43+
/ fails with FR_INT_ERR.
44+
*/
45+
46+
int ff_mutex_create ( /* Returns 1:Function succeeded or 0:Could not create the mutex */
47+
int vol /* Mutex ID: Volume mutex (0 to FF_VOLUMES - 1) or system mutex (FF_VOLUMES) */
48+
)
49+
{
50+
return 1;
51+
}
52+
53+
54+
/*------------------------------------------------------------------------*/
55+
/* Delete a Mutex */
56+
/*------------------------------------------------------------------------*/
57+
/* This function is called in f_mount function to delete a mutex or
58+
/ semaphore of the volume created with ff_mutex_create function.
59+
*/
60+
61+
void ff_mutex_delete ( /* Returns 1:Function succeeded or 0:Could not delete due to an error */
62+
int vol /* Mutex ID: Volume mutex (0 to FF_VOLUMES - 1) or system mutex (FF_VOLUMES) */
63+
)
64+
{
65+
return 1;
66+
}
67+
68+
69+
/*------------------------------------------------------------------------*/
70+
/* Request a Grant to Access the Volume */
71+
/*------------------------------------------------------------------------*/
72+
/* This function is called on enter file functions to lock the volume.
73+
/ When a 0 is returned, the file function fails with FR_TIMEOUT.
74+
*/
75+
76+
int ff_mutex_take ( /* Returns 1:Succeeded or 0:Timeout */
77+
int vol /* Mutex ID: Volume mutex (0 to FF_VOLUMES - 1) or system mutex (FF_VOLUMES) */
78+
)
79+
{
80+
return 1;
81+
}
82+
83+
84+
85+
/*------------------------------------------------------------------------*/
86+
/* Release a Grant to Access the Volume */
87+
/*------------------------------------------------------------------------*/
88+
/* This function is called on leave file functions to unlock the volume.
89+
*/
90+
91+
void ff_mutex_give (
92+
int vol /* Mutex ID: Volume mutex (0 to FF_VOLUMES - 1) or system mutex (FF_VOLUMES) */
93+
)
94+
{
95+
return 1;
96+
}
97+
98+
#endif /* FF_FS_REENTRANT */
99+

0 commit comments

Comments
 (0)