Initial commit: CCU621_M firmware project with BLE debug link support.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,333 @@
|
||||
/**
|
||||
* @file app_fatfs.c
|
||||
* @brief FATFS 文件系统 API 桩实现(功能待实现)
|
||||
*
|
||||
* 本文件为 app_fatfs.h 中声明的所有函数提供桩实现。
|
||||
* 所有函数返回"未实现"错误状态,待 FATFS 功能完整移植后再替换为真实实现。
|
||||
*/
|
||||
|
||||
#include "app_fatfs.h"
|
||||
#include <string.h>
|
||||
|
||||
/* 文件系统基础操作 */
|
||||
FS_Status fs_init(void)
|
||||
{
|
||||
return FS_STATUS_INIT_FAILED;
|
||||
}
|
||||
|
||||
FS_Status fs_deinit(void)
|
||||
{
|
||||
return FS_STATUS_OK;
|
||||
}
|
||||
|
||||
FS_Status fs_mount(const char *path)
|
||||
{
|
||||
(void)path;
|
||||
return FS_STATUS_FS_ERROR;
|
||||
}
|
||||
|
||||
FS_Status fs_unmount(const char *path)
|
||||
{
|
||||
(void)path;
|
||||
return FS_STATUS_OK;
|
||||
}
|
||||
|
||||
FS_Status fs_check_space(void)
|
||||
{
|
||||
return FS_STATUS_NO_SPACE;
|
||||
}
|
||||
|
||||
bool fs_get_is_mounted(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* 文件系统格式化 */
|
||||
FS_Status fs_format_drive(const char *drive_path)
|
||||
{
|
||||
(void)drive_path;
|
||||
return FS_STATUS_FS_ERROR;
|
||||
}
|
||||
|
||||
FS_Status fs_format_drive_fat16(const char *drive_path)
|
||||
{
|
||||
(void)drive_path;
|
||||
return FS_STATUS_FS_ERROR;
|
||||
}
|
||||
|
||||
/* 目录操作 */
|
||||
FS_Status fs_mkdir(const char *path)
|
||||
{
|
||||
(void)path;
|
||||
return FS_STATUS_FS_ERROR;
|
||||
}
|
||||
|
||||
FS_Status fs_dir_exists(const char *path, bool *exists)
|
||||
{
|
||||
(void)path;
|
||||
if (exists != NULL) {
|
||||
*exists = false;
|
||||
}
|
||||
return FS_STATUS_OK;
|
||||
}
|
||||
|
||||
FS_Status fs_list_dir(const char *path, FS_FileInfo *file_list, uint32_t *count, uint32_t max_count)
|
||||
{
|
||||
(void)path;
|
||||
(void)file_list;
|
||||
(void)max_count;
|
||||
if (count != NULL) {
|
||||
*count = 0;
|
||||
}
|
||||
return FS_STATUS_OK;
|
||||
}
|
||||
|
||||
/* 文件操作 */
|
||||
FS_Status fs_create_file(const char *path)
|
||||
{
|
||||
(void)path;
|
||||
return FS_STATUS_FS_ERROR;
|
||||
}
|
||||
|
||||
FS_Status fs_delete_file(const char *path)
|
||||
{
|
||||
(void)path;
|
||||
return FS_STATUS_FS_ERROR;
|
||||
}
|
||||
|
||||
FS_Status fs_file_exists(const char *path, bool *exists)
|
||||
{
|
||||
(void)path;
|
||||
if (exists != NULL) {
|
||||
*exists = false;
|
||||
}
|
||||
return FS_STATUS_OK;
|
||||
}
|
||||
|
||||
FS_Status fs_get_file_size(const char *path, uint32_t *size)
|
||||
{
|
||||
(void)path;
|
||||
if (size != NULL) {
|
||||
*size = 0;
|
||||
}
|
||||
return FS_STATUS_FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
FS_Status fs_get_file_info(const char *path, FS_FileInfo *info)
|
||||
{
|
||||
(void)path;
|
||||
if (info != NULL) {
|
||||
memset(info, 0, sizeof(*info));
|
||||
}
|
||||
return FS_STATUS_FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
FS_Status fs_rename_file(const char *old_path, const char *new_path)
|
||||
{
|
||||
(void)old_path;
|
||||
(void)new_path;
|
||||
return FS_STATUS_FS_ERROR;
|
||||
}
|
||||
|
||||
FS_Status fs_copy_file(const char *src_path, const char *dst_path)
|
||||
{
|
||||
(void)src_path;
|
||||
(void)dst_path;
|
||||
return FS_STATUS_FS_ERROR;
|
||||
}
|
||||
|
||||
/* 文件读写 */
|
||||
FS_Status fs_open(void *file, const char *path, uint8_t mode)
|
||||
{
|
||||
(void)file;
|
||||
(void)path;
|
||||
(void)mode;
|
||||
return FS_STATUS_FS_ERROR;
|
||||
}
|
||||
|
||||
FS_Status fs_close(void *file)
|
||||
{
|
||||
(void)file;
|
||||
return FS_STATUS_OK;
|
||||
}
|
||||
|
||||
FS_Status fs_read(void *file, void *buffer, uint32_t size, uint32_t *bytes_read)
|
||||
{
|
||||
(void)file;
|
||||
(void)buffer;
|
||||
(void)size;
|
||||
if (bytes_read != NULL) {
|
||||
*bytes_read = 0;
|
||||
}
|
||||
return FS_STATUS_READ_FAILED;
|
||||
}
|
||||
|
||||
FS_Status fs_write(void *file, const void *buffer, uint32_t size, uint32_t *bytes_written)
|
||||
{
|
||||
(void)file;
|
||||
(void)buffer;
|
||||
(void)size;
|
||||
if (bytes_written != NULL) {
|
||||
*bytes_written = 0;
|
||||
}
|
||||
return FS_STATUS_WRITE_FAILED;
|
||||
}
|
||||
|
||||
FS_Status fs_seek(void *file, uint32_t offset)
|
||||
{
|
||||
(void)file;
|
||||
(void)offset;
|
||||
return FS_STATUS_FS_ERROR;
|
||||
}
|
||||
|
||||
FS_Status fs_truncate(void *file)
|
||||
{
|
||||
(void)file;
|
||||
return FS_STATUS_FS_ERROR;
|
||||
}
|
||||
|
||||
FS_Status fs_sync(void *file)
|
||||
{
|
||||
(void)file;
|
||||
return FS_STATUS_OK;
|
||||
}
|
||||
|
||||
/* 文件内容操作 */
|
||||
FS_Status fs_read_file_content(const char *path, char *buffer, uint32_t buffer_size, FS_ReadRange *range)
|
||||
{
|
||||
(void)path;
|
||||
(void)buffer;
|
||||
(void)buffer_size;
|
||||
if (range != NULL) {
|
||||
range->actual_read = 0;
|
||||
}
|
||||
return FS_STATUS_READ_FAILED;
|
||||
}
|
||||
|
||||
FS_Status fs_write_file_content(const char *path, const void *data, uint32_t size, bool append)
|
||||
{
|
||||
(void)path;
|
||||
(void)data;
|
||||
(void)size;
|
||||
(void)append;
|
||||
return FS_STATUS_WRITE_FAILED;
|
||||
}
|
||||
|
||||
FS_Status fs_write_string(const char *path, const char *str, bool append)
|
||||
{
|
||||
(void)path;
|
||||
(void)str;
|
||||
(void)append;
|
||||
return FS_STATUS_WRITE_FAILED;
|
||||
}
|
||||
|
||||
/* 文件系统信息 */
|
||||
FS_Status fs_get_volume_info(const char *path, uint32_t *total_kb, uint32_t *free_kb, float *usage_percent)
|
||||
{
|
||||
(void)path;
|
||||
if (total_kb != NULL) *total_kb = 0;
|
||||
if (free_kb != NULL) *free_kb = 0;
|
||||
if (usage_percent != NULL) *usage_percent = 0.0f;
|
||||
return FS_STATUS_FS_ERROR;
|
||||
}
|
||||
|
||||
/* 通用文件管理 */
|
||||
FS_Status fs_file_manager_check_and_roll_ex(const FileManagerConfig *config, const char *current_file,
|
||||
uint32_t pending_write_size, char *new_filename, uint32_t new_filename_len)
|
||||
{
|
||||
(void)config;
|
||||
(void)current_file;
|
||||
(void)pending_write_size;
|
||||
(void)new_filename;
|
||||
(void)new_filename_len;
|
||||
return FS_STATUS_FS_ERROR;
|
||||
}
|
||||
|
||||
FS_Status fs_file_manager_create_new(const FileManagerConfig *config, char *new_filename, uint32_t max_len)
|
||||
{
|
||||
(void)config;
|
||||
if (new_filename != NULL && max_len > 0) new_filename[0] = '\0';
|
||||
return FS_STATUS_FS_ERROR;
|
||||
}
|
||||
|
||||
FS_Status fs_file_manager_ensure_dir_exists(const FileManagerConfig *config)
|
||||
{
|
||||
(void)config;
|
||||
return FS_STATUS_FS_ERROR;
|
||||
}
|
||||
|
||||
FS_Status fs_file_manager_get_count(const FileManagerConfig *config, uint32_t *count)
|
||||
{
|
||||
(void)config;
|
||||
if (count != NULL) *count = 0;
|
||||
return FS_STATUS_OK;
|
||||
}
|
||||
|
||||
FS_Status fs_file_manager_delete_oldest(const FileManagerConfig *config)
|
||||
{
|
||||
(void)config;
|
||||
return FS_STATUS_FS_ERROR;
|
||||
}
|
||||
|
||||
FS_Status fs_file_manager_find_latest(const FileManagerConfig *config, char *filename, uint32_t max_len)
|
||||
{
|
||||
(void)config;
|
||||
if (filename != NULL && max_len > 0) filename[0] = '\0';
|
||||
return FS_STATUS_FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
FS_Status fs_file_manager_find_oldest(const FileManagerConfig *config, char *filename, uint32_t max_len)
|
||||
{
|
||||
(void)config;
|
||||
if (filename != NULL && max_len > 0) filename[0] = '\0';
|
||||
return FS_STATUS_FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
FS_Status fs_file_manager_resolve_log_append_path(const FileManagerConfig *config, char *filename, uint32_t max_len)
|
||||
{
|
||||
(void)config;
|
||||
if (filename != NULL && max_len > 0) filename[0] = '\0';
|
||||
return FS_STATUS_FS_ERROR;
|
||||
}
|
||||
|
||||
void fs_log_set_filename_start_seq(uint8_t start_seq)
|
||||
{
|
||||
(void)start_seq;
|
||||
}
|
||||
|
||||
FS_Status fs_generate_timestamp_filename(const FileManagerConfig *config, char *filename, uint32_t max_len)
|
||||
{
|
||||
(void)config;
|
||||
if (filename != NULL && max_len > 0) filename[0] = '\0';
|
||||
return FS_STATUS_FS_ERROR;
|
||||
}
|
||||
|
||||
bool fs_is_filename_valid(const char *filename, const FileManagerConfig *config)
|
||||
{
|
||||
(void)filename;
|
||||
(void)config;
|
||||
return false;
|
||||
}
|
||||
|
||||
FS_Status fs_cleanup_invalid_files(const FileManagerConfig *config)
|
||||
{
|
||||
(void)config;
|
||||
return FS_STATUS_OK;
|
||||
}
|
||||
|
||||
uint32_t fs_get_current_fat_time(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
FS_Status fs_get_current_time_string(char *buffer, uint32_t size)
|
||||
{
|
||||
if (buffer != NULL && size > 0) buffer[0] = '\0';
|
||||
return FS_STATUS_FS_ERROR;
|
||||
}
|
||||
|
||||
FS_Status fs_get_formatted_time_string(char *buffer, uint32_t size)
|
||||
{
|
||||
if (buffer != NULL && size > 0) buffer[0] = '\0';
|
||||
return FS_STATUS_FS_ERROR;
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
/**
|
||||
* @file app_fatfs.h
|
||||
* @brief FATFS 文件系统兼容头文件(整合自 CCU601E_D)
|
||||
*
|
||||
* CCU621_M 平台:FATFS 功能由 flash_file_mgr + externalflash + sdmmc 共同实现。
|
||||
* 本头文件为从 CCU601E_D 移植的应用层代码提供兼容的类型和 API 声明。
|
||||
*/
|
||||
|
||||
#ifndef APP_FATFS_H
|
||||
#define APP_FATFS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "publicdata/type.h"
|
||||
#include "publicdata/public_define.h"
|
||||
|
||||
#define FS_PATH_LEN 64
|
||||
#define FS_FILE_NAME_LEN 32
|
||||
#define FS_READ_BUF_SIZE 512
|
||||
|
||||
#define LOG_DIR_PATH "0:/log"
|
||||
#define LOG_FILE_MAX_SIZE (2*1024*1024)
|
||||
#define LOG_FILE_MAX_COUNT 3
|
||||
#define LOG_MAX_FILES 20
|
||||
|
||||
#if FATFS_ENABLE_FAULT
|
||||
#define FAULT_DIR_PATH "0:/fault"
|
||||
#define FAULT_FILE_MAX_SIZE (1024*500)
|
||||
#define FAULT_FILE_MAX_COUNT 2
|
||||
#define FAULT_MAX_FILES 20
|
||||
#endif
|
||||
|
||||
#if FATFS_ENABLE_ORDER
|
||||
#define ORDER_DIR_PATH "0:/order"
|
||||
#define ORDER_FILE_MAX_SIZE (1024*500)
|
||||
#define ORDER_FILE_MAX_COUNT 2
|
||||
#define ORDER_MAX_FILES 20
|
||||
#endif
|
||||
|
||||
#define LOG_SYNC_INTERVAL 10
|
||||
|
||||
typedef enum {
|
||||
FS_STATUS_OK = 0,
|
||||
FS_STATUS_INIT_FAILED,
|
||||
FS_STATUS_FS_ERROR,
|
||||
FS_STATUS_FILE_FULL,
|
||||
FS_STATUS_WRITE_FAILED,
|
||||
FS_STATUS_READ_FAILED,
|
||||
FS_STATUS_FILE_NOT_FOUND,
|
||||
FS_STATUS_PARAM_ERROR,
|
||||
FS_STATUS_NO_SPACE
|
||||
} FS_Status;
|
||||
|
||||
typedef struct {
|
||||
char name[FS_FILE_NAME_LEN];
|
||||
uint32_t size;
|
||||
uint16_t year;
|
||||
uint8_t month;
|
||||
uint8_t day;
|
||||
uint8_t hour;
|
||||
uint8_t minute;
|
||||
uint8_t second;
|
||||
} FS_FileInfo;
|
||||
|
||||
typedef struct {
|
||||
uint32_t start_pos;
|
||||
uint32_t end_pos;
|
||||
uint32_t actual_read;
|
||||
} FS_ReadRange;
|
||||
|
||||
typedef enum {
|
||||
FILE_TYPE_LOG = 0,
|
||||
FILE_TYPE_FAULT,
|
||||
FILE_TYPE_ORDER,
|
||||
FILE_TYPE_MAX
|
||||
} FileType;
|
||||
|
||||
typedef struct {
|
||||
FileType type;
|
||||
const char *dir_path;
|
||||
const char *file_prefix;
|
||||
const char *file_extension;
|
||||
uint32_t max_file_size;
|
||||
uint32_t max_file_count;
|
||||
} FileManagerConfig;
|
||||
|
||||
/* 文件系统基础操作 */
|
||||
FS_Status fs_init(void);
|
||||
FS_Status fs_deinit(void);
|
||||
FS_Status fs_mount(const char *path);
|
||||
FS_Status fs_unmount(const char *path);
|
||||
FS_Status fs_check_space(void);
|
||||
bool fs_get_is_mounted(void);
|
||||
|
||||
/* 文件系统格式化 */
|
||||
FS_Status fs_format_drive(const char *drive_path);
|
||||
FS_Status fs_format_drive_fat16(const char *drive_path);
|
||||
|
||||
/* 目录操作 */
|
||||
FS_Status fs_mkdir(const char *path);
|
||||
FS_Status fs_dir_exists(const char *path, bool *exists);
|
||||
FS_Status fs_list_dir(const char *path, FS_FileInfo *file_list, uint32_t *count, uint32_t max_count);
|
||||
|
||||
/* 文件操作 */
|
||||
FS_Status fs_create_file(const char *path);
|
||||
FS_Status fs_delete_file(const char *path);
|
||||
FS_Status fs_file_exists(const char *path, bool *exists);
|
||||
FS_Status fs_get_file_size(const char *path, uint32_t *size);
|
||||
FS_Status fs_get_file_info(const char *path, FS_FileInfo *info);
|
||||
FS_Status fs_rename_file(const char *old_path, const char *new_path);
|
||||
FS_Status fs_copy_file(const char *src_path, const char *dst_path);
|
||||
|
||||
/* 文件读写(FatFs FIL 类型用 void* 代理,避免引入 ff.h) */
|
||||
FS_Status fs_open(void *file, const char *path, uint8_t mode);
|
||||
FS_Status fs_close(void *file);
|
||||
FS_Status fs_read(void *file, void *buffer, uint32_t size, uint32_t *bytes_read);
|
||||
FS_Status fs_write(void *file, const void *buffer, uint32_t size, uint32_t *bytes_written);
|
||||
FS_Status fs_seek(void *file, uint32_t offset);
|
||||
FS_Status fs_truncate(void *file);
|
||||
FS_Status fs_sync(void *file);
|
||||
|
||||
/* 文件内容操作 */
|
||||
FS_Status fs_read_file_content(const char *path, char *buffer, uint32_t buffer_size, FS_ReadRange *range);
|
||||
FS_Status fs_write_file_content(const char *path, const void *data, uint32_t size, bool append);
|
||||
FS_Status fs_write_string(const char *path, const char *str, bool append);
|
||||
|
||||
/* 文件系统信息 */
|
||||
FS_Status fs_get_volume_info(const char *path, uint32_t *total_kb, uint32_t *free_kb, float *usage_percent);
|
||||
|
||||
/* 通用文件管理 */
|
||||
FS_Status fs_file_manager_check_and_roll_ex(const FileManagerConfig *config, const char *current_file,
|
||||
uint32_t pending_write_size, char *new_filename, uint32_t new_filename_len);
|
||||
FS_Status fs_file_manager_create_new(const FileManagerConfig *config, char *new_filename, uint32_t max_len);
|
||||
FS_Status fs_file_manager_ensure_dir_exists(const FileManagerConfig *config);
|
||||
FS_Status fs_file_manager_get_count(const FileManagerConfig *config, uint32_t *count);
|
||||
FS_Status fs_file_manager_delete_oldest(const FileManagerConfig *config);
|
||||
FS_Status fs_file_manager_find_latest(const FileManagerConfig *config, char *filename, uint32_t max_len);
|
||||
FS_Status fs_file_manager_find_oldest(const FileManagerConfig *config, char *filename, uint32_t max_len);
|
||||
FS_Status fs_file_manager_resolve_log_append_path(const FileManagerConfig *config, char *filename, uint32_t max_len);
|
||||
void fs_log_set_filename_start_seq(uint8_t start_seq);
|
||||
FS_Status fs_generate_timestamp_filename(const FileManagerConfig *config, char *filename, uint32_t max_len);
|
||||
bool fs_is_filename_valid(const char *filename, const FileManagerConfig *config);
|
||||
FS_Status fs_cleanup_invalid_files(const FileManagerConfig *config);
|
||||
uint32_t fs_get_current_fat_time(void);
|
||||
FS_Status fs_get_current_time_string(char *buffer, uint32_t size);
|
||||
FS_Status fs_get_formatted_time_string(char *buffer, uint32_t size);
|
||||
|
||||
extern const FileManagerConfig g_log_file_config;
|
||||
#if FATFS_ENABLE_FAULT
|
||||
extern const FileManagerConfig g_fault_file_config;
|
||||
#endif
|
||||
#if FATFS_ENABLE_ORDER
|
||||
extern const FileManagerConfig g_order_file_config;
|
||||
#endif
|
||||
|
||||
#endif /* APP_FATFS_H */
|
||||
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* @file fatfs_card.h
|
||||
* @brief 卡号白名单兼容头文件(整合自 CCU601E_D)
|
||||
*
|
||||
* 实际存储由 flash_file_mgr/card_flash_impl 通过 EEPROM + SPI Flash 实现。
|
||||
*/
|
||||
|
||||
#ifndef FATFS_CARD_H
|
||||
#define FATFS_CARD_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define CARD_DIR_PATH "0:/card"
|
||||
#define CARD_FILE_NAME "card_data.csv"
|
||||
#define CARD_NUM_MAX_LEN 32
|
||||
#define CARD_MAX_COUNT 595
|
||||
|
||||
typedef struct {
|
||||
char card_num[CARD_NUM_MAX_LEN];
|
||||
uint32_t balance;
|
||||
uint32_t create_time;
|
||||
uint32_t last_use_time;
|
||||
uint16_t status;
|
||||
uint8_t reserved[8];
|
||||
} CardInfo;
|
||||
|
||||
typedef enum {
|
||||
CARD_STATUS_OK = 0,
|
||||
CARD_STATUS_INIT_FAILED,
|
||||
CARD_STATUS_FS_ERROR,
|
||||
CARD_STATUS_FILE_FULL,
|
||||
CARD_STATUS_WRITE_FAILED,
|
||||
CARD_STATUS_READ_FAILED,
|
||||
CARD_STATUS_FILE_NOT_FOUND,
|
||||
CARD_STATUS_PARAM_ERROR,
|
||||
CARD_STATUS_NO_SPACE,
|
||||
CARD_STATUS_CARD_EXIST,
|
||||
CARD_STATUS_CARD_NOT_FOUND,
|
||||
CARD_STATUS_ALREADY_INIT
|
||||
} CardStatus;
|
||||
|
||||
CardStatus card_init(void);
|
||||
void card_deinit(void);
|
||||
CardStatus card_add(const CardInfo *card_info);
|
||||
CardStatus card_update(const CardInfo *card_info);
|
||||
CardStatus card_delete(const char *card_num);
|
||||
CardStatus card_find(const char *card_num, CardInfo *card_info);
|
||||
CardStatus card_get_count(uint32_t *count);
|
||||
CardStatus card_get_all(CardInfo *card_list, uint32_t *count, uint32_t max_count);
|
||||
CardStatus card_check_exist(const char *card_num, bool *exist);
|
||||
|
||||
CardStatus card_backup(void);
|
||||
CardStatus card_restore(void);
|
||||
CardStatus card_clear_all(void);
|
||||
|
||||
#endif /* FATFS_CARD_H */
|
||||
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* @file fatfs_fault.h
|
||||
* @brief FATFS 故障记录模块兼容头文件
|
||||
*/
|
||||
#ifndef FATFS_FAULT_H
|
||||
#define FATFS_FAULT_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* Fault module placeholder — fault storage is handled by flash_file_mgr/fault_flash_impl */
|
||||
|
||||
#endif /* FATFS_FAULT_H */
|
||||
@@ -0,0 +1,100 @@
|
||||
/**
|
||||
* @file fatfs_init.c
|
||||
* @brief FATFS 初始化模块桩实现(功能待实现)
|
||||
*
|
||||
* 本文件为 fatfs_init.h 中声明的函数提供桩实现。
|
||||
* 所有函数提供安全默认行为,待 FATFS 功能完整移植后再替换为真实实现。
|
||||
*/
|
||||
|
||||
#include "fatfs_init.h"
|
||||
#include <stddef.h>
|
||||
|
||||
void fatfs_init(void)
|
||||
{
|
||||
/* FATFS 尚未初始化 */
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
(void)u8_type;
|
||||
(void)u8_action;
|
||||
(void)u8_flag;
|
||||
return 0;
|
||||
}
|
||||
|
||||
U8_T u8_file_set_cat_cmd(char *path)
|
||||
{
|
||||
(void)path;
|
||||
return 0;
|
||||
}
|
||||
|
||||
U8_T u8_file_card_action(U8_T action, const char *card_num, U32_T balance)
|
||||
{
|
||||
(void)action;
|
||||
(void)card_num;
|
||||
(void)balance;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
U8_T cache_add_log(const char *format, ...)
|
||||
{
|
||||
(void)format;
|
||||
return 0;
|
||||
}
|
||||
|
||||
U8_T cache_add_card(const char *card_num, U32_T balance)
|
||||
{
|
||||
(void)card_num;
|
||||
(void)balance;
|
||||
return 0;
|
||||
}
|
||||
|
||||
U8_T cache_add_fault(const void *fault_data)
|
||||
{
|
||||
(void)fault_data;
|
||||
return 0;
|
||||
}
|
||||
|
||||
U8_T cache_add_order(const void *order_data)
|
||||
{
|
||||
(void)order_data;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cache_process_all(void)
|
||||
{
|
||||
/* 无缓存数据待处理 */
|
||||
}
|
||||
|
||||
void cache_clear_all(void)
|
||||
{
|
||||
/* 无缓存数据待清除 */
|
||||
}
|
||||
|
||||
U8_T fatfs_set_write_disable_flag(U8_T flag_mask, U8_T enable)
|
||||
{
|
||||
(void)flag_mask;
|
||||
(void)enable;
|
||||
return 0;
|
||||
}
|
||||
|
||||
U8_T fatfs_get_write_disable_flag(U8_T flag_mask)
|
||||
{
|
||||
(void)flag_mask;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void v_app_fatfs_log_real_file_name(char *fileName, int len, int pathEn)
|
||||
{
|
||||
if (fileName != NULL && len > 0) {
|
||||
fileName[0] = '\0';
|
||||
}
|
||||
(void)pathEn;
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/**
|
||||
* @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 */
|
||||
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* @file fatfs_log.h
|
||||
* @brief FATFS 日志模块兼容头文件
|
||||
*/
|
||||
#ifndef FATFS_LOG_H
|
||||
#define FATFS_LOG_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* Log module placeholder — log storage is handled by flash_file_mgr */
|
||||
void fatfs_log_init(void);
|
||||
void fatfs_log_write(const char *format, ...);
|
||||
|
||||
#endif /* FATFS_LOG_H */
|
||||
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* @file fatfs_order.h
|
||||
* @brief FATFS 充电订单模块兼容头文件
|
||||
*/
|
||||
#ifndef FATFS_ORDER_H
|
||||
#define FATFS_ORDER_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* Order module placeholder — order storage is handled by flash_file_mgr/unsettled_order_mng */
|
||||
|
||||
#endif /* FATFS_ORDER_H */
|
||||
Reference in New Issue
Block a user