/* ################################################################### ** This component module is generated by Processor Expert. Do not modify it. ** Filename : McuFatFS.h ** Project : FRDM-K64F_Generator ** Processor : MK64FN1M0VLL12 ** Component : FAT_FileSystem ** Version : Component 01.214, Driver 01.00, CPU db: 3.00.000 ** Compiler : GNU C Compiler ** Date/Time : 2021-05-13, 11:07, # CodeGen: 738 ** Abstract : ** ** Settings : ** Component name : McuFatFS ** FatFs Version : R0.12 (Patch 3, 29-April-2016) ** Tiny : no ** Volumes : 1 ** Drives : 1 ** Drive0 : SDCard ** FS_MINIMIZE : 0 ** Maximum Sector Size : 512 ** Relative Path : Enabled with f_getcwd() ** Code Page : U.S. (OEM) ** File Sharing : 0 ** Multipartion : no ** Fast Seek : yes ** Use Find : Disable (0) ** String Functions : enable ** LFN : Long File Name Support ** Use LFN : Disable ** exFAT : no ** Max LFN Length : 255 ** LFN Unicode : no ** Write enabled : Enabled ** Use TimeDate : Enabled ** Realtime clock : McuTimeDate ** Reentrant : Enabled ** Timeout ticks : 1000 ** Handle : HANDLE ** User Sync Functions : no ** RTOS : Enabled ** RTOS : McuRTOS ** Use dynamic heap : yes ** Utility : McuUtility ** Wait : McuWait ** SDK : McuLib ** Shell : Enabled ** Shell : McuShell ** Card Insert Delay (ms) : 100 ** File print buffer size : 32 ** File copy buffer size : 32 ** Contents : ** open - FRESULT McuFatFS_open(FIL *fp, const XCHAR *path, BYTE mode); ** close - FRESULT McuFatFS_close(FIL *fp); ** read - FRESULT McuFatFS_read(FIL *fp, void *buff, UINT btr, UINT *br); ** write - FRESULT McuFatFS_write(FIL *fp, const *void buff, UINT btw, UINT *bw); ** opendir - FRESULT McuFatFS_opendir(DIR *dj, const XCHAR *path); ** readdir - FRESULT McuFatFS_readdir(DIR *dj, FILINFO *fno); ** lseek - FRESULT McuFatFS_lseek(FIL *fp, DWORD ofs); ** unlink - FRESULT McuFatFS_unlink(const XCHAR *path); ** mount - FRESULT McuFatFS_mount(FATFS *fs, const TCHAR* path, byte opt); ** getfree - FRESULT McuFatFS_getfree(const XCHAR *path, dword *nclst, FATFS **fatfs); ** sync - FRESULT McuFatFS_sync(FIL *fp); ** rename - FRESULT McuFatFS_rename(const XCHAR *path_old, const XCHAR *path_new); ** isWriteProtected - bool McuFatFS_isWriteProtected(uint8_t *drvStr); ** isDiskPresent - bool McuFatFS_isDiskPresent(uint8_t *drvStr); ** mkdir - FRESULT McuFatFS_mkdir(const XCHAR *path); ** chmod - FRESULT McuFatFS_chmod(const TCHAR* FileName, uint8_t Attribute, uint8_t... ** truncate - FRESULT McuFatFS_truncate(FIL *FileObject); ** stat - FRESULT McuFatFS_stat(const TCHAR* FileName, FILINFO* FileInfo); ** utime - FRESULT McuFatFS_utime(const TCHAR* FileName, const FILINFO* TimeDate); ** mkfs - FRESULT McuFatFS_mkfs(byte drive, uint8_t PartitioningRule, UINT AllocSize); ** chdir - FRESULT McuFatFS_chdir(const TCHAR* Path); ** chdrive - FRESULT McuFatFS_chdrive(uint8_t Drive); ** getcwd - FRESULT McuFatFS_getcwd(TCHAR* Buffer, UINT BufferLen); ** errFResultMsg - char* McuFatFS_errFResultMsg(int errNo); ** errDResultMsg - char* McuFatFS_errDResultMsg(int errNo); ** f_gets - McuFatFS_CHARP McuFatFS_f_gets(TCHAR* buff, int len, FIL *fil); ** f_puts - McuFatFS_INT McuFatFS_f_puts(const TCHAR* str, FIL *fil); ** f_putc - McuFatFS_INT McuFatFS_f_putc(TCHAR c, FIL *fil); ** f_printf - McuFatFS_INT McuFatFS_f_printf(FIL* fil, const TCHAR* str, ...); ** f_eof - byte McuFatFS_f_eof(FIL *fil); ** f_error - uint8_t McuFatFS_f_error(FIL *fil); ** f_tell - dword McuFatFS_f_tell(FIL *fil); ** f_size - dword McuFatFS_f_size(FIL *fil); ** f_getlabel - FRESULT McuFatFS_f_getlabel(const TCHAR* path, TCHAR* label, DWORD* vsn); ** f_setlabel - FRESULT McuFatFS_f_setlabel(const TCHAR* label); ** f_expand - FRESULT McuFatFS_f_expand(FIL* fp, FSIZE_t fsz, BYTE opt); ** f_findfirst - FRESULT McuFatFS_f_findfirst(DIR* dp, FILINFO* fno, const TCHAR* path, const... ** f_findnext - FRESULT McuFatFS_f_findnext(DIR* dp, FILINFO* fno); ** f_opendir - FRESULT McuFatFS_f_opendir(DIR* dp, const TCHAR* path); ** f_readdir - FRESULT McuFatFS_f_readdir(DIR *dj, FILINFO *fno); ** f_closedir - FRESULT McuFatFS_f_closedir(DIR* dp); ** get_fattime - uint32_t McuFatFS_get_fattime(void); ** ParseCommand - uint8_t McuFatFS_ParseCommand(const unsigned char *cmd, bool *handled, const... ** StrToDriveNumber - uint8_t McuFatFS_StrToDriveNumber(uint8_t *drvStr); ** CheckCardPresence - uint8_t McuFatFS_CheckCardPresence(bool *cardMounted, uint8_t *drive, FATFS... ** MountFileSystem - uint8_t McuFatFS_MountFileSystem(FATFS *fileSystemObject, uint8_t... ** UnMountFileSystem - uint8_t McuFatFS_UnMountFileSystem(uint8_t *logicalDrive, const... ** PrintDirectory - uint8_t McuFatFS_PrintDirectory(const uint8_t *dirName, const... ** CopyFile - uint8_t McuFatFS_CopyFile(const uint8_t*srcFileName, const uint8_t... ** DeleteFile - uint8_t McuFatFS_DeleteFile(const uint8_t *fileName, const... ** CreateFile - uint8_t McuFatFS_CreateFile(const uint8_t *fileName, const... ** PrintFile - uint8_t McuFatFS_PrintFile(const uint8_t *fileName, const... ** PrintHexFile - uint8_t McuFatFS_PrintHexFile(const uint8_t *fileName, const... ** MakeDirectory - uint8_t McuFatFS_MakeDirectory(const uint8_t *dirName, const... ** ChangeDirectory - uint8_t McuFatFS_ChangeDirectory(const uint8_t *dirName, const... ** RenameFile - uint8_t McuFatFS_RenameFile(const uint8_t *srcFileName, const uint8_t... ** PrintSector - uint8_t McuFatFS_PrintSector(uint8_t drive, uint32_t sectorNo, const... ** PrintDiskInfo - uint8_t McuFatFS_PrintDiskInfo(uint8_t *drive, const... ** Benchmark - uint8_t McuFatFS_Benchmark(const %@Shell@'ModuleName'%.StdIOType *io); ** Deinit - uint8_t McuFatFS_Deinit(void); ** Init - uint8_t McuFatFS_Init(void); ** ** Copyright (c) 2014-2021, Erich Styger ** Web: http://mcuoneclipse.com/ ** SourceForge: https://sourceforge.net/projects/mcuoneclipse ** Git: https://github.com/ErichStyger/McuOnEclipse_PEx ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: ** - Redistributions of source code must retain the above copyright notice, this list ** of conditions and the following disclaimer. ** - Redistributions in binary form must reproduce the above copyright notice, this ** list of conditions and the following disclaimer in the documentation and/or ** other materials provided with the distribution. ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ** ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ** ###################################################################*/ /*! ** @file McuFatFS.h ** @version 01.00 ** @brief ** */ /*! ** @addtogroup McuFatFS_module McuFatFS module documentation ** @{ */ #ifndef __McuFatFS_H #define __McuFatFS_H /* MODULE McuFatFS. */ #include "McuLib.h" /* SDK and API used */ #include "McuFatFSconfig.h" /* configuration */ /* Wrappers to FatFS types and constants */ #define McuFatFS_FATFS FATFS #define McuFatFS_DIR DIR #define McuFatFS_FIL FIL #define McuFatFS_FILINFO FILINFO #define McuFatFS_FRESULT FRESULT #define McuFatFS_DRESULT DRESULT #if McuLib_CONFIG_SDK_VERSION_USED == McuLib_CONFIG_SDK_PROCESSOR_EXPERT #define McuFatFS_USE_LFN _USE_LFN #define McuFatFS_MAX_LFN _MAX_LFN #define McuFatFS_MAX_SS _MAX_SS #define McuFatFS_FS_RPATH _FS_RPATH #define McuFatFS_FS_READONLY _FS_READONLY #define McuFatFS_FS_REENTRANT _FS_REENTRANT #define McuFatFS_SYNC_t _SYNC_t #define McuFatFS_FS_TIMEOUT _FS_TIMEOUT #define McuFatFS_VOLUMES _VOLUMES #else /* use newer defines in NXP SDK and FatFS */ #define McuFatFS_USE_LFN FF_USE_LFN #define McuFatFS_MAX_LFN FF_MAX_LFN #define McuFatFS_MAX_SS FF_MAX_SS #define McuFatFS_FS_RPATH FF_FS_RPATH #define McuFatFS_FS_READONLY FF_FS_READONLY #define McuFatFS_FS_REENTRANT FF_FS_REENTRANT #define McuFatFS_SYNC_t FF_SYNC_t #define McuFatFS_FS_TIMEOUT FF_FS_TIMEOUT #define McuFatFS_VOLUMES FF_VOLUMES #endif /* prototypes for application callbacks */ extern bool McuFatFS_CONFIG_IS_DISK_PRESENT_CALLBACK(uint8_t *drvStr); extern bool McuFatFS_CONFIG_IS_WRITE_PROTECTED_CALLBACK(uint8_t *drvStr); #if McuFatFS_CONFIG_SHELL_ENABLED #include "McuShell.h" #endif #include "McuUtility.h" #include "McuWait.h" #include "McuTimeDate.h" #include "McuRTOS.h" #include "ff.h" #include "diskio.h" #ifndef __BWUserType_McuFatFS_CHARP #define __BWUserType_McuFatFS_CHARP typedef char * McuFatFS_CHARP; /* alias to a char pointer */ #endif #ifndef __BWUserType_McuFatFS_INT #define __BWUserType_McuFatFS_INT typedef int McuFatFS_INT; /* alias to int type. */ #endif #define McuFatFS_PARSE_COMMAND_ENABLED McuFatFS_CONFIG_SHELL_ENABLED /* set to 1 if method ParseCommand() is present, 0 otherwise */ #define McuFatFS_USE_RTOS_DYNAMIC_MEMORY (1 && configSUPPORT_DYNAMIC_ALLOCATION) /* 1: use RTOS dynamic memory allocation, 0: use static memory */ #define McuFatFS_open(fp, path, mode) \ f_open(fp, path, mode) /* ** =================================================================== ** Method : open (component FAT_FileSystem) ** ** Description : ** Open/Create a file ** Parameters : ** NAME - DESCRIPTION ** fp - Pointer to the blank file object structure ** path - Pointer to a null-terminated string that ** specifies the file name to create or open. ** mode - Specifies the type of access and open ** method for the file. It is specified by a ** combination of following flags. ** FA_READ: Specifies read access to the ** object. Data can be read from the file. ** Combine with FA_WRITE for read-write access. ** FA_WRITE: Specifies write access to the ** object. Data can be written to the file. ** Combine with FA_READ for read-write access. ** FA_OPEN_EXISTING: Opens the file. The ** function fails if the file is not existing. ** (Default) ** FA_OPEN_ALWAYS: Opens the file if it is ** existing. If not, a new file is created. To ** append data to the file, use f_lseek ** function after file open in this method. ** FA_CREATE_NEW: Creates a new file. The ** function fails if the file is already ** existing. ** FA_CREATE_ALWAYS: Creates a new file. If ** the file is existing, it is truncated and ** overwritten. ** Returns : ** --- - Error code ** =================================================================== */ #define McuFatFS_close(fp) \ f_close(fp) /* ** =================================================================== ** Method : close (component FAT_FileSystem) ** ** Description : ** Close a file ** Parameters : ** NAME - DESCRIPTION ** fp - Pointer to the open file object structure to ** be closed. ** Returns : ** --- - Error code ** =================================================================== */ #define McuFatFS_read(fp, buff, btr, br) \ f_read(fp, buff, btr, br) /* ** =================================================================== ** Method : read (component FAT_FileSystem) ** ** Description : ** Read file ** Parameters : ** NAME - DESCRIPTION ** fp - Pointer to the file object ** buff - Pointer to the data buffer ** btr - Number of bytes to read ** br - Pointer to the number of bytes read ** Returns : ** --- - Error code ** =================================================================== */ #define McuFatFS_write(fp, buff, btw, bw) \ f_write(fp, buff, btw, bw) /* ** =================================================================== ** Method : write (component FAT_FileSystem) ** ** Description : ** Write to a file ** Parameters : ** NAME - DESCRIPTION ** fp - Pointer to the file object structure ** buff - Pointer to the data to be written ** btw - Number of bytes to write ** bw - Pointer to the variable to return number of ** bytes written ** Returns : ** --- - Error code ** =================================================================== */ #define McuFatFS_opendir(dj, path) \ f_opendir(dj, path) /* ** =================================================================== ** Method : opendir (component FAT_FileSystem) ** ** Description : ** Open a directory ** Parameters : ** NAME - DESCRIPTION ** dj - Pointer to the blank directory object to be ** created. ** path - Pointer to the null-terminated string ** that specifies the directory name to be ** opened. ** Returns : ** --- - Error code ** =================================================================== */ #define McuFatFS_readdir(dj, fno) \ f_readdir(dj, fno) /* ** =================================================================== ** Method : readdir (component FAT_FileSystem) ** ** Description : ** Read a directory item ** Parameters : ** NAME - DESCRIPTION ** dir - Pointer to the open directory object ** fno - Pointer to the file information structure ** Returns : ** --- - Error code ** =================================================================== */ #define McuFatFS_lseek(fp, ofs) \ f_lseek(fp, ofs) /* ** =================================================================== ** Method : lseek (component FAT_FileSystem) ** ** Description : ** The f_lseek function moves the file read/write pointer of an ** open file object. It can also be used to increase the file ** size (cluster pre-allocation). ** Parameters : ** NAME - DESCRIPTION ** fp - Pointer to the file object ** ofs - File pointer from top of file ** Returns : ** --- - Error code ** =================================================================== */ #define McuFatFS_unlink(path) \ f_unlink(path) /* ** =================================================================== ** Method : unlink (component FAT_FileSystem) ** ** Description : ** Remove a file or directory ** Parameters : ** NAME - DESCRIPTION ** path - Pointer to the object name ** Returns : ** --- - Error code ** =================================================================== */ #define McuFatFS_mount(fs, path, opt) \ f_mount(fs, path, opt) /* ** =================================================================== ** Method : mount (component FAT_FileSystem) ** ** Description : ** Mount/unmount a logical drive ** Parameters : ** NAME - DESCRIPTION ** fs - pointer to the new file system object (NULL ** for unmount) ** * path - Logical drive number to be ** mounted/unmounted ** opt - options: 0:Do not mount (delayed mount), 1: ** Mount immediately ** Returns : ** --- - Error code ** =================================================================== */ #define McuFatFS_getfree(path, nclst, fs) f_getfree(path, nclst, fs) /* ** =================================================================== ** Method : getfree (component FAT_FileSystem) ** ** Description : ** Get Number of Free Clusters ** Parameters : ** NAME - DESCRIPTION ** path - Pointer to the logical drive number ** (root dir) ** * nclst - Pointer to the variable to return ** number of free clusters ** fatfs - Pointer to pointer to file system ** object ** Returns : ** --- - Error code ** =================================================================== */ #define McuFatFS_sync(fp) \ f_sync(fp) /* ** =================================================================== ** Method : sync (component FAT_FileSystem) ** ** Description : ** Flush cached data of a writing file ** Parameters : ** NAME - DESCRIPTION ** fp - Pointer to the file object ** Returns : ** --- - Error code ** =================================================================== */ #define McuFatFS_rename(path_old, path_new) \ f_rename(path_old, path_new) /* ** =================================================================== ** Method : rename (component FAT_FileSystem) ** ** Description : ** Delete a file or directory ** Parameters : ** NAME - DESCRIPTION ** path_old - Pointer to old object name ** path_new - Pointer to new object name ** Returns : ** --- - Error code ** =================================================================== */ bool McuFatFS_isWriteProtected(uint8_t *drvStr); /* ** =================================================================== ** Method : isWriteProtected (component FAT_FileSystem) ** ** Description : ** Determines if the file system is write protected. ** Parameters : ** NAME - DESCRIPTION ** * drvStr - Pointer to drive string, e.g. "" or ** "0" ** Returns : ** --- - TRUE if file system is write protected ** =================================================================== */ #define McuFatFS_mkdir(path) \ f_mkdir(path) /* ** =================================================================== ** Method : mkdir (component FAT_FileSystem) ** ** Description : ** Creates a directory ** Parameters : ** NAME - DESCRIPTION ** path - Name of directory to be created ** Returns : ** --- - Error code ** =================================================================== */ #define McuFatFS_chmod(FileName, Attribute, AttributeMask) \ f_chmod(FileName, Attribute, AttributeMask) /* ** =================================================================== ** Method : chmod (component FAT_FileSystem) ** ** Description : ** Changes the attribute of a file or directory ** Following attribute flags to be set in one or more ** combination of the following flags. The specified flags are ** set and others are cleared. ** AM_RDO Read only ** AM_ARC Archive ** AM_SYS System ** AM_HID Hidden ** Parameters : ** NAME - DESCRIPTION ** FileName - Pointer to the file or directory ** Attribute - Attribute flags. Attribute ** flags to be set in one or more combination ** of the following flags. The specified flags ** are set and others are cleard. ** AttributeMask - Attribute mask. ** Attribute mask that specifies which ** attribute is changed. The specified ** aattributes are set or cleard. ** Returns : ** --- - Error code ** =================================================================== */ #define McuFatFS_truncate(FILP) \ f_truncate(FILP) /* ** =================================================================== ** Method : truncate (component FAT_FileSystem) ** ** Description : ** Truncates the file size. ** The truncate() function truncates the file size to the ** current file read/write point. This function has no effect ** if the file read/write pointer is already pointing end of ** the file. ** Parameters : ** NAME - DESCRIPTION ** * FileObject - Pointer to the file object ** Returns : ** --- - Error code ** =================================================================== */ #define McuFatFS_stat(FileName, FileInfo) \ f_stat(FileName, FileInfo) /* ** =================================================================== ** Method : stat (component FAT_FileSystem) ** ** Description : ** The f_stat gets the information of a file or directory. For ** details of the infomation, refer to the FILINFO structure ** and f_readdir function. This function is not supported in ** minimization level of >= 1. ** Parameters : ** NAME - DESCRIPTION ** FileName - Pointer to the file or directory ** path ** * FileInfo - Pointer to the FILINFO structure ** Returns : ** --- - Error code ** =================================================================== */ #define McuFatFS_utime(FileName, TimeDate) \ f_utime(FileName, TimeDate) /* ** =================================================================== ** Method : utime (component FAT_FileSystem) ** ** Description : ** The f_utime function changes the timestamp of a file or ** directory ** Parameters : ** NAME - DESCRIPTION ** * FileName - Pointer to the file or directory ** path ** * TimeDate - Pointer to time and data to be ** set ** Returns : ** --- - Error code ** =================================================================== */ #define McuFatFS_mkfs(drive, PartitioningRule, AllocSize) \ f_mkfs(drive, PartitioningRule, AllocSize) /* ** =================================================================== ** Method : mkfs (component FAT_FileSystem) ** ** Description : ** The f_mkfs fucntion creates a file system on the drive. ** Parameters : ** NAME - DESCRIPTION ** drive - Logical drive number ** PartitioningRule - When 0 is given, ** a partition table is created into the ** master boot record and a primary DOS ** partition is created and then an FAT volume ** is created on the partition. This is called ** FDISK format and used for harddisk and ** memory cards. When 1 is given, the FAT ** volume starts from the first sector on the ** drive without partition table. This is ** called SFD format and used for floppy disk ** and most optical disk ** AllocSize - Size of the allocation unit. ** Force the allocation unit (cluster) size in ** unit of byte. The value must be power of 2 ** and between the sector size and 128 times ** sector size. When invalid value is ** specified, the cluster size is determined ** depends on the volume size. ** Returns : ** --- - Error code ** =================================================================== */ #define McuFatFS_chdir(Path) \ f_chdir(Path) /* ** =================================================================== ** Method : chdir (component FAT_FileSystem) ** ** Description : ** The f_chdir function changes the current directory of the ** logical drive. The current directory of a drive is ** initialized to the root directory when the drive is ** auto-mounted. Note that the current directory is retained in ** the each file system object so that it also affects other ** tasks that using the drive. ** Parameters : ** NAME - DESCRIPTION ** Path - Pointer to the path name ** Returns : ** --- - Error code ** =================================================================== */ #define McuFatFS_chdrive(Drive) \ f_chdrive(Drive) /* ** =================================================================== ** Method : chdrive (component FAT_FileSystem) ** ** Description : ** The f_chdrive function changes the current drive. The ** initial value of the current drive number is 0. Note that ** the current drive is retained in a static variable so that ** it also affects other tasks that using the file functions. ** Parameters : ** NAME - DESCRIPTION ** Drive - Logical drive number ** Returns : ** --- - Error code ** =================================================================== */ #define McuFatFS_getcwd(Buffer, BufferLen) \ f_getcwd(Buffer, BufferLen) /* ** =================================================================== ** Method : getcwd (component FAT_FileSystem) ** ** Description : ** The f_getcwd function retrieves the current directory of the ** current drive in full path string including drive number. ** Parameters : ** NAME - DESCRIPTION ** Buffer - Pointer to the buffer to receive the ** current directory string. ** BufferLen - Size of the buffer in unit of ** TCHAR. ** Returns : ** --- - Error code ** =================================================================== */ char* McuFatFS_errFResultMsg(int errNo); /* ** =================================================================== ** Method : errFResultMsg (component FAT_FileSystem) ** ** Description : ** Returns for a given FatFs FRESULT error code a string ** Parameters : ** NAME - DESCRIPTION ** errNo - FatFs error code ** Returns : ** --- - Error code ** =================================================================== */ char* McuFatFS_errDResultMsg(int errNo); /* ** =================================================================== ** Method : errDResultMsg (component FAT_FileSystem) ** ** Description : ** Returns for a given FatFs DRESULT error code a string ** Parameters : ** NAME - DESCRIPTION ** errNo - FatFs error code ** Returns : ** --- - Error code ** =================================================================== */ bool McuFatFS_isDiskPresent(uint8_t *drvStr); /* ** =================================================================== ** Method : isDiskPresent (component FAT_FileSystem) ** ** Description : ** Determines if the disk is present or not (e.g. disk inserted). ** Parameters : ** NAME - DESCRIPTION ** * drvStr - drive string, "" or "0" or "1" ** Returns : ** --- - TRUE if file system is write protected ** =================================================================== */ #define McuFatFS_f_gets(buff, len, fil) \ f_gets(buff,len,fil) /* ** =================================================================== ** Method : f_gets (component FAT_FileSystem) ** ** Description : ** Get a string from the file ** Parameters : ** NAME - DESCRIPTION ** * buff - Pointer to the string buffer to read ** len - Size of string buffer (characters) ** fil - Pointer to the file object ** Returns : ** --- - zero (NULL) if failed, otherwise a string ** to the buffer is returned. ** =================================================================== */ #define McuFatFS_f_puts(str, fil) \ f_puts(str, fil) /* ** =================================================================== ** Method : f_puts (component FAT_FileSystem) ** ** Description : ** Put a string to the file ** Parameters : ** NAME - DESCRIPTION ** * buff - A character to be output ** fil - Pointer to the file object ** Returns : ** --- - number of characters written. ** =================================================================== */ #define McuFatFS_f_putc(c, fil) \ f_putc(c, fil) /* ** =================================================================== ** Method : f_putc (component FAT_FileSystem) ** ** Description : ** Put a character to the file ** Parameters : ** NAME - DESCRIPTION ** * buff - A character to be output ** fil - Pointer to the file object ** Returns : ** --- - 1 if ok, EOF otherwise ** =================================================================== */ #define McuFatFS_f_printf \ f_printf /* ** =================================================================== ** Method : f_printf (component FAT_FileSystem) ** ** Description : ** Put a formatted string to the file ** Parameters : ** NAME - DESCRIPTION ** Variable_1 - Pointer to the file object ** str - Pointer to the format string ** Variable_2 - Optional arguments... ** Returns : ** --- - Error code ** =================================================================== */ #define McuFatFS_f_eof(fp) \ f_eof(fp) /* ** =================================================================== ** Method : f_eof (component FAT_FileSystem) ** ** Description : ** Wrapper to to the f_eof() macro. Returns 1 if at the end of ** the file, 0 otherwise. ** Parameters : ** NAME - DESCRIPTION ** * fp - Pointer to file object ** Returns : ** --- - Error code ** =================================================================== */ #define McuFatFS_f_error(fp) \ f_error(fp) /* ** =================================================================== ** Method : f_error (component FAT_FileSystem) ** ** Description : ** Wrapper to to the f_eof() macro. Returns 1 if at the end of ** the file, 0 otherwise. ** Parameters : ** NAME - DESCRIPTION ** * fp - Pointer to file object ** Returns : ** --- - Error code ** =================================================================== */ #define McuFatFS_f_tell(fp) \ f_tell(fp) /* ** =================================================================== ** Method : f_tell (component FAT_FileSystem) ** ** Description : ** Wrapper to to the f_tell() macro. Returns the file ** read/write pointer (0 on file open). ** Parameters : ** NAME - DESCRIPTION ** * fp - Pointer to file object ** Returns : ** --- - Error code ** =================================================================== */ #define McuFatFS_f_size(fp) \ f_size(fp) /* ** =================================================================== ** Method : f_size (component FAT_FileSystem) ** ** Description : ** Wrapper to to the f_size() macro. Returns the file size. ** Parameters : ** NAME - DESCRIPTION ** * fp - Pointer to file object ** Returns : ** --- - Error code ** =================================================================== */ uint8_t McuFatFS_Init(void); /* ** =================================================================== ** Method : Init (component FAT_FileSystem) ** ** Description : ** Initializes the device driver. ** Parameters : None ** Returns : ** --- - Error code ** =================================================================== */ uint8_t McuFatFS_Deinit(void); /* ** =================================================================== ** Method : Deinit (component FAT_FileSystem) ** ** Description : ** Deinitializes the driver. ** Parameters : None ** Returns : ** --- - Error code ** =================================================================== */ uint32_t McuFatFS_get_fattime(void); /* ** =================================================================== ** Method : get_fattime (component FAT_FileSystem) ** ** Description : ** Returns the current time ** Parameters : None ** Returns : ** --- - Error code ** =================================================================== */ uint8_t McuFatFS_ParseCommand(const unsigned char *cmd, bool *handled, const McuShell_StdIOType *io); /* ** =================================================================== ** Method : ParseCommand (component FAT_FileSystem) ** ** Description : ** Shell Command Line parser. This method is enabled/disabled ** depending on if you have the Shell enabled/disabled in the ** properties. ** Parameters : ** NAME - DESCRIPTION ** * cmd - Pointer to command string ** * handled - Pointer to variable which tells if ** the command has been handled or not ** * io - Pointer to I/O structure ** Returns : ** --- - Error code ** =================================================================== */ uint8_t McuFatFS_CheckCardPresence(bool *cardMounted, uint8_t *drive, FATFS *fileSystemObject, const McuShell_StdIOType *io); /* ** =================================================================== ** Method : CheckCardPresence (component FAT_FileSystem) ** ** Description : ** This method checks if card has been inserted or removed and ** mounts or unmounts the file system. ** Parameters : ** NAME - DESCRIPTION ** * cardMounted - Pointer to initialize this ** variable to FALSE on the caller side the ** first time. ** * drive - drive string, or "" ** * fileSystemObject - Pointer to file ** system object ** io - Pointer to io handler to be used. Can be ** NULL, then no messages are written. ** Returns : ** --- - Error code ** =================================================================== */ uint8_t McuFatFS_MountFileSystem(FATFS *fileSystemObject, uint8_t *logicalDrive, const McuShell_StdIOType *io); /* ** =================================================================== ** Method : MountFileSystem (component FAT_FileSystem) ** ** Description : ** Mounts a file system ** Parameters : ** NAME - DESCRIPTION ** * fileSystemObject - Pointer to a ** file system object ** * logicalDrive - Pointer to the drive ** string, or "" ** * io - Pointer to I/O handler ** Returns : ** --- - Error code ** =================================================================== */ uint8_t McuFatFS_UnMountFileSystem(uint8_t *logicalDrive, const McuShell_StdIOType *io); /* ** =================================================================== ** Method : UnMountFileSystem (component FAT_FileSystem) ** ** Description : ** Mounts a file system ** Parameters : ** NAME - DESCRIPTION ** * logicalDrive - Pointer to the drive ** string, or "" ** * io - Pointer to I/O handler ** Returns : ** --- - Error code ** =================================================================== */ uint8_t McuFatFS_PrintDirectory(const uint8_t *dirName, const McuShell_StdIOType *io); /* ** =================================================================== ** Method : PrintDirectory (component FAT_FileSystem) ** ** Description : ** Prints a directory ** Parameters : ** NAME - DESCRIPTION ** dirName - Directory folder to be printed ** io - Pointer to I/O handler ** Returns : ** --- - Error code ** =================================================================== */ uint8_t McuFatFS_CopyFile(const uint8_t*srcFileName, const uint8_t *dstFileName, const McuShell_StdIOType *io); /* ** =================================================================== ** Method : CopyFile (component FAT_FileSystem) ** ** Description : ** Copy a file ** Parameters : ** NAME - DESCRIPTION ** srcFileName - Source file name ** dstFileName - Destination file name ** io - Pointer to I/O handler ** Returns : ** --- - Error code ** =================================================================== */ uint8_t McuFatFS_DeleteFile(const uint8_t *fileName, const McuShell_StdIOType *io); /* ** =================================================================== ** Method : DeleteFile (component FAT_FileSystem) ** ** Description : ** Deletes a file ** Parameters : ** NAME - DESCRIPTION ** fileName - Filename of file to be deleted ** io - Pointer to I/O handler ** Returns : ** --- - Error code ** =================================================================== */ uint8_t McuFatFS_PrintFile(const uint8_t *fileName, const McuShell_StdIOType *io); /* ** =================================================================== ** Method : PrintFile (component FAT_FileSystem) ** ** Description : ** Prints the content of a file ** Parameters : ** NAME - DESCRIPTION ** fileName - Name of file to be printed ** io - Pointer to I/O handler ** Returns : ** --- - Error code ** =================================================================== */ uint8_t McuFatFS_MakeDirectory(const uint8_t *dirName, const McuShell_StdIOType *io); /* ** =================================================================== ** Method : MakeDirectory (component FAT_FileSystem) ** ** Description : ** Creates a directory ** Parameters : ** NAME - DESCRIPTION ** dirName - Directory name ** io - Pointer to I/O handler ** Returns : ** --- - Error code ** =================================================================== */ uint8_t McuFatFS_ChangeDirectory(const uint8_t *dirName, const McuShell_StdIOType *io); /* ** =================================================================== ** Method : ChangeDirectory (component FAT_FileSystem) ** ** Description : ** Changes to a directory ** Parameters : ** NAME - DESCRIPTION ** dirName - Directory name ** io - Pointer to I/O handler ** Returns : ** --- - Error code ** =================================================================== */ uint8_t McuFatFS_RenameFile(const uint8_t *srcFileName, const uint8_t *dstFileName, const McuShell_StdIOType *io); /* ** =================================================================== ** Method : RenameFile (component FAT_FileSystem) ** ** Description : ** Renames a file ** Parameters : ** NAME - DESCRIPTION ** srcFileName - Source file name ** dstFileName - Destination file name ** io - Pointer to I/O handler ** Returns : ** --- - Error code ** =================================================================== */ uint8_t McuFatFS_PrintSector(uint8_t drive, uint32_t sectorNo, const McuShell_StdIOType *io); /* ** =================================================================== ** Method : PrintSector (component FAT_FileSystem) ** ** Description : ** Prints information about the current disk ** Parameters : ** NAME - DESCRIPTION ** drive - drive number, starting with zero ** sectorNo - sector number ** io - Pointer to I/O handler ** Returns : ** --- - Error code ** =================================================================== */ uint8_t McuFatFS_PrintDiskInfo(uint8_t *drive, const McuShell_StdIOType *io); /* ** =================================================================== ** Method : PrintDiskInfo (component FAT_FileSystem) ** ** Description : ** Prints information about the current disk ** Parameters : ** NAME - DESCRIPTION ** * drive - Drive string, can be NULL or e.g. ** pointing to "0" ** io - Pointer to I/O handler ** Returns : ** --- - Error code ** =================================================================== */ uint8_t McuFatFS_Benchmark(const McuShell_StdIOType *io); /* ** =================================================================== ** Method : Benchmark (component FAT_FileSystem) ** ** Description : ** Performs a disk benchmark ** Parameters : ** NAME - DESCRIPTION ** io - Pointer to I/O handler ** Returns : ** --- - Error code ** =================================================================== */ uint8_t McuFatFS_PrintHexFile(const uint8_t *fileName, const McuShell_StdIOType *io); /* ** =================================================================== ** Method : PrintHexFile (component FAT_FileSystem) ** ** Description : ** Prints the content of a file in hexadecimal format, useful ** for binary files. ** Parameters : ** NAME - DESCRIPTION ** fileName - Name of file to be printed ** io - Pointer to I/O handler ** Returns : ** --- - Error code ** =================================================================== */ uint8_t McuFatFS_CreateFile(const uint8_t *fileName, const McuShell_StdIOType *io); /* ** =================================================================== ** Method : CreateFile (component FAT_FileSystem) ** ** Description : ** Creates an empty file ** Parameters : ** NAME - DESCRIPTION ** fileName - Filename of file to be created ** io - Pointer to I/O handler ** Returns : ** --- - Error code ** =================================================================== */ #define McuFatFS_f_getlabel(path, label, vsn) \ f_getlabel(path, label, vsn) /* ** =================================================================== ** Method : f_getlabel (component FAT_FileSystem) ** ** Description : ** Get volume label ** Parameters : ** NAME - DESCRIPTION ** * path - Pointer to path name of the logical ** drive number ** * label - Pointer to a buffer to return the ** volume label ** vsn - ** Returns : ** --- - Error code ** =================================================================== */ #define McuFatFS_f_setlabel(label) \ f_setlabel(label); /* ** =================================================================== ** Method : f_setlabel (component FAT_FileSystem) ** ** Description : ** Set Volume Label ** Parameters : ** NAME - DESCRIPTION ** * label - Pointer to the volume label to set ** Returns : ** --- - Error code ** =================================================================== */ #define McuFatFS_f_expand(fp, fsz, opt) \ f_expand(fp, fsz, opt); /* ** =================================================================== ** Method : f_expand (component FAT_FileSystem) ** ** Description : ** Allocate a Contiguous Blocks to the File ** Parameters : ** NAME - DESCRIPTION ** * fp - Pointer to the file object ** fsz - File size to be expanded to ** opt - Operation mode 0:Find and prepare or 1: ** Find and allocate ** Returns : ** --- - Error code ** =================================================================== */ #define McuFatFS_f_findfirst(dp, fno, path, pattern) \ f_findfirst(dp, fno, path, pattern) /* ** =================================================================== ** Method : f_findfirst (component FAT_FileSystem) ** ** Description : ** Find FirstFile ** Parameters : ** NAME - DESCRIPTION ** dp - Pointer to the open directory object ** fno - Pointer to the file information structure ** path - Pointer to the directory to open ** pattern - Pointer to the matching pattern ** Returns : ** --- - Error code ** =================================================================== */ #define McuFatFS_f_findnext(dp, fno) \ f_findnext(dp, fno) /* ** =================================================================== ** Method : f_findnext (component FAT_FileSystem) ** ** Description : ** Find Next File ** Parameters : ** NAME - DESCRIPTION ** dp - Pointer to the open directory object ** fno - Pointer to the file information structure ** Returns : ** --- - Error code ** =================================================================== */ #define McuFatFS_f_opendir(dp, path) \ f_opendir(dp, path) /* ** =================================================================== ** Method : f_opendir (component FAT_FileSystem) ** ** Description : ** Open a directory ** Parameters : ** NAME - DESCRIPTION ** dp - Pointer to the open directory object ** path - path of directory ** Returns : ** --- - Error code ** =================================================================== */ #define McuFatFS_f_closedir(dp) \ f_closedir(dp) /* ** =================================================================== ** Method : f_closedir (component FAT_FileSystem) ** ** Description : ** Close a directory ** Parameters : ** NAME - DESCRIPTION ** dp - Pointer to the open directory object ** Returns : ** --- - Error code ** =================================================================== */ #define McuFatFS_f_readdir(dj, fno) \ f_readdir(dj, fno) /* ** =================================================================== ** Method : f_readdir (component FAT_FileSystem) ** ** Description : ** Read a directory item ** Parameters : ** NAME - DESCRIPTION ** dir - Pointer to the open directory object ** fno - Pointer to the file information structure ** Returns : ** --- - Error code ** =================================================================== */ uint8_t McuFatFS_StrToDriveNumber(uint8_t *drvStr); /* ** =================================================================== ** Method : StrToDriveNumber (component FAT_FileSystem) ** ** Description : ** Transforms a drive string ("0:/") into a drive number (0) ** Parameters : ** NAME - DESCRIPTION ** * drvStr - Pointer to drive string, e.g. "0:/" ** Returns : ** --- - Error code ** =================================================================== */ /* END McuFatFS. */ #endif /* ifndef __McuFatFS_H */ /*! ** @} */