9ceb218f80
Co-authored-by: Cursor <cursoragent@cursor.com>
100 lines
2.5 KiB
C
100 lines
2.5 KiB
C
/**
|
|
* @file fatfs_init.h
|
|
* @brief FATFS 模块初始化兼容头文件(整合自 CCU601E_D)
|
|
*
|
|
* CCU621_M 的 BSP 没有独立的 app_fatfs 模块,FATFS 功能通过
|
|
* flash_file_mgr + externalflash + sdmmc 实现。
|
|
* 本头文件为从 CCU601E_D 移植的应用层代码提供兼容的 API 声明。
|
|
*/
|
|
|
|
#ifndef FATFS_INIT_H
|
|
#define FATFS_INIT_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include "publicdata/type.h"
|
|
#include "publicdata/public_define.h"
|
|
|
|
#define USE_FREERTOS_HEAP
|
|
#define USE_CACHE_MUTEX
|
|
|
|
#ifdef USE_FREERTOS_HEAP
|
|
#include "FreeRTOS.h"
|
|
#include "task.h"
|
|
#define CACHE_MALLOC(size) pvPortMalloc(size)
|
|
#define CACHE_FREE(ptr) vPortFree(ptr)
|
|
#else
|
|
#define CACHE_MALLOC(size) malloc(size)
|
|
#define CACHE_FREE(ptr) free(ptr)
|
|
#endif
|
|
|
|
#ifdef USE_CACHE_MUTEX
|
|
#include "semphr.h"
|
|
#define CACHE_MUTEX_CREATE() xSemaphoreCreateMutex()
|
|
#define CACHE_MUTEX_TAKE(mutex) xSemaphoreTake(mutex, portMAX_DELAY)
|
|
#define CACHE_MUTEX_GIVE(mutex) xSemaphoreGive(mutex)
|
|
#define CACHE_MUTEX_DELETE(mutex) vSemaphoreDelete(mutex)
|
|
#else
|
|
#define CACHE_MUTEX_CREATE() NULL
|
|
#define CACHE_MUTEX_TAKE(mutex) (void)0
|
|
#define CACHE_MUTEX_GIVE(mutex) (void)0
|
|
#define CACHE_MUTEX_DELETE(mutex) (void)0
|
|
#endif
|
|
|
|
#define FATFS_SHELL_RM_CAT_EN (0)
|
|
#define FATFS_FILE_ACTION_FLAG (0xFF)
|
|
#define FATFS_WRITE_DISABLE_TCP_DEBUG 0x10
|
|
|
|
#define FATFS_PRINT_EN (0)
|
|
|
|
#if FATFS_PRINT_EN
|
|
#define FATFS_PRINT(fmt, ...) printf(fmt, ##__VA_ARGS__)
|
|
#else
|
|
#define FATFS_PRINT(fmt, ...) do {} while(0)
|
|
#endif
|
|
|
|
typedef enum {
|
|
CACHE_TYPE_NONE = 0,
|
|
#if FATFS_ENABLE_LOG
|
|
CACHE_TYPE_LOG,
|
|
#endif
|
|
#if FATFS_ENABLE_CARD
|
|
CACHE_TYPE_CARD,
|
|
#endif
|
|
#if FATFS_ENABLE_FAULT
|
|
CACHE_TYPE_FAULT,
|
|
#endif
|
|
#if FATFS_ENABLE_ORDER
|
|
CACHE_TYPE_ORDER,
|
|
#endif
|
|
} CacheType;
|
|
|
|
void fatfs_init(void);
|
|
void fatfs_action(void);
|
|
|
|
#if FATFS_SHELL_RM_CAT_EN
|
|
U8_T u8_file_clear_action(U8_T u8_type, U8_T u8_action, U8_T u8_flag);
|
|
U8_T u8_file_set_cat_cmd(char *path);
|
|
U8_T u8_file_card_action(U8_T action, const char *card_num, U32_T balance);
|
|
#endif
|
|
|
|
U8_T cache_add_log(const char *format, ...);
|
|
U8_T cache_add_card(const char *card_num, U32_T balance);
|
|
U8_T cache_add_fault(const void *fault_data);
|
|
U8_T cache_add_order(const void *order_data);
|
|
void cache_process_all(void);
|
|
void cache_clear_all(void);
|
|
|
|
U8_T fatfs_set_write_disable_flag(U8_T flag_mask, U8_T enable);
|
|
U8_T fatfs_get_write_disable_flag(U8_T flag_mask);
|
|
|
|
void v_app_fatfs_log_real_file_name(char *fileName, int len, int pathEn);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* FATFS_INIT_H */
|