Prusa MINI Firmware overview
|
#include "integer.h"
#include "ffconf.h"
Go to the source code of this file.
|
enum | FRESULT {
FR_OK = 0,
FR_DISK_ERR,
FR_INT_ERR,
FR_NOT_READY,
FR_NO_FILE,
FR_NO_PATH,
FR_INVALID_NAME,
FR_DENIED,
FR_EXIST,
FR_INVALID_OBJECT,
FR_WRITE_PROTECTED,
FR_INVALID_DRIVE,
FR_NOT_ENABLED,
FR_NO_FILESYSTEM,
FR_MKFS_ABORTED,
FR_TIMEOUT,
FR_LOCKED,
FR_NOT_ENOUGH_CORE,
FR_TOO_MANY_OPEN_FILES,
FR_INVALID_PARAMETER
} |
|
|
FRESULT | f_open (FIL *fp, const TCHAR *path, BYTE mode) |
|
FRESULT | f_close (FIL *fp) |
|
FRESULT | f_read (FIL *fp, void *buff, UINT btr, UINT *br) |
|
FRESULT | f_write (FIL *fp, const void *buff, UINT btw, UINT *bw) |
|
FRESULT | f_lseek (FIL *fp, FSIZE_t ofs) |
|
FRESULT | f_truncate (FIL *fp) |
|
FRESULT | f_sync (FIL *fp) |
|
FRESULT | f_opendir (DIR *dp, const TCHAR *path) |
|
FRESULT | f_closedir (DIR *dp) |
|
FRESULT | f_readdir (DIR *dp, FILINFO *fno) |
|
FRESULT | f_findfirst (DIR *dp, FILINFO *fno, const TCHAR *path, const TCHAR *pattern) |
|
FRESULT | f_findnext (DIR *dp, FILINFO *fno) |
|
FRESULT | f_mkdir (const TCHAR *path) |
|
FRESULT | f_unlink (const TCHAR *path) |
|
FRESULT | f_rename (const TCHAR *path_old, const TCHAR *path_new) |
|
FRESULT | f_stat (const TCHAR *path, FILINFO *fno) |
|
FRESULT | f_chmod (const TCHAR *path, BYTE attr, BYTE mask) |
|
FRESULT | f_utime (const TCHAR *path, const FILINFO *fno) |
|
FRESULT | f_chdir (const TCHAR *path) |
|
FRESULT | f_chdrive (const TCHAR *path) |
|
FRESULT | f_getcwd (TCHAR *buff, UINT len) |
|
FRESULT | f_getdirpath (DIR *pd, TCHAR *buff, UINT len) |
|
FRESULT | f_getfree (const TCHAR *path, DWORD *nclst, FATFS **fatfs) |
|
FRESULT | f_getlabel (const TCHAR *path, TCHAR *label, DWORD *vsn) |
|
FRESULT | f_setlabel (const TCHAR *label) |
|
FRESULT | f_forward (FIL *fp, UINT(*func)(const BYTE *, UINT), UINT btf, UINT *bf) |
|
FRESULT | f_expand (FIL *fp, FSIZE_t szf, BYTE opt) |
|
FRESULT | f_mount (FATFS *fs, const TCHAR *path, BYTE opt) |
|
FRESULT | f_mkfs (const TCHAR *path, BYTE opt, DWORD au, void *work, UINT len) |
|
FRESULT | f_fdisk (BYTE pdrv, const DWORD *szt, void *work) |
|
int | f_putc (TCHAR c, FIL *fp) |
|
int | f_puts (const TCHAR *str, FIL *cp) |
|
int | f_printf (FIL *fp, const TCHAR *str,...) |
|
TCHAR * | f_gets (TCHAR *buff, int len, FIL *fp) |
|
DWORD | get_fattime (void) |
| Gets Time from RTC. More...
|
|
◆ _FATFS
#define _FATFS 68300 /* Revision ID */ |
◆ _T
◆ _TEXT
◆ f_eof
#define f_eof |
( |
|
fp | ) |
((int)((fp)->fptr == (fp)->obj.objsize)) |
◆ f_error
#define f_error |
( |
|
fp | ) |
((fp)->err) |
◆ f_tell
#define f_tell |
( |
|
fp | ) |
((fp)->fptr) |
◆ f_size
#define f_size |
( |
|
fp | ) |
((fp)->obj.objsize) |
◆ f_rewind
#define f_rewind |
( |
|
fp | ) |
f_lseek((fp), 0) |
◆ f_rewinddir
◆ f_rmdir
◆ EOF
◆ FA_READ
◆ FA_WRITE
◆ FA_OPEN_EXISTING
#define FA_OPEN_EXISTING 0x00 |
◆ FA_CREATE_NEW
#define FA_CREATE_NEW 0x04 |
◆ FA_CREATE_ALWAYS
#define FA_CREATE_ALWAYS 0x08 |
◆ FA_OPEN_ALWAYS
#define FA_OPEN_ALWAYS 0x10 |
◆ FA_OPEN_APPEND
#define FA_OPEN_APPEND 0x30 |
◆ CREATE_LINKMAP
#define CREATE_LINKMAP ((FSIZE_t)0 - 1) |
◆ FM_FAT
◆ FM_FAT32
◆ FM_EXFAT
◆ FM_ANY
◆ FM_SFD
◆ FS_FAT12
◆ FS_FAT16
◆ FS_FAT32
◆ FS_EXFAT
◆ AM_RDO
#define AM_RDO 0x01 /* Read only */ |
◆ AM_HID
#define AM_HID 0x02 /* Hidden */ |
◆ AM_SYS
#define AM_SYS 0x04 /* System */ |
◆ AM_DIR
#define AM_DIR 0x10 /* Directory */ |
◆ AM_ARC
#define AM_ARC 0x20 /* Archive */ |
◆ TCHAR
◆ FSIZE_t
◆ FRESULT
Enumerator |
---|
FR_OK | |
FR_DISK_ERR | |
FR_INT_ERR | |
FR_NOT_READY | |
FR_NO_FILE | |
FR_NO_PATH | |
FR_INVALID_NAME | |
FR_DENIED | |
FR_EXIST | |
FR_INVALID_OBJECT | |
FR_WRITE_PROTECTED | |
FR_INVALID_DRIVE | |
FR_NOT_ENABLED | |
FR_NO_FILESYSTEM | |
FR_MKFS_ABORTED | |
FR_TIMEOUT | |
FR_LOCKED | |
FR_NOT_ENOUGH_CORE | |
FR_TOO_MANY_OPEN_FILES | |
FR_INVALID_PARAMETER | |
◆ f_open()
3306 DWORD dw, cl, bcs, clst, sc;
3371 res = store_xdir(&dj);
3437 fp->
obj.c_ofs = dj.blk_ofs;
3470 if (res ==
FR_OK && ofs %
SS(fs)) {
◆ f_close()
3816 res = dec_lock(fp->
obj.lockid);
3823 unlock_fs(fs,
FR_OK);
◆ f_read()
3510 UINT rcnt, cc, csect;
3519 if (btr > remain) btr = (
UINT)remain;
3522 rbuff += rcnt, fp->
fptr += rcnt, *br += rcnt, btr -= rcnt) {
3523 if (fp->
fptr %
SS(fs) == 0) {
3526 if (fp->
fptr == 0) {
3531 clst = clmt_clust(fp, fp->
fptr);
3547 if (csect + cc > fs->
csize) {
3548 cc = fs->
csize - csect;
3551 #if !_FS_READONLY && _FS_MINIMIZE <= 2
3566 if (fp->
sect != sect) {
3579 if (rcnt > btr) rcnt = btr;
◆ f_write()
3609 UINT wcnt, cc, csect;
3610 const BYTE *wbuff = (
const BYTE*)buff;
3625 if (fp->
fptr %
SS(fs) == 0) {
3628 if (fp->
fptr == 0) {
3636 clst = clmt_clust(fp, fp->
fptr);
3643 if (clst == 0)
break;
3662 if (csect + cc > fs->
csize) {
3663 cc = fs->
csize - csect;
3666 #if _FS_MINIMIZE <= 2
3668 if (fs->
winsect - sect < cc) {
3673 if (fp->
sect - sect < cc) {
3688 if (fp->
sect != sect &&
3697 if (wcnt > btw) wcnt = btw;
◆ f_lseek()
4067 DWORD clst, bcs, nsect;
4070 DWORD cl, pcl, ncl, tcl, dsc, tlen, ulen, *tbl;
4077 res = fill_last_frag(&fp->
obj, fp->
clust, 0xFFFFFFFF);
4086 tlen = *tbl++; ulen = 2;
4091 tcl = cl; ncl = 0; ulen += 2;
4097 }
while (cl == pcl + 1);
4099 *tbl++ = ncl; *tbl++ = tcl;
4101 }
while (cl < fs->n_fatent);
4113 fp->
clust = clmt_clust(fp, ofs - 1);
4143 fp->
fptr = nsect = 0;
4147 (ofs - 1) / bcs >= (ifptr - 1) / bcs) {
4165 ofs -= bcs; fp->
fptr += bcs;
4189 nsect += (
DWORD)(ofs /
SS(fs));
4197 if (fp->
fptr %
SS(fs) && nsect != fp->
sect) {
◆ f_truncate()
4548 if (fp->
fptr == 0) {
4556 if (res ==
FR_OK && ncl < fs->n_fatent) {
◆ f_sync()
3746 res = fill_first_frag(&fp->
obj);
3748 res = fill_last_frag(&fp->
obj, fp->
clust, 0xFFFFFFFF);
3752 res = load_obj_dir(&dj, &fp->
obj);
3762 res = store_xdir(&dj);
◆ f_opendir()
4246 obj->c_scl = obj->
sclust;
4248 obj->c_ofs = dp->blk_ofs;
4267 obj->lockid = inc_lock(dp, 0);
4279 if (res !=
FR_OK) obj->
fs = 0;
◆ f_closedir()
4302 if (dp->
obj.lockid) {
4303 res = dec_lock(dp->
obj.lockid);
4311 unlock_fs(fs,
FR_OK);
◆ f_readdir()
◆ f_findfirst()
◆ f_findnext()
◆ f_mkdir()
4688 DWORD dsc, dcl, pcl, tm;
4726 for (n = fs->
csize; n; n--) {
4730 if (res !=
FR_OK)
break;
4746 res = store_xdir(&dj);
◆ f_unlink()
4608 if (res ==
FR_OK) res = chk_lock(&dj, 2);
4632 if (dclst == fs->cdir) {
4656 if (res ==
FR_OK && dclst) {
◆ f_rename()
4798 res = chk_lock(&djo, 2);
4808 mem_cpy(&djn, &djo,
sizeof djo);
4822 res = store_xdir(&djn);
4838 mem_cpy(dir + 13, buf + 2, 19);
4849 if (res ==
FR_OK && dir[1] ==
'.') {
◆ f_stat()
◆ f_chmod()
◆ f_utime()
◆ f_chdir()
◆ f_chdrive()
◆ f_getcwd()
◆ f_getdirpath()
◆ f_getfree()
4455 DWORD nfree, clst, sect, stat;
4472 clst = 2; obj.
fs = fs;
4475 if (stat == 0xFFFFFFFF) { res =
FR_DISK_ERR;
break; }
4477 if (stat == 0) nfree++;
4478 }
while (++clst < fs->n_fatent);
4490 for (
b = 8, bm = fs->
win[
i];
b && clst;
b--, clst--) {
4491 if (!(bm & 1)) nfree++;
4494 i = (
i + 1) %
SS(fs);
4504 if (res !=
FR_OK)
break;
4512 if ((
ld_dword(p) & 0x0FFFFFFF) == 0) nfree++;
◆ f_getlabel()
◆ f_setlabel()
◆ f_forward()
◆ f_expand()
◆ f_mount()
3257 const TCHAR *rp = path;
3270 if (!ff_del_syncobj(cfs->sobj))
return FR_INT_ERR;
3283 if (!fs || opt != 1)
return FR_OK;
◆ f_mkfs()
◆ f_fdisk()
◆ f_putc()
◆ f_puts()
◆ f_printf()
◆ f_gets()
◆ get_fattime()
Gets Time from RTC.
- Parameters
-
- Return values
-
static FRESULT dir_read(DIR *dp, int vol)
Definition: ff.c:2131
#define FA_OPEN_ALWAYS
Definition: ff.h:331
#define XDIR_FstClus
Definition: ff.c:427
char TCHAR
Definition: ff.h:62
#define XDIR_FileSize
Definition: ff.c:428
static FRESULT dir_next(DIR *dp, int stretch)
Definition: ff.c:1519
#define XDIR_ValidFileSize
Definition: ff.c:426
#define DIR_CrtTime
Definition: ff.c:397
DWORD fatbase
Definition: ff.h:121
DWORD last_clst
Definition: ff.h:107
static FRESULT dir_sdi(DIR *dp, DWORD ofs)
Definition: ff.c:1470
BYTE stat
Definition: ff.h:136
#define FA_WRITE
Definition: ff.h:327
static void st_dword(BYTE *ptr, DWORD val)
Definition: ff.c:661
#define DIR_FileSize
Definition: ff.c:402
#define XDIR_AccTime
Definition: ff.c:417
WORD csize
Definition: ff.h:93
FSIZE_t fptr
Definition: ff.h:159
DWORD winsect
Definition: ff.h:124
#define CREATE_LINKMAP
Definition: ff.h:335
#define INIT_NAMBUF(fs)
Definition: ff.c:546
#define FA_OPEN_APPEND
Definition: ff.h:332
DWORD clust
Definition: ff.h:160
static FRESULT dir_remove(DIR *dp)
Definition: ff.c:2396
static FRESULT validate(_FDID *obj, FATFS **fs)
Definition: ff.c:3215
#define FA_CREATE_ALWAYS
Definition: ff.h:330
DWORD n_fatent
Definition: ff.h:118
unsigned short WORD
Definition: onboard_sd.h:14
_FDID obj
Definition: ff.h:156
DRESULT disk_read(BYTE pdrv, BYTE *buff, DWORD sector, UINT count)
Reads Sector(s)
Definition: diskio.c:113
uint8_t i
Definition: screen_test_graph.c:72
static void get_fileinfo(DIR *dp, FILINFO *fno)
Definition: ff.c:2444
#define FS_EXFAT
Definition: ff.h:348
DWORD sclust
Definition: ff.h:137
DWORD FSIZE_t
Definition: ff.h:78
static DWORD ld_clust(FATFS *fs, const BYTE *dir)
Definition: ff.c:1632
#define NS_NONAME
Definition: ff.c:321
static DWORD clust2sect(FATFS *fs, DWORD clst)
Definition: ff.c:983
static FRESULT remove_chain(_FDID *obj, DWORD clst, DWORD pclst)
Definition: ff.c:1271
#define FS_FAT16
Definition: ff.h:346
#define DIR_ModTime
Definition: ff.c:400
BYTE fn[12]
Definition: ff.h:184
static FRESULT dir_register(DIR *dp)
Definition: ff.c:2292
DWORD dptr
Definition: ff.h:180
BYTE flag
Definition: ff.h:157
static FRESULT sync_window(FATFS *fs)
Definition: ff.c:883
#define NSFLAG
Definition: ff.c:313
#define DIR_Name
Definition: ff.c:393
static WORD ld_word(const BYTE *ptr)
Definition: ff.c:613
BYTE * dir
Definition: ff.h:183
#define BYTE
Definition: MarlinSerial.h:142
static void st_clust(FATFS *fs, BYTE *dir, DWORD cl)
Definition: ff.c:1650
#define FA_MODIFIED
Definition: ff.c:308
#define _FS_RPATH
Definition: ffconf.h:182
static void mem_cpy(void *dst, const void *src, UINT cnt)
Definition: ff.c:693
#define XDIR_CrtTime
Definition: ff.c:415
static DWORD ld_dword(const BYTE *ptr)
Definition: ff.c:623
BYTE fsi_flag
Definition: ff.h:90
#define XDIR_NameHash
Definition: ff.c:425
FSIZE_t objsize
Definition: ff.h:138
#define XDIR_ModTime
Definition: ff.c:416
#define FA_READ
Definition: ff.h:326
#define FS_FAT32
Definition: ff.h:347
static FRESULT follow_path(DIR *dp, const TCHAR *path)
Definition: ff.c:2812
#define XDIR_Attr
Definition: ff.c:414
static void st_word(BYTE *ptr, WORD val)
Definition: ff.c:654
static FRESULT find_volume(const TCHAR **path, FATFS **rfs, BYTE mode)
Definition: ff.c:2992
#define GET_FATTIME()
Definition: ff.c:499
static DWORD create_chain(_FDID *obj, DWORD clst)
Definition: ff.c:1351
static void mem_set(void *dst, int val, UINT cnt)
Definition: ff.c:706
BYTE * dir_ptr
Definition: ff.h:164
#define FA_SEEKEND
Definition: ff.c:307
WORD id
Definition: ff.h:134
#define NS_DOT
Definition: ff.c:319
Definition: onboard_sd.h:23
#define DIR_Attr
Definition: ff.c:394
if(size<=((png_alloc_size_t) -1) - ob)
Definition: pngwrite.c:2176
WORD id
Definition: ff.h:91
BYTE err
Definition: ff.h:158
BYTE fs_type
Definition: ff.h:86
DRESULT disk_write(BYTE pdrv, const BYTE *buff, DWORD sector, UINT count)
Writes Sector(s)
Definition: diskio.c:135
BYTE wflag
Definition: ff.h:89
BYTE win[_MAX_SS]
Definition: ff.h:125
DWORD dir_sect
Definition: ff.h:163
#define XDIR_GenFlags
Definition: ff.c:423
#define XDIR_NumName
Definition: ff.c:424
#define LEAVE_FF(fs, res)
Definition: ff.c:467
#define SS(fs)
Definition: ff.c:486
DWORD free_clst
Definition: ff.h:108
unsigned long DWORD
Definition: onboard_sd.h:15
static DWORD get_fat(_FDID *obj, DWORD clst)
Definition: ff.c:1001
FRESULT
Definition: ff.h:214
#define AM_DIR
Definition: ff.h:354
#define _FS_READONLY
Definition: ffconf.h:69
uint8_t rbuff[10]
Definition: HardwareSerial.cpp:19
#define XDIR_NumSec
Definition: ff.c:412
#define _FS_EXFAT
Definition: ffconf.h:249
BYTE buf[_MAX_SS]
Definition: ff.h:170
#define FREE_NAMBUF()
Definition: ff.c:547
#define FS_FAT12
Definition: ff.h:345
#define ABORT(fs, res)
Definition: ff.c:455
static int get_ldnumber(const TCHAR **path)
Definition: ff.c:2903
DWORD sect
Definition: ff.h:161
static FRESULT sync_fs(FATFS *fs)
Definition: ff.c:944
#define XDIR_CrtTime10
Definition: ff.c:418
unsigned char BYTE
Definition: onboard_sd.h:13
DWORD dirbase
Definition: ff.h:122
FATFS * fs
Definition: ff.h:133
BYTE drv
Definition: ff.h:87
#define XDIR_ModTime10
Definition: ff.c:419
#define DEF_NAMBUF
Definition: ff.c:545
#define FA_DIRTY
Definition: ff.c:309
#define SZDIRE
Definition: ff.c:430
png_structrp int mode
Definition: png.h:1139
list b
Definition: createSpeedLookupTable.py:30
#define AM_RDO
Definition: ff.h:351
unsigned int UINT
Definition: onboard_sd.h:16
#define AM_ARC
Definition: ff.h:355
FRESULT f_sync(FIL *fp)
Definition: ff.c:3720
DWORD database
Definition: ff.h:123
_FDID obj
Definition: ff.h:179
static FRESULT move_window(FATFS *fs, DWORD sector)
Definition: ff.c:912
#define FA_CREATE_NEW
Definition: ff.h:329
static FATFS * FatFs[_VOLUMES]
Definition: ff.c:533
BYTE attr
Definition: ff.h:135
#define _MAX_SS
Definition: ffconf.h:215
#define DIR_LstAccDate
Definition: ff.c:398