- 添加sendBackup方法用于在备份APP激活时发送确认消息 - 优化OTA跳转逻辑,在jumpToApplication中清除复位标志 - 修复move_app_data函数中数据源地址错误,从备份区域正确读取数据 - 在OTA流程中正确设置APP状态标志,确保应用验证状态管理 refactor(can): 清理调试代码和函数签名优化 - 移除调试用的printf语句和未使用的cstdio头文件 - 统一函数参数类型为u8和u32,提高代码一致性 - 优化CAN通信检查逻辑,移除冗余的调试输出 perf(ota): 优化OTA处理中的延时函数 - 将delay_1ms(1)改为delay_1us(100),提高延时精度 - 添加微秒级延时函数delay_1us实现 - 增加OTA超时时间从10秒到100秒 fix(ota): 修复OTA状态管理和错误处理 - 在各种错误情况下正确设置ota_state为OTA_STATE_IDLE - 在eraseApplicationArea中正确初始化APP状态标志 - 添加CRC校验失败时的调试输出选项 - 修复数据包大小验证逻辑
49 lines
1.3 KiB
C++
49 lines
1.3 KiB
C++
#ifndef _CAN_H
|
|
#define _CAN_H
|
|
|
|
#include <stdint.h>
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include "gd32c10x_can.h"
|
|
#include "stdint.h"
|
|
#include <stdio.h>
|
|
|
|
u8 can_gpio_init(void); // CAN引脚初始化
|
|
void canfd_config(void); // CANFD初始化
|
|
void can_dma_init(void); // CAN DMA初始化
|
|
void CAN0_RX0_IRQHandler(void); // CAN接收中断处理函数
|
|
void DMA0_Channel4_IRQHandler(void); // DMA通道4中断处理函数(CAN接收)
|
|
void DMA0_Channel5_IRQHandler(void); // DMA通道5中断处理函数(CAN发送)
|
|
/*!
|
|
\brief CAN通信类
|
|
\note 封装CAN发送和接收功能
|
|
*/
|
|
class CAN_transmiter {
|
|
|
|
private:
|
|
can_trasnmit_message_struct transmit_message; // 发送消息结构体
|
|
u8 transmit_mailbox = CAN_NOMAILBOX; // 初始化为无mailbox状态
|
|
u8 transmit_data[64]; // CANFD最大64字节
|
|
|
|
public:
|
|
// 添加构造函数声明
|
|
u8 init(void);
|
|
|
|
can_receive_message_struct receive_message; // 接收消息结构体
|
|
FlagStatus can0_receive_flag; // CAN0接收标志
|
|
FlagStatus can0_send_flag; // CAN0发送标志
|
|
|
|
void communication_check(); // 通信检查
|
|
u8 CANFD_AsyncSend(u32 ID, u8 length, u8 *data); // CANFD异步发送(使用DMA)
|
|
u8 sendDATA_ACK(u32 packet_num, bool if_success);
|
|
u8 sendDATA_ACK(u32 packet_num, u8 *data); // 恢复原函数签名
|
|
u8 sendBackup();
|
|
};
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif |