Skip to content

Commit 7416c1d

Browse files
committed
[fatfs] Add Petit FatFs v0.03a module
1 parent 37abc03 commit 7416c1d

File tree

2 files changed

+141
-0
lines changed

2 files changed

+141
-0
lines changed

ext/chan/module_petit.lb

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Copyright (c) 2021, Niklas Hauser
5+
#
6+
# This file is part of the modm project.
7+
#
8+
# This Source Code Form is subject to the terms of the Mozilla Public
9+
# License, v. 2.0. If a copy of the MPL was not distributed with this
10+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
11+
# -----------------------------------------------------------------------------
12+
13+
def init(module):
14+
module.name = ":fatfs.petit"
15+
module.description = """
16+
# Petit FatFs: Tiny FAT Filesystem
17+
18+
Petit FatFs is a sub-set of FatFs module for tiny 8-bit microcontrollers. It can
19+
be incorporated into the tiny microcontrollers with limited memory even if the
20+
RAM size is less than sector size.
21+
22+
See http://elm-chan.org/fsw/ff/00index_p.html.
23+
24+
25+
## Configuration
26+
27+
To configure Petit FatFs for your project, create a `<pffconf_local.h>` file,
28+
which is included at the *beginning* of the config, thus overwriting the default
29+
settings. Please see the `modm/ext/fatfs-petit/pffconf.h` file for the available
30+
configuration options and their default values.
31+
32+
Example `<pffconf_local.h>` configuration:
33+
34+
```c
35+
// Enable directories: pf_opendir(), pf_readdir()
36+
#define PF_USE_DIR 1
37+
38+
// Enabling writing: pf_write()
39+
#define PF_USE_WRITE 1
40+
41+
// Use FAT12 file system
42+
#define PF_FS_FAT12 1
43+
#define PF_FS_FAT16 0
44+
#define PF_FS_FAT32 0
45+
```
46+
"""
47+
48+
def prepare(module, options):
49+
return True
50+
51+
def build(env):
52+
env.collect(":build:path.include", "modm/ext")
53+
env.outbasepath = "modm/ext/fatfs-petit"
54+
55+
env.copy("fatfs/tiny/source/diskio.h", "diskio.h")
56+
env.copy("fatfs/tiny/source/pff.h", "pff.h")
57+
env.copy("fatfs/tiny/source/pff.c", "pff.c")
58+
env.copy("fatfs/tiny/LICENSE.txt", "LICENSE.txt")
59+
60+
env.copy("pffconf.h")

ext/chan/pffconf.h

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*---------------------------------------------------------------------------/
2+
/ Petit FatFs - Configuration file
3+
/---------------------------------------------------------------------------*/
4+
5+
#ifndef PFCONF_DEF
6+
#define PFCONF_DEF 8088 /* Revision ID */
7+
8+
/* A header file that overwrites with local project settings. */
9+
#if __has_include(<pffconf_local.h>)
10+
#include <pffconf_local.h>
11+
#endif
12+
13+
/*---------------------------------------------------------------------------/
14+
/ Function Configurations (0:Disable, 1:Enable)
15+
/---------------------------------------------------------------------------*/
16+
17+
#ifndef PF_USE_READ
18+
# define PF_USE_READ 1 /* pf_read() function */
19+
#endif
20+
#ifndef PF_USE_DIR
21+
# define PF_USE_DIR 0 /* pf_opendir() and pf_readdir() function */
22+
#endif
23+
#ifndef PF_USE_LSEEK
24+
# define PF_USE_LSEEK 0 /* pf_lseek() function */
25+
#endif
26+
#ifndef PF_USE_WRITE
27+
# define PF_USE_WRITE 0 /* pf_write() function */
28+
#endif
29+
30+
#ifndef PF_FS_FAT12
31+
# define PF_FS_FAT12 0 /* FAT12 */
32+
#endif
33+
#ifndef PF_FS_FAT16
34+
# define PF_FS_FAT16 1 /* FAT16 */
35+
#endif
36+
#ifndef PF_FS_FAT32
37+
# define PF_FS_FAT32 0 /* FAT32 */
38+
#endif
39+
40+
41+
/*---------------------------------------------------------------------------/
42+
/ Locale and Namespace Configurations
43+
/---------------------------------------------------------------------------*/
44+
45+
#ifndef PF_USE_LCC
46+
# define PF_USE_LCC 0 /* Allow lower case ASCII and non-ASCII chars */
47+
#endif
48+
49+
#ifndef PF_CODE_PAGE
50+
# define PF_CODE_PAGE 437
51+
#endif
52+
/* The PF_CODE_PAGE specifies the code page to be used on the target system.
53+
/ SBCS code pages with PF_USE_LCC == 1 requiers a 128 byte of case conversion
54+
/ table. It might occupy RAM on some platforms, e.g. avr-gcc.
55+
/ When PF_USE_LCC == 0, PF_CODE_PAGE has no effect.
56+
/
57+
/ 437 - U.S.
58+
/ 720 - Arabic
59+
/ 737 - Greek
60+
/ 771 - KBL
61+
/ 775 - Baltic
62+
/ 850 - Latin 1
63+
/ 852 - Latin 2
64+
/ 855 - Cyrillic
65+
/ 857 - Turkish
66+
/ 860 - Portuguese
67+
/ 861 - Icelandic
68+
/ 862 - Hebrew
69+
/ 863 - Canadian French
70+
/ 864 - Arabic
71+
/ 865 - Nordic
72+
/ 866 - Russian
73+
/ 869 - Greek 2
74+
/ 932 - Japanese (DBCS)
75+
/ 936 - Simplified Chinese (DBCS)
76+
/ 949 - Korean (DBCS)
77+
/ 950 - Traditional Chinese (DBCS)
78+
*/
79+
80+
81+
#endif /* PF_CONF */

0 commit comments

Comments
 (0)