Merge pull request 'Pre-Release v0.5' (#54) from dev into master
Reviewed-on: #54
This commit is contained in:
commit
dd6a7bef18
@ -38,9 +38,8 @@ if (GIT_FOUND)
|
|||||||
)
|
)
|
||||||
message("${BoldGreen}Git based version number: ${GIT_DESCRIBE}${ColorReset}")
|
message("${BoldGreen}Git based version number: ${GIT_DESCRIBE}${ColorReset}")
|
||||||
else (GIT_FOUND)
|
else (GIT_FOUND)
|
||||||
set(GIT_DESCRIBE "v0.0.0-unknown")
|
|
||||||
message("${BoldRed}No git installation found. It is highly recommended using git to generate the version number")
|
message("${BoldRed}No git installation found. It is highly recommended using git to generate the version number")
|
||||||
message("Version is set to: ${GIT_DESCRIBE}${ColorReset}")
|
message(FATAL_ERROR "Git is required")
|
||||||
endif (GIT_FOUND)
|
endif (GIT_FOUND)
|
||||||
|
|
||||||
find_program(PATCHELFCRC patchelfcrc)
|
find_program(PATCHELFCRC patchelfcrc)
|
||||||
@ -60,8 +59,7 @@ add_compile_options(-Wall -Wextra -Wold-style-declaration -Wuninitialized -Wmayb
|
|||||||
add_compile_options(-mlittle-endian -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -nostartfiles -Wimplicit-fallthrough=3 -Wsign-compare)
|
add_compile_options(-mlittle-endian -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -nostartfiles -Wimplicit-fallthrough=3 -Wsign-compare)
|
||||||
|
|
||||||
|
|
||||||
set(GIT_DESCRIBE "${GIT_DESCRIBE}")
|
add_definitions(-DBASE64_LOOKUP_TABLE_SECTION=\".ccm.bss\" -DSHELLMATTA_HELP_ALIAS=\"?\" -DHSE_VALUE=8000000UL -DSTM32F407xx -DSTM32F4XX -DARM_MATH_CM4)
|
||||||
add_definitions(-DBASE64_LOOKUP_TABLE_SECTION=\".ccm.bss\" -DSHELLMATTA_HELP_ALIAS=\"?\" -DGIT_VER=${GIT_DESCRIBE} -DHSE_VALUE=8000000UL -DSTM32F407xx -DSTM32F4XX -DARM_MATH_CM4)
|
|
||||||
|
|
||||||
add_subdirectory(doxygen)
|
add_subdirectory(doxygen)
|
||||||
add_subdirectory(updater/ram-code)
|
add_subdirectory(updater/ram-code)
|
||||||
@ -101,18 +99,29 @@ aux_source_directory("shellmatta/src" SHELLMATTA_SRCS)
|
|||||||
aux_source_directory("updater" UPDATER_SRCS)
|
aux_source_directory("updater" UPDATER_SRCS)
|
||||||
aux_source_directory("temp-profile" PROFILE_SRCS)
|
aux_source_directory("temp-profile" PROFILE_SRCS)
|
||||||
|
|
||||||
|
set(GEN_VERSION_HEADER_PATH "${CMAKE_CURRENT_BINARY_DIR}/include/generated-version")
|
||||||
|
|
||||||
|
|
||||||
|
add_custom_target(
|
||||||
|
generate-version-header
|
||||||
|
COMMAND mkdir -p ${GEN_VERSION_HEADER_PATH} && bash "${CMAKE_CURRENT_SOURCE_DIR}/create_version_header.sh" "${GEN_VERSION_HEADER_PATH}/version.h"
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
COMMENT "Generating version number using git"
|
||||||
|
)
|
||||||
|
|
||||||
add_executable(${ELFFILE} ${MAIN_SOURCES} ${CFG_PARSER_SRCS} ${UI_SRCS}
|
add_executable(${ELFFILE} ${MAIN_SOURCES} ${CFG_PARSER_SRCS} ${UI_SRCS}
|
||||||
${FAT_SRCS} ${SDIO_SRCS} ${BOOT_SRCS} ${SETUP_SRCS}
|
${FAT_SRCS} ${SDIO_SRCS} ${BOOT_SRCS} ${SETUP_SRCS}
|
||||||
${STM_PERIPH_SRCS} ${SETTINGS_SRCS} ${SAFETY_SRCS}
|
${STM_PERIPH_SRCS} ${SETTINGS_SRCS} ${SAFETY_SRCS}
|
||||||
${SHELLMATTA_SRCS} ${UPDATER_SRCS} ${PROFILE_SRCS}
|
${SHELLMATTA_SRCS} ${UPDATER_SRCS} ${PROFILE_SRCS}
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(${ELFFILE} updater-ram-code-header-blob)
|
add_dependencies(${ELFFILE} updater-ram-code-header-blob generate-version-header)
|
||||||
|
|
||||||
|
|
||||||
target_include_directories(${ELFFILE} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/shellmatta/api ${CMAKE_CURRENT_SOURCE_DIR}/config-parser/include)
|
target_include_directories(${ELFFILE} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/shellmatta/api ${CMAKE_CURRENT_SOURCE_DIR}/config-parser/include)
|
||||||
target_link_options(${ELFFILE} PRIVATE -mlittle-endian -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 --disable-newlib-supplied-syscalls -nostartfiles -T${LINKER_SCRIPT} -Wl,--print-memory-usage)
|
target_link_options(${ELFFILE} PRIVATE -mlittle-endian -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 --disable-newlib-supplied-syscalls -nostartfiles -T${LINKER_SCRIPT} -Wl,--print-memory-usage)
|
||||||
target_link_libraries(${ELFFILE} base64-lib linklist-lib)
|
target_link_libraries(${ELFFILE} base64-lib linklist-lib)
|
||||||
target_include_directories(${ELFFILE} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/updater/ram-code/include/")
|
target_include_directories(${ELFFILE} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/updater/ram-code/include/" "${CMAKE_CURRENT_BINARY_DIR}/include/")
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET ${ELFFILE}
|
TARGET ${ELFFILE}
|
||||||
|
15
stm-firmware/create_version_header.sh
Executable file
15
stm-firmware/create_version_header.sh
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [[ -z $1 ]]; then
|
||||||
|
# Exit with error in case no output file is specified
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
|
||||||
|
firmware_version=`git describe --tags --always --dirty`
|
||||||
|
commit=`git rev-parse HEAD`
|
||||||
|
|
||||||
|
echo "#ifndef _VERSION_GENERATED_H_" > $1
|
||||||
|
echo "#define _VERSION_GENERATED_H_" >> $1
|
||||||
|
echo "#define GIT_VERSION_STRING \"$firmware_version\"" >> $1
|
||||||
|
echo "#define GIT_FULL_COMMIT \"$commit\"" >> $1
|
||||||
|
echo "#endif /* _VERSION_GENERATED_H_ */" >> $1
|
File diff suppressed because it is too large
Load Diff
@ -1,170 +1,208 @@
|
|||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* Sample Code of OS Dependent Functions for FatFs */
|
/* A Sample Code of User Provided OS Dependent Functions for FatFs */
|
||||||
/* (C)ChaN, 2018 */
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
#include <fatfs/ff.h>
|
#include <fatfs/ff.h>
|
||||||
|
|
||||||
|
|
||||||
#if FF_USE_LFN == 3 /* Dynamic memory allocation */
|
#if FF_USE_LFN == 3 /* Use dynamic memory allocation */
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* Allocate a memory block */
|
/* Allocate/Free a Memory Block */
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include <stdlib.h> /* with POSIX API */
|
||||||
|
|
||||||
|
|
||||||
void* ff_memalloc ( /* Returns pointer to the allocated memory block (null if not enough core) */
|
void* ff_memalloc ( /* Returns pointer to the allocated memory block (null if not enough core) */
|
||||||
UINT msize /* Number of bytes to allocate */
|
UINT msize /* Number of bytes to allocate */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return malloc(msize); /* Allocate a new memory block with POSIX API */
|
return malloc((size_t)msize); /* Allocate a new memory block */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* Free a memory block */
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
void ff_memfree (
|
void ff_memfree (
|
||||||
void* mblock /* Pointer to the memory block to free (nothing to do if null) */
|
void* mblock /* Pointer to the memory block to free (no effect if null) */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
free(mblock); /* Free the memory block with POSIX API */
|
free(mblock); /* Free the memory block */
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if FF_FS_REENTRANT /* Mutal exclusion */
|
#if FF_FS_REENTRANT /* Mutal exclusion */
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* Create a Synchronization Object */
|
/* Definitions of Mutex */
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* This function is called in f_mount() function to create a new
|
|
||||||
/ synchronization object for the volume, such as semaphore and mutex.
|
|
||||||
/ When a 0 is returned, the f_mount() function fails with FR_INT_ERR.
|
|
||||||
*/
|
|
||||||
|
|
||||||
//const osMutexDef_t Mutex[FF_VOLUMES]; /* Table of CMSIS-RTOS mutex */
|
#define OS_TYPE 0 /* 0:Win32, 1:uITRON4.0, 2:uC/OS-II, 3:FreeRTOS, 4:CMSIS-RTOS */
|
||||||
|
|
||||||
|
|
||||||
int ff_cre_syncobj ( /* 1:Function succeeded, 0:Could not create the sync object */
|
#if OS_TYPE == 0 /* Win32 */
|
||||||
BYTE vol, /* Corresponding volume (logical drive number) */
|
#include <windows.h>
|
||||||
FF_SYNC_t* sobj /* Pointer to return the created sync object */
|
static HANDLE Mutex[FF_VOLUMES + 1]; /* Table of mutex handle */
|
||||||
)
|
|
||||||
{
|
|
||||||
/* Win32 */
|
|
||||||
*sobj = CreateMutex(NULL, FALSE, NULL);
|
|
||||||
return (int)(*sobj != INVALID_HANDLE_VALUE);
|
|
||||||
|
|
||||||
/* uITRON */
|
#elif OS_TYPE == 1 /* uITRON */
|
||||||
// T_CSEM csem = {TA_TPRI,1,1};
|
#include "itron.h"
|
||||||
// *sobj = acre_sem(&csem);
|
#include "kernel.h"
|
||||||
// return (int)(*sobj > 0);
|
static mtxid Mutex[FF_VOLUMES + 1]; /* Table of mutex ID */
|
||||||
|
|
||||||
/* uC/OS-II */
|
#elif OS_TYPE == 2 /* uc/OS-II */
|
||||||
// OS_ERR err;
|
#include "includes.h"
|
||||||
// *sobj = OSMutexCreate(0, &err);
|
static OS_EVENT *Mutex[FF_VOLUMES + 1]; /* Table of mutex pinter */
|
||||||
// return (int)(err == OS_NO_ERR);
|
|
||||||
|
|
||||||
/* FreeRTOS */
|
#elif OS_TYPE == 3 /* FreeRTOS */
|
||||||
// *sobj = xSemaphoreCreateMutex();
|
#include "FreeRTOS.h"
|
||||||
// return (int)(*sobj != NULL);
|
#include "semphr.h"
|
||||||
|
static SemaphoreHandle_t Mutex[FF_VOLUMES + 1]; /* Table of mutex handle */
|
||||||
|
|
||||||
/* CMSIS-RTOS */
|
#elif OS_TYPE == 4 /* CMSIS-RTOS */
|
||||||
// *sobj = osMutexCreate(&Mutex[vol]);
|
#include "cmsis_os.h"
|
||||||
// return (int)(*sobj != NULL);
|
static osMutexId Mutex[FF_VOLUMES + 1]; /* Table of mutex ID */
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* Delete a Synchronization Object */
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* This function is called in f_mount() function to delete a synchronization
|
|
||||||
/ object that created with ff_cre_syncobj() function. When a 0 is returned,
|
|
||||||
/ the f_mount() function fails with FR_INT_ERR.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ff_del_syncobj ( /* 1:Function succeeded, 0:Could not delete due to an error */
|
|
||||||
FF_SYNC_t sobj /* Sync object tied to the logical drive to be deleted */
|
|
||||||
)
|
|
||||||
{
|
|
||||||
/* Win32 */
|
|
||||||
return (int)CloseHandle(sobj);
|
|
||||||
|
|
||||||
/* uITRON */
|
|
||||||
// return (int)(del_sem(sobj) == E_OK);
|
|
||||||
|
|
||||||
/* uC/OS-II */
|
|
||||||
// OS_ERR err;
|
|
||||||
// OSMutexDel(sobj, OS_DEL_ALWAYS, &err);
|
|
||||||
// return (int)(err == OS_NO_ERR);
|
|
||||||
|
|
||||||
/* FreeRTOS */
|
|
||||||
// vSemaphoreDelete(sobj);
|
|
||||||
// return 1;
|
|
||||||
|
|
||||||
/* CMSIS-RTOS */
|
|
||||||
// return (int)(osMutexDelete(sobj) == osOK);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* Request Grant to Access the Volume */
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* This function is called on entering file functions to lock the volume.
|
|
||||||
/ When a 0 is returned, the file function fails with FR_TIMEOUT.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ff_req_grant ( /* 1:Got a grant to access the volume, 0:Could not get a grant */
|
|
||||||
FF_SYNC_t sobj /* Sync object to wait */
|
|
||||||
)
|
|
||||||
{
|
|
||||||
/* Win32 */
|
|
||||||
return (int)(WaitForSingleObject(sobj, FF_FS_TIMEOUT) == WAIT_OBJECT_0);
|
|
||||||
|
|
||||||
/* uITRON */
|
|
||||||
// return (int)(wai_sem(sobj) == E_OK);
|
|
||||||
|
|
||||||
/* uC/OS-II */
|
|
||||||
// OS_ERR err;
|
|
||||||
// OSMutexPend(sobj, FF_FS_TIMEOUT, &err));
|
|
||||||
// return (int)(err == OS_NO_ERR);
|
|
||||||
|
|
||||||
/* FreeRTOS */
|
|
||||||
// return (int)(xSemaphoreTake(sobj, FF_FS_TIMEOUT) == pdTRUE);
|
|
||||||
|
|
||||||
/* CMSIS-RTOS */
|
|
||||||
// return (int)(osMutexWait(sobj, FF_FS_TIMEOUT) == osOK);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* Release Grant to Access the Volume */
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* This function is called on leaving file functions to unlock the volume.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void ff_rel_grant (
|
|
||||||
FF_SYNC_t sobj /* Sync object to be signaled */
|
|
||||||
)
|
|
||||||
{
|
|
||||||
/* Win32 */
|
|
||||||
ReleaseMutex(sobj);
|
|
||||||
|
|
||||||
/* uITRON */
|
|
||||||
// sig_sem(sobj);
|
|
||||||
|
|
||||||
/* uC/OS-II */
|
|
||||||
// OSMutexPost(sobj);
|
|
||||||
|
|
||||||
/* FreeRTOS */
|
|
||||||
// xSemaphoreGive(sobj);
|
|
||||||
|
|
||||||
/* CMSIS-RTOS */
|
|
||||||
// osMutexRelease(sobj);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* Create a Mutex */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* This function is called in f_mount function to create a new mutex
|
||||||
|
/ or semaphore for the volume. When a 0 is returned, the f_mount function
|
||||||
|
/ fails with FR_INT_ERR.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int ff_mutex_create ( /* Returns 1:Function succeeded or 0:Could not create the mutex */
|
||||||
|
int vol /* Mutex ID: Volume mutex (0 to FF_VOLUMES - 1) or system mutex (FF_VOLUMES) */
|
||||||
|
)
|
||||||
|
{
|
||||||
|
#if OS_TYPE == 0 /* Win32 */
|
||||||
|
Mutex[vol] = CreateMutex(NULL, FALSE, NULL);
|
||||||
|
return (int)(Mutex[vol] != INVALID_HANDLE_VALUE);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 1 /* uITRON */
|
||||||
|
T_CMTX cmtx = {TA_TPRI,1};
|
||||||
|
|
||||||
|
Mutex[vol] = acre_mtx(&cmtx);
|
||||||
|
return (int)(Mutex[vol] > 0);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 2 /* uC/OS-II */
|
||||||
|
OS_ERR err;
|
||||||
|
|
||||||
|
Mutex[vol] = OSMutexCreate(0, &err);
|
||||||
|
return (int)(err == OS_NO_ERR);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 3 /* FreeRTOS */
|
||||||
|
Mutex[vol] = xSemaphoreCreateMutex();
|
||||||
|
return (int)(Mutex[vol] != NULL);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 4 /* CMSIS-RTOS */
|
||||||
|
osMutexDef(cmsis_os_mutex);
|
||||||
|
|
||||||
|
Mutex[vol] = osMutexCreate(osMutex(cmsis_os_mutex));
|
||||||
|
return (int)(Mutex[vol] != NULL);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* Delete a Mutex */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* This function is called in f_mount function to delete a mutex or
|
||||||
|
/ semaphore of the volume created with ff_mutex_create function.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void ff_mutex_delete ( /* Returns 1:Function succeeded or 0:Could not delete due to an error */
|
||||||
|
int vol /* Mutex ID: Volume mutex (0 to FF_VOLUMES - 1) or system mutex (FF_VOLUMES) */
|
||||||
|
)
|
||||||
|
{
|
||||||
|
#if OS_TYPE == 0 /* Win32 */
|
||||||
|
CloseHandle(Mutex[vol]);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 1 /* uITRON */
|
||||||
|
del_mtx(Mutex[vol]);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 2 /* uC/OS-II */
|
||||||
|
OS_ERR err;
|
||||||
|
|
||||||
|
OSMutexDel(Mutex[vol], OS_DEL_ALWAYS, &err);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 3 /* FreeRTOS */
|
||||||
|
vSemaphoreDelete(Mutex[vol]);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 4 /* CMSIS-RTOS */
|
||||||
|
osMutexDelete(Mutex[vol]);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* Request a Grant to Access the Volume */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* This function is called on enter file functions to lock the volume.
|
||||||
|
/ When a 0 is returned, the file function fails with FR_TIMEOUT.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int ff_mutex_take ( /* Returns 1:Succeeded or 0:Timeout */
|
||||||
|
int vol /* Mutex ID: Volume mutex (0 to FF_VOLUMES - 1) or system mutex (FF_VOLUMES) */
|
||||||
|
)
|
||||||
|
{
|
||||||
|
#if OS_TYPE == 0 /* Win32 */
|
||||||
|
return (int)(WaitForSingleObject(Mutex[vol], FF_FS_TIMEOUT) == WAIT_OBJECT_0);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 1 /* uITRON */
|
||||||
|
return (int)(tloc_mtx(Mutex[vol], FF_FS_TIMEOUT) == E_OK);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 2 /* uC/OS-II */
|
||||||
|
OS_ERR err;
|
||||||
|
|
||||||
|
OSMutexPend(Mutex[vol], FF_FS_TIMEOUT, &err));
|
||||||
|
return (int)(err == OS_NO_ERR);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 3 /* FreeRTOS */
|
||||||
|
return (int)(xSemaphoreTake(Mutex[vol], FF_FS_TIMEOUT) == pdTRUE);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 4 /* CMSIS-RTOS */
|
||||||
|
return (int)(osMutexWait(Mutex[vol], FF_FS_TIMEOUT) == osOK);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* Release a Grant to Access the Volume */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* This function is called on leave file functions to unlock the volume.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void ff_mutex_give (
|
||||||
|
int vol /* Mutex ID: Volume mutex (0 to FF_VOLUMES - 1) or system mutex (FF_VOLUMES) */
|
||||||
|
)
|
||||||
|
{
|
||||||
|
#if OS_TYPE == 0 /* Win32 */
|
||||||
|
ReleaseMutex(Mutex[vol]);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 1 /* uITRON */
|
||||||
|
unl_mtx(Mutex[vol]);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 2 /* uC/OS-II */
|
||||||
|
OSMutexPost(Mutex[vol]);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 3 /* FreeRTOS */
|
||||||
|
xSemaphoreGive(Mutex[vol]);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 4 /* CMSIS-RTOS */
|
||||||
|
osMutexRelease(Mutex[vol]);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* FF_FS_REENTRANT */
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* Unicode handling functions for FatFs R0.13+ */
|
/* Unicode Handling Functions for FatFs R0.13 and Later */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* This module will occupy a huge memory in the .rodata section when the */
|
||||||
|
/* FatFs is configured for LFN with DBCS. If the system has a Unicode */
|
||||||
|
/* library for the code conversion, this module should be modified to use */
|
||||||
|
/* it to avoid silly memory consumption. */
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* This module will occupy a huge memory in the .const section when the /
|
|
||||||
/ FatFs is configured for LFN with DBCS. If the system has any Unicode /
|
|
||||||
/ utilitiy for the code conversion, this module should be modified to use /
|
|
||||||
/ that function to avoid silly memory consumption. /
|
|
||||||
/-------------------------------------------------------------------------*/
|
|
||||||
/*
|
/*
|
||||||
/ Copyright (C) 2014, ChaN, all right reserved.
|
/ Copyright (C) 2022, ChaN, all right reserved.
|
||||||
/
|
/
|
||||||
/ FatFs module is an open source software. Redistribution and use of FatFs in
|
/ FatFs module is an open source software. Redistribution and use of FatFs in
|
||||||
/ source and binary forms, with or without modification, are permitted provided
|
/ source and binary forms, with or without modification, are permitted provided
|
||||||
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include <fatfs/ff.h>
|
#include <fatfs/ff.h>
|
||||||
|
|
||||||
#if FF_USE_LFN /* This module will be blanked if non-LFN configuration */
|
#if FF_USE_LFN != 0 /* This module will be blanked if in non-LFN configuration */
|
||||||
|
|
||||||
#define MERGE2(a, b) a ## b
|
#define MERGE2(a, b) a ## b
|
||||||
#define CVTBL(tbl, cp) MERGE2(tbl, cp)
|
#define CVTBL(tbl, cp) MERGE2(tbl, cp)
|
||||||
@ -15214,8 +15214,8 @@ static const WCHAR uc869[] = { /* CP869(Greek 2) to Unicode conversion table */
|
|||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* OEM <==> Unicode conversions for static code page configuration */
|
/* OEM <==> Unicode Conversions for Static Code Page Configuration with */
|
||||||
/* SBCS fixed code page */
|
/* SBCS Fixed Code Page */
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#if FF_CODE_PAGE != 0 && FF_CODE_PAGE < 900
|
#if FF_CODE_PAGE != 0 && FF_CODE_PAGE < 900
|
||||||
@ -15225,7 +15225,7 @@ WCHAR ff_uni2oem ( /* Returns OEM code character, zero on error */
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
WCHAR c = 0;
|
WCHAR c = 0;
|
||||||
const WCHAR *p = CVTBL(uc, FF_CODE_PAGE);
|
const WCHAR* p = CVTBL(uc, FF_CODE_PAGE);
|
||||||
|
|
||||||
|
|
||||||
if (uni < 0x80) { /* ASCII? */
|
if (uni < 0x80) { /* ASCII? */
|
||||||
@ -15247,7 +15247,7 @@ WCHAR ff_oem2uni ( /* Returns Unicode character in UTF-16, zero on error */
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
WCHAR c = 0;
|
WCHAR c = 0;
|
||||||
const WCHAR *p = CVTBL(uc, FF_CODE_PAGE);
|
const WCHAR* p = CVTBL(uc, FF_CODE_PAGE);
|
||||||
|
|
||||||
|
|
||||||
if (oem < 0x80) { /* ASCII? */
|
if (oem < 0x80) { /* ASCII? */
|
||||||
@ -15267,8 +15267,8 @@ WCHAR ff_oem2uni ( /* Returns Unicode character in UTF-16, zero on error */
|
|||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* OEM <==> Unicode conversions for static code page configuration */
|
/* OEM <==> Unicode Conversions for Static Code Page Configuration with */
|
||||||
/* DBCS fixed code page */
|
/* DBCS Fixed Code Page */
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#if FF_CODE_PAGE >= 900
|
#if FF_CODE_PAGE >= 900
|
||||||
@ -15277,7 +15277,7 @@ WCHAR ff_uni2oem ( /* Returns OEM code character, zero on error */
|
|||||||
WORD cp /* Code page for the conversion */
|
WORD cp /* Code page for the conversion */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const WCHAR *p;
|
const WCHAR* p;
|
||||||
WCHAR c = 0, uc;
|
WCHAR c = 0, uc;
|
||||||
UINT i = 0, n, li, hi;
|
UINT i = 0, n, li, hi;
|
||||||
|
|
||||||
@ -15313,7 +15313,7 @@ WCHAR ff_oem2uni ( /* Returns Unicode character in UTF-16, zero on error */
|
|||||||
WORD cp /* Code page for the conversion */
|
WORD cp /* Code page for the conversion */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const WCHAR *p;
|
const WCHAR* p;
|
||||||
WCHAR c = 0;
|
WCHAR c = 0;
|
||||||
UINT i = 0, n, li, hi;
|
UINT i = 0, n, li, hi;
|
||||||
|
|
||||||
@ -15346,7 +15346,7 @@ WCHAR ff_oem2uni ( /* Returns Unicode character in UTF-16, zero on error */
|
|||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* OEM <==> Unicode conversions for dynamic code page configuration */
|
/* OEM <==> Unicode Conversions for Dynamic Code Page Configuration */
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#if FF_CODE_PAGE == 0
|
#if FF_CODE_PAGE == 0
|
||||||
@ -15360,7 +15360,7 @@ WCHAR ff_uni2oem ( /* Returns OEM code character, zero on error */
|
|||||||
WORD cp /* Code page for the conversion */
|
WORD cp /* Code page for the conversion */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const WCHAR *p;
|
const WCHAR* p;
|
||||||
WCHAR c = 0, uc;
|
WCHAR c = 0, uc;
|
||||||
UINT i, n, li, hi;
|
UINT i, n, li, hi;
|
||||||
|
|
||||||
@ -15412,7 +15412,7 @@ WCHAR ff_oem2uni ( /* Returns Unicode character in UTF-16, zero on error */
|
|||||||
WORD cp /* Code page for the conversion */
|
WORD cp /* Code page for the conversion */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const WCHAR *p;
|
const WCHAR* p;
|
||||||
WCHAR c = 0;
|
WCHAR c = 0;
|
||||||
UINT i, n, li, hi;
|
UINT i, n, li, hi;
|
||||||
|
|
||||||
@ -15458,14 +15458,14 @@ WCHAR ff_oem2uni ( /* Returns Unicode character in UTF-16, zero on error */
|
|||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* Unicode up-case conversion */
|
/* Unicode Up-case Conversion */
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
DWORD ff_wtoupper ( /* Returns up-converted code point */
|
DWORD ff_wtoupper ( /* Returns up-converted code point */
|
||||||
DWORD uni /* Unicode code point to be up-converted */
|
DWORD uni /* Unicode code point to be up-converted */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const WORD *p;
|
const WORD* p;
|
||||||
WORD uc, bc, nc, cmd;
|
WORD uc, bc, nc, cmd;
|
||||||
static const WORD cvt1[] = { /* Compressed up conversion table for U+0000 - U+0FFF */
|
static const WORD cvt1[] = { /* Compressed up conversion table for U+0000 - U+0FFF */
|
||||||
/* Basic Latin */
|
/* Basic Latin */
|
||||||
@ -15590,4 +15590,4 @@ DWORD ff_wtoupper ( /* Returns up-converted code point */
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* #if FF_USE_LFN */
|
#endif /* #if FF_USE_LFN != 0 */
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/*----------------------------------------------------------------------------/
|
/*----------------------------------------------------------------------------/
|
||||||
/ FatFs - Generic FAT Filesystem module R0.14b /
|
/ FatFs - Generic FAT Filesystem module R0.15 /
|
||||||
/-----------------------------------------------------------------------------/
|
/-----------------------------------------------------------------------------/
|
||||||
/
|
/
|
||||||
/ Copyright (C) 2021, ChaN, all right reserved.
|
/ Copyright (C) 2022, ChaN, all right reserved.
|
||||||
/
|
/
|
||||||
/ FatFs module is an open source software. Redistribution and use of FatFs in
|
/ FatFs module is an open source software. Redistribution and use of FatFs in
|
||||||
/ source and binary forms, with or without modification, are permitted provided
|
/ source and binary forms, with or without modification, are permitted provided
|
||||||
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef FF_DEFINED
|
#ifndef FF_DEFINED
|
||||||
#define FF_DEFINED 86631 /* Revision ID */
|
#define FF_DEFINED 80286 /* Revision ID */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -131,10 +131,11 @@ extern const char* VolumeStr[FF_VOLUMES]; /* User defied volume ID */
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
BYTE fs_type; /* Filesystem type (0:not mounted) */
|
BYTE fs_type; /* Filesystem type (0:not mounted) */
|
||||||
BYTE pdrv; /* Associated physical drive */
|
BYTE pdrv; /* Volume hosting physical drive */
|
||||||
|
BYTE ldrv; /* Logical drive number (used only when FF_FS_REENTRANT) */
|
||||||
BYTE n_fats; /* Number of FATs (1 or 2) */
|
BYTE n_fats; /* Number of FATs (1 or 2) */
|
||||||
BYTE wflag; /* win[] flag (b0:dirty) */
|
BYTE wflag; /* win[] status (b0:dirty) */
|
||||||
BYTE fsi_flag; /* FSINFO flags (b7:disabled, b0:dirty) */
|
BYTE fsi_flag; /* FSINFO status (b7:disabled, b0:dirty) */
|
||||||
WORD id; /* Volume mount ID */
|
WORD id; /* Volume mount ID */
|
||||||
WORD n_rootdir; /* Number of root directory entries (FAT12/16) */
|
WORD n_rootdir; /* Number of root directory entries (FAT12/16) */
|
||||||
WORD csize; /* Cluster size [sectors] */
|
WORD csize; /* Cluster size [sectors] */
|
||||||
@ -147,9 +148,6 @@ typedef struct {
|
|||||||
#if FF_FS_EXFAT
|
#if FF_FS_EXFAT
|
||||||
BYTE* dirbuf; /* Directory entry block scratchpad buffer for exFAT */
|
BYTE* dirbuf; /* Directory entry block scratchpad buffer for exFAT */
|
||||||
#endif
|
#endif
|
||||||
#if FF_FS_REENTRANT
|
|
||||||
FF_SYNC_t sobj; /* Identifier of sync object */
|
|
||||||
#endif
|
|
||||||
#if !FF_FS_READONLY
|
#if !FF_FS_READONLY
|
||||||
DWORD last_clst; /* Last allocated cluster */
|
DWORD last_clst; /* Last allocated cluster */
|
||||||
DWORD free_clst; /* Number of free clusters */
|
DWORD free_clst; /* Number of free clusters */
|
||||||
@ -163,10 +161,10 @@ typedef struct {
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
DWORD n_fatent; /* Number of FAT entries (number of clusters + 2) */
|
DWORD n_fatent; /* Number of FAT entries (number of clusters + 2) */
|
||||||
DWORD fsize; /* Size of an FAT [sectors] */
|
DWORD fsize; /* Number of sectors per FAT */
|
||||||
LBA_t volbase; /* Volume base sector */
|
LBA_t volbase; /* Volume base sector */
|
||||||
LBA_t fatbase; /* FAT base sector */
|
LBA_t fatbase; /* FAT base sector */
|
||||||
LBA_t dirbase; /* Root directory base sector/cluster */
|
LBA_t dirbase; /* Root directory base sector (FAT12/16) or cluster (FAT32/exFAT) */
|
||||||
LBA_t database; /* Data base sector */
|
LBA_t database; /* Data base sector */
|
||||||
#if FF_FS_EXFAT
|
#if FF_FS_EXFAT
|
||||||
LBA_t bitbase; /* Allocation bitmap base sector */
|
LBA_t bitbase; /* Allocation bitmap base sector */
|
||||||
@ -181,7 +179,7 @@ typedef struct {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
FATFS* fs; /* Pointer to the hosting volume of this object */
|
FATFS* fs; /* Pointer to the hosting volume of this object */
|
||||||
WORD id; /* Hosting volume mount ID */
|
WORD id; /* Hosting volume's mount ID */
|
||||||
BYTE attr; /* Object attribute */
|
BYTE attr; /* Object attribute */
|
||||||
BYTE stat; /* Object chain status (b1-0: =0:not contiguous, =2:contiguous, =3:fragmented in this session, b2:sub-directory stretched) */
|
BYTE stat; /* Object chain status (b1-0: =0:not contiguous, =2:contiguous, =3:fragmented in this session, b2:sub-directory stretched) */
|
||||||
DWORD sclust; /* Object data start cluster (0:no cluster or root directory) */
|
DWORD sclust; /* Object data start cluster (0:no cluster or root directory) */
|
||||||
@ -250,7 +248,7 @@ typedef struct {
|
|||||||
WORD ftime; /* Modified time */
|
WORD ftime; /* Modified time */
|
||||||
BYTE fattrib; /* File attribute */
|
BYTE fattrib; /* File attribute */
|
||||||
#if FF_USE_LFN
|
#if FF_USE_LFN
|
||||||
TCHAR altname[FF_SFN_BUF + 1];/* Altenative file name */
|
TCHAR altname[FF_SFN_BUF + 1];/* Alternative file name */
|
||||||
TCHAR fname[FF_LFN_BUF + 1]; /* Primary file name */
|
TCHAR fname[FF_LFN_BUF + 1]; /* Primary file name */
|
||||||
#else
|
#else
|
||||||
TCHAR fname[12 + 1]; /* File name */
|
TCHAR fname[12 + 1]; /* File name */
|
||||||
@ -298,8 +296,10 @@ typedef enum {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------*/
|
||||||
|
/* FatFs Module Application Interface */
|
||||||
/*--------------------------------------------------------------*/
|
/*--------------------------------------------------------------*/
|
||||||
/* FatFs module application interface */
|
|
||||||
|
|
||||||
FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */
|
FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */
|
||||||
FRESULT f_close (FIL* fp); /* Close an open file object */
|
FRESULT f_close (FIL* fp); /* Close an open file object */
|
||||||
@ -336,6 +336,8 @@ int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */
|
|||||||
int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */
|
int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */
|
||||||
TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */
|
TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */
|
||||||
|
|
||||||
|
/* Some API fucntions are implemented as macro */
|
||||||
|
|
||||||
#define f_eof(fp) ((int)((fp)->fptr == (fp)->obj.objsize))
|
#define f_eof(fp) ((int)((fp)->fptr == (fp)->obj.objsize))
|
||||||
#define f_error(fp) ((fp)->err)
|
#define f_error(fp) ((fp)->err)
|
||||||
#define f_tell(fp) ((fp)->fptr)
|
#define f_tell(fp) ((fp)->fptr)
|
||||||
@ -349,38 +351,43 @@ TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the fil
|
|||||||
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------*/
|
/*--------------------------------------------------------------*/
|
||||||
/* Additional user defined functions */
|
/* Additional Functions */
|
||||||
|
/*--------------------------------------------------------------*/
|
||||||
|
|
||||||
/* RTC function */
|
/* RTC function (provided by user) */
|
||||||
#if !FF_FS_READONLY && !FF_FS_NORTC
|
#if !FF_FS_READONLY && !FF_FS_NORTC
|
||||||
DWORD get_fattime (void);
|
DWORD get_fattime (void); /* Get current time */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* LFN support functions */
|
|
||||||
#if FF_USE_LFN >= 1 /* Code conversion (defined in unicode.c) */
|
/* LFN support functions (defined in ffunicode.c) */
|
||||||
|
|
||||||
|
#if FF_USE_LFN >= 1
|
||||||
WCHAR ff_oem2uni (WCHAR oem, WORD cp); /* OEM code to Unicode conversion */
|
WCHAR ff_oem2uni (WCHAR oem, WORD cp); /* OEM code to Unicode conversion */
|
||||||
WCHAR ff_uni2oem (DWORD uni, WORD cp); /* Unicode to OEM code conversion */
|
WCHAR ff_uni2oem (DWORD uni, WORD cp); /* Unicode to OEM code conversion */
|
||||||
DWORD ff_wtoupper (DWORD uni); /* Unicode upper-case conversion */
|
DWORD ff_wtoupper (DWORD uni); /* Unicode upper-case conversion */
|
||||||
#endif
|
#endif
|
||||||
#if FF_USE_LFN == 3 /* Dynamic memory allocation */
|
|
||||||
void* ff_memalloc (UINT msize); /* Allocate memory block */
|
|
||||||
void ff_memfree (void* mblock); /* Free memory block */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Sync functions */
|
|
||||||
#if FF_FS_REENTRANT
|
/* O/S dependent functions (samples available in ffsystem.c) */
|
||||||
int ff_cre_syncobj (BYTE vol, FF_SYNC_t* sobj); /* Create a sync object */
|
|
||||||
int ff_req_grant (FF_SYNC_t sobj); /* Lock sync object */
|
#if FF_USE_LFN == 3 /* Dynamic memory allocation */
|
||||||
void ff_rel_grant (FF_SYNC_t sobj); /* Unlock sync object */
|
void* ff_memalloc (UINT msize); /* Allocate memory block */
|
||||||
int ff_del_syncobj (FF_SYNC_t sobj); /* Delete a sync object */
|
void ff_memfree (void* mblock); /* Free memory block */
|
||||||
|
#endif
|
||||||
|
#if FF_FS_REENTRANT /* Sync functions */
|
||||||
|
int ff_mutex_create (int vol); /* Create a sync object */
|
||||||
|
void ff_mutex_delete (int vol); /* Delete a sync object */
|
||||||
|
int ff_mutex_take (int vol); /* Lock sync object */
|
||||||
|
void ff_mutex_give (int vol); /* Unlock sync object */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------*/
|
/*--------------------------------------------------------------*/
|
||||||
/* Flags and offset address */
|
/* Flags and Offset Address */
|
||||||
|
/*--------------------------------------------------------------*/
|
||||||
|
|
||||||
/* File access mode and open method flags (3rd argument of f_open) */
|
/* File access mode and open method flags (3rd argument of f_open) */
|
||||||
#define FA_READ 0x01
|
#define FA_READ 0x01
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/*---------------------------------------------------------------------------/
|
/*---------------------------------------------------------------------------/
|
||||||
/ FatFs Functional Configurations
|
/ Configurations of FatFs Module
|
||||||
/---------------------------------------------------------------------------*/
|
/---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#define FFCONF_DEF 86631 /* Revision ID */
|
#define FFCONF_DEF 80286 /* Revision ID */
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------/
|
/*---------------------------------------------------------------------------/
|
||||||
/ Function Configurations
|
/ Function Configurations
|
||||||
@ -68,7 +68,7 @@
|
|||||||
/ 2: Enable with LF-CRLF conversion.
|
/ 2: Enable with LF-CRLF conversion.
|
||||||
/
|
/
|
||||||
/ FF_PRINT_LLI = 1 makes f_printf() support long long argument and FF_PRINT_FLOAT = 1/2
|
/ FF_PRINT_LLI = 1 makes f_printf() support long long argument and FF_PRINT_FLOAT = 1/2
|
||||||
makes f_printf() support floating point argument. These features want C99 or later.
|
/ makes f_printf() support floating point argument. These features want C99 or later.
|
||||||
/ When FF_LFN_UNICODE >= 1 with LFN enabled, string functions convert the character
|
/ When FF_LFN_UNICODE >= 1 with LFN enabled, string functions convert the character
|
||||||
/ encoding in it. FF_STRF_ENCODE selects assumption of character encoding ON THE FILE
|
/ encoding in it. FF_STRF_ENCODE selects assumption of character encoding ON THE FILE
|
||||||
/ to be read/written via those functions.
|
/ to be read/written via those functions.
|
||||||
@ -178,7 +178,7 @@
|
|||||||
/ logical drives. Number of items must not be less than FF_VOLUMES. Valid
|
/ logical drives. Number of items must not be less than FF_VOLUMES. Valid
|
||||||
/ characters for the volume ID strings are A-Z, a-z and 0-9, however, they are
|
/ characters for the volume ID strings are A-Z, a-z and 0-9, however, they are
|
||||||
/ compared in case-insensitive. If FF_STR_VOLUME_ID >= 1 and FF_VOLUME_STRS is
|
/ compared in case-insensitive. If FF_STR_VOLUME_ID >= 1 and FF_VOLUME_STRS is
|
||||||
/ not defined, a user defined volume string table needs to be defined as:
|
/ not defined, a user defined volume string table is needed as:
|
||||||
/
|
/
|
||||||
/ const char* VolumeStr[FF_VOLUMES] = {"ram","flash","sd","usb",...
|
/ const char* VolumeStr[FF_VOLUMES] = {"ram","flash","sd","usb",...
|
||||||
*/
|
*/
|
||||||
@ -190,7 +190,7 @@
|
|||||||
/ number and only an FAT volume found on the physical drive will be mounted.
|
/ number and only an FAT volume found on the physical drive will be mounted.
|
||||||
/ When this function is enabled (1), each logical drive number can be bound to
|
/ When this function is enabled (1), each logical drive number can be bound to
|
||||||
/ arbitrary physical drive and partition listed in the VolToPart[]. Also f_fdisk()
|
/ arbitrary physical drive and partition listed in the VolToPart[]. Also f_fdisk()
|
||||||
/ funciton will be available. */
|
/ function will be available. */
|
||||||
|
|
||||||
|
|
||||||
#define FF_MIN_SS 512
|
#define FF_MIN_SS 512
|
||||||
@ -240,10 +240,10 @@
|
|||||||
#define FF_FS_NORTC 0
|
#define FF_FS_NORTC 0
|
||||||
#define FF_NORTC_MON 1
|
#define FF_NORTC_MON 1
|
||||||
#define FF_NORTC_MDAY 1
|
#define FF_NORTC_MDAY 1
|
||||||
#define FF_NORTC_YEAR 2020
|
#define FF_NORTC_YEAR 2022
|
||||||
/* The option FF_FS_NORTC switches timestamp functiton. If the system does not have
|
/* The option FF_FS_NORTC switches timestamp feature. If the system does not have
|
||||||
/ any RTC function or valid timestamp is not needed, set FF_FS_NORTC = 1 to disable
|
/ an RTC or valid timestamp is not needed, set FF_FS_NORTC = 1 to disable the
|
||||||
/ the timestamp function. Every object modified by FatFs will have a fixed timestamp
|
/ timestamp feature. Every object modified by FatFs will have a fixed timestamp
|
||||||
/ defined by FF_NORTC_MON, FF_NORTC_MDAY and FF_NORTC_YEAR in local time.
|
/ defined by FF_NORTC_MON, FF_NORTC_MDAY and FF_NORTC_YEAR in local time.
|
||||||
/ To enable timestamp function (FF_FS_NORTC = 0), get_fattime() function need to be
|
/ To enable timestamp function (FF_FS_NORTC = 0), get_fattime() function need to be
|
||||||
/ added to the project to read current time form real-time clock. FF_NORTC_MON,
|
/ added to the project to read current time form real-time clock. FF_NORTC_MON,
|
||||||
@ -253,7 +253,7 @@
|
|||||||
|
|
||||||
#define FF_FS_NOFSINFO 0
|
#define FF_FS_NOFSINFO 0
|
||||||
/* If you need to know correct free space on the FAT32 volume, set bit 0 of this
|
/* If you need to know correct free space on the FAT32 volume, set bit 0 of this
|
||||||
/ option, and f_getfree() function at first time after volume mount will force
|
/ option, and f_getfree() function at the first time after volume mount will force
|
||||||
/ a full FAT scan. Bit 1 controls the use of last allocated cluster number.
|
/ a full FAT scan. Bit 1 controls the use of last allocated cluster number.
|
||||||
/
|
/
|
||||||
/ bit0=0: Use free cluster count in the FSINFO if available.
|
/ bit0=0: Use free cluster count in the FSINFO if available.
|
||||||
@ -275,26 +275,21 @@
|
|||||||
/ lock control is independent of re-entrancy. */
|
/ lock control is independent of re-entrancy. */
|
||||||
|
|
||||||
|
|
||||||
/* #include <somertos.h> // O/S definitions */
|
|
||||||
#define FF_FS_REENTRANT 0
|
#define FF_FS_REENTRANT 0
|
||||||
#define FF_FS_TIMEOUT 1000
|
#define FF_FS_TIMEOUT 1000
|
||||||
#define FF_SYNC_t HANDLE
|
|
||||||
/* The option FF_FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs
|
/* The option FF_FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs
|
||||||
/ module itself. Note that regardless of this option, file access to different
|
/ module itself. Note that regardless of this option, file access to different
|
||||||
/ volume is always re-entrant and volume control functions, f_mount(), f_mkfs()
|
/ volume is always re-entrant and volume control functions, f_mount(), f_mkfs()
|
||||||
/ and f_fdisk() function, are always not re-entrant. Only file/directory access
|
/ and f_fdisk() function, are always not re-entrant. Only file/directory access
|
||||||
/ to the same volume is under control of this function.
|
/ to the same volume is under control of this featuer.
|
||||||
/
|
/
|
||||||
/ 0: Disable re-entrancy. FF_FS_TIMEOUT and FF_SYNC_t have no effect.
|
/ 0: Disable re-entrancy. FF_FS_TIMEOUT have no effect.
|
||||||
/ 1: Enable re-entrancy. Also user provided synchronization handlers,
|
/ 1: Enable re-entrancy. Also user provided synchronization handlers,
|
||||||
/ ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj()
|
/ ff_mutex_create(), ff_mutex_delete(), ff_mutex_take() and ff_mutex_give()
|
||||||
/ function, must be added to the project. Samples are available in
|
/ function, must be added to the project. Samples are available in ffsystem.c.
|
||||||
/ option/syscall.c.
|
|
||||||
/
|
/
|
||||||
/ The FF_FS_TIMEOUT defines timeout period in unit of time tick.
|
/ The FF_FS_TIMEOUT defines timeout period in unit of O/S time tick.
|
||||||
/ The FF_SYNC_t defines O/S dependent sync object type. e.g. HANDLE, ID, OS_EVENT*,
|
*/
|
||||||
/ SemaphoreHandle_t and etc. A header file for O/S definitions needs to be
|
|
||||||
/ included somewhere in the scope of ff.h. */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,10 +30,16 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initialize/Reset the main cycle counter to 0.
|
* @brief Initialize the main cycle counter and reset to 0. This also enables the core cycle counter
|
||||||
* This function can be called multiple times.
|
* This function can be called multiple times.
|
||||||
*/
|
*/
|
||||||
void main_cycle_counter_init(void);
|
void main_and_core_cycle_counter_init(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reset the main cycle counter.
|
||||||
|
* @note This does not reset the core cycle counter
|
||||||
|
*/
|
||||||
|
void main_cycle_counter_reset(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Increment the main cycle counter by 1
|
* @brief Increment the main cycle counter by 1
|
||||||
@ -46,6 +52,18 @@ void main_cycle_counter_inc(void);
|
|||||||
*/
|
*/
|
||||||
uint64_t main_cycle_counter_get(void);
|
uint64_t main_cycle_counter_get(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reset the core cycle counter to 0
|
||||||
|
*/
|
||||||
|
void core_cycle_counter_reset(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the current value of the core cycle counter
|
||||||
|
*
|
||||||
|
* @return uint32_t Counter value
|
||||||
|
*/
|
||||||
|
uint32_t core_cycle_counter_get(void);
|
||||||
|
|
||||||
#endif /* __MAIN_CYCLE_COUNTER_H__ */
|
#endif /* __MAIN_CYCLE_COUNTER_H__ */
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
29
stm-firmware/include/reflow-controller/version.h
Normal file
29
stm-firmware/include/reflow-controller/version.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/* Reflow Oven Controller
|
||||||
|
*
|
||||||
|
* Copyright (C) 2022 Mario Hüttel <mario.huettel@gmx.net>
|
||||||
|
*
|
||||||
|
* This file is part of the Reflow Oven Controller Project.
|
||||||
|
*
|
||||||
|
* The reflow oven controller is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* The Reflow Oven Control Firmware is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with the reflow oven controller project.
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _VERSION_H_
|
||||||
|
#define _VERSION_H_
|
||||||
|
|
||||||
|
extern const char *version_git_version_string;
|
||||||
|
extern const char *version_git_full_commit_string;
|
||||||
|
extern const char *version_compile_date;
|
||||||
|
extern const char *version_compile_time;
|
||||||
|
|
||||||
|
#endif /* _VERSION_H_ */
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include <reflow-controller/main-cycle-counter.h>
|
#include <reflow-controller/main-cycle-counter.h>
|
||||||
#include <helper-macros/helper-macros.h>
|
#include <helper-macros/helper-macros.h>
|
||||||
|
#include <stm32/stm32f4xx.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Variable storing the main cycle counter.
|
* @brief Variable storing the main cycle counter.
|
||||||
@ -33,7 +34,22 @@
|
|||||||
*/
|
*/
|
||||||
static uint64_t IN_SECTION(.ccm.bss) main_cycle_counter;
|
static uint64_t IN_SECTION(.ccm.bss) main_cycle_counter;
|
||||||
|
|
||||||
void main_cycle_counter_init(void)
|
void main_and_core_cycle_counter_init(void)
|
||||||
|
{
|
||||||
|
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
|
||||||
|
|
||||||
|
/* Enable the core cycle counter if available on current processor */
|
||||||
|
if (!(DWT->CTRL & DWT_CTRL_NOCYCCNT_Msk)) {
|
||||||
|
/* Cycle counter is available. Enable */
|
||||||
|
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Reset the counters to 0 */
|
||||||
|
main_cycle_counter_reset();
|
||||||
|
core_cycle_counter_reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void main_cycle_counter_reset(void)
|
||||||
{
|
{
|
||||||
main_cycle_counter = 0ULL;
|
main_cycle_counter = 0ULL;
|
||||||
}
|
}
|
||||||
@ -48,4 +64,14 @@ uint64_t main_cycle_counter_get(void)
|
|||||||
return main_cycle_counter;
|
return main_cycle_counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void core_cycle_counter_reset(void)
|
||||||
|
{
|
||||||
|
DWT->CYCCNT = 0UL;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t core_cycle_counter_get(void)
|
||||||
|
{
|
||||||
|
return DWT->CYCCNT;
|
||||||
|
}
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
@ -268,8 +268,8 @@ int main(void)
|
|||||||
/** - Print motd to shell */
|
/** - Print motd to shell */
|
||||||
shell_print_motd(shell_handle);
|
shell_print_motd(shell_handle);
|
||||||
|
|
||||||
/** - Set the main cycle counter to 0 */
|
/** - Set the main cycle counter to 0 and activate the core cycle counter if available */
|
||||||
main_cycle_counter_init();
|
main_and_core_cycle_counter_init();
|
||||||
|
|
||||||
/** - Do a loop over the following */
|
/** - Do a loop over the following */
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
* If not, see <http://www.gnu.org/licenses/>.
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "reflow-controller/version.h"
|
||||||
#include <reflow-controller/ui/gui.h>
|
#include <reflow-controller/ui/gui.h>
|
||||||
#include <reflow-controller/ui/gui-config.h>
|
#include <reflow-controller/ui/gui-config.h>
|
||||||
#include <reflow-controller/ui/menu.h>
|
#include <reflow-controller/ui/menu.h>
|
||||||
@ -167,9 +168,9 @@ static void gui_menu_about(struct lcd_menu *menu, enum menu_entry_func_entry ent
|
|||||||
break;
|
break;
|
||||||
last_page = 1;
|
last_page = 1;
|
||||||
menu_lcd_output(menu, 0, "Version Number:");
|
menu_lcd_output(menu, 0, "Version Number:");
|
||||||
menu_lcd_outputf(menu, 1, "%.*s", LCD_CHAR_WIDTH, xstr(GIT_VER));
|
menu_lcd_outputf(menu, 1, "%.*s", LCD_CHAR_WIDTH, version_git_version_string);
|
||||||
if (strlen(xstr(GIT_VER)) > LCD_CHAR_WIDTH) {
|
if (strlen(version_git_version_string) > LCD_CHAR_WIDTH) {
|
||||||
menu_lcd_outputf(menu, 2, "%s", &xstr(GIT_VER)[LCD_CHAR_WIDTH]);
|
menu_lcd_outputf(menu, 2, "%s", &version_git_version_string[LCD_CHAR_WIDTH]);
|
||||||
}
|
}
|
||||||
#ifdef DEBUGBUILD
|
#ifdef DEBUGBUILD
|
||||||
menu_lcd_output(menu, 3, "Page 2/5 [DEBUG]");
|
menu_lcd_output(menu, 3, "Page 2/5 [DEBUG]");
|
||||||
|
@ -49,13 +49,10 @@
|
|||||||
#include <reflow-controller/ui/gui.h>
|
#include <reflow-controller/ui/gui.h>
|
||||||
#include <reflow-controller/ui/shell-uart.h>
|
#include <reflow-controller/ui/shell-uart.h>
|
||||||
#include <reflow-controller/safety/flash-crc.h>
|
#include <reflow-controller/safety/flash-crc.h>
|
||||||
|
#include <reflow-controller/version.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifndef GIT_VER
|
|
||||||
#define GIT_VER "VERSION NOT SET"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static shellmatta_instance_t shell;
|
static shellmatta_instance_t shell;
|
||||||
static char shell_buffer[512];
|
static char shell_buffer[512];
|
||||||
static char IN_SECTION(.ccm.bss) history_buffer[512];
|
static char IN_SECTION(.ccm.bss) history_buffer[512];
|
||||||
@ -81,8 +78,9 @@ static shellmatta_retCode_t shell_cmd_ver(const shellmatta_handle_t handle,
|
|||||||
stm_unique_id_get(&high_id, &mid_id, &low_id);
|
stm_unique_id_get(&high_id, &mid_id, &low_id);
|
||||||
stm_dev_rev_id_get(&stm_dev_id, &stm_rev_id);
|
stm_dev_rev_id_get(&stm_dev_id, &stm_rev_id);
|
||||||
|
|
||||||
shellmatta_printf(handle, "Reflow Oven Controller Firmware " xstr(GIT_VER) "\r\n"
|
shellmatta_printf(handle, "Reflow Oven Controller Firmware %s\r\n"
|
||||||
"Compiled: " __DATE__ " at " __TIME__ "\r\n");
|
"Compiled: %s at %s\r\n",
|
||||||
|
version_git_version_string, version_compile_date, version_compile_time);
|
||||||
shellmatta_printf(handle, "Serial: %08X-%08X-%08X\r\n", high_id, mid_id, low_id);
|
shellmatta_printf(handle, "Serial: %08X-%08X-%08X\r\n", high_id, mid_id, low_id);
|
||||||
|
|
||||||
pcb_rev = get_pcb_hardware_version();
|
pcb_rev = get_pcb_hardware_version();
|
||||||
@ -892,7 +890,7 @@ shellmatta_retCode_t shell_cmd_cycle_count(const shellmatta_handle_t handle, con
|
|||||||
|
|
||||||
|
|
||||||
counter = main_cycle_counter_get();
|
counter = main_cycle_counter_get();
|
||||||
core_cycle_count = DWT->CYCCNT;
|
core_cycle_count = core_cycle_counter_get();
|
||||||
if (hex) {
|
if (hex) {
|
||||||
shellmatta_printf(handle, "Main loop: 0x%016"PRIX64"\r\n", counter);
|
shellmatta_printf(handle, "Main loop: 0x%016"PRIX64"\r\n", counter);
|
||||||
shellmatta_printf(handle, "CPU cycles: 0x%08"PRIX32"\r\n", core_cycle_count);
|
shellmatta_printf(handle, "CPU cycles: 0x%08"PRIX32"\r\n", core_cycle_count);
|
||||||
@ -901,8 +899,8 @@ shellmatta_retCode_t shell_cmd_cycle_count(const shellmatta_handle_t handle, con
|
|||||||
shellmatta_printf(handle, "CPU cycles: %"PRIu32"\r\n", core_cycle_count);
|
shellmatta_printf(handle, "CPU cycles: %"PRIu32"\r\n", core_cycle_count);
|
||||||
}
|
}
|
||||||
if (clear) {
|
if (clear) {
|
||||||
main_cycle_counter_init();
|
main_cycle_counter_reset();
|
||||||
DWT->CYCCNT = 0UL;
|
core_cycle_counter_reset();
|
||||||
}
|
}
|
||||||
return SHELLMATTA_OK;
|
return SHELLMATTA_OK;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ add_executable(${ELFFILE} ${SRCS} ${FATFS_SRCS} ${SDIO_SRCS} ${STM_PERIPH_SRCS}
|
|||||||
target_include_directories(${ELFFILE} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include ../../include ${CMAKE_CURRENT_SOURCE_DIR}/3rd-party)
|
target_include_directories(${ELFFILE} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include ../../include ${CMAKE_CURRENT_SOURCE_DIR}/3rd-party)
|
||||||
target_compile_options(${ELFFILE} PRIVATE -Wall -Wextra -Wold-style-declaration -Wuninitialized -Wmaybe-uninitialized -Wunused-parameter)
|
target_compile_options(${ELFFILE} PRIVATE -Wall -Wextra -Wold-style-declaration -Wuninitialized -Wmaybe-uninitialized -Wunused-parameter)
|
||||||
target_compile_options(${ELFFILE} PRIVATE -mlittle-endian -mthumb -mcpu=cortex-m4 -mthumb-interwork -mfloat-abi=hard -mfpu=fpv4-sp-d16 -nostartfiles -Wimplicit-fallthrough=3 -Wsign-compare -Os -g3)
|
target_compile_options(${ELFFILE} PRIVATE -mlittle-endian -mthumb -mcpu=cortex-m4 -mthumb-interwork -mfloat-abi=hard -mfpu=fpv4-sp-d16 -nostartfiles -Wimplicit-fallthrough=3 -Wsign-compare -Os -g3)
|
||||||
target_compile_definitions(${ELFFILE} PRIVATE -DGIT_VER=${GIT_DESCRIBE} -DHSE_VALUE=8000000UL -DSTM32F407xx -DSTM32F4XX -DARM_MATH_CM4 -DSAFETY_MEMORY_STRIPOUT_DUMP)
|
target_compile_definitions(${ELFFILE} PRIVATE -DHSE_VALUE=8000000UL -DSTM32F407xx -DSTM32F4XX -DARM_MATH_CM4 -DSAFETY_MEMORY_STRIPOUT_DUMP)
|
||||||
target_link_options(${ELFFILE} PRIVATE -mlittle-endian -mthumb -mcpu=cortex-m4 -mthumb-interwork -mfloat-abi=hard -mfpu=fpv4-sp-d16 --disable-newlib-supplied-syscalls -nostartfiles -T${LINKER_SCRIPT} -Wl,--print-memory-usage)
|
target_link_options(${ELFFILE} PRIVATE -mlittle-endian -mthumb -mcpu=cortex-m4 -mthumb-interwork -mfloat-abi=hard -mfpu=fpv4-sp-d16 --disable-newlib-supplied-syscalls -nostartfiles -T${LINKER_SCRIPT} -Wl,--print-memory-usage)
|
||||||
set(GEN_HEADER_PATH "${CMAKE_CURRENT_BINARY_DIR}/include/generated")
|
set(GEN_HEADER_PATH "${CMAKE_CURRENT_BINARY_DIR}/include/generated")
|
||||||
set(GEN_HEADER_FILE "${GEN_HEADER_PATH}/${PROJECT_NAME}.bin.h")
|
set(GEN_HEADER_FILE "${GEN_HEADER_PATH}/${PROJECT_NAME}.bin.h")
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,170 +1,208 @@
|
|||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* Sample Code of OS Dependent Functions for FatFs */
|
/* A Sample Code of User Provided OS Dependent Functions for FatFs */
|
||||||
/* (C)ChaN, 2018 */
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
#include <fatfs/ff.h>
|
#include <fatfs/ff.h>
|
||||||
|
|
||||||
|
|
||||||
#if FF_USE_LFN == 3 /* Dynamic memory allocation */
|
#if FF_USE_LFN == 3 /* Use dynamic memory allocation */
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* Allocate a memory block */
|
/* Allocate/Free a Memory Block */
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include <stdlib.h> /* with POSIX API */
|
||||||
|
|
||||||
|
|
||||||
void* ff_memalloc ( /* Returns pointer to the allocated memory block (null if not enough core) */
|
void* ff_memalloc ( /* Returns pointer to the allocated memory block (null if not enough core) */
|
||||||
UINT msize /* Number of bytes to allocate */
|
UINT msize /* Number of bytes to allocate */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return malloc(msize); /* Allocate a new memory block with POSIX API */
|
return malloc((size_t)msize); /* Allocate a new memory block */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* Free a memory block */
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
void ff_memfree (
|
void ff_memfree (
|
||||||
void* mblock /* Pointer to the memory block to free (nothing to do if null) */
|
void* mblock /* Pointer to the memory block to free (no effect if null) */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
free(mblock); /* Free the memory block with POSIX API */
|
free(mblock); /* Free the memory block */
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if FF_FS_REENTRANT /* Mutal exclusion */
|
#if FF_FS_REENTRANT /* Mutal exclusion */
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* Create a Synchronization Object */
|
/* Definitions of Mutex */
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* This function is called in f_mount() function to create a new
|
|
||||||
/ synchronization object for the volume, such as semaphore and mutex.
|
|
||||||
/ When a 0 is returned, the f_mount() function fails with FR_INT_ERR.
|
|
||||||
*/
|
|
||||||
|
|
||||||
//const osMutexDef_t Mutex[FF_VOLUMES]; /* Table of CMSIS-RTOS mutex */
|
#define OS_TYPE 0 /* 0:Win32, 1:uITRON4.0, 2:uC/OS-II, 3:FreeRTOS, 4:CMSIS-RTOS */
|
||||||
|
|
||||||
|
|
||||||
int ff_cre_syncobj ( /* 1:Function succeeded, 0:Could not create the sync object */
|
#if OS_TYPE == 0 /* Win32 */
|
||||||
BYTE vol, /* Corresponding volume (logical drive number) */
|
#include <windows.h>
|
||||||
FF_SYNC_t* sobj /* Pointer to return the created sync object */
|
static HANDLE Mutex[FF_VOLUMES + 1]; /* Table of mutex handle */
|
||||||
)
|
|
||||||
{
|
|
||||||
/* Win32 */
|
|
||||||
*sobj = CreateMutex(NULL, FALSE, NULL);
|
|
||||||
return (int)(*sobj != INVALID_HANDLE_VALUE);
|
|
||||||
|
|
||||||
/* uITRON */
|
#elif OS_TYPE == 1 /* uITRON */
|
||||||
// T_CSEM csem = {TA_TPRI,1,1};
|
#include "itron.h"
|
||||||
// *sobj = acre_sem(&csem);
|
#include "kernel.h"
|
||||||
// return (int)(*sobj > 0);
|
static mtxid Mutex[FF_VOLUMES + 1]; /* Table of mutex ID */
|
||||||
|
|
||||||
/* uC/OS-II */
|
#elif OS_TYPE == 2 /* uc/OS-II */
|
||||||
// OS_ERR err;
|
#include "includes.h"
|
||||||
// *sobj = OSMutexCreate(0, &err);
|
static OS_EVENT *Mutex[FF_VOLUMES + 1]; /* Table of mutex pinter */
|
||||||
// return (int)(err == OS_NO_ERR);
|
|
||||||
|
|
||||||
/* FreeRTOS */
|
#elif OS_TYPE == 3 /* FreeRTOS */
|
||||||
// *sobj = xSemaphoreCreateMutex();
|
#include "FreeRTOS.h"
|
||||||
// return (int)(*sobj != NULL);
|
#include "semphr.h"
|
||||||
|
static SemaphoreHandle_t Mutex[FF_VOLUMES + 1]; /* Table of mutex handle */
|
||||||
|
|
||||||
/* CMSIS-RTOS */
|
#elif OS_TYPE == 4 /* CMSIS-RTOS */
|
||||||
// *sobj = osMutexCreate(&Mutex[vol]);
|
#include "cmsis_os.h"
|
||||||
// return (int)(*sobj != NULL);
|
static osMutexId Mutex[FF_VOLUMES + 1]; /* Table of mutex ID */
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* Delete a Synchronization Object */
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* This function is called in f_mount() function to delete a synchronization
|
|
||||||
/ object that created with ff_cre_syncobj() function. When a 0 is returned,
|
|
||||||
/ the f_mount() function fails with FR_INT_ERR.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ff_del_syncobj ( /* 1:Function succeeded, 0:Could not delete due to an error */
|
|
||||||
FF_SYNC_t sobj /* Sync object tied to the logical drive to be deleted */
|
|
||||||
)
|
|
||||||
{
|
|
||||||
/* Win32 */
|
|
||||||
return (int)CloseHandle(sobj);
|
|
||||||
|
|
||||||
/* uITRON */
|
|
||||||
// return (int)(del_sem(sobj) == E_OK);
|
|
||||||
|
|
||||||
/* uC/OS-II */
|
|
||||||
// OS_ERR err;
|
|
||||||
// OSMutexDel(sobj, OS_DEL_ALWAYS, &err);
|
|
||||||
// return (int)(err == OS_NO_ERR);
|
|
||||||
|
|
||||||
/* FreeRTOS */
|
|
||||||
// vSemaphoreDelete(sobj);
|
|
||||||
// return 1;
|
|
||||||
|
|
||||||
/* CMSIS-RTOS */
|
|
||||||
// return (int)(osMutexDelete(sobj) == osOK);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* Request Grant to Access the Volume */
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* This function is called on entering file functions to lock the volume.
|
|
||||||
/ When a 0 is returned, the file function fails with FR_TIMEOUT.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ff_req_grant ( /* 1:Got a grant to access the volume, 0:Could not get a grant */
|
|
||||||
FF_SYNC_t sobj /* Sync object to wait */
|
|
||||||
)
|
|
||||||
{
|
|
||||||
/* Win32 */
|
|
||||||
return (int)(WaitForSingleObject(sobj, FF_FS_TIMEOUT) == WAIT_OBJECT_0);
|
|
||||||
|
|
||||||
/* uITRON */
|
|
||||||
// return (int)(wai_sem(sobj) == E_OK);
|
|
||||||
|
|
||||||
/* uC/OS-II */
|
|
||||||
// OS_ERR err;
|
|
||||||
// OSMutexPend(sobj, FF_FS_TIMEOUT, &err));
|
|
||||||
// return (int)(err == OS_NO_ERR);
|
|
||||||
|
|
||||||
/* FreeRTOS */
|
|
||||||
// return (int)(xSemaphoreTake(sobj, FF_FS_TIMEOUT) == pdTRUE);
|
|
||||||
|
|
||||||
/* CMSIS-RTOS */
|
|
||||||
// return (int)(osMutexWait(sobj, FF_FS_TIMEOUT) == osOK);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* Release Grant to Access the Volume */
|
|
||||||
/*------------------------------------------------------------------------*/
|
|
||||||
/* This function is called on leaving file functions to unlock the volume.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void ff_rel_grant (
|
|
||||||
FF_SYNC_t sobj /* Sync object to be signaled */
|
|
||||||
)
|
|
||||||
{
|
|
||||||
/* Win32 */
|
|
||||||
ReleaseMutex(sobj);
|
|
||||||
|
|
||||||
/* uITRON */
|
|
||||||
// sig_sem(sobj);
|
|
||||||
|
|
||||||
/* uC/OS-II */
|
|
||||||
// OSMutexPost(sobj);
|
|
||||||
|
|
||||||
/* FreeRTOS */
|
|
||||||
// xSemaphoreGive(sobj);
|
|
||||||
|
|
||||||
/* CMSIS-RTOS */
|
|
||||||
// osMutexRelease(sobj);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* Create a Mutex */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* This function is called in f_mount function to create a new mutex
|
||||||
|
/ or semaphore for the volume. When a 0 is returned, the f_mount function
|
||||||
|
/ fails with FR_INT_ERR.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int ff_mutex_create ( /* Returns 1:Function succeeded or 0:Could not create the mutex */
|
||||||
|
int vol /* Mutex ID: Volume mutex (0 to FF_VOLUMES - 1) or system mutex (FF_VOLUMES) */
|
||||||
|
)
|
||||||
|
{
|
||||||
|
#if OS_TYPE == 0 /* Win32 */
|
||||||
|
Mutex[vol] = CreateMutex(NULL, FALSE, NULL);
|
||||||
|
return (int)(Mutex[vol] != INVALID_HANDLE_VALUE);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 1 /* uITRON */
|
||||||
|
T_CMTX cmtx = {TA_TPRI,1};
|
||||||
|
|
||||||
|
Mutex[vol] = acre_mtx(&cmtx);
|
||||||
|
return (int)(Mutex[vol] > 0);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 2 /* uC/OS-II */
|
||||||
|
OS_ERR err;
|
||||||
|
|
||||||
|
Mutex[vol] = OSMutexCreate(0, &err);
|
||||||
|
return (int)(err == OS_NO_ERR);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 3 /* FreeRTOS */
|
||||||
|
Mutex[vol] = xSemaphoreCreateMutex();
|
||||||
|
return (int)(Mutex[vol] != NULL);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 4 /* CMSIS-RTOS */
|
||||||
|
osMutexDef(cmsis_os_mutex);
|
||||||
|
|
||||||
|
Mutex[vol] = osMutexCreate(osMutex(cmsis_os_mutex));
|
||||||
|
return (int)(Mutex[vol] != NULL);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* Delete a Mutex */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* This function is called in f_mount function to delete a mutex or
|
||||||
|
/ semaphore of the volume created with ff_mutex_create function.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void ff_mutex_delete ( /* Returns 1:Function succeeded or 0:Could not delete due to an error */
|
||||||
|
int vol /* Mutex ID: Volume mutex (0 to FF_VOLUMES - 1) or system mutex (FF_VOLUMES) */
|
||||||
|
)
|
||||||
|
{
|
||||||
|
#if OS_TYPE == 0 /* Win32 */
|
||||||
|
CloseHandle(Mutex[vol]);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 1 /* uITRON */
|
||||||
|
del_mtx(Mutex[vol]);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 2 /* uC/OS-II */
|
||||||
|
OS_ERR err;
|
||||||
|
|
||||||
|
OSMutexDel(Mutex[vol], OS_DEL_ALWAYS, &err);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 3 /* FreeRTOS */
|
||||||
|
vSemaphoreDelete(Mutex[vol]);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 4 /* CMSIS-RTOS */
|
||||||
|
osMutexDelete(Mutex[vol]);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* Request a Grant to Access the Volume */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* This function is called on enter file functions to lock the volume.
|
||||||
|
/ When a 0 is returned, the file function fails with FR_TIMEOUT.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int ff_mutex_take ( /* Returns 1:Succeeded or 0:Timeout */
|
||||||
|
int vol /* Mutex ID: Volume mutex (0 to FF_VOLUMES - 1) or system mutex (FF_VOLUMES) */
|
||||||
|
)
|
||||||
|
{
|
||||||
|
#if OS_TYPE == 0 /* Win32 */
|
||||||
|
return (int)(WaitForSingleObject(Mutex[vol], FF_FS_TIMEOUT) == WAIT_OBJECT_0);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 1 /* uITRON */
|
||||||
|
return (int)(tloc_mtx(Mutex[vol], FF_FS_TIMEOUT) == E_OK);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 2 /* uC/OS-II */
|
||||||
|
OS_ERR err;
|
||||||
|
|
||||||
|
OSMutexPend(Mutex[vol], FF_FS_TIMEOUT, &err));
|
||||||
|
return (int)(err == OS_NO_ERR);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 3 /* FreeRTOS */
|
||||||
|
return (int)(xSemaphoreTake(Mutex[vol], FF_FS_TIMEOUT) == pdTRUE);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 4 /* CMSIS-RTOS */
|
||||||
|
return (int)(osMutexWait(Mutex[vol], FF_FS_TIMEOUT) == osOK);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* Release a Grant to Access the Volume */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* This function is called on leave file functions to unlock the volume.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void ff_mutex_give (
|
||||||
|
int vol /* Mutex ID: Volume mutex (0 to FF_VOLUMES - 1) or system mutex (FF_VOLUMES) */
|
||||||
|
)
|
||||||
|
{
|
||||||
|
#if OS_TYPE == 0 /* Win32 */
|
||||||
|
ReleaseMutex(Mutex[vol]);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 1 /* uITRON */
|
||||||
|
unl_mtx(Mutex[vol]);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 2 /* uC/OS-II */
|
||||||
|
OSMutexPost(Mutex[vol]);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 3 /* FreeRTOS */
|
||||||
|
xSemaphoreGive(Mutex[vol]);
|
||||||
|
|
||||||
|
#elif OS_TYPE == 4 /* CMSIS-RTOS */
|
||||||
|
osMutexRelease(Mutex[vol]);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* FF_FS_REENTRANT */
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* Unicode handling functions for FatFs R0.13+ */
|
/* Unicode Handling Functions for FatFs R0.13 and Later */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* This module will occupy a huge memory in the .rodata section when the */
|
||||||
|
/* FatFs is configured for LFN with DBCS. If the system has a Unicode */
|
||||||
|
/* library for the code conversion, this module should be modified to use */
|
||||||
|
/* it to avoid silly memory consumption. */
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* This module will occupy a huge memory in the .const section when the /
|
|
||||||
/ FatFs is configured for LFN with DBCS. If the system has any Unicode /
|
|
||||||
/ utilitiy for the code conversion, this module should be modified to use /
|
|
||||||
/ that function to avoid silly memory consumption. /
|
|
||||||
/-------------------------------------------------------------------------*/
|
|
||||||
/*
|
/*
|
||||||
/ Copyright (C) 2014, ChaN, all right reserved.
|
/ Copyright (C) 2022, ChaN, all right reserved.
|
||||||
/
|
/
|
||||||
/ FatFs module is an open source software. Redistribution and use of FatFs in
|
/ FatFs module is an open source software. Redistribution and use of FatFs in
|
||||||
/ source and binary forms, with or without modification, are permitted provided
|
/ source and binary forms, with or without modification, are permitted provided
|
||||||
@ -22,10 +22,9 @@
|
|||||||
/ by use of this software.
|
/ by use of this software.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <fatfs/ff.h>
|
#include <fatfs/ff.h>
|
||||||
|
|
||||||
#if FF_USE_LFN /* This module will be blanked if non-LFN configuration */
|
#if FF_USE_LFN != 0 /* This module will be blanked if in non-LFN configuration */
|
||||||
|
|
||||||
#define MERGE2(a, b) a ## b
|
#define MERGE2(a, b) a ## b
|
||||||
#define CVTBL(tbl, cp) MERGE2(tbl, cp)
|
#define CVTBL(tbl, cp) MERGE2(tbl, cp)
|
||||||
@ -15214,8 +15213,8 @@ static const WCHAR uc869[] = { /* CP869(Greek 2) to Unicode conversion table */
|
|||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* OEM <==> Unicode conversions for static code page configuration */
|
/* OEM <==> Unicode Conversions for Static Code Page Configuration with */
|
||||||
/* SBCS fixed code page */
|
/* SBCS Fixed Code Page */
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#if FF_CODE_PAGE != 0 && FF_CODE_PAGE < 900
|
#if FF_CODE_PAGE != 0 && FF_CODE_PAGE < 900
|
||||||
@ -15225,7 +15224,7 @@ WCHAR ff_uni2oem ( /* Returns OEM code character, zero on error */
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
WCHAR c = 0;
|
WCHAR c = 0;
|
||||||
const WCHAR *p = CVTBL(uc, FF_CODE_PAGE);
|
const WCHAR* p = CVTBL(uc, FF_CODE_PAGE);
|
||||||
|
|
||||||
|
|
||||||
if (uni < 0x80) { /* ASCII? */
|
if (uni < 0x80) { /* ASCII? */
|
||||||
@ -15247,7 +15246,7 @@ WCHAR ff_oem2uni ( /* Returns Unicode character in UTF-16, zero on error */
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
WCHAR c = 0;
|
WCHAR c = 0;
|
||||||
const WCHAR *p = CVTBL(uc, FF_CODE_PAGE);
|
const WCHAR* p = CVTBL(uc, FF_CODE_PAGE);
|
||||||
|
|
||||||
|
|
||||||
if (oem < 0x80) { /* ASCII? */
|
if (oem < 0x80) { /* ASCII? */
|
||||||
@ -15267,8 +15266,8 @@ WCHAR ff_oem2uni ( /* Returns Unicode character in UTF-16, zero on error */
|
|||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* OEM <==> Unicode conversions for static code page configuration */
|
/* OEM <==> Unicode Conversions for Static Code Page Configuration with */
|
||||||
/* DBCS fixed code page */
|
/* DBCS Fixed Code Page */
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#if FF_CODE_PAGE >= 900
|
#if FF_CODE_PAGE >= 900
|
||||||
@ -15277,7 +15276,7 @@ WCHAR ff_uni2oem ( /* Returns OEM code character, zero on error */
|
|||||||
WORD cp /* Code page for the conversion */
|
WORD cp /* Code page for the conversion */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const WCHAR *p;
|
const WCHAR* p;
|
||||||
WCHAR c = 0, uc;
|
WCHAR c = 0, uc;
|
||||||
UINT i = 0, n, li, hi;
|
UINT i = 0, n, li, hi;
|
||||||
|
|
||||||
@ -15313,7 +15312,7 @@ WCHAR ff_oem2uni ( /* Returns Unicode character in UTF-16, zero on error */
|
|||||||
WORD cp /* Code page for the conversion */
|
WORD cp /* Code page for the conversion */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const WCHAR *p;
|
const WCHAR* p;
|
||||||
WCHAR c = 0;
|
WCHAR c = 0;
|
||||||
UINT i = 0, n, li, hi;
|
UINT i = 0, n, li, hi;
|
||||||
|
|
||||||
@ -15346,7 +15345,7 @@ WCHAR ff_oem2uni ( /* Returns Unicode character in UTF-16, zero on error */
|
|||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* OEM <==> Unicode conversions for dynamic code page configuration */
|
/* OEM <==> Unicode Conversions for Dynamic Code Page Configuration */
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#if FF_CODE_PAGE == 0
|
#if FF_CODE_PAGE == 0
|
||||||
@ -15360,7 +15359,7 @@ WCHAR ff_uni2oem ( /* Returns OEM code character, zero on error */
|
|||||||
WORD cp /* Code page for the conversion */
|
WORD cp /* Code page for the conversion */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const WCHAR *p;
|
const WCHAR* p;
|
||||||
WCHAR c = 0, uc;
|
WCHAR c = 0, uc;
|
||||||
UINT i, n, li, hi;
|
UINT i, n, li, hi;
|
||||||
|
|
||||||
@ -15412,7 +15411,7 @@ WCHAR ff_oem2uni ( /* Returns Unicode character in UTF-16, zero on error */
|
|||||||
WORD cp /* Code page for the conversion */
|
WORD cp /* Code page for the conversion */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const WCHAR *p;
|
const WCHAR* p;
|
||||||
WCHAR c = 0;
|
WCHAR c = 0;
|
||||||
UINT i, n, li, hi;
|
UINT i, n, li, hi;
|
||||||
|
|
||||||
@ -15458,14 +15457,14 @@ WCHAR ff_oem2uni ( /* Returns Unicode character in UTF-16, zero on error */
|
|||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* Unicode up-case conversion */
|
/* Unicode Up-case Conversion */
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
DWORD ff_wtoupper ( /* Returns up-converted code point */
|
DWORD ff_wtoupper ( /* Returns up-converted code point */
|
||||||
DWORD uni /* Unicode code point to be up-converted */
|
DWORD uni /* Unicode code point to be up-converted */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const WORD *p;
|
const WORD* p;
|
||||||
WORD uc, bc, nc, cmd;
|
WORD uc, bc, nc, cmd;
|
||||||
static const WORD cvt1[] = { /* Compressed up conversion table for U+0000 - U+0FFF */
|
static const WORD cvt1[] = { /* Compressed up conversion table for U+0000 - U+0FFF */
|
||||||
/* Basic Latin */
|
/* Basic Latin */
|
||||||
@ -15590,4 +15589,4 @@ DWORD ff_wtoupper ( /* Returns up-converted code point */
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* #if FF_USE_LFN */
|
#endif /* #if FF_USE_LFN != 0 */
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/*----------------------------------------------------------------------------/
|
/*----------------------------------------------------------------------------/
|
||||||
/ FatFs - Generic FAT Filesystem module R0.14b /
|
/ FatFs - Generic FAT Filesystem module R0.15 /
|
||||||
/-----------------------------------------------------------------------------/
|
/-----------------------------------------------------------------------------/
|
||||||
/
|
/
|
||||||
/ Copyright (C) 2021, ChaN, all right reserved.
|
/ Copyright (C) 2022, ChaN, all right reserved.
|
||||||
/
|
/
|
||||||
/ FatFs module is an open source software. Redistribution and use of FatFs in
|
/ FatFs module is an open source software. Redistribution and use of FatFs in
|
||||||
/ source and binary forms, with or without modification, are permitted provided
|
/ source and binary forms, with or without modification, are permitted provided
|
||||||
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef FF_DEFINED
|
#ifndef FF_DEFINED
|
||||||
#define FF_DEFINED 86631 /* Revision ID */
|
#define FF_DEFINED 80286 /* Revision ID */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -131,10 +131,11 @@ extern const char* VolumeStr[FF_VOLUMES]; /* User defied volume ID */
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
BYTE fs_type; /* Filesystem type (0:not mounted) */
|
BYTE fs_type; /* Filesystem type (0:not mounted) */
|
||||||
BYTE pdrv; /* Associated physical drive */
|
BYTE pdrv; /* Volume hosting physical drive */
|
||||||
|
BYTE ldrv; /* Logical drive number (used only when FF_FS_REENTRANT) */
|
||||||
BYTE n_fats; /* Number of FATs (1 or 2) */
|
BYTE n_fats; /* Number of FATs (1 or 2) */
|
||||||
BYTE wflag; /* win[] flag (b0:dirty) */
|
BYTE wflag; /* win[] status (b0:dirty) */
|
||||||
BYTE fsi_flag; /* FSINFO flags (b7:disabled, b0:dirty) */
|
BYTE fsi_flag; /* FSINFO status (b7:disabled, b0:dirty) */
|
||||||
WORD id; /* Volume mount ID */
|
WORD id; /* Volume mount ID */
|
||||||
WORD n_rootdir; /* Number of root directory entries (FAT12/16) */
|
WORD n_rootdir; /* Number of root directory entries (FAT12/16) */
|
||||||
WORD csize; /* Cluster size [sectors] */
|
WORD csize; /* Cluster size [sectors] */
|
||||||
@ -147,9 +148,6 @@ typedef struct {
|
|||||||
#if FF_FS_EXFAT
|
#if FF_FS_EXFAT
|
||||||
BYTE* dirbuf; /* Directory entry block scratchpad buffer for exFAT */
|
BYTE* dirbuf; /* Directory entry block scratchpad buffer for exFAT */
|
||||||
#endif
|
#endif
|
||||||
#if FF_FS_REENTRANT
|
|
||||||
FF_SYNC_t sobj; /* Identifier of sync object */
|
|
||||||
#endif
|
|
||||||
#if !FF_FS_READONLY
|
#if !FF_FS_READONLY
|
||||||
DWORD last_clst; /* Last allocated cluster */
|
DWORD last_clst; /* Last allocated cluster */
|
||||||
DWORD free_clst; /* Number of free clusters */
|
DWORD free_clst; /* Number of free clusters */
|
||||||
@ -163,10 +161,10 @@ typedef struct {
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
DWORD n_fatent; /* Number of FAT entries (number of clusters + 2) */
|
DWORD n_fatent; /* Number of FAT entries (number of clusters + 2) */
|
||||||
DWORD fsize; /* Size of an FAT [sectors] */
|
DWORD fsize; /* Number of sectors per FAT */
|
||||||
LBA_t volbase; /* Volume base sector */
|
LBA_t volbase; /* Volume base sector */
|
||||||
LBA_t fatbase; /* FAT base sector */
|
LBA_t fatbase; /* FAT base sector */
|
||||||
LBA_t dirbase; /* Root directory base sector/cluster */
|
LBA_t dirbase; /* Root directory base sector (FAT12/16) or cluster (FAT32/exFAT) */
|
||||||
LBA_t database; /* Data base sector */
|
LBA_t database; /* Data base sector */
|
||||||
#if FF_FS_EXFAT
|
#if FF_FS_EXFAT
|
||||||
LBA_t bitbase; /* Allocation bitmap base sector */
|
LBA_t bitbase; /* Allocation bitmap base sector */
|
||||||
@ -181,7 +179,7 @@ typedef struct {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
FATFS* fs; /* Pointer to the hosting volume of this object */
|
FATFS* fs; /* Pointer to the hosting volume of this object */
|
||||||
WORD id; /* Hosting volume mount ID */
|
WORD id; /* Hosting volume's mount ID */
|
||||||
BYTE attr; /* Object attribute */
|
BYTE attr; /* Object attribute */
|
||||||
BYTE stat; /* Object chain status (b1-0: =0:not contiguous, =2:contiguous, =3:fragmented in this session, b2:sub-directory stretched) */
|
BYTE stat; /* Object chain status (b1-0: =0:not contiguous, =2:contiguous, =3:fragmented in this session, b2:sub-directory stretched) */
|
||||||
DWORD sclust; /* Object data start cluster (0:no cluster or root directory) */
|
DWORD sclust; /* Object data start cluster (0:no cluster or root directory) */
|
||||||
@ -250,7 +248,7 @@ typedef struct {
|
|||||||
WORD ftime; /* Modified time */
|
WORD ftime; /* Modified time */
|
||||||
BYTE fattrib; /* File attribute */
|
BYTE fattrib; /* File attribute */
|
||||||
#if FF_USE_LFN
|
#if FF_USE_LFN
|
||||||
TCHAR altname[FF_SFN_BUF + 1];/* Altenative file name */
|
TCHAR altname[FF_SFN_BUF + 1];/* Alternative file name */
|
||||||
TCHAR fname[FF_LFN_BUF + 1]; /* Primary file name */
|
TCHAR fname[FF_LFN_BUF + 1]; /* Primary file name */
|
||||||
#else
|
#else
|
||||||
TCHAR fname[12 + 1]; /* File name */
|
TCHAR fname[12 + 1]; /* File name */
|
||||||
@ -298,8 +296,10 @@ typedef enum {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------*/
|
||||||
|
/* FatFs Module Application Interface */
|
||||||
/*--------------------------------------------------------------*/
|
/*--------------------------------------------------------------*/
|
||||||
/* FatFs module application interface */
|
|
||||||
|
|
||||||
FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */
|
FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */
|
||||||
FRESULT f_close (FIL* fp); /* Close an open file object */
|
FRESULT f_close (FIL* fp); /* Close an open file object */
|
||||||
@ -336,6 +336,8 @@ int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */
|
|||||||
int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */
|
int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */
|
||||||
TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */
|
TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */
|
||||||
|
|
||||||
|
/* Some API fucntions are implemented as macro */
|
||||||
|
|
||||||
#define f_eof(fp) ((int)((fp)->fptr == (fp)->obj.objsize))
|
#define f_eof(fp) ((int)((fp)->fptr == (fp)->obj.objsize))
|
||||||
#define f_error(fp) ((fp)->err)
|
#define f_error(fp) ((fp)->err)
|
||||||
#define f_tell(fp) ((fp)->fptr)
|
#define f_tell(fp) ((fp)->fptr)
|
||||||
@ -349,38 +351,43 @@ TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the fil
|
|||||||
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------*/
|
/*--------------------------------------------------------------*/
|
||||||
/* Additional user defined functions */
|
/* Additional Functions */
|
||||||
|
/*--------------------------------------------------------------*/
|
||||||
|
|
||||||
/* RTC function */
|
/* RTC function (provided by user) */
|
||||||
#if !FF_FS_READONLY && !FF_FS_NORTC
|
#if !FF_FS_READONLY && !FF_FS_NORTC
|
||||||
DWORD get_fattime (void);
|
DWORD get_fattime (void); /* Get current time */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* LFN support functions */
|
|
||||||
#if FF_USE_LFN >= 1 /* Code conversion (defined in unicode.c) */
|
/* LFN support functions (defined in ffunicode.c) */
|
||||||
|
|
||||||
|
#if FF_USE_LFN >= 1
|
||||||
WCHAR ff_oem2uni (WCHAR oem, WORD cp); /* OEM code to Unicode conversion */
|
WCHAR ff_oem2uni (WCHAR oem, WORD cp); /* OEM code to Unicode conversion */
|
||||||
WCHAR ff_uni2oem (DWORD uni, WORD cp); /* Unicode to OEM code conversion */
|
WCHAR ff_uni2oem (DWORD uni, WORD cp); /* Unicode to OEM code conversion */
|
||||||
DWORD ff_wtoupper (DWORD uni); /* Unicode upper-case conversion */
|
DWORD ff_wtoupper (DWORD uni); /* Unicode upper-case conversion */
|
||||||
#endif
|
#endif
|
||||||
#if FF_USE_LFN == 3 /* Dynamic memory allocation */
|
|
||||||
void* ff_memalloc (UINT msize); /* Allocate memory block */
|
|
||||||
void ff_memfree (void* mblock); /* Free memory block */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Sync functions */
|
|
||||||
#if FF_FS_REENTRANT
|
/* O/S dependent functions (samples available in ffsystem.c) */
|
||||||
int ff_cre_syncobj (BYTE vol, FF_SYNC_t* sobj); /* Create a sync object */
|
|
||||||
int ff_req_grant (FF_SYNC_t sobj); /* Lock sync object */
|
#if FF_USE_LFN == 3 /* Dynamic memory allocation */
|
||||||
void ff_rel_grant (FF_SYNC_t sobj); /* Unlock sync object */
|
void* ff_memalloc (UINT msize); /* Allocate memory block */
|
||||||
int ff_del_syncobj (FF_SYNC_t sobj); /* Delete a sync object */
|
void ff_memfree (void* mblock); /* Free memory block */
|
||||||
|
#endif
|
||||||
|
#if FF_FS_REENTRANT /* Sync functions */
|
||||||
|
int ff_mutex_create (int vol); /* Create a sync object */
|
||||||
|
void ff_mutex_delete (int vol); /* Delete a sync object */
|
||||||
|
int ff_mutex_take (int vol); /* Lock sync object */
|
||||||
|
void ff_mutex_give (int vol); /* Unlock sync object */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------*/
|
/*--------------------------------------------------------------*/
|
||||||
/* Flags and offset address */
|
/* Flags and Offset Address */
|
||||||
|
/*--------------------------------------------------------------*/
|
||||||
|
|
||||||
/* File access mode and open method flags (3rd argument of f_open) */
|
/* File access mode and open method flags (3rd argument of f_open) */
|
||||||
#define FA_READ 0x01
|
#define FA_READ 0x01
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/*---------------------------------------------------------------------------/
|
/*---------------------------------------------------------------------------/
|
||||||
/ FatFs Functional Configurations
|
/ Configurations of FatFs Module
|
||||||
/---------------------------------------------------------------------------*/
|
/---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#define FFCONF_DEF 86631 /* Revision ID */
|
#define FFCONF_DEF 80286 /* Revision ID */
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------/
|
/*---------------------------------------------------------------------------/
|
||||||
/ Function Configurations
|
/ Function Configurations
|
||||||
@ -68,7 +68,7 @@
|
|||||||
/ 2: Enable with LF-CRLF conversion.
|
/ 2: Enable with LF-CRLF conversion.
|
||||||
/
|
/
|
||||||
/ FF_PRINT_LLI = 1 makes f_printf() support long long argument and FF_PRINT_FLOAT = 1/2
|
/ FF_PRINT_LLI = 1 makes f_printf() support long long argument and FF_PRINT_FLOAT = 1/2
|
||||||
makes f_printf() support floating point argument. These features want C99 or later.
|
/ makes f_printf() support floating point argument. These features want C99 or later.
|
||||||
/ When FF_LFN_UNICODE >= 1 with LFN enabled, string functions convert the character
|
/ When FF_LFN_UNICODE >= 1 with LFN enabled, string functions convert the character
|
||||||
/ encoding in it. FF_STRF_ENCODE selects assumption of character encoding ON THE FILE
|
/ encoding in it. FF_STRF_ENCODE selects assumption of character encoding ON THE FILE
|
||||||
/ to be read/written via those functions.
|
/ to be read/written via those functions.
|
||||||
@ -178,7 +178,7 @@
|
|||||||
/ logical drives. Number of items must not be less than FF_VOLUMES. Valid
|
/ logical drives. Number of items must not be less than FF_VOLUMES. Valid
|
||||||
/ characters for the volume ID strings are A-Z, a-z and 0-9, however, they are
|
/ characters for the volume ID strings are A-Z, a-z and 0-9, however, they are
|
||||||
/ compared in case-insensitive. If FF_STR_VOLUME_ID >= 1 and FF_VOLUME_STRS is
|
/ compared in case-insensitive. If FF_STR_VOLUME_ID >= 1 and FF_VOLUME_STRS is
|
||||||
/ not defined, a user defined volume string table needs to be defined as:
|
/ not defined, a user defined volume string table is needed as:
|
||||||
/
|
/
|
||||||
/ const char* VolumeStr[FF_VOLUMES] = {"ram","flash","sd","usb",...
|
/ const char* VolumeStr[FF_VOLUMES] = {"ram","flash","sd","usb",...
|
||||||
*/
|
*/
|
||||||
@ -190,7 +190,7 @@
|
|||||||
/ number and only an FAT volume found on the physical drive will be mounted.
|
/ number and only an FAT volume found on the physical drive will be mounted.
|
||||||
/ When this function is enabled (1), each logical drive number can be bound to
|
/ When this function is enabled (1), each logical drive number can be bound to
|
||||||
/ arbitrary physical drive and partition listed in the VolToPart[]. Also f_fdisk()
|
/ arbitrary physical drive and partition listed in the VolToPart[]. Also f_fdisk()
|
||||||
/ funciton will be available. */
|
/ function will be available. */
|
||||||
|
|
||||||
|
|
||||||
#define FF_MIN_SS 512
|
#define FF_MIN_SS 512
|
||||||
@ -240,10 +240,10 @@
|
|||||||
#define FF_FS_NORTC 0
|
#define FF_FS_NORTC 0
|
||||||
#define FF_NORTC_MON 1
|
#define FF_NORTC_MON 1
|
||||||
#define FF_NORTC_MDAY 1
|
#define FF_NORTC_MDAY 1
|
||||||
#define FF_NORTC_YEAR 2020
|
#define FF_NORTC_YEAR 2022
|
||||||
/* The option FF_FS_NORTC switches timestamp functiton. If the system does not have
|
/* The option FF_FS_NORTC switches timestamp feature. If the system does not have
|
||||||
/ any RTC function or valid timestamp is not needed, set FF_FS_NORTC = 1 to disable
|
/ an RTC or valid timestamp is not needed, set FF_FS_NORTC = 1 to disable the
|
||||||
/ the timestamp function. Every object modified by FatFs will have a fixed timestamp
|
/ timestamp feature. Every object modified by FatFs will have a fixed timestamp
|
||||||
/ defined by FF_NORTC_MON, FF_NORTC_MDAY and FF_NORTC_YEAR in local time.
|
/ defined by FF_NORTC_MON, FF_NORTC_MDAY and FF_NORTC_YEAR in local time.
|
||||||
/ To enable timestamp function (FF_FS_NORTC = 0), get_fattime() function need to be
|
/ To enable timestamp function (FF_FS_NORTC = 0), get_fattime() function need to be
|
||||||
/ added to the project to read current time form real-time clock. FF_NORTC_MON,
|
/ added to the project to read current time form real-time clock. FF_NORTC_MON,
|
||||||
@ -253,7 +253,7 @@
|
|||||||
|
|
||||||
#define FF_FS_NOFSINFO 0
|
#define FF_FS_NOFSINFO 0
|
||||||
/* If you need to know correct free space on the FAT32 volume, set bit 0 of this
|
/* If you need to know correct free space on the FAT32 volume, set bit 0 of this
|
||||||
/ option, and f_getfree() function at first time after volume mount will force
|
/ option, and f_getfree() function at the first time after volume mount will force
|
||||||
/ a full FAT scan. Bit 1 controls the use of last allocated cluster number.
|
/ a full FAT scan. Bit 1 controls the use of last allocated cluster number.
|
||||||
/
|
/
|
||||||
/ bit0=0: Use free cluster count in the FSINFO if available.
|
/ bit0=0: Use free cluster count in the FSINFO if available.
|
||||||
@ -275,26 +275,21 @@
|
|||||||
/ lock control is independent of re-entrancy. */
|
/ lock control is independent of re-entrancy. */
|
||||||
|
|
||||||
|
|
||||||
/* #include <somertos.h> // O/S definitions */
|
|
||||||
#define FF_FS_REENTRANT 0
|
#define FF_FS_REENTRANT 0
|
||||||
#define FF_FS_TIMEOUT 1000
|
#define FF_FS_TIMEOUT 1000
|
||||||
#define FF_SYNC_t HANDLE
|
|
||||||
/* The option FF_FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs
|
/* The option FF_FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs
|
||||||
/ module itself. Note that regardless of this option, file access to different
|
/ module itself. Note that regardless of this option, file access to different
|
||||||
/ volume is always re-entrant and volume control functions, f_mount(), f_mkfs()
|
/ volume is always re-entrant and volume control functions, f_mount(), f_mkfs()
|
||||||
/ and f_fdisk() function, are always not re-entrant. Only file/directory access
|
/ and f_fdisk() function, are always not re-entrant. Only file/directory access
|
||||||
/ to the same volume is under control of this function.
|
/ to the same volume is under control of this featuer.
|
||||||
/
|
/
|
||||||
/ 0: Disable re-entrancy. FF_FS_TIMEOUT and FF_SYNC_t have no effect.
|
/ 0: Disable re-entrancy. FF_FS_TIMEOUT have no effect.
|
||||||
/ 1: Enable re-entrancy. Also user provided synchronization handlers,
|
/ 1: Enable re-entrancy. Also user provided synchronization handlers,
|
||||||
/ ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj()
|
/ ff_mutex_create(), ff_mutex_delete(), ff_mutex_take() and ff_mutex_give()
|
||||||
/ function, must be added to the project. Samples are available in
|
/ function, must be added to the project. Samples are available in ffsystem.c.
|
||||||
/ option/syscall.c.
|
|
||||||
/
|
/
|
||||||
/ The FF_FS_TIMEOUT defines timeout period in unit of time tick.
|
/ The FF_FS_TIMEOUT defines timeout period in unit of O/S time tick.
|
||||||
/ The FF_SYNC_t defines O/S dependent sync object type. e.g. HANDLE, ID, OS_EVENT*,
|
*/
|
||||||
/ SemaphoreHandle_t and etc. A header file for O/S definitions needs to be
|
|
||||||
/ included somewhere in the scope of ff.h. */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
27
stm-firmware/version.c
Normal file
27
stm-firmware/version.c
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/* Reflow Oven Controller
|
||||||
|
*
|
||||||
|
* Copyright (C) 2022 Mario Hüttel <mario.huettel@gmx.net>
|
||||||
|
*
|
||||||
|
* This file is part of the Reflow Oven Controller Project.
|
||||||
|
*
|
||||||
|
* The reflow oven controller is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* The Reflow Oven Control Firmware is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with the reflow oven controller project.
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <reflow-controller/version.h>
|
||||||
|
#include <generated-version/version.h>
|
||||||
|
|
||||||
|
const char *version_git_version_string = GIT_VERSION_STRING;
|
||||||
|
const char *version_git_full_commit_string = GIT_FULL_COMMIT;
|
||||||
|
const char *version_compile_date = __DATE__;
|
||||||
|
const char *version_compile_time = __TIME__;
|
Loading…
Reference in New Issue
Block a user