-
Notifications
You must be signed in to change notification settings - Fork 7
FatFS
gicking edited this page Feb 8, 2018
·
2 revisions
back to Command Reference
Read/write to SD card via the FatFS library v0.13 by ChaN (thanks!!!).
Uses software SPI (=bitbanging) for interfacing with SD card. This is rather slow (measured 27kB/s), but requires no dedicated SPI and is pretty much fool-proof (porting the generic example took less than 1h). If you only require less functionality, use PetitFS instead.
Notes:
- SD cards generally use 3.3V -> assert correct supply and signal voltage
- define required macros for bitbanging via
config.h
(see example)-
#define INIT_PORT()
configure pins for bitbang: CSN,MOSI,SCK=OUTPUT, MISO=INPUT_PULLUP -
#define SPI_MOSI
MOSI pin output register, e.g. pinOutputReg(&PORT_C,pin6) -
#define SPI_MISO
MISO pin input register, e.g. pinInputReg(&PORT_C,pin7) -
#define SPI_SCK
CLK pin output register, e.g. pinOutputReg(&PORT_C,pin5) -
#define SPI_SD_CSN
Chip select output register, e.g. pinOutputReg(&PORT_F,pin0)
-
Commands (not all enabled by default, see file ffconf.h
):
-
Misc
-
f_print_error()
- print textual error message
-
-
File Access
- f_open() - Open/Create a file
- f_close() - Close an open file
- f_read() - Read data from the file
- f_write() - Write data to the file
- f_lseek() - Move read/write pointer, Expand size
- f_truncate() - Truncate file size
- f_sync() - Flush cached data
- f_forward() - Forward data to the stream
- f_expand() - Allocate a contiguous block to the file
- f_gets() - Read a string
- f_putc() - Write a character
- f_puts() - Write a string
- f_printf() - Write a formatted string
- f_tell() - Get current read/write pointer
- f_eof() - Test for end-of-file
- f_size() - Get size
- f_error() - Test for an error
-
Directory Access
- f_opendir() - Open a directory
- f_closedir() - Close an open directory
- f_readdir() - Read an directory item
- f_findfirst() - Open a directory and read the first item matched
- f_findnext() - Read a next item matched
-
File and Directory Management
- f_stat() - Check existance of a file or sub-directory
- f_unlink() - Remove a file or sub-directory
- f_rename() - Rename/Move a file or sub-directory
- f_chmod() - Change attribute of a file or sub-directory
- f_utime() - Change timestamp of a file or sub-directory
- f_mkdir() - Create a sub-directory
- f_chdir() - Change current directory
- f_chdrive() - Change current drive
- f_getcwd() - Retrieve the current directory and drive
-
Volume Management and System Configuration
- f_mount() - Register/Unregister the work area of the volume
- f_mkfs() - Create an FAT volume on the logical drive
- f_fdisk() - Create logical drives on the physical drive
- f_getfree() - Get total size and free size on the volume
- f_getlabel() - Get volume label
- f_setlabel() - Set volume label
- f_setcp() - Set active code page
-
Getting Started
-
- General Commands
- Libraries
- LCD BTHQ21605V
- poti AD5280
- poti AD5282
- freemodbus
- PetitFS SD-card (min)
- FatFS: SD card (full)
- Board Specific
-
- Universal
- Board Specific