Skip to content

Commit 39ff700

Browse files
committed
FatFS moved
# Conflicts: # OS/FileSystem/File.cpp
1 parent 693a06d commit 39ff700

14 files changed

Lines changed: 19235 additions & 28 deletions

File tree

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,3 @@
77
[submodule "Library/cb0r"]
88
path = Library/cb0r
99
url = https://github.com/203-Systems/cb0r.git
10-
[submodule "Library/FatFs"]
11-
path = Library/FatFs
12-
url = https://github.com/abbrev/fatfs.git

Library/FatFs

Lines changed: 0 additions & 1 deletion
This file was deleted.

OS/FileSystem/CMakeLists.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
file(GLOB_RECURSE FILE_HEADERS "*.h")
22
set(FILE_SOURCES
33
File.cpp
4-
diskio.cpp
54
)
65

7-
set(FATFS_DIR ${CMAKE_SOURCE_DIR}/Library/FatFs/)
8-
9-
# FATFS_SOURCES - exclude the template diskio.c, use our own
6+
# Local FatFS sources
107
set(FATFS_SOURCES
11-
${FATFS_DIR}/source/ff.c
8+
FatFS/ff.c
9+
FatFS/ffunicode.c
10+
FatFS/diskio.cpp
11+
FatFS/ffsystem.c
1212
)
1313

1414
add_library(MatrixOSFile
@@ -19,7 +19,7 @@ add_library(MatrixOSFile
1919

2020
target_include_directories(MatrixOSFile PUBLIC
2121
${CMAKE_CURRENT_SOURCE_DIR}
22-
${FATFS_DIR}/source
22+
${CMAKE_CURRENT_SOURCE_DIR}/FatFS
2323
)
2424

2525
target_link_libraries(MatrixOSFile PUBLIC MatrixOSInterface MatrixOSAPPInterface)

OS/FileSystem/FatFS/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# FatFS for MatrixOS
2+
3+
This directory contains a copy of the FatFS library with MatrixOS-specific configuration.
4+
5+
## Source
6+
7+
Original FatFS library: http://elm-chan.org/fsw/ff/00index_e.html
8+
GitHub mirror: https://github.com/abbrev/fatfs
9+
10+
## MatrixOS Modifications
11+
12+
- **`ffconf.h`**: Custom configuration with Long File Name (LFN) support enabled
13+
- `FF_USE_LFN = 2` - Enables long filenames with dynamic stack buffer
14+
- `FF_CODE_PAGE = 437` - U.S. ASCII code page

OS/FileSystem/FatFS/diskio.h

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*-----------------------------------------------------------------------/
2+
/ Low level disk interface modlue include file (C)ChaN, 2025 /
3+
/-----------------------------------------------------------------------*/
4+
5+
#ifndef _DISKIO_DEFINED
6+
#define _DISKIO_DEFINED
7+
8+
#ifdef __cplusplus
9+
extern "C" {
10+
#endif
11+
12+
/* Status of Disk Functions */
13+
typedef BYTE DSTATUS;
14+
15+
/* Results of Disk Functions */
16+
typedef enum {
17+
RES_OK = 0, /* 0: Successful */
18+
RES_ERROR, /* 1: R/W Error */
19+
RES_WRPRT, /* 2: Write Protected */
20+
RES_NOTRDY, /* 3: Not Ready */
21+
RES_PARERR /* 4: Invalid Parameter */
22+
} DRESULT;
23+
24+
25+
/*---------------------------------------*/
26+
/* Prototypes for disk control functions */
27+
28+
29+
DSTATUS disk_initialize (BYTE pdrv);
30+
DSTATUS disk_status (BYTE pdrv);
31+
DRESULT disk_read (BYTE pdrv, BYTE* buff, LBA_t sector, UINT count);
32+
DRESULT disk_write (BYTE pdrv, const BYTE* buff, LBA_t sector, UINT count);
33+
DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
34+
35+
36+
/* Disk Status Bits (DSTATUS) */
37+
38+
#define STA_NOINIT 0x01 /* Drive not initialized */
39+
#define STA_NODISK 0x02 /* No medium in the drive */
40+
#define STA_PROTECT 0x04 /* Write protected */
41+
42+
43+
/* Command code for disk_ioctrl fucntion */
44+
45+
/* Generic command (Used by FatFs) */
46+
#define CTRL_SYNC 0 /* Complete pending write process (needed at FF_FS_READONLY == 0) */
47+
#define GET_SECTOR_COUNT 1 /* Get media size (needed at FF_USE_MKFS == 1) */
48+
#define GET_SECTOR_SIZE 2 /* Get sector size (needed at FF_MAX_SS != FF_MIN_SS) */
49+
#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at FF_USE_MKFS == 1) */
50+
#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at FF_USE_TRIM == 1) */
51+
52+
/* Generic command (Not used by FatFs) */
53+
#define CTRL_POWER 5 /* Get/Set power status */
54+
#define CTRL_LOCK 6 /* Lock/Unlock media removal */
55+
#define CTRL_EJECT 7 /* Eject media */
56+
#define CTRL_FORMAT 8 /* Create physical format on the media */
57+
58+
/* MMC/SDC specific ioctl command (Not used by FatFs) */
59+
#define MMC_GET_TYPE 10 /* Get card type */
60+
#define MMC_GET_CSD 11 /* Get CSD */
61+
#define MMC_GET_CID 12 /* Get CID */
62+
#define MMC_GET_OCR 13 /* Get OCR */
63+
#define MMC_GET_SDSTAT 14 /* Get SD status */
64+
#define ISDIO_READ 55 /* Read data form SD iSDIO register */
65+
#define ISDIO_WRITE 56 /* Write data to SD iSDIO register */
66+
#define ISDIO_MRITE 57 /* Masked write data to SD iSDIO register */
67+
68+
/* ATA/CF specific ioctl command (Not used by FatFs) */
69+
#define ATA_GET_REV 20 /* Get F/W revision */
70+
#define ATA_GET_MODEL 21 /* Get model name */
71+
#define ATA_GET_SN 22 /* Get serial number */
72+
73+
#ifdef __cplusplus
74+
}
75+
#endif
76+
77+
#endif

0 commit comments

Comments
 (0)