mikroSDK Reference Manual
ff.h
1/*----------------------------------------------------------------------------/
2/ FatFs - Generic FAT Filesystem module R0.15 /
3/-----------------------------------------------------------------------------/
4/
5/ Copyright (C) 2022, ChaN, all right reserved.
6/
7/ FatFs module is an open source software. Redistribution and use of FatFs in
8/ source and binary forms, with or without modification, are permitted provided
9/ that the following condition is met:
10
11/ 1. Redistributions of source code must retain the above copyright notice,
12/ this condition and the following disclaimer.
13/
14/ This software is provided by the copyright holder and contributors "AS IS"
15/ and any warranties related to this software are DISCLAIMED.
16/ The copyright owner or contributors be NOT LIABLE for any damages caused
17/ by use of this software.
18/
19/----------------------------------------------------------------------------*/
20
21
22#ifndef FF_DEFINED
23#define FF_DEFINED 80286 /* Revision ID */
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29#include "ff_types.h" /* Declarations of FatFs custom types */
30#include "ffconf.h" /* FatFs configuration options */
31#include "generic_pointer.h"
32
33#if FF_DEFINED != FFCONF_DEF
34#error Wrong configuration file (ffconf.h).
35#endif
36
37
38/*--------------------------------------------------------------*/
39/* FatFs Module Application Interface */
40/*--------------------------------------------------------------*/
41
42FRESULT f_open (FIL* fp, const TCHAR* __generic_ptr path, BYTE mode); /* Open or create a file */
43FRESULT f_close (FIL* fp); /* Close an open file object */
44FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from the file */
45FRESULT f_write (FIL* fp, const void* __generic_ptr buff, UINT btw, UINT* bw); /* Write data to the file */
46FRESULT f_lseek (FIL* fp, FSIZE_t ofs); /* Move file pointer of the file object */
47FRESULT f_truncate (FIL* fp); /* Truncate the file */
48FRESULT f_sync (FIL* fp); /* Flush cached data of the writing file */
49FRESULT f_opendir (DIR* dp, const TCHAR* __generic_ptr path); /* Open a directory */
50FRESULT f_closedir (DIR* dp); /* Close an open directory */
51FRESULT f_readdir (DIR* dp, FILINFO* fno); /* Read a directory item */
52FRESULT f_findfirst (DIR* dp, FILINFO* fno, const TCHAR* __generic_ptr path, const TCHAR* __generic_ptr pattern); /* Find first file */
53FRESULT f_findnext (DIR* dp, FILINFO* fno); /* Find next file */
54FRESULT f_mkdir (const TCHAR* __generic_ptr path); /* Create a sub directory */
55FRESULT f_unlink (const TCHAR* __generic_ptr path); /* Delete an existing file or directory */
56FRESULT f_rename (const TCHAR* __generic_ptr path_old, const TCHAR* __generic_ptr path_new); /* Rename/Move a file or directory */
57FRESULT f_stat (const TCHAR* __generic_ptr path, FILINFO* fno); /* Get file status */
58FRESULT f_chmod (const TCHAR* __generic_ptr path, BYTE attr, BYTE mask); /* Change attribute of a file/dir */
59FRESULT f_utime (const TCHAR* __generic_ptr path, const FILINFO* fno); /* Change timestamp of a file/dir */
60FRESULT f_chdir (const TCHAR* __generic_ptr path); /* Change current directory */
61FRESULT f_chdrive (const TCHAR* __generic_ptr path); /* Change current drive */
62FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */
63FRESULT f_getfree (const TCHAR* __generic_ptr path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */
64FRESULT f_getlabel (const TCHAR* __generic_ptr path, TCHAR* label, DWORD* vsn); /* Get volume label */
65FRESULT f_setlabel (const TCHAR* __generic_ptr label); /* Set volume label */
66FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE* __generic_ptr,UINT), UINT btf, UINT* bf); /* Forward data to the stream */
67FRESULT f_expand (FIL* fp, FSIZE_t fsz, BYTE opt); /* Allocate a contiguous block to the file */
68FRESULT f_mount (FATFS* fs, const TCHAR* __generic_ptr path, BYTE opt); /* Mount/Unmount a logical drive */
69FRESULT f_mkfs (const TCHAR* __generic_ptr path, const MKFS_PARM* __generic_ptr opt, void* work, UINT len); /* Create a FAT volume */
70FRESULT f_fdisk (BYTE pdrv, const LBA_t ptbl[], void* work); /* Divide a physical drive into some partitions */
71FRESULT f_setcp (WORD cp); /* Set current code page */
72int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */
73int f_puts (const TCHAR* __generic_ptr str, FIL* cp); /* Put a string to the file */
74int f_printf (FIL* fp, const TCHAR* __generic_ptr str, ...); /* Put a formatted string to the file */
75TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */
76
77/* Some API fucntions are implemented as macro */
78
79#define f_eof(fp) ((int)((fp)->fptr == (fp)->obj.objsize))
80#define f_error(fp) ((fp)->err)
81#define f_tell(fp) ((fp)->fptr)
82#define f_size(fp) ((fp)->obj.objsize)
83#define f_rewind(fp) f_lseek((fp), 0)
84#define f_rewinddir(dp) f_readdir((dp), 0)
85#define f_rmdir(path) f_unlink(path)
86#define f_unmount(path) f_mount(0, path, 0)
87
88
89
90
91/*--------------------------------------------------------------*/
92/* Additional Functions */
93/*--------------------------------------------------------------*/
94
95/* RTC function (provided by user) */
96#if !FF_FS_READONLY && !FF_FS_NORTC
97DWORD get_fattime (void); /* Get current time */
98#endif
99
100
101/* LFN support functions (defined in ffunicode.c) */
102
103#if FF_USE_LFN >= 1
104WCHAR ff_oem2uni (WCHAR oem, WORD cp); /* OEM code to Unicode conversion */
105WCHAR ff_uni2oem (DWORD uni, WORD cp); /* Unicode to OEM code conversion */
106DWORD ff_wtoupper (DWORD uni); /* Unicode upper-case conversion */
107#endif
108
109
110/* O/S dependent functions (samples available in ffsystem.c) */
111
112#if FF_USE_LFN == 3 /* Dynamic memory allocation */
113void* ff_memalloc (UINT msize); /* Allocate memory block */
114void ff_memfree (void* mblock); /* Free memory block */
115#endif
116#if FF_FS_REENTRANT /* Sync functions */
117int ff_mutex_create (int vol); /* Create a sync object */
118void ff_mutex_delete (int vol); /* Delete a sync object */
119int ff_mutex_take (int vol); /* Lock sync object */
120void ff_mutex_give (int vol); /* Unlock sync object */
121#endif
122
123
124
125
126/*--------------------------------------------------------------*/
127/* Flags and Offset Address */
128/*--------------------------------------------------------------*/
129
130
131
132#ifdef __cplusplus
133}
134#endif
135
136#endif /* FF_DEFINED */
Definition ff_types.h:208
Definition ff_types.h:114
Definition ff_types.h:227
Definition ff_types.h:185
Definition ff_types.h:244