CARPLAY版本整理
This commit is contained in:
@ -0,0 +1,202 @@
|
||||
/*
|
||||
*FreeRTOS+FAT is an open source,
|
||||
*thread aware and scalable FAT12/FAT16/FAT32 DOS/Windows compatible embedded FAT file system which was recently acquired by Real Time Engineers ltd.
|
||||
*for use with and without the RTOS.
|
||||
*FreeRTOS+FAT is already used in commercial products,
|
||||
*and is the file system used in the FTP and HTTP server examples that are documented on the FreeRTOS+TCP pages.
|
||||
*The standard C library style API includes a thread local errno value, and the lower level native API provides a rich set of detailed error codes.
|
||||
*We are currently working hard on improving the embedded file system’s documentation,
|
||||
*adding additional scalability options, and updating the source code to ensure it conforms with our strict coding standards.
|
||||
*We encourage you to download FreeRTOS+FAT to try the embedded FAT file system for yourself while we continue this work.
|
||||
|
||||
*Applications that use FreeRTOS+FAT must provide a FreeRTOSFATConfig.h header file – in which the parameters described on this page can be defined:
|
||||
***/
|
||||
|
||||
#ifndef FF_FATCONFIG_H
|
||||
#define FF_FATCONFIG_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define portINLINE inline
|
||||
#define FF_PRINTF printf
|
||||
|
||||
/*Must be set to either pdFREERTOS_LITTLE_ENDIAN or pdFREERTOS_BIG_ENDIAN,
|
||||
depending on the endian of the architecture on which FreeRTOS is running.*/
|
||||
//大小端
|
||||
#define ffconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
|
||||
|
||||
/*Set to 1 to maintain a current working directory (CWD) for each task that accesses the file system, allowing relative paths to be used.
|
||||
Set to 0 not to use a CWD, in which case full paths must be used for each file access.*/
|
||||
//维护当前目录
|
||||
#define ffconfigHAS_CWD 0
|
||||
|
||||
/*Set to an index within FreeRTOS’s thread local storage array that is free for use by FreeRTOS+FAT.
|
||||
FreeRTOS+FAT will use two consecutive indexes from this that set by ffconfigCWD_THREAD_LOCAL_INDEX.
|
||||
The number of thread local storage pointers provided by FreeRTOS is set by configNUM_THREAD_LOCAL_STORAGE_POINTERS in FreeRTOSConfig.h.*/
|
||||
//本地线程数组索引
|
||||
#define ffconfigCWD_THREAD_LOCAL_INDEX 0
|
||||
|
||||
/*Set to 1 to include long file name support. Set to 0 to exclude long file name support.
|
||||
If long file name support is excluded then only 8.3 file names can be used. Long file names will be recognised, but ignored.
|
||||
Users should familiarise themselves with any patent issues that may potentially exist around the use of long file names in FAT file systems before enabling long file name support.*/
|
||||
//长文件名
|
||||
#define ffconfigLFN_SUPPORT 1
|
||||
|
||||
/*Only used when ffconfigLFN_SUPPORT is set to 1.
|
||||
Set to 1 to include a file’s short name when listing a directory, i.e. when calling findfirst()/findnext().
|
||||
The short name will be stored in the ‘pcShortName’ field of FF_DIRENT.
|
||||
Set to 0 to only include a file’s long name.*/
|
||||
//短文件名
|
||||
#define ffconfigINCLUDE_SHORT_NAME 0
|
||||
|
||||
/*Set to 1 to recognise and apply the case bits used by Windows XP+
|
||||
when using short file names – storing file names such as “readme.TXT” or “SETUP.exe” in a short-name entry.
|
||||
This is the recommended setting for maximum compatibility.
|
||||
Set to 0 to ignore the case bits.*/
|
||||
#define ffconfigSHORTNAME_CASE 0
|
||||
|
||||
/*Only used when ffconfigLFN_SUPPORT is set to 1.
|
||||
Set to 1 to use UTF-16 (wide-characters) for file and directory names.
|
||||
Set to 0 to use either 8-bit ASCII or UTF-8 for file and directory names (see the ffconfigUNICODE_UTF8_SUPPORT).*/
|
||||
#define ffconfigUNICODE_UTF16_SUPPORT 0
|
||||
|
||||
/*Only used when ffconfigLFN_SUPPORT is set to 1.
|
||||
Set to 1 to use UTF-8 encoding for file and directory names.
|
||||
Set to 0 to use either 8-bit ASCII or UTF-16 for file and directory names (see the ffconfig_UTF_16_SUPPORT setting).*/
|
||||
#define ffconfigUNICODE_UTF8_SUPPORT 0
|
||||
|
||||
/*Set to 1 to include FAT12 support.
|
||||
Set to 0 to exclude FAT12 support.
|
||||
FAT16 and FAT32 are always enabled.*/
|
||||
#define ffconfigFAT12_SUPPORT 0
|
||||
|
||||
/*When writing and reading data, i/o becomes less efficient if sizes other than 512 bytes are being used.
|
||||
When set to 1 each file handle will allocate a 512-byte character buffer to facilitate “unaligned access”.*/
|
||||
//当写入和读取数据时,如果使用的大小不是512字节,i/o的效率就会降低。当设置为1时,每个文件句柄将分配一个512字节的字符缓冲区,以促进“非对齐访问”。
|
||||
#define ffconfigOPTIMISE_UNALIGNED_ACCESS 0
|
||||
|
||||
/*Input and output to a disk uses buffers that are only flushed at the following times:
|
||||
When a new buffer is needed and no other buffers are available.
|
||||
When opening a buffer in READ mode for a sector that has just been changed.
|
||||
After creating, removing or closing a file or a directory.
|
||||
Normally this is quick enough and it is efficient.
|
||||
If ffconfigCACHE_WRITE_THROUGH is set to 1 then buffers will also be flushed each time a buffer is released – which is less efficient but more secure.*/
|
||||
//如果设置为1,那么缓冲区也将在每次释放缓冲区时被刷新—这样效率较低,但更安全。
|
||||
#define ffconfigCACHE_WRITE_THROUGH 1
|
||||
|
||||
/*In most cases, the FAT table has two identical copies on the disk, allowing the second copy to be used in the case of a read error.
|
||||
If Set to 1 to use both FATs – this is less efficient but more secure.
|
||||
Set to 0 to use only one FAT – the second FAT will never be written to.*/
|
||||
#define ffconfigWRITE_BOTH_FATS 1
|
||||
|
||||
/*Set to 1 to have the number of free clusters and the first free cluster to be written to the FS info sector each time one of those values changes.
|
||||
Set to 0 not to store these values in the FS info sector, making booting slower, but making changes faster.*/
|
||||
#define ffconfigWRITE_FREE_COUNT 1
|
||||
|
||||
/*Set to 1 to maintain file and directory time stamps for creation, modify and last access.
|
||||
Set to 0 to exclude time stamps.
|
||||
If time support is used, the following function must be supplied:
|
||||
time_t FreeRTOS_time( time_t *pxTime );
|
||||
FreeRTOS_time has the same semantics as the standard time() function.*/
|
||||
#define ffconfigTIME_SUPPORT 0
|
||||
|
||||
/*Set to 1 if the media is removable (such as a memory card).
|
||||
Set to 0 if the media is not removable.
|
||||
When set to 1 all file handles will be “invalidated” if the media is extracted.
|
||||
If set to 0 then file handles will not be invalidated.
|
||||
In that case the user will have to confirm that the media is still present before every access.*/
|
||||
//如果介质是可移动的(如存储卡),则设置为1。
|
||||
#define ffconfigREMOVABLE_MEDIA 1
|
||||
|
||||
/*Set to 1 to determine the disk’s free space and the disk’s first free cluster when a disk is mounted.
|
||||
Set to 0 to find these two values when they are first needed. Determining the values can take some time.*/
|
||||
#define ffconfigMOUNT_FIND_FREE 1
|
||||
|
||||
/*Set to 1 to ‘trust’ the contents of the ‘ulLastFreeCluster’ and ulFreeClusterCount fields.
|
||||
Set to 0 not to ‘trust’ these fields.*/
|
||||
#define ffconfigFSINFO_TRUSTED 1
|
||||
|
||||
/*Set to 1 to store recent paths in a cache,
|
||||
enabling much faster access when the path is deep within a directory structure at the expense of additional RAM usage.
|
||||
Set to 0 to not use a path cache.*/
|
||||
#define ffconfigPATH_CACHE 1
|
||||
|
||||
/*Only used if ffconfigPATH_CACHE is 1.
|
||||
Sets the maximum number of paths that can exist in the patch cache at any one time.*/
|
||||
#define ffconfigPATH_CACHE_DEPTH 8
|
||||
|
||||
/*Set to 1 to calculate a HASH value for each existing short file name.
|
||||
Use of HASH values can improve performance when working with large directories, or with files that have a similar name.
|
||||
Set to 0 not to calculate a HASH value.*/
|
||||
#define ffconfigHASH_CACHE 0
|
||||
#define ffconfigHASH_CACHE_DEPTH 2
|
||||
/*Only used if ffconfigHASH_CACHE is set to 1
|
||||
Set to CRC8 or CRC16 to use 8-bit or 16-bit HASH values respectively.*/
|
||||
#define ffconfigHASH_FUNCTION CRC16
|
||||
|
||||
/*Set to 1 to add a parameter to ff_mkdir() that allows an entire directory tree to be created in one go,
|
||||
rather than having to create one directory in the tree at a time.
|
||||
For example mkdir( “/etc/settings/network”, pdTRUE );.
|
||||
Set to 0 to use the normal mkdir() semantics (without the additional parameter).*/
|
||||
//可创建目录树
|
||||
#define ffconfigMKDIR_RECURSIVE 1
|
||||
|
||||
/*Set to 1 for each call to fnReadBlocks and fnWriteBlocks to be performed with a semphore lock.
|
||||
Set to 0 for each call to fnReadBlocks and fnWriteBlocks not to use an additional semaphore.*/
|
||||
//#define ffconfigBLKDEV_USES_SEM 0
|
||||
|
||||
/*Set to a function that will be used for all dynamic memory allocations.
|
||||
Setting to pvPortMalloc() will use the same memory allocator as FreeRTOS.
|
||||
For example: #define ffconfigMALLOC( size ) pvPortMalloc( size )*/
|
||||
#define ffconfigMALLOC( size ) pvPortMalloc( size )
|
||||
|
||||
/*Set to a function that matches the above allocator defined with ffconfigMALLOC.
|
||||
Setting to vPortFree() will use the same memory free function as FreeRTOS.
|
||||
For example: #define ffconfigFREE( ptr ) vPortFree( ptr )*/
|
||||
#define ffconfigFREE( ptr ) vPortFree( ptr )
|
||||
|
||||
/*Set to 1 to calculate the free size and volume size as a 64-bit number.
|
||||
Set to 0 to calculate these values as a 32-bit number.*/
|
||||
#define ffconfig64_NUM_SUPPORT 1
|
||||
|
||||
/*Defines the maximum number of partitions (and also logical partitions) that can be recognised.*/
|
||||
#define ffconfigMAX_PARTITIONS 4
|
||||
|
||||
/*Defines how many drives can be combined in total. Should be set to at least 2.*/
|
||||
#define ffconfigMAX_FILE_SYS 4
|
||||
|
||||
/*In case the low-level driver returns an error ‘FF_ERR_DRIVER_BUSY’,
|
||||
the library will pause for a number of ms, defined in ffconfigDRIVER_BUSY_SLEEP_MS before re-trying.*/
|
||||
#define ffconfigDRIVER_BUSY_SLEEP_MS 20
|
||||
|
||||
/*Set to 1 to include the ff_fprintf() function in the build.
|
||||
Set to 0 to exclude the ff_fprintf() function from the build.
|
||||
ff_fprintf() is quite a heavy function because it allocates RAM and brings in a lot of string and variable argument handling code.
|
||||
If ff_fprintf() is not being used then the code size can be reduced by setting ffconfigFPRINTF_SUPPORT to 0.*/
|
||||
#define ffconfigFPRINTF_SUPPORT 1
|
||||
|
||||
/*ff_fprintf() will allocate a buffer of this size in which it will create its formatted string. The buffer will be freed before the function exits.*/
|
||||
#define ffconfigFPRINTF_BUFFER_LENGTH 128
|
||||
|
||||
/*Set to 1 to inline some internal memory access functions.
|
||||
Set to 0 not to use inline memory access functions.*/
|
||||
#define ffconfigINLINE_MEMORY_ACCESS 0
|
||||
|
||||
/*Officially the only criteria to determine the FAT type (12, 16, or 32 bits) is the total number of clusters:
|
||||
if( ulNumberOfClusters < 4085 ) : Volume is FAT12
|
||||
if( ulNumberOfClusters < 65525 ) : Volume is FAT16
|
||||
if( ulNumberOfClusters >= 65525 ) : Volume is FAT32
|
||||
Not every formatted device follows the above rule.
|
||||
Set to 1 to perform additional checks over and above inspecting the number of clusters on a disk to determine the FAT type.
|
||||
Set to 0 to only look at the number of clusters on a disk to determine the FAT type.*/
|
||||
#define ffconfigFAT_CHECK 1
|
||||
|
||||
/*Sets the maximum length for file names,
|
||||
including the path. Note that the value of this define is directly related to the maximum stack use of the +FAT library.
|
||||
In some API’s, a character buffer of size ‘ffconfigMAX_FILENAME’ will be declared on stack.*/
|
||||
//#define ffconfigMAX_FILENAME (49+1)
|
||||
#define ffconfigMAX_FILENAME (79+1)
|
||||
|
||||
#define ffconfigMIN_CLUSTERS_FAT16 1024//2048
|
||||
|
||||
#endif
|
@ -0,0 +1,463 @@
|
||||
/*
|
||||
* FreeRTOS+FAT V2.3.3
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FF_DEFAULTCONFIG_H
|
||||
|
||||
/* The error numbers defined in this file will be moved to the core FreeRTOS
|
||||
* code in future versions of FreeRTOS - at which time the following header file
|
||||
* will be removed. */
|
||||
#include "FreeRTOS_errno_FAT.h"
|
||||
|
||||
#if !defined( ffconfigBYTE_ORDER )
|
||||
|
||||
/* Must be set to either pdFREERTOS_LITTLE_ENDIAN or pdFREERTOS_BIG_ENDIAN,
|
||||
* depending on the endian of the architecture on which FreeRTOS is running. */
|
||||
#error Invalid FreeRTOSFATConfig.h file: ffconfigBYTE_ORDER must be set to either pdFREERTOS_LITTLE_ENDIAN or pdFREERTOS_BIG_ENDIAN
|
||||
#endif
|
||||
|
||||
#if ( ffconfigBYTE_ORDER != pdFREERTOS_LITTLE_ENDIAN ) && ( ffconfigBYTE_ORDER != pdFREERTOS_BIG_ENDIAN )
|
||||
#error Invalid FreeRTOSFATConfig.h file: ffconfigBYTE_ORDER must be set to either pdFREERTOS_LITTLE_ENDIAN or pdFREERTOS_BIG_ENDIAN
|
||||
#endif
|
||||
|
||||
#if ( pdFREERTOS_LITTLE_ENDIAN != 0 ) || ( pdFREERTOS_BIG_ENDIAN != 1 )
|
||||
#error Invalid projdefs.h or FreeRTOS_errno_FAT.h file
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigHAS_CWD )
|
||||
|
||||
/* Set to 1 to maintain a current working directory (CWD) for each task that
|
||||
* accesses the file system, allowing relative paths to be used.
|
||||
*
|
||||
* Set to 0 not to use a CWD, in which case full paths must be used for each
|
||||
* file access. */
|
||||
#define ffconfigHAS_CWD 0
|
||||
|
||||
#if !defined( ffconfigCWD_THREAD_LOCAL_INDEX )
|
||||
#error ffconfigCWD_THREAD_LOCAL_INDEX must be set to a free position within FreeRTOSs thread local storage pointer array for storage of a pointer to the CWD structure.
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigLFN_SUPPORT )
|
||||
|
||||
/* Set to 1 to include long file name support. Set to 0 to exclude long
|
||||
* file name support.
|
||||
*
|
||||
* If long file name support is excluded then only 8.3 file names can be used.
|
||||
* Long file names will be recognised but ignored.
|
||||
*
|
||||
* Users should familiarise themselves with any patent issues that may
|
||||
* potentially exist around the use of long file names in FAT file systems
|
||||
* before enabling long file name support. */
|
||||
#define ffconfigLFN_SUPPORT 0
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigINCLUDE_SHORT_NAME )
|
||||
|
||||
/* Only used when ffconfigLFN_SUPPORT is set to 1.
|
||||
*
|
||||
* Set to 1 to include a file's short name when listing a directory, i.e. when
|
||||
* calling findfirst()/findnext(). The short name will be stored in the
|
||||
* 'pcShortName' field of FF_DirEnt_t.
|
||||
*
|
||||
* Set to 0 to only include a file's long name. */
|
||||
#define ffconfigINCLUDE_SHORT_NAME 0
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigSHORTNAME_CASE )
|
||||
|
||||
/* Set to 1 to recognise and apply the case bits used by Windows XP+ when
|
||||
* using short file names - storing file names such as "readme.TXT" or
|
||||
* "SETUP.exe" in a short-name entry. This is the recommended setting for
|
||||
* maximum compatibility.
|
||||
*
|
||||
* Set to 0 to ignore the case bits. */
|
||||
#define ffconfigSHORTNAME_CASE 0
|
||||
#endif
|
||||
|
||||
#if !defined( ipconfigQUICK_SHORT_FILENAME_CREATION )
|
||||
|
||||
/* This method saves a lot of time when creating directories with
|
||||
* many similar file names: when the short name version of a LFN already
|
||||
* exists, try at most 3 entries with a tilde:
|
||||
* README~1.TXT
|
||||
* README~2.TXT
|
||||
* README~3.TXT
|
||||
* After that create entries with pseudo-random 4-digit hex digits:
|
||||
* REA~E7BB.TXT
|
||||
* REA~BA32.TXT
|
||||
* REA~D394.TXT
|
||||
*/
|
||||
#define ipconfigQUICK_SHORT_FILENAME_CREATION 1
|
||||
#endif
|
||||
|
||||
/* ASCII versus UNICODE, UTF-16 versus UTF-8 :
|
||||
* FAT directories, when using Long File Names, always store file and directory
|
||||
* names UTF-16 encoded.
|
||||
* The user can select how these names must be represented internally:
|
||||
* - ASCII (default)
|
||||
* - UTF-8 (ffconfigUNICODE_UTF8_SUPPORT = 1)
|
||||
* - UTF-16 (ffconfigUNICODE_UTF16_SUPPORT = 1)
|
||||
*/
|
||||
#if ( ffconfigUNICODE_UTF16_SUPPORT == 0 )
|
||||
|
||||
/* Only used when ffconfigLFN_SUPPORT is set to 1.
|
||||
*
|
||||
* Set to 1 to use UTF-16 (wide-characters) for file and directory names.
|
||||
*
|
||||
* Set to 0 to use either 8-bit ASCII or UTF-8 for file and directory names
|
||||
* (see the ffconfigUNICODE_UTF8_SUPPORT). */
|
||||
#define ffconfigUNICODE_UTF16_SUPPORT 0
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigUNICODE_UTF8_SUPPORT )
|
||||
|
||||
/* Only used when ffconfigLFN_SUPPORT is set to 1.
|
||||
*
|
||||
* Set to 1 to use UTF-8 encoding for file and directory names.
|
||||
*
|
||||
* Set to 0 to use either 8-bit ASCII or UTF-16 for file and directory
|
||||
* names (see the ffconfig_UTF_16_SUPPORT setting). */
|
||||
#define ffconfigUNICODE_UTF8_SUPPORT 0
|
||||
#endif
|
||||
|
||||
#if ( ffconfigUNICODE_UTF16_SUPPORT != 0 ) && ( ffconfigUNICODE_UTF8_SUPPORT != 0 )
|
||||
#error Can not use both UTF-16 and UTF-8
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigFAT12_SUPPORT )
|
||||
|
||||
/* Set to 1 to include FAT12 support.
|
||||
*
|
||||
* Set to 0 to exclude FAT12 support.
|
||||
*
|
||||
* FAT16 and FAT32 are always enabled. */
|
||||
#define ffconfigFAT12_SUPPORT 0
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigOPTIMISE_UNALIGNED_ACCESS )
|
||||
|
||||
/* When writing and reading data, i/o becomes less efficient if sizes other
|
||||
* than the sector size (usually 512 bytes) are being used. When set to 1, each file handle will
|
||||
* allocate a one sector size character buffer to facilitate "unaligned access". */
|
||||
#define ffconfigOPTIMISE_UNALIGNED_ACCESS 0
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigCACHE_WRITE_THROUGH )
|
||||
|
||||
/* Input and output to a disk uses buffers that are only flushed at the
|
||||
* following times:
|
||||
*
|
||||
* - When a new buffer is needed and no other buffers are available.
|
||||
* - When opening a buffer in READ mode for a sector that has just been changed.
|
||||
* - After creating, removing or closing a file or a directory.
|
||||
*
|
||||
* Normally this is quick enough and it is efficient. If
|
||||
* ffconfigCACHE_WRITE_THROUGH is set to 1 then buffers will also be flushed each
|
||||
* time a buffer is released - which is less efficient but more secure. */
|
||||
#define ffconfigCACHE_WRITE_THROUGH 0
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigWRITE_BOTH_FATS )
|
||||
|
||||
/* In most cases, the FAT table has two identical copies on the disk,
|
||||
* allowing the second copy to be used in the case of a read error. If
|
||||
*
|
||||
* Set to 1 to use both FATs - this is less efficient but more secure.
|
||||
*
|
||||
* Set to 0 to use only one FAT - the second FAT will never be written to. */
|
||||
#define ffconfigWRITE_BOTH_FATS 0
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigWRITE_FREE_COUNT )
|
||||
|
||||
/* Set to 1 to have the number of free clusters and the first free cluster
|
||||
* to be written to the FS info sector each time one of those values changes.
|
||||
*
|
||||
* Set to 0 not to store these values in the FS info sector, making booting
|
||||
* slower, but making changes faster. */
|
||||
#define ffconfigWRITE_FREE_COUNT 0
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigTIME_SUPPORT )
|
||||
|
||||
/* Set to 1 to maintain file and directory time stamps for creation, modify
|
||||
* and last access.
|
||||
*
|
||||
* Set to 0 to exclude time stamps.
|
||||
*
|
||||
* If time support is used, the following function must be supplied:
|
||||
*
|
||||
* time_t FreeRTOS_time( time_t *pxTime );
|
||||
*
|
||||
* FreeRTOS_time has the same semantics as the standard time() function. */
|
||||
#define ffconfigTIME_SUPPORT 0
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigREMOVABLE_MEDIA )
|
||||
|
||||
/* Set to 1 if the media is removable (such as a memory card).
|
||||
*
|
||||
* Set to 0 if the media is not removable.
|
||||
*
|
||||
* When set to 1 all file handles will be "invalidated" if the media is
|
||||
* extracted. If set to 0 then file handles will not be invalidated.
|
||||
* In that case the user will have to confirm that the media is still present
|
||||
* before every access. */
|
||||
#define ffconfigREMOVABLE_MEDIA 0
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigMOUNT_FIND_FREE )
|
||||
|
||||
/* Set to 1 to determine the disk's free space and the disk's first free
|
||||
* cluster when a disk is mounted.
|
||||
*
|
||||
* Set to 0 to find these two values when they are first needed. Determining
|
||||
* the values can take some time. */
|
||||
#define ffconfigMOUNT_FIND_FREE 0
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigFSINFO_TRUSTED )
|
||||
|
||||
/* Set to 1 to 'trust' the contents of the 'ulLastFreeCluster' and
|
||||
* ulFreeClusterCount fields.
|
||||
*
|
||||
* Set to 0 not to 'trust' these fields.*/
|
||||
#define ffconfigFSINFO_TRUSTED 0
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigFINDAPI_ALLOW_WILDCARDS )
|
||||
/* For now must be set to 0. */
|
||||
#define ffconfigFINDAPI_ALLOW_WILDCARDS 0
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigWILDCARD_CASE_INSENSITIVE )
|
||||
/* For now must be set to 0. */
|
||||
#define ffconfigWILDCARD_CASE_INSENSITIVE 0
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigPATH_CACHE )
|
||||
|
||||
/* Set to 1 to store recent paths in a cache, enabling much faster access
|
||||
* when the path is deep within a directory structure at the expense of
|
||||
* additional RAM usage.
|
||||
*
|
||||
* Set to 0 to not use a path cache. */
|
||||
#define ffconfigPATH_CACHE 0
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigPATH_CACHE_DEPTH )
|
||||
|
||||
/* Only used if ffconfigPATH_CACHE is 1.
|
||||
*
|
||||
* Sets the maximum number of paths that can exist in the patch cache at any
|
||||
* one time. */
|
||||
#define ffconfigPATH_CACHE_DEPTH 5
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigHASH_CACHE )
|
||||
|
||||
/* Set to 1 to calculate a HASH value for each existing short file name.
|
||||
* Use of HASH values can improve performance when working with large
|
||||
* directories, or with files that have a similar name.
|
||||
*
|
||||
* Set to 0 not to calculate a HASH value. */
|
||||
#define ffconfigHASH_CACHE 0
|
||||
#endif
|
||||
|
||||
#if ( ffconfigHASH_CACHE != 0 )
|
||||
#if !defined( ffconfigHASH_FUNCTION )
|
||||
|
||||
/* Only used if ffconfigHASH_CACHE is set to 1
|
||||
*
|
||||
* Set to CRC8 or CRC16 to use 8-bit or 16-bit HASH values respectively. */
|
||||
#define ffconfigHASH_FUNCTION CRC16
|
||||
#endif
|
||||
|
||||
#if ffconfigHASH_FUNCTION == CRC16
|
||||
#define ffconfigHASH_TABLE_SIZE 8192
|
||||
#elif ffconfigHASH_FUNCTION == CRC8
|
||||
#define ffconfigHASH_TABLE_SIZE 32
|
||||
#else
|
||||
#error Invalid Hashing function selected. CRC16 or CRC8. See your FreeRTOSFATConfig.h.
|
||||
#endif
|
||||
#endif /* ffconfigHASH_CACHE != 0 */
|
||||
|
||||
#if !defined( ffconfigMKDIR_RECURSIVE )
|
||||
|
||||
/* Set to 1 to add a parameter to ff_mkdir() that allows an entire directory
|
||||
* tree to be created in one go, rather than having to create one directory in
|
||||
* the tree at a time. For example mkdir( "/etc/settings/network", pdTRUE );.
|
||||
*
|
||||
* Set to 0 to use the normal mkdir() semantics (without the additional
|
||||
* parameter). */
|
||||
#define ffconfigMKDIR_RECURSIVE 0
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigMALLOC )
|
||||
|
||||
/* Set to a function that will be used for all dynamic memory allocations.
|
||||
* Setting to pvPortMalloc() will use the same memory allocator as FreeRTOS. */
|
||||
#define ffconfigMALLOC( size ) pvPortMalloc( size )
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigFREE )
|
||||
|
||||
/* Set to a function that matches the above allocator defined with
|
||||
* ffconfigMALLOC. Setting to vPortFree() will use the same memory free
|
||||
* function as FreeRTOS. */
|
||||
#define ffconfigFREE( ptr ) vPortFree( ptr )
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfig64_NUM_SUPPORT )
|
||||
|
||||
/* Set to 1 to calculate the free size and volume size as a 64-bit number.
|
||||
*
|
||||
* Set to 0 to calculate these values as a 32-bit number. */
|
||||
#define ffconfig64_NUM_SUPPORT 0
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigMAX_PARTITIONS )
|
||||
|
||||
/* Defines the maximum number of partitions (and also logical partitions)
|
||||
* that can be recognised. */
|
||||
#define ffconfigMAX_PARTITIONS 4
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigMAX_FILE_SYS )
|
||||
|
||||
/* Defines how many drives can be combined in total. Should be set to at
|
||||
* least 2. */
|
||||
#define ffconfigMAX_FILE_SYS 4
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigDRIVER_BUSY_SLEEP_MS )
|
||||
|
||||
/* In case the low-level driver returns an error 'FF_ERR_DRIVER_BUSY',
|
||||
* the library will pause for a number of ms, defined in
|
||||
* ffconfigDRIVER_BUSY_SLEEP_MS before re-trying. */
|
||||
#define ffconfigDRIVER_BUSY_SLEEP_MS 20
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigFPRINTF_SUPPORT )
|
||||
|
||||
/* Set to 1 to include the ff_fprintf() function.
|
||||
*
|
||||
* Set to 0 to exclude the ff_fprintf() function.
|
||||
*
|
||||
* ff_fprintf() is quite a heavy function because it allocates RAM and
|
||||
* brings in a lot of string and variable argument handling code. If
|
||||
* ff_fprintf() is not being used then the code size can be reduced by setting
|
||||
* ffconfigFPRINTF_SUPPORT to 0. */
|
||||
#define ffconfigFPRINTF_SUPPORT 0
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigFPRINTF_BUFFER_LENGTH )
|
||||
|
||||
/* ff_fprintf() will allocate a buffer of this size in which it will create
|
||||
* its formatted string. The buffer will be freed before the function
|
||||
* exits. */
|
||||
#define ffconfigFPRINTF_BUFFER_LENGTH 128
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigDEBUG )
|
||||
#define ffconfigDEBUG 0
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigLONG_ERR_MSG )
|
||||
#define ffconfigLONG_ERR_MSG 0
|
||||
#endif
|
||||
|
||||
#if ( ffconfigDEBUG != 0 )
|
||||
#if !defined( ffconfigHAS_FUNCTION_TAB )
|
||||
#define ffconfigHAS_FUNCTION_TAB 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigINLINE_MEMORY_ACCESS )
|
||||
|
||||
/* Set to 1 to inline some internal memory access functions.
|
||||
*
|
||||
* Set to 0 to not inline the memory access functions. */
|
||||
#define ffconfigINLINE_MEMORY_ACCESS 0
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigMIRROR_FATS_UMOUNT )
|
||||
/*_RB_ not sure. */
|
||||
#define ffconfigMIRROR_FATS_UMOUNT 0
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigFAT_CHECK )
|
||||
|
||||
/* Officially the only criteria to determine the FAT type (12, 16, or 32
|
||||
* bits) is the total number of clusters:
|
||||
* if( ulNumberOfClusters < 4085 ) : Volume is FAT12
|
||||
* if( ulNumberOfClusters < 65525 ) : Volume is FAT16
|
||||
* if( ulNumberOfClusters >= 65525 ) : Volume is FAT32
|
||||
* Not every formatted device follows the above rule.
|
||||
*
|
||||
* Set to 1 to perform additional checks over and above inspecting the
|
||||
* number of clusters on a disk to determine the FAT type.
|
||||
*
|
||||
* Set to 0 to only look at the number of clusters on a disk to determine the
|
||||
* FAT type. */
|
||||
#define ffconfigFAT_CHECK 0
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigMAX_FILENAME )
|
||||
|
||||
/* Sets the maximum length for file names, including the path.
|
||||
* Note that the value of this define is directly related to the maximum stack
|
||||
* use of the +FAT library. In some API's, a character buffer of size
|
||||
* 'ffconfigMAX_FILENAME' will be declared on stack. */
|
||||
#define ffconfigMAX_FILENAME 129
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigUSE_DELTREE )
|
||||
|
||||
/* By default, do not include the recursive function ff_deltree() as
|
||||
* recursion breaches the coding standard - USE WITH CARE. */
|
||||
#define ffconfigUSE_DELTREE 0
|
||||
#endif
|
||||
|
||||
#if !defined( ffconfigFILE_EXTEND_FLUSHES_BUFFERS )
|
||||
|
||||
/* When writing large files, the contents of the FAT entries will be flushed
|
||||
* after every call to FF_Write(). This flushing can be inhibited, by defining
|
||||
* ffconfigFILE_EXTEND_FLUSHES_BUFFERS as 0. */
|
||||
#define ffconfigFILE_EXTEND_FLUSHES_BUFFERS 1
|
||||
#endif
|
||||
|
||||
#if !defined( FF_PRINTF )
|
||||
#define FF_PRINTF FF_PRINTF
|
||||
static portINLINE void FF_PRINTF( const char * pcFormat,
|
||||
... )
|
||||
{
|
||||
( void ) pcFormat;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ifndef FF_DEFAULTCONFIG_H */
|
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* FreeRTOS+FAT V2.3.3
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FREERTOS_ERRNO_FAT
|
||||
#define FREERTOS_ERRNO_FAT
|
||||
|
||||
/* The following definitions will be included in the core FreeRTOS code in
|
||||
* future versions of FreeRTOS - hence the 'pd' (ProjDefs) prefix - at which time
|
||||
* this file will be removed. */
|
||||
|
||||
/* The following errno values are used by FreeRTOS+ components, not FreeRTOS
|
||||
* itself. */
|
||||
|
||||
/* For future compatibility (see comment above), check the definitions have not
|
||||
* already been made. */
|
||||
#ifndef pdFREERTOS_ERRNO_NONE
|
||||
#define pdFREERTOS_ERRNO_NONE 0 /* No errors */
|
||||
#define pdFREERTOS_ERRNO_ENOENT 2 /* No such file or directory */
|
||||
#define pdFREERTOS_ERRNO_EIO 5 /* I/O error */
|
||||
#define pdFREERTOS_ERRNO_ENXIO 6 /* No such device or address */
|
||||
#define pdFREERTOS_ERRNO_EBADF 9 /* Bad file number */
|
||||
#define pdFREERTOS_ERRNO_EAGAIN 11 /* No more processes */
|
||||
#define pdFREERTOS_ERRNO_EWOULDBLOCK 11 /* Operation would block */
|
||||
#define pdFREERTOS_ERRNO_ENOMEM 12 /* Not enough memory */
|
||||
#define pdFREERTOS_ERRNO_EACCES 13 /* Permission denied */
|
||||
#define pdFREERTOS_ERRNO_EFAULT 14 /* Bad address */
|
||||
#define pdFREERTOS_ERRNO_EBUSY 16 /* Mount device busy */
|
||||
#define pdFREERTOS_ERRNO_EEXIST 17 /* File exists */
|
||||
#define pdFREERTOS_ERRNO_EXDEV 18 /* Cross-device link */
|
||||
#define pdFREERTOS_ERRNO_ENODEV 19 /* No such device */
|
||||
#define pdFREERTOS_ERRNO_ENOTDIR 20 /* Not a directory */
|
||||
#define pdFREERTOS_ERRNO_EISDIR 21 /* Is a directory */
|
||||
#define pdFREERTOS_ERRNO_EINVAL 22 /* Invalid argument */
|
||||
#define pdFREERTOS_ERRNO_ENOSPC 28 /* No space left on device */
|
||||
#define pdFREERTOS_ERRNO_ESPIPE 29 /* Illegal seek */
|
||||
#define pdFREERTOS_ERRNO_EROFS 30 /* Read only file system */
|
||||
#define pdFREERTOS_ERRNO_EUNATCH 42 /* Protocol driver not attached */
|
||||
#define pdFREERTOS_ERRNO_EBADE 50 /* Invalid exchange */
|
||||
#define pdFREERTOS_ERRNO_EFTYPE 79 /* Inappropriate file type or format */
|
||||
#define pdFREERTOS_ERRNO_ENMFILE 89 /* No more files */
|
||||
#define pdFREERTOS_ERRNO_ENOTEMPTY 90 /* Directory not empty */
|
||||
#define pdFREERTOS_ERRNO_ENAMETOOLONG 91 /* File or path name too long */
|
||||
#define pdFREERTOS_ERRNO_EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
|
||||
#define pdFREERTOS_ERRNO_ENOBUFS 105 /* No buffer space available */
|
||||
#define pdFREERTOS_ERRNO_ENOPROTOOPT 109 /* Protocol not available */
|
||||
#define pdFREERTOS_ERRNO_EADDRINUSE 112 /* Address already in use */
|
||||
#define pdFREERTOS_ERRNO_ETIMEDOUT 116 /* Connection timed out */
|
||||
#define pdFREERTOS_ERRNO_EINPROGRESS 119 /* Connection already in progress */
|
||||
#define pdFREERTOS_ERRNO_EALREADY 120 /* Socket already connected */
|
||||
#define pdFREERTOS_ERRNO_EADDRNOTAVAIL 125 /* Address not available */
|
||||
#define pdFREERTOS_ERRNO_EISCONN 127 /* Socket is already connected */
|
||||
#define pdFREERTOS_ERRNO_ENOTCONN 128 /* Socket is not connected */
|
||||
#define pdFREERTOS_ERRNO_ENOMEDIUM 135 /* No medium inserted */
|
||||
#define pdFREERTOS_ERRNO_EILSEQ 138 /* An invalid UTF-16 sequence was encountered. */
|
||||
#define pdFREERTOS_ERRNO_ECANCELED 140 /* Operation canceled. */
|
||||
|
||||
/* The following endian values are used by FreeRTOS+ components, not FreeRTOS
|
||||
* itself. */
|
||||
#define pdFREERTOS_LITTLE_ENDIAN 0
|
||||
#define pdFREERTOS_BIG_ENDIAN 1
|
||||
|
||||
#endif /* pdFREERTOS_ERRNO_NONE */
|
||||
|
||||
#endif /* FREERTOS_ERRNO_FAT */
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* FreeRTOS+FAT V2.3.3
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file ff_crc.h
|
||||
* @ingroup CRC
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef _FF_CRC_H_
|
||||
|
||||
#define _FF_CRC_H_
|
||||
|
||||
uint8_t FF_GetCRC8( uint8_t * pbyData,
|
||||
uint32_t stLength );
|
||||
uint16_t FF_GetCRC16( uint8_t * pbyData,
|
||||
uint32_t stLength );
|
||||
uint32_t FF_GetCRC32( uint8_t * pbyData,
|
||||
uint32_t stLength );
|
||||
extern const uint32_t crc32_table[ 256 ];
|
||||
|
||||
#endif /* ifndef _FF_CRC_H_ */
|
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* FreeRTOS+FAT V2.3.3
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file ff_devices.h
|
||||
**/
|
||||
#ifndef FF_DEVICES_H
|
||||
#define FF_DEVICES_H
|
||||
|
||||
#ifndef PLUS_FAT_H
|
||||
#error this header will be included from "ff_headers.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define FF_DEV_NO_DEV 0
|
||||
#define FF_DEV_CHAR_DEV 1
|
||||
#define FF_DEV_BLOCK_DEV 2
|
||||
|
||||
BaseType_t xCheckDevicePath( const char * pcPath );
|
||||
|
||||
int FF_Device_Seek( FF_FILE * pxStream,
|
||||
long lOffset,
|
||||
int iWhence );
|
||||
|
||||
BaseType_t FF_Device_Open( const char * pcPath,
|
||||
FF_FILE * pxStream );
|
||||
|
||||
void FF_Device_Close( FF_FILE * pxStream );
|
||||
|
||||
size_t FF_Device_Read( void * pvBuf,
|
||||
size_t lSize,
|
||||
size_t lCount,
|
||||
FF_FILE * pxStream );
|
||||
|
||||
size_t FF_Device_Write( const void * pvBuf,
|
||||
size_t lSize,
|
||||
size_t lCount,
|
||||
FF_FILE * pxStream );
|
||||
|
||||
|
||||
int FF_Device_GetDirEnt( const char * pcPath,
|
||||
FF_DirEnt_t * pxDirEnt );
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* FF_DEVICES_H */
|
274
MXC_A27-PCB4.5-270T/FreeRTOS-Plus/FreeRTOS-FAT/include/ff_dir.h
Normal file
274
MXC_A27-PCB4.5-270T/FreeRTOS-Plus/FreeRTOS-FAT/include/ff_dir.h
Normal file
@ -0,0 +1,274 @@
|
||||
/*
|
||||
* FreeRTOS+FAT V2.3.3
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file ff_dir.h
|
||||
* @ingroup DIR
|
||||
**/
|
||||
#ifndef _FF_DIR_H_
|
||||
|
||||
#define _FF_DIR_H_
|
||||
|
||||
#ifndef PLUS_FAT_H
|
||||
#error this header will be included from "ff_headers.h"
|
||||
#endif
|
||||
|
||||
#define FIND_FLAG_SHORTNAME_SET 0x01u
|
||||
#define FIND_FLAG_SHORTNAME_CHECKED 0x02u
|
||||
#define FIND_FLAG_SHORTNAME_FOUND 0x04u
|
||||
#define FIND_FLAG_FITS_SHORT 0x08u
|
||||
#define FIND_FLAG_SIZE_OK 0x10u
|
||||
#define FIND_FLAG_CREATE_FLAG 0x20u
|
||||
|
||||
#define FIND_FLAG_FITS_SHORT_OK ( FIND_FLAG_FITS_SHORT | FIND_FLAG_SIZE_OK )
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t ulChainLength;
|
||||
uint32_t ulDirCluster;
|
||||
uint32_t ulCurrentClusterLCN;
|
||||
uint32_t ulCurrentClusterNum;
|
||||
FF_Buffer_t * pxBuffer;
|
||||
} FF_FetchContext_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t ulFileSize;
|
||||
uint32_t ulObjectCluster;
|
||||
|
||||
/* Book Keeping. */
|
||||
uint32_t ulCurrentCluster;
|
||||
uint32_t ulAddrCurrentCluster;
|
||||
uint32_t ulDirCluster;
|
||||
uint16_t usCurrentItem;
|
||||
/* End Book Keeping. */
|
||||
|
||||
#if ( ffconfigTIME_SUPPORT != 0 )
|
||||
FF_SystemTime_t xCreateTime; /* Date and Time Created. */
|
||||
FF_SystemTime_t xModifiedTime; /* Date and Time Modified. */
|
||||
FF_SystemTime_t xAccessedTime; /* Date of Last Access. */
|
||||
#endif
|
||||
|
||||
#if ( ffconfigFINDAPI_ALLOW_WILDCARDS != 0 )
|
||||
#if ( ffconfigUNICODE_UTF16_SUPPORT != 0 )
|
||||
FF_T_WCHAR pcWildCard[ ffconfigMAX_FILENAME ];
|
||||
#else
|
||||
char pcWildCard[ ffconfigMAX_FILENAME ];
|
||||
#endif
|
||||
BaseType_t xInvertWildCard;
|
||||
#endif
|
||||
|
||||
#if ( ffconfigUNICODE_UTF16_SUPPORT != 0 )
|
||||
FF_T_WCHAR pcFileName[ ffconfigMAX_FILENAME ];
|
||||
#else
|
||||
char pcFileName[ ffconfigMAX_FILENAME ];
|
||||
#endif
|
||||
|
||||
#if ( ffconfigLFN_SUPPORT != 0 ) && ( ffconfigINCLUDE_SHORT_NAME != 0 )
|
||||
char pcShortName[ 13 ];
|
||||
#endif
|
||||
uint8_t ucAttrib;
|
||||
#if ( ffconfigDEV_SUPPORT != 0 )
|
||||
uint8_t ucIsDeviceDir;
|
||||
#endif
|
||||
FF_FetchContext_t xFetchContext;
|
||||
} FF_DirEnt_t;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Some public API's, i.e. they're used but ff_stdio.c
|
||||
*/
|
||||
#if ( ffconfigUNICODE_UTF16_SUPPORT != 0 )
|
||||
FF_Error_t FF_FindFirst( FF_IOManager_t * pxIOManager,
|
||||
FF_DirEnt_t * pxDirent,
|
||||
const FF_T_WCHAR * pcPath );
|
||||
FF_Error_t FF_MkDir( FF_IOManager_t * pxIOManager,
|
||||
const FF_T_WCHAR * pcPath );
|
||||
#else
|
||||
FF_Error_t FF_FindFirst( FF_IOManager_t * pxIOManager,
|
||||
FF_DirEnt_t * pxDirent,
|
||||
const char * pcPath );
|
||||
FF_Error_t FF_MkDir( FF_IOManager_t * pxIOManager,
|
||||
const char * pcPath );
|
||||
#endif /* if ( ffconfigUNICODE_UTF16_SUPPORT != 0 ) */
|
||||
|
||||
FF_Error_t FF_FindNext( FF_IOManager_t * pxIOManager,
|
||||
FF_DirEnt_t * pxDirent );
|
||||
|
||||
static portINLINE void FF_RewindFind( FF_DirEnt_t * pxDirent )
|
||||
{
|
||||
pxDirent->usCurrentItem = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Some API's internal to the +FAT library.
|
||||
*/
|
||||
FF_Error_t FF_GetEntry( FF_IOManager_t * pxIOManager,
|
||||
uint16_t usEntry,
|
||||
uint32_t ulDirCluster,
|
||||
FF_DirEnt_t * pxDirent );
|
||||
FF_Error_t FF_PutEntry( FF_IOManager_t * pxIOManager,
|
||||
uint16_t usEntry,
|
||||
uint32_t ulDirCluster,
|
||||
FF_DirEnt_t * pxDirent,
|
||||
uint8_t * pucContents );
|
||||
int8_t FF_FindEntry( FF_IOManager_t * pxIOManager,
|
||||
uint32_t ulDirCluster,
|
||||
int8_t * Name,
|
||||
FF_DirEnt_t * pxDirent,
|
||||
BaseType_t LFNs );
|
||||
|
||||
void FF_PopulateShortDirent( FF_IOManager_t * pxIOManager,
|
||||
FF_DirEnt_t * pxDirent,
|
||||
const uint8_t * pucEntryBuffer );
|
||||
FF_Error_t FF_PopulateLongDirent( FF_IOManager_t * pxIOManager,
|
||||
FF_DirEnt_t * pxDirent,
|
||||
uint16_t usEntry,
|
||||
FF_FetchContext_t * pFetchContext );
|
||||
|
||||
FF_Error_t FF_InitEntryFetch( FF_IOManager_t * pxIOManager,
|
||||
uint32_t ulDirCluster,
|
||||
FF_FetchContext_t * pContext );
|
||||
FF_Error_t FF_FetchEntryWithContext( FF_IOManager_t * pxIOManager,
|
||||
uint32_t ulEntry,
|
||||
FF_FetchContext_t * pContext,
|
||||
uint8_t * pEntryBuffer );
|
||||
FF_Error_t FF_PushEntryWithContext( FF_IOManager_t * pxIOManager,
|
||||
uint32_t ulEntry,
|
||||
FF_FetchContext_t * pContext,
|
||||
uint8_t * pEntryBuffer );
|
||||
FF_Error_t FF_CleanupEntryFetch( FF_IOManager_t * pxIOManager,
|
||||
FF_FetchContext_t * pContext );
|
||||
|
||||
int8_t FF_PushEntry( FF_IOManager_t * pxIOManager,
|
||||
uint32_t ulDirCluster,
|
||||
uint16_t usEntry,
|
||||
uint8_t * buffer,
|
||||
void * pParam );
|
||||
|
||||
static portINLINE BaseType_t FF_isEndOfDir( const uint8_t * pucEntryBuffer )
|
||||
{
|
||||
return pucEntryBuffer[ 0 ] == ( uint8_t ) 0;
|
||||
}
|
||||
|
||||
static portINLINE BaseType_t FF_isDeleted( const uint8_t * pucEntryBuffer )
|
||||
{
|
||||
return pucEntryBuffer[ 0 ] == ( uint8_t ) FF_FAT_DELETED;
|
||||
}
|
||||
|
||||
struct _FF_FIND_PARAMS
|
||||
{
|
||||
uint32_t ulDirCluster; /* The beginning cluster of this directory. */
|
||||
int32_t lFreeEntry; /* The first free entry big enough to add the file. */
|
||||
uint32_t ulFlags; /* See FIND_FLAG_xxx defines above. */
|
||||
char pcEntryBuffer[ 32 ]; /* LFN converted to short name. */
|
||||
uint8_t ucCaseAttrib;
|
||||
uint8_t ucFirstTilde;
|
||||
};
|
||||
|
||||
typedef struct _FF_FIND_PARAMS FF_FindParams_t;
|
||||
|
||||
#if ( ffconfigUNICODE_UTF16_SUPPORT != 0 )
|
||||
uint32_t FF_CreateFile( FF_IOManager_t * pxIOManager,
|
||||
FF_FindParams_t * findParams,
|
||||
FF_T_WCHAR * FileName,
|
||||
FF_DirEnt_t * pxDirent,
|
||||
FF_Error_t * pError );
|
||||
|
||||
uint32_t FF_FindEntryInDir( FF_IOManager_t * pxIOManager,
|
||||
FF_FindParams_t * findParams,
|
||||
const FF_T_WCHAR * name,
|
||||
uint8_t pa_Attrib,
|
||||
FF_DirEnt_t * pxDirent,
|
||||
FF_Error_t * pError );
|
||||
|
||||
uint32_t FF_FindDir( FF_IOManager_t * pxIOManager,
|
||||
const FF_T_WCHAR * pcPath,
|
||||
uint16_t pathLen,
|
||||
FF_Error_t * pError );
|
||||
void FF_CreateShortName( FF_FindParams_t * pxFindParams,
|
||||
const FF_T_WCHAR * pcLongName );
|
||||
#else /* if ( ffconfigUNICODE_UTF16_SUPPORT != 0 ) */
|
||||
uint32_t FF_CreateFile( FF_IOManager_t * pxIOManager,
|
||||
FF_FindParams_t * findParams,
|
||||
char * FileName,
|
||||
FF_DirEnt_t * pxDirent,
|
||||
FF_Error_t * pError );
|
||||
|
||||
uint32_t FF_FindEntryInDir( FF_IOManager_t * pxIOManager,
|
||||
FF_FindParams_t * findParams,
|
||||
const char * name,
|
||||
uint8_t pa_Attrib,
|
||||
FF_DirEnt_t * pxDirent,
|
||||
FF_Error_t * pError );
|
||||
|
||||
uint32_t FF_FindDir( FF_IOManager_t * pxIOManager,
|
||||
const char * pcPath,
|
||||
uint16_t pathLen,
|
||||
FF_Error_t * pError );
|
||||
void FF_CreateShortName( FF_FindParams_t * pxFindParams,
|
||||
const char * pcLongName );
|
||||
#endif /* if ( ffconfigUNICODE_UTF16_SUPPORT != 0 ) */
|
||||
|
||||
int32_t FF_FindShortName( FF_IOManager_t * pxIOManager,
|
||||
FF_FindParams_t * findParams );
|
||||
|
||||
FF_Error_t FF_CreateDirent( FF_IOManager_t * pxIOManager,
|
||||
FF_FindParams_t * findParams,
|
||||
FF_DirEnt_t * pxDirent );
|
||||
FF_Error_t FF_ExtendDirectory( FF_IOManager_t * pxIOManager,
|
||||
uint32_t ulDirCluster );
|
||||
FF_Error_t FF_RmLFNs( FF_IOManager_t * pxIOManager,
|
||||
uint16_t usDirEntry,
|
||||
FF_FetchContext_t * pContext );
|
||||
|
||||
#if ( ffconfigHASH_CACHE != 0 )
|
||||
BaseType_t FF_CheckDirentHash( FF_IOManager_t * pxIOManager,
|
||||
uint32_t ulDirCluster,
|
||||
uint32_t ulHash );
|
||||
BaseType_t FF_DirHashed( FF_IOManager_t * pxIOManager,
|
||||
uint32_t ulDirCluster );
|
||||
void FF_AddDirentHash( FF_IOManager_t * pxIOManager,
|
||||
uint32_t ulDirCluster,
|
||||
uint32_t ulHash );
|
||||
FF_Error_t FF_HashDir( FF_IOManager_t * pxIOManager,
|
||||
uint32_t ulDirCluster );
|
||||
void FF_UnHashDir( FF_IOManager_t * pxIOManager,
|
||||
uint32_t ulDirCluster );
|
||||
#endif /* if ( ffconfigHASH_CACHE != 0 ) */
|
||||
|
||||
struct SBuffStats
|
||||
{
|
||||
unsigned sectorMatch;
|
||||
unsigned sectorMiss;
|
||||
unsigned bufCounts;
|
||||
unsigned bufCalls;
|
||||
};
|
||||
|
||||
extern struct SBuffStats buffStats;
|
||||
|
||||
#endif /* ifndef _FF_DIR_H_ */
|
@ -0,0 +1,264 @@
|
||||
/*
|
||||
* FreeRTOS+FAT V2.3.3
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _FF_ERROR_H_
|
||||
#define _FF_ERROR_H_
|
||||
|
||||
/**
|
||||
* @file ff_error.h
|
||||
* @ingroup ERROR
|
||||
**/
|
||||
|
||||
/**
|
||||
* Error codes are 32-bit numbers, and consist of three items:
|
||||
* 1Bit 7Bits 8Bits 16Bits
|
||||
* . ........ ........ ........ ........
|
||||
* [ErrFlag][ModuleID][FunctionID][-- ERROR CODE --]
|
||||
*
|
||||
* Error Codes should always have the ErrFlag set, this is the reason why all module
|
||||
* codes include it.
|
||||
*
|
||||
* When returning an error simply return the defined Error Code, OR'd with the function
|
||||
* name (capitalised) in which the error has occurred.
|
||||
*
|
||||
* When receiving an Error code from another layer, do not modify the code, as this will
|
||||
* prevent the error code from containing the origin of the error, simply pass it to the
|
||||
* next layer.
|
||||
*
|
||||
* Some API's have been defined to provide, useful and meaningful Error messages to the
|
||||
* the 'userspace' application layer.
|
||||
*
|
||||
**/
|
||||
|
||||
#define FF_MODULE_SHIFT 24
|
||||
#define FF_FUNCTION_SHIFT 16
|
||||
|
||||
#define FF_GETERROR( x ) ( ( ( unsigned ) x ) & 0xFFFF )
|
||||
#define FF_GETMODULE( x ) ( ( ( ( unsigned ) x ) >> FF_MODULE_SHIFT ) & 0x7F )
|
||||
#define FF_GETFUNCTION( x ) ( ( ( ( unsigned ) x ) >> FF_FUNCTION_SHIFT ) & 0xFF )
|
||||
#define FF_GETMOD_FUNC( x ) ( ( ( ( unsigned ) x ) >> FF_FUNCTION_SHIFT ) & 0xFFFF )
|
||||
#define FF_ERRFLAG 0x80000000
|
||||
#define FF_isERR( x ) ( ( ( x ) & FF_ERRFLAG ) != 0 )
|
||||
|
||||
/*----- FreeRTOS+FAT Module Identifiers */
|
||||
#define FF_MODULE_IOMAN ( ( 1 << FF_MODULE_SHIFT ) | FF_ERRFLAG )
|
||||
#define FF_MODULE_DIR ( ( 2 << FF_MODULE_SHIFT ) | FF_ERRFLAG )
|
||||
#define FF_MODULE_FILE ( ( 3 << FF_MODULE_SHIFT ) | FF_ERRFLAG )
|
||||
#define FF_MODULE_FAT ( ( 4 << FF_MODULE_SHIFT ) | FF_ERRFLAG )
|
||||
#define FF_MODULE_CRC ( ( 5 << FF_MODULE_SHIFT ) | FF_ERRFLAG )
|
||||
#define FF_MODULE_FORMAT ( ( 6 << FF_MODULE_SHIFT ) | FF_ERRFLAG )
|
||||
#define FF_MODULE_MEMORY ( ( 7 << FF_MODULE_SHIFT ) | FF_ERRFLAG )
|
||||
#define FF_MODULE_STRING ( ( 8 << FF_MODULE_SHIFT ) | FF_ERRFLAG )
|
||||
#define FF_MODULE_LOCKING ( ( 9 << FF_MODULE_SHIFT ) | FF_ERRFLAG )
|
||||
#define FF_MODULE_TIME ( ( 10 << FF_MODULE_SHIFT ) | FF_ERRFLAG )
|
||||
#define FF_MODULE_DRIVER ( ( 11 << FF_MODULE_SHIFT ) | FF_ERRFLAG )
|
||||
#define FF_MODULE_STDIO ( ( 12 << FF_MODULE_SHIFT ) | FF_ERRFLAG )
|
||||
|
||||
/*----- FreeRTOS+FAT Function Identifiers (In Modular Order) */
|
||||
/*----- FF_IOManager_t - The FreeRTOS+FAT I/O Manager. */
|
||||
#define FF_CREATEIOMAN ( ( 1 << FF_FUNCTION_SHIFT ) | FF_MODULE_IOMAN )
|
||||
#define FF_DESTROYIOMAN ( ( 2 << FF_FUNCTION_SHIFT ) | FF_MODULE_IOMAN )
|
||||
#define FF_MOUNT ( ( 3 << FF_FUNCTION_SHIFT ) | FF_MODULE_IOMAN )
|
||||
#define FF_UNMOUNT ( ( 4 << FF_FUNCTION_SHIFT ) | FF_MODULE_IOMAN )
|
||||
#define FF_FLUSHCACHE ( ( 5 << FF_FUNCTION_SHIFT ) | FF_MODULE_IOMAN )
|
||||
#define FF_GETPARTITIONBLOCKSIZE ( ( 6 << FF_FUNCTION_SHIFT ) | FF_MODULE_IOMAN )
|
||||
#define FF_BLOCKREAD ( ( 7 << FF_FUNCTION_SHIFT ) | FF_MODULE_IOMAN )
|
||||
#define FF_BLOCKWRITE ( ( 8 << FF_FUNCTION_SHIFT ) | FF_MODULE_IOMAN )
|
||||
#define FF_DETERMINEFATTYPE ( ( 9 << FF_FUNCTION_SHIFT ) | FF_MODULE_IOMAN )
|
||||
#define FF_GETEFIPARTITIONENTRY ( ( 10 << FF_FUNCTION_SHIFT ) | FF_MODULE_IOMAN )
|
||||
#define FF_USERDRIVER ( ( 11 << FF_FUNCTION_SHIFT ) | FF_MODULE_IOMAN )
|
||||
#define FF_DECREASEFREECLUSTERS ( ( 12 << FF_FUNCTION_SHIFT ) | FF_MODULE_IOMAN )
|
||||
#define FF_INCREASEFREECLUSTERS ( ( 13 << FF_FUNCTION_SHIFT ) | FF_MODULE_IOMAN )
|
||||
#define FF_PARTITIONSEARCH ( ( 14 << FF_FUNCTION_SHIFT ) | FF_MODULE_IOMAN )
|
||||
#define FF_PARSEEXTENDED ( ( 15 << FF_FUNCTION_SHIFT ) | FF_MODULE_IOMAN )
|
||||
|
||||
|
||||
/*----- FreeRTOS+FAT Return codes for user Rd/Wr routines */
|
||||
|
||||
#define FF_ERR_DRIVER_NOMEDIUM ( FF_ERR_IOMAN_DRIVER_NOMEDIUM | FF_USERDRIVER | FF_MODULE_DRIVER )
|
||||
#define FF_ERR_DRIVER_BUSY ( FF_ERR_IOMAN_DRIVER_BUSY | FF_USERDRIVER | FF_MODULE_DRIVER )
|
||||
#define FF_ERR_DRIVER_FATAL_ERROR ( FF_ERR_IOMAN_DRIVER_FATAL_ERROR | FF_USERDRIVER | FF_MODULE_DRIVER )
|
||||
|
||||
/*----- FF_DIR - The FreeRTOS+FAT directory handling routines. */
|
||||
#define FF_FETCHENTRYWITHCONTEXT ( ( 1 << FF_FUNCTION_SHIFT ) | FF_MODULE_DIR )
|
||||
#define FF_PUSHENTRYWITHCONTEXT ( ( 2 << FF_FUNCTION_SHIFT ) | FF_MODULE_DIR )
|
||||
#define FF_GETENTRY ( ( 3 << FF_FUNCTION_SHIFT ) | FF_MODULE_DIR )
|
||||
#define FF_FINDFIRST ( ( 4 << FF_FUNCTION_SHIFT ) | FF_MODULE_DIR )
|
||||
#define FF_FINDNEXT ( ( 5 << FF_FUNCTION_SHIFT ) | FF_MODULE_DIR )
|
||||
#define FF_REWINDFIND ( ( 6 << FF_FUNCTION_SHIFT ) | FF_MODULE_DIR )
|
||||
#define FF_FINDFREEDIRENT ( ( 7 << FF_FUNCTION_SHIFT ) | FF_MODULE_DIR )
|
||||
#define FF_PUTENTRY ( ( 8 << FF_FUNCTION_SHIFT ) | FF_MODULE_DIR )
|
||||
#define FF_CREATESHORTNAME ( ( 9 << FF_FUNCTION_SHIFT ) | FF_MODULE_DIR )
|
||||
#define FF_CREATELFNS ( ( 10 << FF_FUNCTION_SHIFT ) | FF_MODULE_DIR )
|
||||
#define FF_EXTENDDIRECTORY ( ( 11 << FF_FUNCTION_SHIFT ) | FF_MODULE_DIR )
|
||||
#define FF_MKDIR ( ( 12 << FF_FUNCTION_SHIFT ) | FF_MODULE_DIR )
|
||||
#define FF_TRAVERSE ( ( 13 << FF_FUNCTION_SHIFT ) | FF_MODULE_DIR )
|
||||
#define FF_FINDDIR ( ( 14 << FF_FUNCTION_SHIFT ) | FF_MODULE_DIR )
|
||||
|
||||
/*----- FF_FILE - The FreeRTOS+FAT file handling routines. */
|
||||
#define FF_GETMODEBITS ( ( 1 << FF_FUNCTION_SHIFT ) | FF_MODULE_FILE )
|
||||
#define FF_OPEN ( ( 2 << FF_FUNCTION_SHIFT ) | FF_MODULE_FILE )
|
||||
#define FF_ISDIREMPTY ( ( 3 << FF_FUNCTION_SHIFT ) | FF_MODULE_FILE )
|
||||
#define FF_RMDIR ( ( 4 << FF_FUNCTION_SHIFT ) | FF_MODULE_FILE )
|
||||
#define FF_RMFILE ( ( 5 << FF_FUNCTION_SHIFT ) | FF_MODULE_FILE )
|
||||
#define FF_MOVE ( ( 6 << FF_FUNCTION_SHIFT ) | FF_MODULE_FILE )
|
||||
#define FF_ISEOF ( ( 7 << FF_FUNCTION_SHIFT ) | FF_MODULE_FILE )
|
||||
#define FF_GETSEQUENTIALCLUSTERS ( ( 8 << FF_FUNCTION_SHIFT ) | FF_MODULE_FILE )
|
||||
#define FF_READCLUSTERS ( ( 9 << FF_FUNCTION_SHIFT ) | FF_MODULE_FILE )
|
||||
#define FF_EXTENDFILE ( ( 10 << FF_FUNCTION_SHIFT ) | FF_MODULE_FILE )
|
||||
#define FF_WRITECLUSTERS ( ( 11 << FF_FUNCTION_SHIFT ) | FF_MODULE_FILE )
|
||||
#define FF_READ ( ( 12 << FF_FUNCTION_SHIFT ) | FF_MODULE_FILE )
|
||||
#define FF_GETC ( ( 13 << FF_FUNCTION_SHIFT ) | FF_MODULE_FILE )
|
||||
#define FF_GETLINE ( ( 14 << FF_FUNCTION_SHIFT ) | FF_MODULE_FILE )
|
||||
#define FF_TELL ( ( 15 << FF_FUNCTION_SHIFT ) | FF_MODULE_FILE )
|
||||
#define FF_WRITE ( ( 16 << FF_FUNCTION_SHIFT ) | FF_MODULE_FILE )
|
||||
#define FF_PUTC ( ( 17 << FF_FUNCTION_SHIFT ) | FF_MODULE_FILE )
|
||||
#define FF_SEEK ( ( 18 << FF_FUNCTION_SHIFT ) | FF_MODULE_FILE )
|
||||
#define FF_INVALIDATE ( ( 19 << FF_FUNCTION_SHIFT ) | FF_MODULE_FILE )
|
||||
#define FF_CHECKVALID ( ( 20 << FF_FUNCTION_SHIFT ) | FF_MODULE_FILE )
|
||||
#define FF_CLOSE ( ( 21 << FF_FUNCTION_SHIFT ) | FF_MODULE_FILE )
|
||||
#define FF_SETTIME ( ( 22 << FF_FUNCTION_SHIFT ) | FF_MODULE_FILE )
|
||||
#define FF_BYTESLEFT ( ( 23 << FF_FUNCTION_SHIFT ) | FF_MODULE_FILE )
|
||||
#define FF_SETFILETIME ( ( 24 << FF_FUNCTION_SHIFT ) | FF_MODULE_FILE )
|
||||
#define FF_INITBUF ( ( 25 << FF_FUNCTION_SHIFT ) | FF_MODULE_FILE )
|
||||
#define FF_SETEOF ( ( 26 << FF_FUNCTION_SHIFT ) | FF_MODULE_FILE )
|
||||
|
||||
/*----- FF_FAT - The FreeRTOS+FAT FAT handling routines. */
|
||||
#define FF_GETFATENTRY ( ( 1 << FF_FUNCTION_SHIFT ) | FF_MODULE_FAT )
|
||||
#define FF_CLEARCLUSTER ( ( 2 << FF_FUNCTION_SHIFT ) | FF_MODULE_FAT )
|
||||
#define FF_PUTFATENTRY ( ( 3 << FF_FUNCTION_SHIFT ) | FF_MODULE_FAT )
|
||||
#define FF_FINDFREECLUSTER ( ( 4 << FF_FUNCTION_SHIFT ) | FF_MODULE_FAT )
|
||||
#define FF_COUNTFREECLUSTERS ( ( 5 << FF_FUNCTION_SHIFT ) | FF_MODULE_FAT )
|
||||
|
||||
/*----- FF_FORMAT - The FreeRTOS+FAT format routine */
|
||||
#define FF_FORMATPARTITION ( ( 1 << FF_FUNCTION_SHIFT ) | FF_MODULE_FORMAT )
|
||||
|
||||
/*----- FF_UNICODE - The FreeRTOS+FAT unicode routines. */
|
||||
#define FF_UTF8CTOUTF16C ( ( 1 << FF_FUNCTION_SHIFT ) | FF_MODULE_STRING )
|
||||
#define FF_UTF16CTOUTF8C ( ( 2 << FF_FUNCTION_SHIFT ) | FF_MODULE_STRING )
|
||||
#define FF_UTF32CTOUTF16C ( ( 3 << FF_FUNCTION_SHIFT ) | FF_MODULE_STRING )
|
||||
#define FF_UTF16CTOUTF32C ( ( 4 << FF_FUNCTION_SHIFT ) | FF_MODULE_STRING )
|
||||
|
||||
|
||||
/*----- FF_STDIO - The stdio-interface to FreeRTOS+FAT. */
|
||||
#define FF_CHMOD ( ( 1 << FF_FUNCTION_SHIFT ) | FF_MODULE_STDIO )
|
||||
#define FF_STAT_FUNC ( ( 2 << FF_FUNCTION_SHIFT ) | FF_MODULE_STDIO )
|
||||
|
||||
/* FreeRTOS+FAT defines different Error-Code spaces for each module. This ensures
|
||||
* that all error codes remain unique, and their meaning can be quickly identified.
|
||||
*/
|
||||
/* Global Error Codes */
|
||||
#define FF_ERR_NONE 0 /* No Error */
|
||||
/*#define FF_ERR_GENERIC 1*/ /* BAD NEVER USE THIS! -- Therefore commented out. */
|
||||
#define FF_ERR_NULL_POINTER 2 /* Parameter was NULL. */
|
||||
#define FF_ERR_NOT_ENOUGH_MEMORY 3 /* malloc() failed! - Could not allocate handle memory. */
|
||||
#define FF_ERR_DEVICE_DRIVER_FAILED 4 /* The Block Device driver reported a FATAL error, cannot continue. */
|
||||
|
||||
/* User return codes for Rd/Wr functions: */
|
||||
#define FF_ERR_IOMAN_DRIVER_NOMEDIUM 8
|
||||
#define FF_ERR_IOMAN_DRIVER_BUSY 9
|
||||
#define FF_ERR_IOMAN_DRIVER_FATAL_ERROR 10
|
||||
|
||||
/* IOMAN Error Codes */
|
||||
#define FF_ERR_IOMAN_BAD_BLKSIZE 11 /* The provided blocksize was not a multiple of 512. */
|
||||
#define FF_ERR_IOMAN_BAD_MEMSIZE 12 /* The memory size was not a multiple of the blocksize. */
|
||||
#define FF_ERR_IOMAN_DEV_ALREADY_REGD 13 /* Device was already registered. Use FF_UnRegister() to re-use this IOMAN with another device. */
|
||||
#define FF_ERR_IOMAN_NO_MOUNTABLE_PARTITION 14 /* A mountable partition could not be found on the device. */
|
||||
#define FF_ERR_IOMAN_INVALID_FORMAT 15
|
||||
#define FF_ERR_IOMAN_INVALID_PARTITION_NUM 16 /* The partition number provided was out of range. */
|
||||
#define FF_ERR_IOMAN_NOT_FAT_FORMATTED 17 /* The partition did not look like a FAT partition. */
|
||||
#define FF_ERR_IOMAN_DEV_INVALID_BLKSIZE 18 /* IOMAN object BlkSize is not compatible with the blocksize of this device driver. */
|
||||
#define FF_ERR_IOMAN_PARTITION_MOUNTED 19 /* Device is in use by an actively mounted partition. Unmount the partition first. */
|
||||
#define FF_ERR_IOMAN_ACTIVE_HANDLES 20 /* The partition cannot be unmounted until all active file handles are closed. (There may also be active handles on the cache). */
|
||||
#define FF_ERR_IOMAN_GPT_HEADER_CORRUPT 21 /* The GPT partition table appears to be corrupt, refusing to mount. */
|
||||
#define FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE 22
|
||||
#define FF_ERR_IOMAN_OUT_OF_BOUNDS_READ 23
|
||||
#define FF_ERR_IOMAN_OUT_OF_BOUNDS_WRITE 24
|
||||
|
||||
/* File Error Codes 30 + */
|
||||
#define FF_ERR_FILE_ALREADY_OPEN 30 /* File is in use. */
|
||||
#define FF_ERR_FILE_NOT_FOUND 31 /* File was not found. */
|
||||
#define FF_ERR_FILE_OBJECT_IS_A_DIR 32 /* Tried to FF_Open() a Directory. */
|
||||
#define FF_ERR_FILE_IS_READ_ONLY 33 /* Tried to FF_Open() a file marked read only. */
|
||||
#define FF_ERR_FILE_INVALID_PATH 34 /* The path of the file was not found. */
|
||||
#define FF_ERR_FILE_NOT_OPENED_IN_WRITE_MODE 35
|
||||
#define FF_ERR_FILE_NOT_OPENED_IN_READ_MODE 36
|
||||
#define FF_ERR_FILE_EXTEND_FAILED 37 /* Could not extend the file. */
|
||||
#define FF_ERR_FILE_DESTINATION_EXISTS 38
|
||||
#define FF_ERR_FILE_SOURCE_NOT_FOUND 39
|
||||
#define FF_ERR_FILE_DIR_NOT_FOUND 40
|
||||
#define FF_ERR_FILE_COULD_NOT_CREATE_DIRENT 41
|
||||
#define FF_ERR_FILE_BAD_HANDLE 42 /* A file handle was invalid */
|
||||
#define FF_ERR_FILE_MEDIA_REMOVED 43 /* File handle got invalid because media was removed */
|
||||
#define FF_ERR_FILE_READ_ZERO 44 /* Used internally. */
|
||||
#define FF_ERR_FILE_SEEK_INVALID_ORIGIN 45 /* Seeking beyond end of file. */
|
||||
#define FF_ERR_FILE_SEEK_INVALID_POSITION 46 /* Bad value for the 'whence' parameter. */
|
||||
|
||||
/* Directory Error Codes 50 + */
|
||||
#define FF_ERR_DIR_OBJECT_EXISTS 50 /* A file or folder of the same name already exists in the current directory. */
|
||||
#define FF_ERR_DIR_DIRECTORY_FULL 51 /* No more items could be added to the directory. */
|
||||
#define FF_ERR_DIR_END_OF_DIR 52 /*/ */
|
||||
#define FF_ERR_DIR_NOT_EMPTY 53 /* Cannot delete a directory that contains files or folders. */
|
||||
#define FF_ERR_DIR_INVALID_PATH 54 /* Could not find the directory specified by the path. */
|
||||
#define FF_ERR_DIR_INVALID_PARAMETER 55 /* Could not find the directory specified by the path. */
|
||||
#define FF_ERR_DIR_CANT_EXTEND_ROOT_DIR 56 /* Can't extend the root dir. */
|
||||
#define FF_ERR_DIR_EXTEND_FAILED 57 /* Not enough space to extend the directory. */
|
||||
#define FF_ERR_DIR_NAME_TOO_LONG 58 /* Name exceeds the number of allowed characters for a filename. */
|
||||
|
||||
/* Fat Error Codes 70 + */
|
||||
#define FF_ERR_FAT_NO_FREE_CLUSTERS 70 /* No more free space is available on the disk. */
|
||||
|
||||
/* UNICODE Error Codes 100 + */
|
||||
#define FF_ERR_UNICODE_INVALID_CODE 100 /* An invalid Unicode character was provided! */
|
||||
#define FF_ERR_UNICODE_DEST_TOO_SMALL 101 /* Not enough space in the UTF-16 buffer to encode the entire sequence as UTF-16. */
|
||||
#define FF_ERR_UNICODE_INVALID_SEQUENCE 102 /* An invalid UTF-16 sequence was encountered. */
|
||||
#define FF_ERR_UNICODE_CONVERSION_EXCEEDED 103 /* Filename exceeds MAX long-filename length when converted to UTF-16. */
|
||||
|
||||
typedef int32_t FF_Error_t;
|
||||
|
||||
#if ( ffconfigDEBUG != 0 )
|
||||
const char * FF_GetErrMessage( FF_Error_t iErrorCode );
|
||||
const char * FF_GetErrModule( FF_Error_t iErrorCode );
|
||||
const char * FF_GetErrFunction( FF_Error_t iErrorCode );
|
||||
const char * FF_GetErrDescription( FF_Error_t iErrorCode,
|
||||
char * pcBuffer,
|
||||
int iMaxLength ); /* Get the complete description */
|
||||
#else /* ffconfigDEBUG */
|
||||
#define FF_GetErrMessage( X ) "" /* A special MACRO in case FF_GetErrMessage() isn't gated with ffconfigDEBUG */
|
||||
#define FF_GetErrModule( X ) ""
|
||||
#define FF_GetErrFunction( X ) ""
|
||||
static portINLINE const char * FF_GetErrDescription( FF_Error_t iErrorCode,
|
||||
char * pcBuffer,
|
||||
int iMaxLength )
|
||||
{
|
||||
( void ) iErrorCode;
|
||||
( void ) iMaxLength;
|
||||
strcpy( pcBuffer, "unknown" );
|
||||
return pcBuffer;
|
||||
}
|
||||
#endif /* Function call is safely replaced with a NULL string. */
|
||||
|
||||
#endif /* INCLUDE GUARD END */
|
168
MXC_A27-PCB4.5-270T/FreeRTOS-Plus/FreeRTOS-FAT/include/ff_fat.h
Normal file
168
MXC_A27-PCB4.5-270T/FreeRTOS-Plus/FreeRTOS-FAT/include/ff_fat.h
Normal file
@ -0,0 +1,168 @@
|
||||
/*
|
||||
* FreeRTOS+FAT V2.3.3
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file ff_fat.h
|
||||
* @ingroup FAT
|
||||
**/
|
||||
|
||||
#ifndef _FF_FAT_H_
|
||||
#define _FF_FAT_H_
|
||||
|
||||
#ifndef PLUS_FAT_H
|
||||
#error this header will be included from "ff_headers.h"
|
||||
#endif
|
||||
|
||||
/*---------- ERROR CODES */
|
||||
|
||||
|
||||
/*---------- PROTOTYPES */
|
||||
|
||||
/* HT statistics Will be taken away after testing: */
|
||||
#if ( ffconfigFAT_USES_STAT != 0 )
|
||||
struct SFatStat
|
||||
{
|
||||
unsigned initCount;
|
||||
unsigned clearCount;
|
||||
unsigned getCount[ 2 ]; /* Index 0 for READ counts, index 1 for WRITE counts. */
|
||||
unsigned reuseCount[ 2 ];
|
||||
unsigned missCount[ 2 ];
|
||||
};
|
||||
|
||||
extern struct SFatStat fatStat;
|
||||
#endif /* if ( ffconfigFAT_USES_STAT != 0 ) */
|
||||
|
||||
#if ( ffconfigWRITE_BOTH_FATS != 0 )
|
||||
#define ffconfigBUF_STORE_COUNT 2
|
||||
#else
|
||||
#define ffconfigBUF_STORE_COUNT 1
|
||||
#endif
|
||||
|
||||
typedef struct _FatBuffers
|
||||
{
|
||||
FF_Buffer_t * pxBuffers[ ffconfigBUF_STORE_COUNT ];
|
||||
uint8_t ucMode; /* FF_MODE_READ or WRITE. */
|
||||
} FF_FATBuffers_t;
|
||||
|
||||
uint32_t FF_getClusterPosition( FF_IOManager_t * pxIOManager,
|
||||
uint32_t ulEntry,
|
||||
uint32_t ulEntrySize );
|
||||
uint32_t FF_getClusterChainNumber( FF_IOManager_t * pxIOManager,
|
||||
uint32_t ulEntry,
|
||||
uint32_t ulEntrySize );
|
||||
uint32_t FF_getMajorBlockNumber( FF_IOManager_t * pxIOManager,
|
||||
uint32_t ulEntry,
|
||||
uint32_t ulEntrySize );
|
||||
uint32_t FF_getMinorBlockNumber( FF_IOManager_t * pxIOManager,
|
||||
uint32_t ulEntry,
|
||||
uint32_t ulEntrySize );
|
||||
uint32_t FF_getMinorBlockEntry( FF_IOManager_t * pxIOManager,
|
||||
uint32_t ulEntry,
|
||||
uint32_t ulEntrySize );
|
||||
|
||||
/* A partition may define a block size larger than 512 bytes (at offset 0x0B of the PBR).
|
||||
* This function translates a block address to an address based on 'pxIOManager->usBlkSize',
|
||||
* which is usually 512 bytes.
|
||||
*/
|
||||
static portINLINE uint32_t FF_getRealLBA( FF_IOManager_t * pxIOManager,
|
||||
uint32_t LBA )
|
||||
{
|
||||
return LBA * pxIOManager->xPartition.ucBlkFactor;
|
||||
}
|
||||
|
||||
uint32_t FF_Cluster2LBA( FF_IOManager_t * pxIOManager,
|
||||
uint32_t ulCluster );
|
||||
uint32_t FF_LBA2Cluster( FF_IOManager_t * pxIOManager,
|
||||
uint32_t ulAddress );
|
||||
uint32_t FF_getFATEntry( FF_IOManager_t * pxIOManager,
|
||||
uint32_t ulCluster,
|
||||
FF_Error_t * pxError,
|
||||
FF_FATBuffers_t * pxFATBuffers );
|
||||
FF_Error_t FF_putFATEntry( FF_IOManager_t * pxIOManager,
|
||||
uint32_t ulCluster,
|
||||
uint32_t ulValue,
|
||||
FF_FATBuffers_t * pxFATBuffers );
|
||||
BaseType_t FF_isEndOfChain( FF_IOManager_t * pxIOManager,
|
||||
uint32_t ulFatEntry );
|
||||
uint32_t FF_FindFreeCluster( FF_IOManager_t * pxIOManager,
|
||||
FF_Error_t * pxError,
|
||||
BaseType_t aDoClaim );
|
||||
uint32_t FF_ExtendClusterChain( FF_IOManager_t * pxIOManager,
|
||||
uint32_t ulStartCluster,
|
||||
uint32_t ulCount );
|
||||
FF_Error_t FF_UnlinkClusterChain( FF_IOManager_t * pxIOManager,
|
||||
uint32_t ulStartCluster,
|
||||
BaseType_t xDoTruncate );
|
||||
uint32_t FF_TraverseFAT( FF_IOManager_t * pxIOManager,
|
||||
uint32_t ulStart,
|
||||
uint32_t ulCount,
|
||||
FF_Error_t * pxError );
|
||||
uint32_t FF_CreateClusterChain( FF_IOManager_t * pxIOManager,
|
||||
FF_Error_t * pxError );
|
||||
uint32_t FF_GetChainLength( FF_IOManager_t * pxIOManager,
|
||||
uint32_t pa_nStartCluster,
|
||||
uint32_t * piEndOfChain,
|
||||
FF_Error_t * pxError );
|
||||
uint32_t FF_FindEndOfChain( FF_IOManager_t * pxIOManager,
|
||||
uint32_t Start,
|
||||
FF_Error_t * pxError );
|
||||
FF_Error_t FF_ClearCluster( FF_IOManager_t * pxIOManager,
|
||||
uint32_t ulCluster );
|
||||
|
||||
#if ( ffconfig64_NUM_SUPPORT != 0 )
|
||||
uint64_t FF_GetFreeSize( FF_IOManager_t * pxIOManager,
|
||||
FF_Error_t * pxError );
|
||||
#else
|
||||
uint32_t FF_GetFreeSize( FF_IOManager_t * pxIOManager,
|
||||
FF_Error_t * pxError );
|
||||
#endif
|
||||
|
||||
/* WARNING: If this prototype changes, it must be updated in ff_ioman.c also! */
|
||||
uint32_t FF_CountFreeClusters( FF_IOManager_t * pxIOManager,
|
||||
FF_Error_t * pxError );
|
||||
|
||||
FF_Error_t FF_ReleaseFATBuffers( FF_IOManager_t * pxIOManager,
|
||||
FF_FATBuffers_t * pxFATBuffers );
|
||||
|
||||
static portINLINE void FF_InitFATBuffers( FF_FATBuffers_t * pxFATBuffers,
|
||||
uint8_t ucMode )
|
||||
{
|
||||
pxFATBuffers->pxBuffers[ 0 ] = NULL;
|
||||
#if ffconfigBUF_STORE_COUNT > 1
|
||||
pxFATBuffers->pxBuffers[ 1 ] = NULL;
|
||||
#endif
|
||||
#if ffconfigBUF_STORE_COUNT > 2
|
||||
#error Please check this code, maybe it is time to use memset
|
||||
#endif
|
||||
pxFATBuffers->ucMode = ucMode; /* FF_MODE_READ/WRITE */
|
||||
#if ffconfigFAT_USES_STAT
|
||||
{
|
||||
fatStat.initCount++;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* ifndef _FF_FAT_H_ */
|
@ -0,0 +1,108 @@
|
||||
/*
|
||||
* FreeRTOS+FAT V2.3.3
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _FF_FATDEF_H_
|
||||
#define _FF_FATDEF_H_
|
||||
|
||||
/*
|
||||
* This file defines offsets to various data for the FAT specification.
|
||||
*/
|
||||
|
||||
/* MBR / PBR Offsets. */
|
||||
|
||||
#define FF_FAT_BYTES_PER_SECTOR 0x00B
|
||||
#define FF_FAT_SECTORS_PER_CLUS 0x00D
|
||||
#define FF_FAT_RESERVED_SECTORS 0x00E
|
||||
#define FF_FAT_NUMBER_OF_FATS 0x010
|
||||
#define FF_FAT_ROOT_ENTRY_COUNT 0x011
|
||||
#define FF_FAT_16_TOTAL_SECTORS 0x013
|
||||
#define FF_FAT_MEDIA_TYPE 0x015
|
||||
|
||||
#define FF_FAT_32_TOTAL_SECTORS 0x020
|
||||
#define FF_FAT_16_SECTORS_PER_FAT 0x016
|
||||
#define FF_FAT_32_SECTORS_PER_FAT 0x024
|
||||
#define FF_FAT_ROOT_DIR_CLUSTER 0x02C
|
||||
#define FF_FAT_EXT_BOOT_SIGNATURE 0x042
|
||||
|
||||
#define FF_FAT_16_VOL_LABEL 0x02B
|
||||
#define FF_FAT_32_VOL_LABEL 0x047
|
||||
|
||||
#define FF_FAT_PTBL 0x1BE
|
||||
#define FF_FAT_PTBL_LBA 0x008
|
||||
#define FF_FAT_PTBL_SECT_COUNT 0x00C
|
||||
#define FF_FAT_PTBL_ACTIVE 0x000
|
||||
#define FF_FAT_PTBL_ID 0x004
|
||||
|
||||
#define FF_DOS_EXT_PART 0x05
|
||||
#define FF_LINUX_EXT_PART 0x85
|
||||
#define FF_WIN98_EXT_PART 0x0f
|
||||
|
||||
#define FF_FAT_MBR_SIGNATURE 0x1FE
|
||||
|
||||
#define FF_FAT_DELETED 0xE5
|
||||
|
||||
/* Directory Entry Offsets. */
|
||||
#define FF_FAT_DIRENT_SHORTNAME 0x000
|
||||
#define FF_FAT_DIRENT_ATTRIB 0x00B
|
||||
#define FF_FAT_DIRENT_CREATE_TIME 0x00E /* Creation Time. */
|
||||
#define FF_FAT_DIRENT_CREATE_DATE 0x010 /* Creation Date. */
|
||||
#define FF_FAT_DIRENT_LASTACC_DATE 0x012 /* Date of Last Access. */
|
||||
#define FF_FAT_DIRENT_CLUS_HIGH 0x014
|
||||
#define FF_FAT_DIRENT_LASTMOD_TIME 0x016 /* Time of Last modification. */
|
||||
#define FF_FAT_DIRENT_LASTMOD_DATE 0x018 /* Date of Last modification. */
|
||||
#define FF_FAT_DIRENT_CLUS_LOW 0x01A
|
||||
#define FF_FAT_DIRENT_FILESIZE 0x01C
|
||||
#define FF_FAT_LFN_ORD 0x000
|
||||
#define FF_FAT_LFN_NAME_1 0x001
|
||||
#define FF_FAT_LFN_CHECKSUM 0x00D
|
||||
#define FF_FAT_LFN_NAME_2 0x00E
|
||||
#define FF_FAT_LFN_NAME_3 0x01C
|
||||
|
||||
/* Dirent Attributes. */
|
||||
#define FF_FAT_ATTR_READONLY 0x01
|
||||
#define FF_FAT_ATTR_HIDDEN 0x02
|
||||
#define FF_FAT_ATTR_SYSTEM 0x04
|
||||
#define FF_FAT_ATTR_VOLID 0x08
|
||||
#define FF_FAT_ATTR_DIR 0x10
|
||||
#define FF_FAT_ATTR_ARCHIVE 0x20
|
||||
#define FF_FAT_ATTR_LFN 0x0F
|
||||
|
||||
/**
|
||||
* -- Hein_Tibosch additions for mixed case in shortnames --
|
||||
*
|
||||
* Specifically, bit 4 means lowercase extension and bit 3 lowercase basename,
|
||||
* which allows for combinations such as "example.TXT" or "HELLO.txt" but not "Mixed.txt"
|
||||
*/
|
||||
|
||||
#define FF_FAT_CASE_OFFS 0x0C /* After NT/XP : 2 case bits. */
|
||||
#define FF_FAT_CASE_ATTR_BASE 0x08
|
||||
#define FF_FAT_CASE_ATTR_EXT 0x10
|
||||
|
||||
#if ( ffconfigLFN_SUPPORT != 0 ) && ( ffconfigINCLUDE_SHORT_NAME != 0 )
|
||||
#define FF_FAT_ATTR_IS_LFN 0x40 /* artificial attribute, for debugging only. */
|
||||
#endif
|
||||
|
||||
#endif /* ifndef _FF_FATDEF_H_ */
|
204
MXC_A27-PCB4.5-270T/FreeRTOS-Plus/FreeRTOS-FAT/include/ff_file.h
Normal file
204
MXC_A27-PCB4.5-270T/FreeRTOS-Plus/FreeRTOS-FAT/include/ff_file.h
Normal file
@ -0,0 +1,204 @@
|
||||
/*
|
||||
* FreeRTOS+FAT V2.3.3
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file ff_file.h
|
||||
* @ingroup FILEIO
|
||||
**/
|
||||
#ifndef _FF_FILE_H_
|
||||
#define _FF_FILE_H_
|
||||
|
||||
#ifndef PLUS_FAT_H
|
||||
#error this header will be included from "ff_headers.h"
|
||||
#endif
|
||||
|
||||
#define FF_SEEK_SET 0
|
||||
#define FF_SEEK_CUR 1
|
||||
#define FF_SEEK_END 2
|
||||
|
||||
#if ( ffconfigOPTIMISE_UNALIGNED_ACCESS != 0 )
|
||||
#define FF_BUFSTATE_INVALID 0x00 /* Data in file handle buffer is invalid. */
|
||||
#define FF_BUFSTATE_VALID 0x01 /* Valid data in pBuf (Something has been read into it). */
|
||||
#define FF_BUFSTATE_WRITTEN 0x02 /* Data was written into pBuf, this must be saved when leaving sector. */
|
||||
#endif
|
||||
|
||||
#if ( ffconfigDEV_SUPPORT != 0 )
|
||||
struct xDEV_NODE
|
||||
{
|
||||
uint8_t
|
||||
ucIsDevice;
|
||||
};
|
||||
#endif
|
||||
|
||||
typedef struct _FF_FILE
|
||||
{
|
||||
FF_IOManager_t * pxIOManager; /* Ioman Pointer! */
|
||||
uint32_t ulFileSize; /* File's Size. */
|
||||
uint32_t ulObjectCluster; /* File's Start Cluster. */
|
||||
uint32_t ulChainLength; /* Total Length of the File's cluster chain. */
|
||||
uint32_t ulCurrentCluster; /* Prevents FAT Thrashing. */
|
||||
uint32_t ulAddrCurrentCluster; /* Address of the current cluster. */
|
||||
uint32_t ulEndOfChain; /* Address of the last cluster in the chain. */
|
||||
uint32_t ulFilePointer; /* Current Position Pointer. */
|
||||
uint32_t ulDirCluster; /* Cluster Number that the Dirent is in. */
|
||||
uint32_t ulValidFlags; /* Handle validation flags. */
|
||||
|
||||
#if ( ffconfigOPTIMISE_UNALIGNED_ACCESS != 0 )
|
||||
uint8_t * pucBuffer; /* A buffer for providing fast unaligned access. */
|
||||
uint8_t ucState; /* State information about the buffer. */
|
||||
#endif
|
||||
uint8_t ucMode; /* Mode that File Was opened in. */
|
||||
uint16_t usDirEntry; /* Dirent Entry Number describing this file. */
|
||||
|
||||
#if ( ffconfigDEV_SUPPORT != 0 )
|
||||
struct SFileCache * pxDevNode;
|
||||
#endif
|
||||
struct _FF_FILE * pxNext; /* Pointer to the next file object in the linked list. */
|
||||
} FF_FILE;
|
||||
|
||||
#define FF_VALID_FLAG_INVALID 0x00000001
|
||||
#define FF_VALID_FLAG_DELETED 0x00000002
|
||||
|
||||
/*---------- PROTOTYPES */
|
||||
/* PUBLIC (Interfaces): */
|
||||
|
||||
#if ( ffconfigUNICODE_UTF16_SUPPORT != 0 )
|
||||
FF_FILE * FF_Open( FF_IOManager_t * pxIOManager,
|
||||
const FF_T_WCHAR * path,
|
||||
uint8_t Mode,
|
||||
FF_Error_t * pError );
|
||||
BaseType_t FF_isDirEmpty( FF_IOManager_t * pxIOManager,
|
||||
const FF_T_WCHAR * Path );
|
||||
FF_Error_t FF_RmFile( FF_IOManager_t * pxIOManager,
|
||||
const FF_T_WCHAR * path );
|
||||
FF_Error_t FF_RmDir( FF_IOManager_t * pxIOManager,
|
||||
const FF_T_WCHAR * path );
|
||||
FF_Error_t FF_Move( FF_IOManager_t * pxIOManager,
|
||||
const FF_T_WCHAR * szSourceFile,
|
||||
const FF_T_WCHAR * szDestinationFile,
|
||||
BaseType_t bDeleteIfExists );
|
||||
#else /* ffconfigUNICODE_UTF16_SUPPORT */
|
||||
FF_FILE * FF_Open( FF_IOManager_t * pxIOManager,
|
||||
const char * path,
|
||||
uint8_t Mode,
|
||||
FF_Error_t * pError );
|
||||
BaseType_t FF_isDirEmpty( FF_IOManager_t * pxIOManager,
|
||||
const char * Path );
|
||||
FF_Error_t FF_RmFile( FF_IOManager_t * pxIOManager,
|
||||
const char * path );
|
||||
FF_Error_t FF_RmDir( FF_IOManager_t * pxIOManager,
|
||||
const char * path );
|
||||
FF_Error_t FF_Move( FF_IOManager_t * pxIOManager,
|
||||
const char * szSourceFile,
|
||||
const char * szDestinationFile,
|
||||
BaseType_t bDeleteIfExists );
|
||||
#endif /* ffconfigUNICODE_UTF16_SUPPORT */
|
||||
|
||||
#if ( ffconfigTIME_SUPPORT != 0 )
|
||||
enum
|
||||
{
|
||||
ETimeCreate = 1,
|
||||
ETimeMod = 2,
|
||||
ETimeAccess = 4,
|
||||
ETimeAll = 7
|
||||
};
|
||||
FF_Error_t FF_SetFileTime( FF_FILE * pFile,
|
||||
FF_SystemTime_t * pxTime,
|
||||
UBaseType_t uxWhat );
|
||||
#if ( ffconfigUNICODE_UTF16_SUPPORT != 0 )
|
||||
FF_Error_t FF_SetTime( FF_IOManager_t * pxIOManager,
|
||||
const FF_T_WCHAR * path,
|
||||
FF_SystemTime_t * pxTime,
|
||||
UBaseType_t uxWhat );
|
||||
#else
|
||||
FF_Error_t FF_SetTime( FF_IOManager_t * pxIOManager,
|
||||
const char * path,
|
||||
FF_SystemTime_t * pxTime,
|
||||
UBaseType_t uxWhat );
|
||||
#endif /* ffconfigUNICODE_UTF16_SUPPORT */
|
||||
#endif /* ffconfigTIME_SUPPORT */
|
||||
|
||||
#if ( ffconfigUNICODE_UTF16_SUPPORT != 0 )
|
||||
FF_Error_t FF_SetPerm( FF_IOManager_t * pxIOManager,
|
||||
const FF_T_WCHAR * path,
|
||||
UBaseType_t aPerm );
|
||||
#else
|
||||
FF_Error_t FF_SetPerm( FF_IOManager_t * pxIOManager,
|
||||
const char * path,
|
||||
UBaseType_t aPerm );
|
||||
#endif
|
||||
|
||||
FF_Error_t FF_SetEof( FF_FILE * pFile );
|
||||
|
||||
FF_Error_t FF_Close( FF_FILE * pFile );
|
||||
int32_t FF_GetC( FF_FILE * pFile );
|
||||
int32_t FF_GetLine( FF_FILE * pFile,
|
||||
char * szLine,
|
||||
uint32_t ulLimit );
|
||||
int32_t FF_Read( FF_FILE * pFile,
|
||||
uint32_t ElementSize,
|
||||
uint32_t Count,
|
||||
uint8_t * buffer );
|
||||
int32_t FF_Write( FF_FILE * pFile,
|
||||
uint32_t ElementSize,
|
||||
uint32_t Count,
|
||||
uint8_t * buffer );
|
||||
BaseType_t FF_isEOF( FF_FILE * pFile );
|
||||
int32_t FF_BytesLeft( FF_FILE * pFile ); /* Returns # of bytes left to read. */
|
||||
|
||||
/* FF_FileSize is an earlier version of FF_GetFileSize(). For files
|
||||
* equal to or larger than 2GB, the return value is negative.
|
||||
* Function is deprecated. Please use FF_GetFileSize(). */
|
||||
int32_t FF_FileSize( FF_FILE * pFile ); /* Returns # of bytes in a file. */
|
||||
|
||||
/* Use the following function in case files may get larger than 2 GB.
|
||||
* Writes the size of a file to the parameter.
|
||||
* Returns 0 or error code. */
|
||||
FF_Error_t FF_GetFileSize( FF_FILE * pFile,
|
||||
uint32_t * pulSize );
|
||||
|
||||
FF_Error_t FF_Seek( FF_FILE * pFile,
|
||||
int32_t Offset,
|
||||
BaseType_t xOrigin );
|
||||
int32_t FF_PutC( FF_FILE * pFile,
|
||||
uint8_t Value );
|
||||
|
||||
static portINLINE uint32_t FF_Tell( FF_FILE * pFile )
|
||||
{
|
||||
return pFile ? pFile->ulFilePointer : 0;
|
||||
}
|
||||
|
||||
uint8_t FF_GetModeBits( const char * Mode );
|
||||
|
||||
FF_Error_t FF_CheckValid( FF_FILE * pFile ); /* Check if pFile is a valid FF_FILE pointer. */
|
||||
|
||||
#if ( ffconfigREMOVABLE_MEDIA != 0 )
|
||||
int32_t FF_Invalidate( FF_IOManager_t * pxIOManager ); /* Invalidate all handles belonging to pxIOManager. */
|
||||
#endif
|
||||
|
||||
/* Private : */
|
||||
|
||||
#endif /* ifndef _FF_FILE_H_ */
|
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* FreeRTOS+FAT V2.3.3
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file ff_format.c
|
||||
* @ingroup FORMAT
|
||||
*
|
||||
**/
|
||||
|
||||
|
||||
#ifndef _FF_FORMAT_H_
|
||||
#define _FF_FORMAT_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef PLUS_FAT_H
|
||||
#error this header will be included from "ff_headers.h"
|
||||
#endif
|
||||
|
||||
/*---------- PROTOTYPES */
|
||||
/* PUBLIC (Interfaces): */
|
||||
|
||||
typedef enum _FF_SizeType
|
||||
{
|
||||
eSizeIsQuota, /* Assign a quotum (sum of xSizes is free, all disk space will be allocated) */
|
||||
eSizeIsPercent, /* Assign a percentage of the available space (sum of xSizes must be <= 100) */
|
||||
eSizeIsSectors, /* Assign fixed number of sectors (sum of xSizes must be < ulSectorCount) */
|
||||
} eSizeType_t;
|
||||
|
||||
typedef struct _FF_PartitionParameters
|
||||
{
|
||||
uint32_t ulSectorCount; /* Total number of sectors on the disk, including hidden/reserved */
|
||||
/* Must be obtained from the block driver */
|
||||
uint32_t ulHiddenSectors; /* Keep at least these initial sectors free */
|
||||
uint32_t ulInterSpace; /* Number of sectors to keep free between partitions (when 0 -> 2048) */
|
||||
BaseType_t xSizes[ ffconfigMAX_PARTITIONS ]; /* E.g. 80, 20, 0, 0 (see eSizeType) */
|
||||
BaseType_t xPrimaryCount; /* The number of partitions that must be "primary" */
|
||||
eSizeType_t eSizeType;
|
||||
} FF_PartitionParameters_t;
|
||||
|
||||
FF_Error_t FF_Partition( FF_Disk_t * pxDisk,
|
||||
FF_PartitionParameters_t * pParams );
|
||||
|
||||
FF_Error_t FF_Format( FF_Disk_t * pxDisk,
|
||||
BaseType_t xPartitionNumber,
|
||||
BaseType_t xPreferFAT16,
|
||||
BaseType_t xSmallClusters );
|
||||
|
||||
FF_Error_t FF_FormatDisk( FF_Disk_t * pxDisk,
|
||||
BaseType_t xPartitionNumber,
|
||||
BaseType_t xPreferFAT16,
|
||||
BaseType_t xSmallClusters,
|
||||
const char * pcVolumeName );
|
||||
|
||||
/* Private : */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* ifndef _FF_FORMAT_H_ */
|
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* FreeRTOS+FAT V2.3.3
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PLUS_FAT_H
|
||||
#define PLUS_FAT_H
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "semphr.h"
|
||||
|
||||
#include "FreeRTOSFATConfig.h"
|
||||
#include "FreeRTOSFATConfigDefaults.h"
|
||||
#include "ff_error.h"
|
||||
#include "ff_string.h"
|
||||
#include "ff_ioman.h"
|
||||
#include "ff_fat.h"
|
||||
#include "ff_fatdef.h"
|
||||
#include "ff_memory.h"
|
||||
#include "ff_time.h"
|
||||
#include "ff_crc.h"
|
||||
#include "ff_file.h"
|
||||
#include "ff_dir.h"
|
||||
#include "ff_format.h"
|
||||
#include "ff_locking.h"
|
||||
|
||||
/* See if any older defines with a prefix "FF_" are still defined: */
|
||||
#include "ff_old_config_defines.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* ifndef PLUS_FAT_H */
|
@ -0,0 +1,414 @@
|
||||
/*
|
||||
* FreeRTOS+FAT V2.3.3
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file ff_ioman.h
|
||||
* @ingroup IOMAN
|
||||
**/
|
||||
|
||||
#ifndef _FF_IOMAN_H_
|
||||
#define _FF_IOMAN_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdlib.h> /* Use of malloc() */
|
||||
|
||||
#ifndef PLUS_FAT_H
|
||||
#error this header will be included from "ff_headers.h"
|
||||
#endif
|
||||
|
||||
#define FF_T_FAT12 0x0A
|
||||
#define FF_T_FAT16 0x0B
|
||||
#define FF_T_FAT32 0x0C
|
||||
|
||||
#define FF_MODE_READ 0x01 /* Buffer / FILE Mode for Read Access. */
|
||||
#define FF_MODE_WRITE 0x02 /* Buffer / FILE Mode for Write Access. */
|
||||
#define FF_MODE_APPEND 0x04 /* FILE Mode Append Access. */
|
||||
#define FF_MODE_CREATE 0x08 /* FILE Mode Create file if not existing. */
|
||||
#define FF_MODE_TRUNCATE 0x10 /* FILE Mode Truncate an Existing file. */
|
||||
#define FF_MODE_VIRGIN 0x40 /* Buffer mode: do not fetch content from disk. Used for write-only buffers. */
|
||||
#define FF_MODE_DIR 0x80 /* Special Mode to open a Dir. (Internal use ONLY!) */
|
||||
|
||||
#define FF_MODE_RD_WR ( FF_MODE_READ | FF_MODE_WRITE ) /* Just for bit filtering. */
|
||||
|
||||
/* The buffer write-only mode saves a fetch from disk.
|
||||
* The write-only mode is used when a buffer is needed just
|
||||
* for clearing sectors. */
|
||||
#define FF_MODE_WR_ONLY ( FF_MODE_VIRGIN | FF_MODE_WRITE ) /* Buffer for Write-only Access (Internal use ONLY!) */
|
||||
|
||||
#define FF_BUF_MAX_HANDLES 0xFFFF /* Maximum number handles sharing a buffer. (16 bit integer, we don't want to overflow it!) */
|
||||
|
||||
#define FF_MAX_ENTRIES_PER_DIRECTORY 0xFFFF
|
||||
#define FF_SIZEOF_DIRECTORY_ENTRY 32
|
||||
|
||||
#ifndef pdTRUE_SIGNED
|
||||
|
||||
/* Temporary solution: eventually the defines below will appear
|
||||
* in 'Source\include\projdefs.h' */
|
||||
#define pdTRUE_SIGNED pdTRUE
|
||||
#define pdFALSE_SIGNED pdFALSE
|
||||
#define pdTRUE_UNSIGNED ( ( UBaseType_t ) 1u )
|
||||
#define pdFALSE_UNSIGNED ( ( UBaseType_t ) 0u )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* I/O Driver Definitions
|
||||
* Provide access to any Block Device via the following interfaces.
|
||||
* Returns the number of blocks actually read or written.
|
||||
**/
|
||||
|
||||
/**
|
||||
* A special information structure for the FreeRTOS+FAT mass storage device
|
||||
* driver model.
|
||||
**/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t BlkSize;
|
||||
uint32_t TotalBlocks;
|
||||
} FF_DeviceInfo_t;
|
||||
|
||||
#if ( ffconfigHASH_CACHE != 0 )
|
||||
#define FF_HASH_TABLE_ENTRY_COUNT ( ( ffconfigHASH_TABLE_SIZE + 3 ) / 4 )
|
||||
|
||||
struct xHASH_TABLE
|
||||
{
|
||||
uint32_t ulDirCluster; /* The Starting Cluster of the dir that the hash represents. */
|
||||
uint32_t ulNumHandles; /* Number of active Handles using this hash table. */
|
||||
uint32_t ulMisses; /* Number of times this Hash Table was missed, (i.e. how redundant it is). */
|
||||
uint32_t ulBitTable[ FF_HASH_TABLE_ENTRY_COUNT ];
|
||||
};
|
||||
|
||||
typedef struct xHASH_TABLE FF_HashTable_t;
|
||||
|
||||
void FF_ClearHash( FF_HashTable_t * pxHash,
|
||||
uint32_t ulHash );
|
||||
void FF_SetHash( FF_HashTable_t * pxHash,
|
||||
uint32_t ulHash );
|
||||
BaseType_t FF_isHashSet( FF_HashTable_t * pxHash,
|
||||
uint32_t ulHash );
|
||||
#endif /* ffconfigHASH_CACHE */
|
||||
|
||||
/* A forward declaration for the I/O manager, to be used in 'struct xFFDisk'. */
|
||||
struct _FF_IOMAN;
|
||||
struct xFFDisk;
|
||||
|
||||
typedef void ( * FF_FlushApplicationHook )( struct xFFDisk * pxDisk );
|
||||
|
||||
/*
|
||||
* Some low-level drivers also need to flush data to a device.
|
||||
* Use an Application hook that will be called every time when
|
||||
* FF_FlushCache() is called. The semaphore will still be taken
|
||||
* to avoid unwanted reentrancy.
|
||||
* For example:
|
||||
*
|
||||
* void FTL_FlushData( struct xFFDisk *pxDisk )
|
||||
* {
|
||||
* // You may or may not inspect 'pxDisk'
|
||||
* FTL_FlushTableCache();
|
||||
* }
|
||||
*
|
||||
* Make sure you bind the function to the disc object, right after creation:
|
||||
*
|
||||
* pxDisk->fnFlushApplicationHook = FTL_FlushData;
|
||||
*/
|
||||
|
||||
/* Structure that contains fields common to all media drivers, and can be
|
||||
* extended to contain additional fields to tailor it for use with a specific media
|
||||
* type. */
|
||||
struct xFFDisk
|
||||
{
|
||||
struct
|
||||
{
|
||||
/* Flags that can optionally be used by the media driver to ensure the
|
||||
* disk has been initialised, registered and mounted before it is accessed. */
|
||||
uint32_t bIsInitialised : 1;
|
||||
uint32_t bIsMounted : 1;
|
||||
uint32_t spare0 : 5;
|
||||
|
||||
/* The partition number on the media described by this structure. */
|
||||
uint32_t bPartitionNumber : 8;
|
||||
uint32_t spare1 : 16;
|
||||
}
|
||||
xStatus;
|
||||
|
||||
/* Provided to allow this structure to be extended to include additional
|
||||
* attributes that are specific to a media type. */
|
||||
void * pvTag;
|
||||
|
||||
/* Points to input and output manager used by the disk described by this
|
||||
* structure. */
|
||||
struct _FF_IOMAN * pxIOManager;
|
||||
|
||||
/* The number of sectors on the disk. */
|
||||
uint32_t ulNumberOfSectors;
|
||||
|
||||
/* See comments here above. */
|
||||
FF_FlushApplicationHook fnFlushApplicationHook;
|
||||
|
||||
/* Field that can optionally be set to a signature that is unique to the
|
||||
* media. Read and write functions can check the ulSignature field to validate
|
||||
* the media type before they attempt to access the pvTag field, or perform any
|
||||
* read and write operations. */
|
||||
uint32_t ulSignature;
|
||||
};
|
||||
|
||||
typedef struct xFFDisk FF_Disk_t;
|
||||
|
||||
typedef int32_t ( * FF_WriteBlocks_t ) ( uint8_t * pucBuffer,
|
||||
uint32_t ulSectorAddress,
|
||||
uint32_t ulCount,
|
||||
FF_Disk_t * pxDisk );
|
||||
typedef int32_t ( * FF_ReadBlocks_t ) ( uint8_t * pucBuffer,
|
||||
uint32_t ulSectorAddress,
|
||||
uint32_t ulCount,
|
||||
FF_Disk_t * pxDisk );
|
||||
|
||||
/**
|
||||
* @public
|
||||
* @brief Describes the block device driver interface to FreeRTOS+FAT.
|
||||
**/
|
||||
typedef struct
|
||||
{
|
||||
FF_WriteBlocks_t fnpWriteBlocks; /* Function Pointer, to write a block(s) from a block device. */
|
||||
FF_ReadBlocks_t fnpReadBlocks; /* Function Pointer, to read a block(s) from a block device. */
|
||||
FF_Disk_t * pxDisk; /* Earlier called 'pParam': pointer to some parameters e.g. for a Low-Level Driver Handle. */
|
||||
} FF_BlockDevice_t;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @brief FreeRTOS+FAT handles memory with buffers, described as below.
|
||||
* @note This may change throughout development.
|
||||
**/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t ulSector; /* The LBA of the Cached sector. */
|
||||
uint32_t ulLRU; /* For the Least Recently Used algorithm. */
|
||||
uint8_t * pucBuffer; /* Pointer to the cache block. */
|
||||
uint32_t ucMode : 8, /* Read or Write mode. */
|
||||
bModified : 1, /* If the sector was modified since read. */
|
||||
bValid : 1; /* Initially FALSE. */
|
||||
uint16_t usNumHandles; /* Number of objects using this buffer. */
|
||||
uint16_t usPersistance; /* For the persistance algorithm. */
|
||||
} FF_Buffer_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
#if ( ffconfigUNICODE_UTF16_SUPPORT != 0 )
|
||||
FF_T_WCHAR pcPath[ ffconfigMAX_FILENAME ];
|
||||
#else
|
||||
char pcPath[ ffconfigMAX_FILENAME ];
|
||||
#endif
|
||||
uint32_t ulDirCluster;
|
||||
} FF_PathCache_t;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @brief FreeRTOS+FAT identifies a partition with the following data.
|
||||
* @note This may shrink as development and optimisation goes on.
|
||||
**/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t ulBeginLBA; /* LBA start address of the partition. */
|
||||
uint32_t ulFATBeginLBA; /* LBA of the FAT tables. */
|
||||
uint32_t ulSectorsPerFAT; /* Number of sectors per Fat. */
|
||||
uint32_t ulTotalSectors;
|
||||
uint32_t ulDataSectors;
|
||||
#if ( ffconfigWRITE_FREE_COUNT != 0 )
|
||||
uint32_t ulFSInfoLBA; /* LBA of the FSINFO sector. */
|
||||
#endif
|
||||
uint32_t ulRootDirSectors;
|
||||
uint32_t ulFirstDataSector;
|
||||
uint32_t ulClusterBeginLBA; /* LBA of first cluster. */
|
||||
uint32_t ulNumClusters; /* Number of clusters. */
|
||||
uint32_t ulRootDirCluster; /* Cluster number of the root directory entry. */
|
||||
uint32_t ulLastFreeCluster;
|
||||
uint32_t ulFreeClusterCount; /* Records free space on mount. */
|
||||
uint32_t ulSectorsPerCluster; /* Number of sectors per Cluster. */
|
||||
|
||||
char pcVolumeLabel[ 12 ]; /* Volume Label of the partition. */
|
||||
|
||||
uint16_t usBlkSize; /* Size of a Sector Block in bytes. */
|
||||
uint16_t usReservedSectors;
|
||||
|
||||
uint8_t ucType; /* Partition Type Identifier. */
|
||||
uint8_t ucBlkFactor; /* Scale Factor for block sizes above 512! */
|
||||
uint8_t ucNumFATS; /* Number of FAT tables. */
|
||||
uint8_t ucPartitionMounted; /* pdTRUE if the partition is mounted, otherwise pdFALSE. */
|
||||
|
||||
#if ( ffconfigPATH_CACHE != 0 )
|
||||
FF_PathCache_t pxPathCache[ ffconfigPATH_CACHE_DEPTH ];
|
||||
uint32_t ulPCIndex;
|
||||
#endif
|
||||
} FF_Partition_t;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @public
|
||||
* @brief FF_IOManager_t Object description.
|
||||
*
|
||||
* FreeRTOS+FAT functions around an object like this.
|
||||
**/
|
||||
#define FF_FAT_LOCK 0x01 /* Lock bit mask for FAT table locking. */
|
||||
#define FF_DIR_LOCK 0x02 /* Lock bit mask for DIR modification locking. */
|
||||
#define FF_BUF_LOCK 0x04 /* Lock bit mask for buffers. */
|
||||
|
||||
/**
|
||||
* @public
|
||||
* @brief FF_IOManager_t Object. A developer should not touch these values.
|
||||
*
|
||||
**/
|
||||
typedef struct _FF_IOMAN
|
||||
{
|
||||
FF_BlockDevice_t xBlkDevice; /* Pointer to a Block device description. */
|
||||
FF_Partition_t xPartition; /* A partition description. */
|
||||
FF_Buffer_t * pxBuffers; /* Pointer to an array of buffer descriptors. */
|
||||
void * pvSemaphore; /* Pointer to a Semaphore object. (For buffer description modifications only!). */
|
||||
void * FirstFile; /* Pointer to the first File object. */
|
||||
void * xEventGroup; /* An event group, used for locking FAT, DIR and Buffers. Replaces ucLocks. */
|
||||
uint8_t * pucCacheMem; /* Pointer to a block of memory for the cache. */
|
||||
uint16_t usSectorSize; /* The sector size that IOMAN is configured to. */
|
||||
uint16_t usCacheSize; /* Size of the cache in number of Sectors. */
|
||||
uint8_t ucPreventFlush; /* Flushing to disk only allowed when 0. */
|
||||
uint8_t ucFlags; /* Bit-Mask: identifying allocated pointers and other flags */
|
||||
#if ( ffconfigHASH_CACHE != 0 )
|
||||
FF_HashTable_t xHashCache[ ffconfigHASH_CACHE_DEPTH ];
|
||||
#endif
|
||||
void * pvFATLockHandle;
|
||||
} FF_IOManager_t;
|
||||
|
||||
/* Bit values for 'FF_IOManager_t::ucFlags': */
|
||||
/* Memory Allocation testing and other flags. */
|
||||
#define FF_IOMAN_ALLOC_BUFDESCR 0x01 /* Flags the pxBuffers pointer is allocated. */
|
||||
#define FF_IOMAN_ALLOC_BUFFERS 0x02 /* Flags the pucCacheMem pointer is allocated. */
|
||||
#define FF_IOMAN_BLOCK_DEVICE_IS_REENTRANT 0x10 /* When true, ffRead/ffWrite are not protected by a semaphore. */
|
||||
#if ( ffconfigREMOVABLE_MEDIA != 0 )
|
||||
#define FF_IOMAN_DEVICE_IS_EXTRACTED 0x20
|
||||
#endif /* ffconfigREMOVABLE_MEDIA */
|
||||
|
||||
typedef struct xFF_CREATION_PARAMETERS
|
||||
{
|
||||
uint8_t * pucCacheMemory; /* User provided memory, or use NULL to malloc the cache memory. */
|
||||
uint32_t ulMemorySize; /* Size of the cache memory, must be a multiple of 'ulSectorSize'. */
|
||||
BaseType_t ulSectorSize; /* Sector size, unit for reading/writing to the disk, normally 512 bytes. */
|
||||
FF_WriteBlocks_t fnWriteBlocks; /* A function to write sectors to the device. */
|
||||
FF_ReadBlocks_t fnReadBlocks; /* A function to read sectors from the device. */
|
||||
FF_Disk_t * pxDisk; /* Some properties of the disk driver. */
|
||||
void * pvSemaphore; /* Pointer to a Semaphore object. */
|
||||
BaseType_t xBlockDeviceIsReentrant; /* Make non-zero if ffRead/ffWrite are re-entrant. */
|
||||
} FF_CreationParameters_t;
|
||||
|
||||
/*---------- PROTOTYPES (in order of appearance). */
|
||||
|
||||
/* PUBLIC (Interfaces): */
|
||||
FF_IOManager_t * FF_CreateIOManger( FF_CreationParameters_t * pxParameters,
|
||||
FF_Error_t * pError );
|
||||
FF_Error_t FF_DeleteIOManager( FF_IOManager_t * pxIOManager );
|
||||
FF_Error_t FF_Mount( FF_Disk_t * pxDisk,
|
||||
BaseType_t xPartitionNumber );
|
||||
FF_Error_t FF_Unmount( FF_Disk_t * pxDisk );
|
||||
FF_Error_t FF_FlushCache( FF_IOManager_t * pxIOManager );
|
||||
static portINLINE BaseType_t FF_Mounted( FF_IOManager_t * pxIOManager )
|
||||
{
|
||||
return pxIOManager && pxIOManager->xPartition.ucPartitionMounted;
|
||||
}
|
||||
|
||||
int32_t FF_GetPartitionBlockSize( FF_IOManager_t * pxIOManager );
|
||||
|
||||
#if ( ffconfig64_NUM_SUPPORT != 0 )
|
||||
uint64_t FF_GetVolumeSize( FF_IOManager_t * pxIOManager );
|
||||
#else
|
||||
uint32_t FF_GetVolumeSize( FF_IOManager_t * pxIOManager );
|
||||
#endif
|
||||
|
||||
/* PUBLIC (To FreeRTOS+FAT Only): */
|
||||
int32_t FF_BlockRead( FF_IOManager_t * pxIOManager,
|
||||
uint32_t ulSectorLBA,
|
||||
uint32_t ulNumSectors,
|
||||
void * pBuffer,
|
||||
BaseType_t aSemLocked );
|
||||
int32_t FF_BlockWrite( FF_IOManager_t * pxIOManager,
|
||||
uint32_t ulSectorLBA,
|
||||
uint32_t ulNumSectors,
|
||||
void * pBuffer,
|
||||
BaseType_t aSemLocked );
|
||||
FF_Error_t FF_IncreaseFreeClusters( FF_IOManager_t * pxIOManager,
|
||||
uint32_t Count );
|
||||
FF_Error_t FF_DecreaseFreeClusters( FF_IOManager_t * pxIOManager,
|
||||
uint32_t Count );
|
||||
FF_Buffer_t * FF_GetBuffer( FF_IOManager_t * pxIOManager,
|
||||
uint32_t ulSector,
|
||||
uint8_t Mode );
|
||||
FF_Error_t FF_ReleaseBuffer( FF_IOManager_t * pxIOManager,
|
||||
FF_Buffer_t * pBuffer );
|
||||
|
||||
/* 'Internal' to FreeRTOS+FAT. */
|
||||
typedef struct _SPart
|
||||
{
|
||||
uint32_t ulStartLBA; /* FF_FAT_PTBL_LBA */
|
||||
uint32_t ulSectorCount; /* FF_FAT_PTBL_SECT_COUNT */
|
||||
uint32_t
|
||||
ucActive : 8, /* FF_FAT_PTBL_ACTIVE */
|
||||
ucPartitionID : 8, /* FF_FAT_PTBL_ID */
|
||||
bIsExtended : 1;
|
||||
} FF_Part_t;
|
||||
|
||||
typedef struct _SPartFound
|
||||
{
|
||||
int iCount;
|
||||
FF_Part_t pxPartitions[ ffconfigMAX_PARTITIONS ];
|
||||
} FF_SPartFound_t;
|
||||
|
||||
/* This function will parse the 4 entries in a partition table: */
|
||||
void FF_ReadParts( uint8_t * pucBuffer,
|
||||
FF_Part_t * pxParts );
|
||||
|
||||
/* FF_PartitionCount() has now been replaced by FF_PartitionSearch()
|
||||
* It will enumerate all valid partitions found
|
||||
* If sector-0 happens to be a valid MBR, 1 partition will be returned
|
||||
*/
|
||||
FF_Error_t FF_PartitionSearch( FF_IOManager_t * pxIOManager,
|
||||
FF_SPartFound_t * pPartsFound );
|
||||
|
||||
/* HT : for debugging only. */
|
||||
BaseType_t xIsFatSector( FF_IOManager_t * pxIOManager,
|
||||
uint32_t ulSectorNr );
|
||||
BaseType_t xNeedLogging( FF_IOManager_t * pxIOManager );
|
||||
BaseType_t xIsRootDirSector( FF_IOManager_t * pxIOManager,
|
||||
uint32_t ulSectorNr );
|
||||
const char * pcSectorType( FF_IOManager_t * pxIOManager,
|
||||
uint32_t ulSectorNr );
|
||||
|
||||
/* Needed to make this public/private to be used in FF_Partition/FF_Format. */
|
||||
void FF_IOMAN_InitBufferDescriptors( FF_IOManager_t * pxIOManager );
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* ifndef _FF_IOMAN_H_ */
|
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* FreeRTOS+FAT V2.3.3
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file ff_locking.h
|
||||
* @ingroup LOCKING
|
||||
**/
|
||||
|
||||
#ifndef _FF_LOCKING_H_
|
||||
#define _FF_LOCKING_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/*---------- PROTOTYPES (in order of appearance). */
|
||||
|
||||
/* PUBLIC: */
|
||||
|
||||
|
||||
/* PRIVATE: */
|
||||
void FF_PendSemaphore( void * pSemaphore );
|
||||
BaseType_t FF_TrySemaphore( void * pSemaphore,
|
||||
uint32_t TimeMs );
|
||||
void FF_ReleaseSemaphore( void * pSemaphore );
|
||||
void FF_Sleep( uint32_t TimeMs );
|
||||
|
||||
/* Create an event group and bind it to an I/O manager. */
|
||||
BaseType_t FF_CreateEvents( FF_IOManager_t * pxIOManager );
|
||||
|
||||
/* Delete an event group. */
|
||||
void FF_DeleteEvents( FF_IOManager_t * pxIOManager );
|
||||
|
||||
/* Get a lock on all DIR operations for a given I/O manager. */
|
||||
void FF_LockDirectory( FF_IOManager_t * pxIOManager );
|
||||
|
||||
/* Release the lock on all DIR operations. */
|
||||
void FF_UnlockDirectory( FF_IOManager_t * pxIOManager );
|
||||
|
||||
/* Get a lock on all FAT operations for a given I/O manager. */
|
||||
void FF_LockFAT( FF_IOManager_t * pxIOManager );
|
||||
|
||||
/* Release the lock on all FAT operations. */
|
||||
void FF_UnlockFAT( FF_IOManager_t * pxIOManager );
|
||||
|
||||
/* Called from FF_GetBuffer() as long as no buffer is available. */
|
||||
BaseType_t FF_BufferWait( FF_IOManager_t * pxIOManager,
|
||||
uint32_t xWaitMS );
|
||||
|
||||
/* Called from FF_ReleaseBuffer(). */
|
||||
void FF_BufferProceed( FF_IOManager_t * pxIOManager );
|
||||
|
||||
/* Check if the current task already has locked the FAT. */
|
||||
int FF_Has_Lock( FF_IOManager_t * pxIOManager,
|
||||
uint32_t aBits );
|
||||
|
||||
/*
|
||||
* Throw a configASSERT() in case the FAT has not been locked
|
||||
* by this task.
|
||||
*/
|
||||
/* _HT_ This function is only necessary while testing. */
|
||||
void FF_Assert_Lock( FF_IOManager_t * pxIOManager,
|
||||
uint32_t aBits );
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* _FF_LOCKING_H_ */
|
@ -0,0 +1,187 @@
|
||||
/*
|
||||
* FreeRTOS+FAT V2.3.3
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file ff_memory.h
|
||||
* @ingroup MEMORY
|
||||
**/
|
||||
|
||||
#ifndef _FF_MEMORY_H_
|
||||
#define _FF_MEMORY_H_
|
||||
|
||||
/*
|
||||
* When sector data is written or analysed, some values might be stored unaligned.
|
||||
* The routines below treat all values as little arrays of either 2 or 4 bytes.
|
||||
* Also on big endian platforms, the order of bytes will be swapped.
|
||||
*/
|
||||
/*---------- PROTOTYPES */
|
||||
|
||||
#if ( ffconfigBYTE_ORDER == pdFREERTOS_LITTLE_ENDIAN )
|
||||
|
||||
/*
|
||||
* FAT is little endian.
|
||||
* On a little endian CPU, bytes will be copied to the structures below 1-to-1 :
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t u8_0; /* the first byte */
|
||||
uint8_t u8_1; /* the second byte */
|
||||
} FF_TShort_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t u8_0;
|
||||
uint8_t u8_1;
|
||||
uint8_t u8_2;
|
||||
uint8_t u8_3;
|
||||
} FF_TLong_t;
|
||||
#elif ( ffconfigBYTE_ORDER == pdFREERTOS_BIG_ENDIAN )
|
||||
|
||||
/*
|
||||
* On a big endian CPU, all bytes will be swapped, either 2 or 4 bytes:
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t u8_1; /* the second byte */
|
||||
uint8_t u8_0; /* the first byte */
|
||||
} FF_TShort_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t u8_3;
|
||||
uint8_t u8_2;
|
||||
uint8_t u8_1;
|
||||
uint8_t u8_0;
|
||||
} FF_TLong_t;
|
||||
#else /* if ( ffconfigBYTE_ORDER == pdFREERTOS_LITTLE_ENDIAN ) */
|
||||
#error Little or Big Endian? - Please set ffconfigBYTE_ORDER to either pdFREERTOS_LITTLE_ENDIAN or pdFREERTOS_BIG_ENDIAN 1 in FreeRTOSFATConfig.h
|
||||
#endif /* if ( ffconfigBYTE_ORDER == pdFREERTOS_LITTLE_ENDIAN ) */
|
||||
|
||||
/*! 16-bit union. */
|
||||
typedef union
|
||||
{
|
||||
uint16_t u16;
|
||||
FF_TShort_t bytes;
|
||||
} FF_T_UN16;
|
||||
|
||||
/*! 32-bit union. */
|
||||
typedef union
|
||||
{
|
||||
uint32_t u32;
|
||||
FF_TLong_t bytes;
|
||||
} FF_T_UN32;
|
||||
|
||||
/* HT inlined these functions:
|
||||
*/
|
||||
|
||||
#if ( ffconfigINLINE_MEMORY_ACCESS != 0 )
|
||||
|
||||
static portINLINE uint8_t FF_getChar( const uint8_t * pBuffer,
|
||||
uint32_t aOffset )
|
||||
{
|
||||
return ( uint8_t ) ( pBuffer[ aOffset ] );
|
||||
}
|
||||
|
||||
static portINLINE uint16_t FF_getShort( const uint8_t * pBuffer,
|
||||
uint32_t aOffset )
|
||||
{
|
||||
FF_T_UN16 u16;
|
||||
|
||||
pBuffer += aOffset;
|
||||
u16.bytes.u8_1 = pBuffer[ 1 ];
|
||||
u16.bytes.u8_0 = pBuffer[ 0 ];
|
||||
|
||||
return u16.u16;
|
||||
}
|
||||
|
||||
static portINLINE uint32_t FF_getLong( const uint8_t * pBuffer,
|
||||
uint32_t aOffset )
|
||||
{
|
||||
FF_T_UN32 u32;
|
||||
|
||||
pBuffer += aOffset;
|
||||
u32.bytes.u8_3 = pBuffer[ 3 ];
|
||||
u32.bytes.u8_2 = pBuffer[ 2 ];
|
||||
u32.bytes.u8_1 = pBuffer[ 1 ];
|
||||
u32.bytes.u8_0 = pBuffer[ 0 ];
|
||||
|
||||
return u32.u32;
|
||||
}
|
||||
|
||||
static portINLINE void FF_putChar( uint8_t * pBuffer,
|
||||
uint32_t aOffset,
|
||||
uint32_t Value )
|
||||
{
|
||||
pBuffer[ aOffset ] = ( uint8_t ) Value;
|
||||
}
|
||||
|
||||
static portINLINE void FF_putShort( uint8_t * pBuffer,
|
||||
uint32_t aOffset,
|
||||
uint32_t Value )
|
||||
{
|
||||
FF_T_UN16 u16;
|
||||
|
||||
u16.u16 = ( uint16_t ) Value;
|
||||
pBuffer += aOffset;
|
||||
pBuffer[ 0 ] = u16.bytes.u8_0;
|
||||
pBuffer[ 1 ] = u16.bytes.u8_1;
|
||||
}
|
||||
|
||||
static portINLINE void FF_putLong( uint8_t * pBuffer,
|
||||
uint32_t aOffset,
|
||||
uint32_t Value )
|
||||
{
|
||||
FF_T_UN32 u32;
|
||||
|
||||
u32.u32 = Value;
|
||||
pBuffer += aOffset;
|
||||
pBuffer[ 0 ] = u32.bytes.u8_0;
|
||||
pBuffer[ 1 ] = u32.bytes.u8_1;
|
||||
pBuffer[ 2 ] = u32.bytes.u8_2;
|
||||
pBuffer[ 3 ] = u32.bytes.u8_3;
|
||||
}
|
||||
|
||||
#else /* ffconfigINLINE_MEMORY_ACCESS */
|
||||
|
||||
uint8_t FF_getChar( const uint8_t * pBuffer,
|
||||
uint32_t aOffset );
|
||||
uint16_t FF_getShort( const uint8_t * pBuffer,
|
||||
uint32_t aOffset );
|
||||
uint32_t FF_getLong( const uint8_t * pBuffer,
|
||||
uint32_t aOffset );
|
||||
void FF_putChar( uint8_t * pBuffer,
|
||||
uint32_t aOffset,
|
||||
uint32_t Value );
|
||||
void FF_putShort( uint8_t * pBuffer,
|
||||
uint32_t aOffset,
|
||||
uint32_t Value );
|
||||
void FF_putLong( uint8_t * pBuffer,
|
||||
uint32_t aOffset,
|
||||
uint32_t Value );
|
||||
|
||||
#endif /* ffconfigINLINE_MEMORY_ACCESS */
|
||||
|
||||
#endif /* _FF_MEMORY_H_ */
|
@ -0,0 +1,256 @@
|
||||
/*
|
||||
* FreeRTOS+FAT V2.3.3
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* As of 15/3/2015 all +FAT configuration items changed their prefix,
|
||||
* e.g. FF_LITTLE_ENDIAN has become ffconfigLITTLE_ENDIAN
|
||||
* This tempoary header file checks for the presence old configuration items
|
||||
* and issue a compiler error if any is defined.
|
||||
*/
|
||||
|
||||
#ifdef FF_LITTLE_ENDIAN
|
||||
#error FF_LITTLE_ENDIAN was dropped and replaced with 'ffconfigBYTE_ORDER == pdFREERTOS_LITTLE_ENDIAN'
|
||||
#endif
|
||||
|
||||
#ifdef FF_BIG_ENDIAN
|
||||
#error FF_BIG_ENDIAN was dropped and replaced with 'ffconfigBYTE_ORDER == pdFREERTOS_BIG_ENDIAN'
|
||||
#endif
|
||||
|
||||
#ifdef ffconfigLITTLE_ENDIAN
|
||||
#error ffconfigLITTLE_ENDIAN was dropped.
|
||||
#endif
|
||||
|
||||
#ifdef ffconfigBIG_ENDIAN
|
||||
#error ffconfigBIG_ENDIAN was dropped.
|
||||
#endif
|
||||
|
||||
#ifdef FF_HAS_CWD
|
||||
#error FF_HAS_CWD still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#if !defined( pdFREERTOS_LITTLE_ENDIAN ) || !defined( pdFREERTOS_BIG_ENDIAN )
|
||||
#error Missing defines from FreeRTOS
|
||||
#endif
|
||||
|
||||
#ifdef FF_LFN_SUPPORT
|
||||
#error FF_LFN_SUPPORT still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_INCLUDE_SHORT_NAME
|
||||
#error FF_INCLUDE_SHORT_NAME still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_SHORTNAME_CASE
|
||||
#error FF_SHORTNAME_CASE still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_UNICODE_UTF16_SUPPORT
|
||||
#error FF_UNICODE_UTF16_SUPPORT still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_UNICODE_UTF8_SUPPORT
|
||||
#error FF_UNICODE_UTF8_SUPPORT still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_FAT12_SUPPORT
|
||||
#error FF_FAT12_SUPPORT still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_OPTIMISE_UNALIGNED_ACCESS
|
||||
#error FF_OPTIMISE_UNALIGNED_ACCESS still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_CACHE_WRITE_THROUGH
|
||||
#error FF_CACHE_WRITE_THROUGH still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_WRITE_BOTH_FATS
|
||||
#error FF_WRITE_BOTH_FATS still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_WRITE_FREE_COUNT
|
||||
#error FF_WRITE_FREE_COUNT still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_TIME_SUPPORT
|
||||
#error FF_TIME_SUPPORT still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_REMOVABLE_MEDIA
|
||||
#error FF_REMOVABLE_MEDIA still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_MOUNT_FIND_FREE
|
||||
#error FF_MOUNT_FIND_FREE still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_FINDAPI_ALLOW_WILDCARDS
|
||||
#error FF_FINDAPI_ALLOW_WILDCARDS still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_WILDCARD_CASE_INSENSITIVE
|
||||
#error FF_WILDCARD_CASE_INSENSITIVE still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_PATH_CACHE
|
||||
#error FF_PATH_CACHE still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_PATH_CACHE_DEPTH
|
||||
#error FF_PATH_CACHE_DEPTH still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_HASH_CACHE
|
||||
#error FF_HASH_CACHE still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_HASH_FUNCTION
|
||||
#error FF_HASH_FUNCTION still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_HASH_TABLE_SIZE
|
||||
#error FF_HASH_TABLE_SIZE still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_HASH_TABLE_SIZE
|
||||
#error FF_HASH_TABLE_SIZE still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_MKDIR_RECURSIVE
|
||||
#error FF_MKDIR_RECURSIVE still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_BLKDEV_USES_SEM
|
||||
#error FF_BLKDEV_USES_SEM is not used any more
|
||||
#endif
|
||||
|
||||
#ifdef ffconfigBLKDEV_USES_SEM
|
||||
#error ffconfigBLKDEV_USES_SEM is not used any more
|
||||
#endif
|
||||
|
||||
#ifdef FF_MALLOC
|
||||
#error FF_MALLOC still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_FREE
|
||||
#error FF_FREE still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_64_NUM_SUPPORT
|
||||
#error FF_64_NUM_SUPPORT still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_MAX_PARTITIONS
|
||||
#error FF_MAX_PARTITIONS still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_MAX_FILE_SYS
|
||||
#error FF_MAX_FILE_SYS still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_DRIVER_BUSY_SLEEP_MS
|
||||
#error FF_DRIVER_BUSY_SLEEP_MS still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_FPRINTF_SUPPORT
|
||||
#error FF_FPRINTF_SUPPORT still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_FPRINTF_BUFFER_LENGTH
|
||||
#error FF_FPRINTF_BUFFER_LENGTH still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_DEBUG
|
||||
#error FF_DEBUG still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_HAS_FUNCTION_TAB
|
||||
#error FF_HAS_FUNCTION_TAB still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_FAT_CHECK
|
||||
#error FF_FAT_CHECK still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_MAX_FILENAME
|
||||
#error FF_MAX_FILENAME still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_PRINTFFF_PRINTF
|
||||
#error FF_PRINTFFF_PRINTF still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_FAT_USES_STAT
|
||||
#error FF_FAT_USES_STAT still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef BUF_STORE_COUNT
|
||||
#error BUF_STORE_COUNT still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_USE_NOTIFY
|
||||
#error FF_USE_NOTIFY still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_DEV_SUPPORT
|
||||
#error FF_DEV_SUPPORT still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_FSINFO_TRUSTED
|
||||
#error FF_FSINFO_TRUSTED still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_LONG_ERR_MSG
|
||||
#error FF_LONG_ERR_MSG still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_INLINE_MEMORY_ACCESS
|
||||
#error FF_INLINE_MEMORY_ACCESS still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_MIRROR_FATS_UMOUNT
|
||||
#error FF_MIRROR_FATS_UMOUNT still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_HASH_CACHE_DEPTH
|
||||
#error FF_HASH_CACHE_DEPTH still defined. Please use ffconfig prefix.
|
||||
#endif
|
||||
|
||||
#ifdef FF_HASH_TABLE_SUPPORT
|
||||
#error FF_HASH_TABLE_SUPPORT was dropped
|
||||
#endif
|
||||
|
||||
#ifdef FF_INLINE_BLOCK_CALCULATIONS
|
||||
#error FF_INLINE_BLOCK_CALCULATIONS was dropped
|
||||
#endif
|
||||
|
||||
#ifdef FF_CWD_THREAD_LOCAL_INDEX
|
||||
#error FF_CWD_THREAD_LOCAL_INDEX is now called ffconfigCWD_THREAD_LOCAL_INDEX
|
||||
#endif
|
||||
|
||||
#ifdef FF_DEV_PATH
|
||||
#error FF_DEV_PATH was dropped
|
||||
#endif
|
@ -0,0 +1,383 @@
|
||||
/*
|
||||
* FreeRTOS+FAT V2.3.3
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* ff_stdio.h
|
||||
*
|
||||
* An front-end which make +FAT look like the well-known stdio-functions
|
||||
*/
|
||||
|
||||
#ifndef FF_STDIO_H
|
||||
#define FF_STDIO_H
|
||||
|
||||
#if defined( __WIN32__ )
|
||||
#include <dir.h>
|
||||
#endif
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
/* FreeRTOS+FAT includes. */
|
||||
#include "ff_headers.h"
|
||||
#include "ff_sys.h"
|
||||
|
||||
#if ( ffconfigDEV_SUPPORT != 0 )
|
||||
#include "ff_devices.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Error return from some functions. */
|
||||
#define FF_EOF ( -1 )
|
||||
|
||||
/* Bits used in the FF_Stat_t structure. */
|
||||
#define FF_IFDIR 0040000u /* directory */
|
||||
#define FF_IFCHR 0020000u /* character special */
|
||||
#define FF_IFBLK 0060000u /* block special */
|
||||
#define FF_IFREG 0100000u /* regular */
|
||||
|
||||
/* Bits used in the FF_FindData_t structure. */
|
||||
#define FF_FA_NORMAL 0x00
|
||||
#define FF_FA_RDONLY 0x01
|
||||
#define FF_FA_HIDDEN 0x02
|
||||
#define FF_FA_SYSTEM 0x04
|
||||
#define FF_FA_LABEL 0x08
|
||||
#define FF_FA_DIREC 0x10
|
||||
#define FF_FA_ARCH 0x20
|
||||
|
||||
/* FreeRTOS+FAT uses three thread local buffers. The first stores errno, the
|
||||
* second a pointer to the CWD structure (if one is used), and the third the more
|
||||
* descriptive error code. */
|
||||
#define stdioERRNO_THREAD_LOCAL_OFFSET ( ffconfigCWD_THREAD_LOCAL_INDEX + 0 )
|
||||
#define stdioCWD_THREAD_LOCAL_OFFSET ( ffconfigCWD_THREAD_LOCAL_INDEX + 1 )
|
||||
#define stdioFF_ERROR_THREAD_LOCAL_OFFSET ( ffconfigCWD_THREAD_LOCAL_INDEX + 2 )
|
||||
|
||||
|
||||
/* Structure used with ff_stat(). */
|
||||
typedef struct FF_STAT
|
||||
{
|
||||
uint32_t st_ino; /* First data cluster number. */
|
||||
uint32_t st_size; /* Size of the object in number of bytes. */
|
||||
uint16_t st_dev; /* The device on which the file can be found (see ff_sys.c) */
|
||||
uint16_t st_mode; /* The mode (attribute bits) of this file or directory. */
|
||||
|
||||
#if ( ffconfigTIME_SUPPORT == 1 )
|
||||
uint32_t st_atime;
|
||||
uint32_t st_mtime;
|
||||
uint32_t st_ctime;
|
||||
#endif /* ffconfigTIME_SUPPORT */
|
||||
} FF_Stat_t;
|
||||
|
||||
/* Structure used with ff_findfirst(), ff_findnext(), etc. */
|
||||
typedef struct
|
||||
{
|
||||
/* private */
|
||||
UBaseType_t
|
||||
#if ( ffconfigDEV_SUPPORT != 0 )
|
||||
bIsDeviceDir : 1,
|
||||
#endif
|
||||
bEntryPOwner : 1;
|
||||
struct FF_DIR_HANDLER xDirectoryHandler;
|
||||
FF_DirEnt_t xDirectoryEntry;
|
||||
|
||||
/* Public fields included so FF_DirEnt_t does not need to be public. */
|
||||
const char * pcFileName;
|
||||
uint32_t ulFileSize;
|
||||
uint8_t ucAttributes;
|
||||
} FF_FindData_t;
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Get and set the task's file system errno
|
||||
* The most up to date API documentation is currently provided on the following URL:
|
||||
* http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_FAT/Standard_File_System_API.html
|
||||
*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* int FF_GetErrno( void );
|
||||
* void FF_SetErrno( int ff_errno );
|
||||
*
|
||||
* _RB_ comments are incorrect and index should use the stdioERRNO_THREAD_LOCAL_OFFSET offset.
|
||||
*/
|
||||
|
||||
/* The errno is stored in a thread local buffer. */
|
||||
static portINLINE void stdioSET_ERRNO( int iErrno )
|
||||
{
|
||||
vTaskSetThreadLocalStoragePointer( NULL, ffconfigCWD_THREAD_LOCAL_INDEX, ( void * ) ( iErrno ) );
|
||||
}
|
||||
|
||||
static portINLINE int stdioGET_ERRNO( void )
|
||||
{
|
||||
void * pvResult;
|
||||
|
||||
pvResult = pvTaskGetThreadLocalStoragePointer( ( TaskHandle_t ) NULL, ffconfigCWD_THREAD_LOCAL_INDEX );
|
||||
return ( int ) pvResult;
|
||||
}
|
||||
|
||||
#if ( ( configNUM_THREAD_LOCAL_STORAGE_POINTERS - ffconfigCWD_THREAD_LOCAL_INDEX ) < 3 )
|
||||
#error Please define space for 3 entries
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Store the FreeRTOS+FAT error code, which provides more detail than errno.
|
||||
*/
|
||||
static portINLINE void stdioSET_FF_ERROR( FF_Error_t iFF_ERROR )
|
||||
{
|
||||
vTaskSetThreadLocalStoragePointer( NULL, stdioFF_ERROR_THREAD_LOCAL_OFFSET, ( void * ) ( iFF_ERROR ) );
|
||||
}
|
||||
|
||||
/*
|
||||
* Read back the FreeRTOS+FAT error code, which provides more detail than
|
||||
* errno.
|
||||
*/
|
||||
static portINLINE FF_Error_t stdioGET_FF_ERROR( void )
|
||||
{
|
||||
void * pvResult;
|
||||
|
||||
pvResult = pvTaskGetThreadLocalStoragePointer( NULL, stdioFF_ERROR_THREAD_LOCAL_OFFSET );
|
||||
return ( FF_Error_t ) pvResult;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Open and close a file
|
||||
* The most up to date API documentation is currently provided on the following URL:
|
||||
* http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_FAT/Standard_File_System_API.html
|
||||
*-----------------------------------------------------------*/
|
||||
FF_FILE * ff_fopen( const char * pcFile,
|
||||
const char * pcMode );
|
||||
int ff_fclose( FF_FILE * pxStream );
|
||||
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Seek and tell
|
||||
* The most up to date API documentation is currently provided on the following URL:
|
||||
* http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_FAT/Standard_File_System_API.html
|
||||
*-----------------------------------------------------------*/
|
||||
int ff_fseek( FF_FILE * pxStream,
|
||||
long lOffset,
|
||||
int iWhence );
|
||||
void ff_rewind( FF_FILE * pxStream );
|
||||
long ff_ftell( FF_FILE * pxStream );
|
||||
int ff_feof( FF_FILE * pxStream );
|
||||
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Read and write
|
||||
* The most up to date API documentation is currently provided on the following URL:
|
||||
* http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_FAT/Standard_File_System_API.html
|
||||
*-----------------------------------------------------------*/
|
||||
size_t ff_fread( void * pvBuffer,
|
||||
size_t xSize,
|
||||
size_t xItems,
|
||||
FF_FILE * pxStream );
|
||||
size_t ff_fwrite( const void * pvBuffer,
|
||||
size_t xSize,
|
||||
size_t xItems,
|
||||
FF_FILE * pxStream );
|
||||
|
||||
/* Whenever possible, use ellipsis parameter type checking.
|
||||
* _RB_ Compiler specifics need to be moved to the compiler specific header files. */
|
||||
#if defined( __GNUC__ )
|
||||
/* The GNU-C compiler will check if the parameters are correct. */
|
||||
int ff_fprintf( FF_FILE * pxStream,
|
||||
const char * pcFormat,
|
||||
... )
|
||||
__attribute__( ( format( __printf__, 2, 3 ) ) );
|
||||
#else
|
||||
int ff_fprintf( FF_FILE * pxStream,
|
||||
const char * pcFormat,
|
||||
... );
|
||||
#endif
|
||||
|
||||
int ff_fgetc( FF_FILE * pxStream );
|
||||
int ff_fputc( int iChar,
|
||||
FF_FILE * pxStream );
|
||||
char * ff_fgets( char * pcBuffer,
|
||||
size_t xCount,
|
||||
FF_FILE * pxStream );
|
||||
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Change length of file (truncate)
|
||||
* File should have been opened in "w" or "a" mode
|
||||
* The actual length of the file will be made equal to the current writing
|
||||
* position
|
||||
* The most up to date API documentation is currently provided on the following URL:
|
||||
* http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_FAT/Standard_File_System_API.html
|
||||
*-----------------------------------------------------------*/
|
||||
int ff_seteof( FF_FILE * pxStream );
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Open a file in append/update mode, truncate its length to a given value,
|
||||
* or write zero's up until the required length, and return a handle to the open
|
||||
* file. If NULL is returned, ff_errno contains an error code.
|
||||
* The most up to date API documentation is currently provided on the following URL:
|
||||
* http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_FAT/Standard_File_System_API.html
|
||||
*-----------------------------------------------------------*/
|
||||
FF_FILE * ff_truncate( const char * pcFileName,
|
||||
long lTruncateSize );
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Flush to disk
|
||||
* The most up to date API documentation is currently provided on the following URL:
|
||||
* http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_FAT/Standard_File_System_API.html
|
||||
*-----------------------------------------------------------*/
|
||||
int ff_fflush( FF_FILE * pxStream );
|
||||
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Create directory, remove and rename files
|
||||
* The most up to date API documentation is currently provided on the following URL:
|
||||
* http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_FAT/Standard_File_System_API.html
|
||||
*-----------------------------------------------------------*/
|
||||
#if ( ffconfigMKDIR_RECURSIVE == 0 )
|
||||
int ff_mkdir( const char * pcPath );
|
||||
#else
|
||||
|
||||
/* If the parameter bRecursive is non-zero, the entire path will be checked
|
||||
* and if necessary, created. */
|
||||
int ff_mkdir( const char * pcPath,
|
||||
int bRecursive );
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Create path specified by the pcPath parameter.
|
||||
* The most up to date API documentation is currently provided on the following URL:
|
||||
* http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_FAT/Standard_File_System_API.html
|
||||
*-----------------------------------------------------------*/
|
||||
int ff_mkpath( const char * pcPath );
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Remove the directory specified by the pcDirectory parameter.
|
||||
* The most up to date API documentation is currently provided on the following URL:
|
||||
* http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_FAT/Standard_File_System_API.html
|
||||
*-----------------------------------------------------------*/
|
||||
int ff_rmdir( const char * pcDirectory );
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Delete a directory and, recursively, all of its contents.
|
||||
* The most up to date API documentation is currently provided on the following URL:
|
||||
* http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_FAT/Standard_File_System_API.html
|
||||
*-----------------------------------------------------------*/
|
||||
#if ( ffconfigUSE_DELTREE != 0 )
|
||||
|
||||
/* By default, this function will not be compiled. The function will
|
||||
* recursively call itself, which is against the FreeRTOS coding standards, so
|
||||
* IT MUST BE USED WITH CARE.
|
||||
*
|
||||
* The cost of each recursion will be roughly:
|
||||
* Stack : 48 (12 stack words)
|
||||
* Heap : 112 + ffconfigMAX_FILENAME
|
||||
* These numbers may change depending on CPU and compiler. */
|
||||
int ff_deltree( const char * pcPath );
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Remove/delete a file.
|
||||
* The most up to date API documentation is currently provided on the following URL:
|
||||
* http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_FAT/Standard_File_System_API.html
|
||||
*-----------------------------------------------------------*/
|
||||
int ff_remove( const char * pcPath );
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Move a file, also cross-directory but not across a file system.
|
||||
* The most up to date API documentation is currently provided on the following URL:
|
||||
* http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_FAT/Standard_File_System_API.html
|
||||
*-----------------------------------------------------------*/
|
||||
int ff_rename( const char * pcOldName,
|
||||
const char * pcNewName,
|
||||
int bDeleteIfExists );
|
||||
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Get the status of a file.
|
||||
* The most up to date API documentation is currently provided on the following URL:
|
||||
* http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_FAT/Standard_File_System_API.html
|
||||
*-----------------------------------------------------------*/
|
||||
int ff_stat( const char * pcFileName,
|
||||
FF_Stat_t * pxStatBuffer );
|
||||
/* _HT_ Keep this for a while, until the new ff_stat() is wel tested */
|
||||
int ff_old_stat( const char * pcName,
|
||||
FF_Stat_t * pxStatBuffer );
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Get the length of a file in bytes.
|
||||
* The most up to date API documentation is currently provided on the following URL:
|
||||
* http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_FAT/Standard_File_System_API.html
|
||||
*-----------------------------------------------------------*/
|
||||
size_t ff_filelength( FF_FILE * pxFile );
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Working directory and iterating through directories.
|
||||
* The most up to date API documentation is currently provided on the following URL:
|
||||
* http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_FAT/Standard_File_System_API.html
|
||||
*-----------------------------------------------------------*/
|
||||
#if ffconfigHAS_CWD
|
||||
int ff_chdir( const char * pcDirectoryName );
|
||||
char * ff_getcwd( char * pcBuffer,
|
||||
size_t xBufferLength );
|
||||
#endif
|
||||
|
||||
int ff_findfirst( const char * pcDirectory,
|
||||
FF_FindData_t * pxFindData );
|
||||
int ff_findnext( FF_FindData_t * pxFindData );
|
||||
int ff_isdirempty( const char * pcPath );
|
||||
|
||||
|
||||
/* _RB_ What to do regarding documentation for the definitions below here. */
|
||||
|
||||
#if ( ffconfig64_NUM_SUPPORT != 0 )
|
||||
int64_t ff_diskfree( const char * pcPath,
|
||||
uint32_t * pxSectorCount );
|
||||
#else
|
||||
int32_t ff_diskfree( const char * pcPath,
|
||||
uint32_t * pxSectorCount );
|
||||
#endif
|
||||
int ff_finddir( const char * pcPath );
|
||||
|
||||
#if ( ffconfigHAS_CWD == 1 )
|
||||
/* Obtain the CWD used by the current task. */
|
||||
void ff_free_CWD_space( void );
|
||||
#endif
|
||||
|
||||
typedef enum _EFileAction
|
||||
{
|
||||
eFileCreate,
|
||||
eFileRemove,
|
||||
eFileChange,
|
||||
eFileIsDir = 0x80,
|
||||
} eFileAction_t;
|
||||
|
||||
void callFileEvents( const char * apPath,
|
||||
eFileAction_t aAction );
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* FF_STDIO_H */
|
@ -0,0 +1,139 @@
|
||||
/*
|
||||
* FreeRTOS+FAT V2.3.3
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file ff_string.c
|
||||
* @ingroup STRING
|
||||
*
|
||||
* @defgroup STRING FreeRTOS+FAT String Library
|
||||
* @brief Portable String Library for FreeRTOS+FAT
|
||||
*
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef _FF_STRING_H_
|
||||
#define _FF_STRING_H_
|
||||
|
||||
#include "FreeRTOSFATConfig.h"
|
||||
#include <string.h>
|
||||
|
||||
#if ( ffconfigUNICODE_UTF16_SUPPORT != 0 )
|
||||
#include <wchar.h>
|
||||
typedef wchar_t FF_T_WCHAR; /*/< Unicode UTF-16 Character type, for FreeRTOS+FAT when UNICODE is enabled. */
|
||||
#endif
|
||||
|
||||
#if defined( _MSC_VER ) && ( _MSC_VER <= 1600 )
|
||||
#define FF_stricmp _stricmp
|
||||
#else
|
||||
#define FF_stricmp strcasecmp
|
||||
#endif
|
||||
|
||||
#if ( ffconfigUNICODE_UTF16_SUPPORT != 0 )
|
||||
void FF_tolower( FF_T_WCHAR * string,
|
||||
uint32_t strLen );
|
||||
void FF_toupper( FF_T_WCHAR * string,
|
||||
uint32_t strLen );
|
||||
BaseType_t FF_strmatch( const FF_T_WCHAR * str1,
|
||||
const FF_T_WCHAR * str2,
|
||||
BaseType_t len );
|
||||
FF_T_WCHAR * FF_strtok( const FF_T_WCHAR * string,
|
||||
FF_T_WCHAR * token,
|
||||
uint16_t * tokenNumber,
|
||||
BaseType_t * last,
|
||||
BaseType_t xLength );
|
||||
BaseType_t FF_wildcompare( const FF_T_WCHAR * pcWildCard,
|
||||
const FF_T_WCHAR * pszString );
|
||||
|
||||
/* ASCII to UTF16 and UTF16 to ASCII routines. -- These are lossy routines, and are only for converting ASCII to UTF-16 */
|
||||
/* and the equivalent back to ASCII. Do not use them for international text. */
|
||||
void FF_cstrtowcs( FF_T_WCHAR * wcsDest,
|
||||
const char * szpSource );
|
||||
void FF_wcstocstr( char * szpDest,
|
||||
const FF_T_WCHAR * wcsSource );
|
||||
void FF_cstrntowcs( FF_T_WCHAR * wcsDest,
|
||||
const char * szpSource,
|
||||
uint32_t len );
|
||||
void FF_wcsntocstr( char * szpDest,
|
||||
const FF_T_WCHAR * wcsSource,
|
||||
uint32_t len );
|
||||
#else /* if ( ffconfigUNICODE_UTF16_SUPPORT != 0 ) */
|
||||
void FF_tolower( char * string,
|
||||
uint32_t strLen );
|
||||
void FF_toupper( char * string,
|
||||
uint32_t strLen );
|
||||
BaseType_t FF_strmatch( const char * str1,
|
||||
const char * str2,
|
||||
BaseType_t len );
|
||||
char * FF_strtok( const char * string,
|
||||
char * token,
|
||||
uint16_t * tokenNumber,
|
||||
BaseType_t * last,
|
||||
BaseType_t xLength );
|
||||
BaseType_t FF_wildcompare( const char * pcWildCard,
|
||||
const char * pszString );
|
||||
#endif /* ffconfigUNICODE_UTF16_SUPPORT */
|
||||
|
||||
/* UTF8 / UTF16 Transformation Functions. */
|
||||
|
||||
#if ( ( ffconfigUNICODE_UTF16_SUPPORT != 0 ) && ( WCHAR_MAX > 0xFFFF ) ) || ( ffconfigUNICODE_UTF8_SUPPORT != 0 )
|
||||
UBaseType_t FF_GetUtf16SequenceLen( uint16_t usLeadChar );
|
||||
#endif
|
||||
|
||||
#if ( ffconfigUNICODE_UTF8_SUPPORT != 0 )
|
||||
int32_t FF_Utf8ctoUtf16c( uint16_t * utf16Dest,
|
||||
const uint8_t * utf8Source,
|
||||
uint32_t ulSize );
|
||||
int32_t FF_Utf16ctoUtf8c( uint8_t * utf8Dest,
|
||||
const uint16_t * utf16Source,
|
||||
uint32_t ulSize );
|
||||
#endif /* ffconfigUNICODE_UTF8_SUPPORT */
|
||||
|
||||
/* UTF16 / UTF32 Transformation Functions. */
|
||||
|
||||
#if ( ffconfigNOT_USED_FOR_NOW != 0 )
|
||||
int32_t FF_Utf16ctoUtf32c( uint32_t * utf32Dest,
|
||||
const uint16_t * utf16Source );
|
||||
#endif
|
||||
|
||||
#if ( ffconfigUNICODE_UTF16_SUPPORT != 0 ) && ( WCHAR_MAX > 0xFFFF )
|
||||
int32_t FF_Utf32ctoUtf16c( uint16_t * utf16Dest,
|
||||
uint32_t utf32char,
|
||||
uint32_t ulSize );
|
||||
#endif
|
||||
|
||||
/* String transformations. */
|
||||
int32_t FF_Utf32stoUtf8s( uint8_t * Utf8String,
|
||||
uint32_t * Utf32String );
|
||||
|
||||
#if ( ffconfigUNICODE_UTF16_SUPPORT != 0 )
|
||||
#define STRNCPY( target, src, maxlen ) wcsncpy( ( target ), ( src ), ( maxlen ) )
|
||||
#define STRLEN( string ) wcslen( ( string ) )
|
||||
#else
|
||||
#define STRNCPY( target, src, maxlen ) strncpy( ( target ), ( src ), ( maxlen ) );
|
||||
#define STRLEN( string ) strlen( ( string ) )
|
||||
#endif
|
||||
|
||||
#endif /* ifndef _FF_STRING_H_ */
|
133
MXC_A27-PCB4.5-270T/FreeRTOS-Plus/FreeRTOS-FAT/include/ff_sys.h
Normal file
133
MXC_A27-PCB4.5-270T/FreeRTOS-Plus/FreeRTOS-FAT/include/ff_sys.h
Normal file
@ -0,0 +1,133 @@
|
||||
/*
|
||||
* FreeRTOS+FAT V2.3.3
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* ff_sys.h
|
||||
*
|
||||
* This module allow to map several separate file-sub-systems into a root directory
|
||||
*
|
||||
* For instance, a system with 3 sub sytems:
|
||||
*
|
||||
* /flash : NAND flash driver
|
||||
* /ram : RAM-disk driver
|
||||
* / : SD-card driver
|
||||
*
|
||||
* In this example, the SD-card driver handles ALL files and directories which
|
||||
* do not match /flash/ * or /ram/ *
|
||||
*
|
||||
* Now for instance a file call "/flash/etc/network.ini"
|
||||
* will be stored as "/etc/network.ini" on the NAND drive
|
||||
*
|
||||
* This module along with ff_stdio.c make translations between absolute
|
||||
* and relative paths
|
||||
*/
|
||||
|
||||
#ifndef FF_SYS_H
|
||||
#define FF_SYS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct FILE_SUB_SYSTEM
|
||||
{
|
||||
char pcPath[ 16 ];
|
||||
BaseType_t xPathlen;
|
||||
FF_IOManager_t * pxManager;
|
||||
} FF_SubSystem_t;
|
||||
|
||||
typedef struct FF_DIR_HANDLER
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
unsigned
|
||||
bEndOfDir : 1,
|
||||
bFirstCalled : 1,
|
||||
bIsValid : 1,
|
||||
bAddDotEntries : 2;
|
||||
} bits;
|
||||
unsigned uFlags;
|
||||
} u;
|
||||
|
||||
/*
|
||||
* path will contain the relative path. It will be used when calling +FAT functions
|
||||
* like FF_FindFirst() / FF_FindNext()
|
||||
* For instance, for "/flash/etc" path will become "/etc"
|
||||
*/
|
||||
const char * pcPath;
|
||||
FF_IOManager_t * pxManager; /* Will point to handler of this partition. */
|
||||
BaseType_t xFSIndex; /* The index of this entry, where 0 always means: the root system. */
|
||||
} FF_DirHandler_t;
|
||||
|
||||
/*
|
||||
* Initialise (clear) the file system table
|
||||
* This will also called by FF_FS_Add()
|
||||
*/
|
||||
void FF_FS_Init( void );
|
||||
|
||||
/*
|
||||
* Add a file system
|
||||
* The path must be absolute, e.g. start with a slash
|
||||
* The second argument is the FF_Disk_t structure that is handling the driver
|
||||
*/
|
||||
int FF_FS_Add( const char * pcPath,
|
||||
FF_Disk_t * pxDisk );
|
||||
|
||||
/*
|
||||
* Remove a file system
|
||||
* which ws earlier added by ff_fs_ad()
|
||||
*/
|
||||
void FF_FS_Remove( const char * pcPath );
|
||||
|
||||
/*
|
||||
* Internally used by ff_stdio:
|
||||
* The ff_dir_handler helps to iterate through a mounte directory
|
||||
*
|
||||
* FF_FS_Find() will find a ff_dir_handler for a given path
|
||||
*/
|
||||
int FF_FS_Find( const char * pcPath,
|
||||
FF_DirHandler_t * pxHandler );
|
||||
|
||||
/*
|
||||
* For internal use:
|
||||
* Get the file system information, based on an index
|
||||
*/
|
||||
int FF_FS_Get( int iIndex,
|
||||
FF_SubSystem_t * pxSystem );
|
||||
|
||||
/*
|
||||
* Returns the number of registered
|
||||
* file systems
|
||||
*/
|
||||
int FF_FS_Count( void );
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* FF_SYS_H */
|
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* FreeRTOS+FAT V2.3.3
|
||||
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file ff_time.h
|
||||
* @ingroup TIME
|
||||
*
|
||||
* Provides a means for receiving the time on any platform.
|
||||
**/
|
||||
|
||||
#ifndef _FF_TIME_H_
|
||||
#define _FF_TIME_H_
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include "FreeRTOSFATConfig.h"
|
||||
|
||||
/* _HT_
|
||||
* The following declarations and functions may be moved to a common directory?
|
||||
*/
|
||||
typedef struct xTIME_STRUCT
|
||||
{
|
||||
int tm_sec; /* Seconds */
|
||||
int tm_min; /* Minutes */
|
||||
int tm_hour; /* Hour (0--23) */
|
||||
int tm_mday; /* Day of month (1--31) */
|
||||
int tm_mon; /* Month (0--11) */
|
||||
int tm_year; /* Year (calendar year minus 1900) */
|
||||
int tm_wday; /* Weekday (0--6; Sunday = 0) */
|
||||
int tm_yday; /* Day of year (0--365) */
|
||||
int tm_isdst; /* 0 if daylight savings time is not in effect) */
|
||||
} FF_TimeStruct_t;
|
||||
|
||||
/* Equivalent of time() : returns the number of seconds after 1-1-1970. */
|
||||
time_t FreeRTOS_time( time_t * pxTime );
|
||||
|
||||
/* Equivalent of mktime() : calculates the number of seconds after 1-1-1970. */
|
||||
time_t FreeRTOS_mktime( const FF_TimeStruct_t * pxTimeBuf );
|
||||
|
||||
/* Equivalent of gmtime_r() : Fills a 'struct tm'. */
|
||||
FF_TimeStruct_t * FreeRTOS_gmtime_r( const time_t * pxTime,
|
||||
FF_TimeStruct_t * pxTimeBuf );
|
||||
|
||||
/**
|
||||
* @public
|
||||
* @brief A TIME and DATE object for FreeRTOS+FAT. A FreeRTOS+FAT time driver must populate these values.
|
||||
*
|
||||
**/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t Year; /* Year (e.g. 2009). */
|
||||
uint16_t Month; /* Month (e.g. 1 = Jan, 12 = Dec). */
|
||||
uint16_t Day; /* Day (1 - 31). */
|
||||
uint16_t Hour; /* Hour (0 - 23). */
|
||||
uint16_t Minute; /* Min (0 - 59). */
|
||||
uint16_t Second; /* Second (0 - 59). */
|
||||
} FF_SystemTime_t;
|
||||
|
||||
/*---------- PROTOTYPES */
|
||||
|
||||
int32_t FF_GetSystemTime( FF_SystemTime_t * pxTime );
|
||||
|
||||
#endif /* ifndef _FF_TIME_H_ */
|
Reference in New Issue
Block a user