Files
RCU_C1P_Launcher/MCU_Driver/inc/bootload_fun.h
caocong 5e9338cee4 新增:串口通讯避障功能
​ 1、Launcher中的串口只使用串口0(调试串口)、串口2(主动RS485端口);串口1与串口3不使用,且不初始化。将串口通讯缓冲区修改为1100Byte。

​  目的:CH564由于将Launcher代码搬运到RAM中运行,因此可使用的变量大小只有32Kbyte。不使用的串口将不初始化,同时使用的通讯缓冲区将节约出来,否则RAM空间不够使用。

​ 2、串口2 - 增加RS485使能,同时通讯增加避障功能。
2026-01-19 16:39:22 +08:00

87 lines
2.5 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* launcher_fun.h
*
* Created on: Jul 28, 2025
* Author: cc
*/
#ifndef _BOOTLOAD_FUN_H_
#define _BOOTLOAD_FUN_H_
#include "ch564.h"
#include "uart.h"
#include "mcu_flash.h"
#define BCOMM_CMD_Handshake 0xC0
#define BCOMM_CMD_Jump 0xC1
#define BCOMM_CMD_SetInfo 0xC2
#define BCOMM_CMD_WriteFlash 0xC3
#define BCOMM_CMD_ReadFlash 0xC4
#define BCOMM_CMD_EraseFlash 0xC5
#define BCOMM_CMD_WriteEEPROM 0xC6
#define BCOMM_CMD_ReadEEPROM 0xC7
#define BCOMM_CMD_EraseEEPROM 0xC8
#define BCOMM_CMD_CheckData 0xC9
#define BCOMM_CMD_ReplySUCC 0x00
#define BCOMM_CMD_ReplyFAIL 0x01
#define BCOMM_ParaSize 4096
typedef enum
{
BCOMM_FMT_TXAddr,
BCOMM_FMT_SN,
BCOMM_FMT_TYPE,
BCOMM_FMT_RXAddr,
BCOMM_FMT_LEN_L,
BCOMM_FMT_LEN_H,
BCOMM_FMT_CKS,
BCOMM_FMT_CMD,
BCOMM_FMT_PARAM,
}BOOTLOAD_COMM_FMT_e;
#define UPDATE_RECORD_INFO_Size 0x28
typedef struct {
/* - 目前仔细想了一下外部的Flash写入需要记录的话需要在APP部分增加上记录才行
* - Launcher中可以做MCU Flash 写入次数统计因为从外部Flash中搬运的到MCU Flash中这个操作只在Launcher中进行操作
* - 但是外部Flash的数据写入 APP中也是可以写入的。
* - 暂不需要外部Flash 固件写入次数统计与配置写入统计
*
*
* */
uint32_t mcuflash_fw_count; //MCU flash 固件写入总次数
uint32_t mcuflash_fw_succ; //MCU flash 固件写入成功总次数
uint32_t mcuflash_fw_fail; //MCU flash 固件写入失败总次数
}UPDATE_RECORD_T;
extern G_SYS_FEATURE_T g_app_feature; //SPI Flash APP特征区
extern G_SYS_FEATURE_T g_mcu_app_feature; //MCU Flash APP特征区
extern G_SYS_FEATURE_T g_update_flag; //升级标志位
extern UPDATE_RECORD_T g_update_recode; //升级信息
extern uint8_t g_jump_flag; //跳转标志位
extern uint32_t g_Boot_Tick; //Boot时间戳 单位ms
extern uint32_t g_Boot_Time; //Boot时间 单位ms
uint16_t CRC16_Check(uint8_t * aStr, uint16_t len);
uint8_t Launcher_Uart_Upgrade_Process(UART_t *g_rev);
uint8_t Read_APP_Feature(void);
uint8_t MCU_APP_Write(void);
uint8_t SPIFLASH_Read_Update_Recode(UPDATE_RECORD_T *info);
uint8_t SPIFLASH_Write_Update_Recode(UPDATE_RECORD_T *info);
uint8_t SPIFLASH_Read_APP_Update_Flag_Info(G_SYS_FEATURE_T *feature_info);
uint8_t SPIFLASH_Write_APP_Upate_Flag_Info(G_SYS_FEATURE_T *flag_info);
#endif /* MCU_DRIVER_INC_LAUNCHER_FUN_H_ */