Skip to content

Commit 71206f0

Browse files
committed
stmhal: Move stmhal-specific FatFs routines/structs to fatfs_port.c.
1 parent 97a0846 commit 71206f0

3 files changed

Lines changed: 51 additions & 24 deletions

File tree

stmhal/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ SRC_C = \
156156
file.c \
157157
sdcard.c \
158158
diskio.c \
159+
fatfs_port.c \
159160
ffconf.c \
160161
lcd.c \
161162
accel.c \

stmhal/diskio.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,10 @@
3535
#include "py/runtime.h"
3636
#include "lib/fatfs/ff.h" /* FatFs lower layer API */
3737
#include "lib/fatfs/diskio.h" /* FatFs lower layer API */
38-
#include "rtc.h"
3938
#include "storage.h"
4039
#include "sdcard.h"
4140
#include "extmod/fsusermount.h"
4241

43-
const PARTITION VolToPart[] = {
44-
{0, 1}, // Logical drive 0 ==> Physical drive 0, 1st partition
45-
{1, 0}, // Logical drive 1 ==> Physical drive 1 (auto detection)
46-
{2, 0}, // Logical drive 2 ==> Physical drive 2 (auto detection)
47-
/*
48-
{0, 2}, // Logical drive 2 ==> Physical drive 0, 2nd partition
49-
{0, 3}, // Logical drive 3 ==> Physical drive 0, 3rd partition
50-
*/
51-
};
52-
53-
5442
/*-----------------------------------------------------------------------*/
5543
/* Initialize a Drive */
5644
/*-----------------------------------------------------------------------*/
@@ -282,15 +270,3 @@ DRESULT disk_ioctl (
282270
return RES_PARERR;
283271
}
284272
#endif
285-
286-
DWORD get_fattime (
287-
void
288-
)
289-
{
290-
rtc_init_finalise();
291-
RTC_TimeTypeDef time;
292-
RTC_DateTypeDef date;
293-
HAL_RTC_GetTime(&RTCHandle, &time, FORMAT_BIN);
294-
HAL_RTC_GetDate(&RTCHandle, &date, FORMAT_BIN);
295-
return ((2000 + date.Year - 1980) << 25) | ((date.Month) << 21) | ((date.Date) << 16) | ((time.Hours) << 11) | ((time.Minutes) << 5) | (time.Seconds / 2);
296-
}

stmhal/fatfs_port.c

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2013, 2014 Damien P. George
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#include "py/mphal.h"
28+
#include "py/runtime.h"
29+
#include "lib/fatfs/ff.h" /* FatFs lower layer API */
30+
#include "lib/fatfs/diskio.h" /* FatFs lower layer API */
31+
#include "rtc.h"
32+
33+
const PARTITION VolToPart[] = {
34+
{0, 1}, // Logical drive 0 ==> Physical drive 0, 1st partition
35+
{1, 0}, // Logical drive 1 ==> Physical drive 1 (auto detection)
36+
{2, 0}, // Logical drive 2 ==> Physical drive 2 (auto detection)
37+
/*
38+
{0, 2}, // Logical drive 2 ==> Physical drive 0, 2nd partition
39+
{0, 3}, // Logical drive 3 ==> Physical drive 0, 3rd partition
40+
*/
41+
};
42+
43+
DWORD get_fattime(void) {
44+
rtc_init_finalise();
45+
RTC_TimeTypeDef time;
46+
RTC_DateTypeDef date;
47+
HAL_RTC_GetTime(&RTCHandle, &time, FORMAT_BIN);
48+
HAL_RTC_GetDate(&RTCHandle, &date, FORMAT_BIN);
49+
return ((2000 + date.Year - 1980) << 25) | ((date.Month) << 21) | ((date.Date) << 16) | ((time.Hours) << 11) | ((time.Minutes) << 5) | (time.Seconds / 2);
50+
}

0 commit comments

Comments
 (0)