编码转换: GBK -> UTF-8,所有.c/.h源文件中文注释统一UTF-8编码

This commit is contained in:
wangfq
2026-07-20 09:07:46 +08:00
parent b1637a13be
commit 8157ce41bd
62 changed files with 1969 additions and 1969 deletions
+43 -43
View File
@@ -3,7 +3,7 @@
* Author : WCH
* Version : V1.10
* Date : 2018/12/14
* Description : oad相关配置定义
* Description : oad相关配置定义
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
@@ -19,18 +19,18 @@
* ------------------------------------------------------------------------------------------------
*/
/* 整个用户code区分成四块,依次为4K,44K,16K,128K 后三块分别叫做imageAAPP),imageBIAP),LIB */
/* 整个用户code区分成四块,依次为4K,44K,16K,128K 后三块分别叫做imageAAPP),imageBIAP),LIB */
/* FLASH定义 */
/* FLASH定义 */
#define FLASH_BLOCK_SIZE EEPROM_BLOCK_SIZE
/* imageA定义 */
/* imageA定义 */
#define IMAGE_A_FLAG 0x01
#define IMAGE_A_START_ADD 0x1000
#define IMAGE_A_SIZE 44 * 1024
/* imageB定义 */
/* imageB定义 */
#define IMAGE_B_FLAG 0x02
#define IMAGE_B_START_ADD (IMAGE_A_START_ADD + IMAGE_A_SIZE)
#define IMAGE_B_SIZE 16 * 1024
@@ -39,72 +39,72 @@
#define jumpApp ((void (*)(void))((uint32_t *)IMAGE_A_START_ADD))
/* IAP定义 */
/* 以下为IAP下载命令定义 */
#define CMD_IAP_PROM 0x80 // IAP编程命令
#define CMD_IAP_ERASE 0x81 // IAP擦除命令
#define CMD_IAP_VERIFY 0x82 // IAP校验命令
#define CMD_IAP_END 0x83 // IAP结束标志
#define CMD_IAP_INFO 0x84 // IAP获取设备信息
/* IAP定义 */
/* 以下为IAP下载命令定义 */
#define CMD_IAP_PROM 0x80 // IAP编程命令
#define CMD_IAP_ERASE 0x81 // IAP擦除命令
#define CMD_IAP_VERIFY 0x82 // IAP校验命令
#define CMD_IAP_END 0x83 // IAP结束标志
#define CMD_IAP_INFO 0x84 // IAP获取设备信息
/* 数据帧长度定义 */
/* 数据帧长度定义 */
#define IAP_LEN 247
/* 存放在DataFlash地址,不能占用蓝牙的位置 */
/* 存放在DataFlash地址,不能占用蓝牙的位置 */
#define OTA_DATAFLASH_ADD 0x00077000 - FLASH_ROM_MAX_SIZE
/* 存放在DataFlash里的OTA信息 */
/* 存放在DataFlash里的OTA信息 */
typedef struct
{
unsigned char ImageFlag; //记录的当前的image标志
unsigned char ImageFlag; //记录的当前的image标志
unsigned char Revd[3];
} OTADataFlashInfo_t;
/* OTA IAP通讯协议定义 */
/* 地址使用4倍偏移 */
/* OTA IAP通讯协议定义 */
/* 地址使用4倍偏移 */
typedef union
{
struct
{
unsigned char cmd; /* 命令码 0x81 */
unsigned char len; /* 后续数据长度 */
unsigned char addr[2]; /* 擦除地址 */
unsigned char block_num[2]; /* 擦除块数 */
unsigned char cmd; /* 命令码 0x81 */
unsigned char len; /* 后续数据长度 */
unsigned char addr[2]; /* 擦除地址 */
unsigned char block_num[2]; /* 擦除块数 */
} erase; /* 擦除命令 */
} erase; /* 擦除命令 */
struct
{
unsigned char cmd; /* 命令码 0x83 */
unsigned char len; /* 后续数据长度 */
unsigned char status[2]; /* 两字节状态,保留 */
} end; /* 结束命令 */
unsigned char cmd; /* 命令码 0x83 */
unsigned char len; /* 后续数据长度 */
unsigned char status[2]; /* 两字节状态,保留 */
} end; /* 结束命令 */
struct
{
unsigned char cmd; /* 命令码 0x82 */
unsigned char len; /* 后续数据长度 */
unsigned char addr[2]; /* 校验地址 */
unsigned char buf[IAP_LEN - 4]; /* 校验数据 */
} verify; /* 校验命令 */
unsigned char cmd; /* 命令码 0x82 */
unsigned char len; /* 后续数据长度 */
unsigned char addr[2]; /* 校验地址 */
unsigned char buf[IAP_LEN - 4]; /* 校验数据 */
} verify; /* 校验命令 */
struct
{
unsigned char cmd; /* 命令码 0x80 */
unsigned char len; /* 后续数据长度 */
unsigned char addr[2]; /* 地址 */
unsigned char buf[IAP_LEN - 4]; /* 后续数据 */
} program; /* 编程命令 */
unsigned char cmd; /* 命令码 0x80 */
unsigned char len; /* 后续数据长度 */
unsigned char addr[2]; /* 地址 */
unsigned char buf[IAP_LEN - 4]; /* 后续数据 */
} program; /* 编程命令 */
struct
{
unsigned char cmd; /* 命令码 0x84 */
unsigned char len; /* 后续数据长度 */
unsigned char buf[IAP_LEN - 2]; /* 后续数据 */
} info; /* 编程命令 */
unsigned char cmd; /* 命令码 0x84 */
unsigned char len; /* 后续数据长度 */
unsigned char buf[IAP_LEN - 2]; /* 后续数据 */
} info; /* 编程命令 */
struct
{
unsigned char buf[IAP_LEN]; /* 接收数据包*/
unsigned char buf[IAP_LEN]; /* 接收数据包*/
} other;
} OTA_IAP_CMD_t;
/* 记录当前的Image */
/* 记录当前的Image */
extern unsigned char CurrImageFlag;
#endif
@@ -28,7 +28,7 @@ extern "C" {
// Simple BLE Peripheral Task Events
#define SBP_START_DEVICE_EVT 0x0001
#define SBP_PERIODIC_EVT 0x0002
#define OTA_FLASH_ERASE_EVT 0x0004 //OTA Flash²Á³ýÈÎÎñ
#define OTA_FLASH_ERASE_EVT 0x0004 //OTA Flash擦除任务
/*********************************************************************
* MACROS
+46 -46
View File
@@ -3,7 +3,7 @@
* Author : WCH
* Version : V1.0
* Date : 2018/12/10
* Description : 外设从机应用程序,初始化广播连接参数,然后广播,直至连接主机后,通过自定义服务传输数据
* Description : 外设从机应用程序,初始化广播连接参数,然后广播,直至连接主机后,通过自定义服务传输数据
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
@@ -128,26 +128,26 @@ static uint8_t advertData[] = {
static uint8_t attDeviceName[GAP_DEVICE_NAME_LEN] = "OTAOTA_OTAOTA_OTA";
// OTA IAP VARIABLES
/* OTA通讯的帧 */
/* OTA通讯的帧 */
OTA_IAP_CMD_t iap_rec_data;
/* OTA解析结果 */
/* OTA解析结果 */
uint32_t OpParaDataLen = 0;
uint32_t OpAdd = 0;
/* flash的数据临时存储 */
/* flash的数据临时存储 */
__attribute__((aligned(8))) uint8_t block_buf[16];
/* Image跳转函数地址定义 */
/* Image跳转函数地址定义 */
typedef int (*pImageTaskFn)(void);
pImageTaskFn user_image_tasks;
/* Flash 擦除过程 */
uint32_t EraseAdd = 0; //擦除地址
uint32_t EraseBlockNum = 0; //需要擦除的块数
uint32_t EraseBlockCnt = 0; //擦除的块计数
/* Flash 擦除过程 */
uint32_t EraseAdd = 0; //擦除地址
uint32_t EraseBlockNum = 0; //需要擦除的块数
uint32_t EraseBlockCnt = 0; //擦除的块计数
/* FLASH 校验过程 */
/* FLASH 校验过程 */
uint8_t VerifyStatus = 0;
/*********************************************************************
@@ -312,7 +312,7 @@ uint16_t Peripheral_ProcessEvent(uint8_t task_id, uint16_t events)
PRINT("ERASE:%08x num:%d\r\n", (int)(EraseAdd + EraseBlockCnt * FLASH_BLOCK_SIZE), (int)EraseBlockCnt);
status = FLASH_ROM_ERASE(EraseAdd + EraseBlockCnt * FLASH_BLOCK_SIZE, FLASH_BLOCK_SIZE);
/* 擦除失败 */
/* 擦除失败 */
if(status != SUCCESS)
{
OTA_IAP_SendCMDDealSta(status);
@@ -321,7 +321,7 @@ uint16_t Peripheral_ProcessEvent(uint8_t task_id, uint16_t events)
EraseBlockCnt++;
/* 擦除结束 */
/* 擦除结束 */
if(EraseBlockCnt >= EraseBlockNum)
{
PRINT("ERASE Complete\r\n");
@@ -438,10 +438,10 @@ static void performPeriodicTask(void)
/*********************************************************************
* @fn OTA_IAP_SendData
*
* @brief OTA IAP发送数据,使用时限制20字节以内
* @brief OTA IAP发送数据,使用时限制20字节以内
*
* @param p_send_data - 发送数据的指针
* @param send_len - 发送数据的长度
* @param p_send_data - 发送数据的指针
* @param send_len - 发送数据的长度
*
* @return none
*/
@@ -453,9 +453,9 @@ void OTA_IAP_SendData(uint8_t *p_send_data, uint8_t send_len)
/*********************************************************************
* @fn OTA_IAP_SendCMDDealSta
*
* @brief OTA IAP执行的状态返回
* @brief OTA IAP执行的状态返回
*
* @param deal_status - 返回的状态
* @param deal_status - 返回的状态
*
* @return none
*/
@@ -471,7 +471,7 @@ void OTA_IAP_SendCMDDealSta(uint8_t deal_status)
/*********************************************************************
* @fn OTA_IAP_CMDErrDeal
*
* @brief OTA IAP异常命令码处理
* @brief OTA IAP异常命令码处理
*
* @return none
*/
@@ -483,9 +483,9 @@ void OTA_IAP_CMDErrDeal(void)
/*********************************************************************
* @fn SwitchImageFlag
*
* @brief 切换dataflash里的ImageFlag
* @brief 切换dataflash里的ImageFlag
*
* @param new_flag - 切换的ImageFlag
* @param new_flag - 切换的ImageFlag
*
* @return none
*/
@@ -494,23 +494,23 @@ void SwitchImageFlag(uint8_t new_flag)
uint16_t i;
uint32_t ver_flag;
/* 读取第一块 */
/* 读取第一块 */
EEPROM_READ(OTA_DATAFLASH_ADD, (uint32_t *)&block_buf[0], 4);
/* 擦除第一块 */
/* 擦除第一块 */
EEPROM_ERASE(OTA_DATAFLASH_ADD, EEPROM_PAGE_SIZE);
/* 更新Image信息 */
/* 更新Image信息 */
block_buf[0] = new_flag;
/* 编程DataFlash */
/* 编程DataFlash */
EEPROM_WRITE(OTA_DATAFLASH_ADD, (uint32_t *)&block_buf[0], 4);
}
/*********************************************************************
* @fn DisableAllIRQ
*
* @brief 关闭所有的中断
* @brief 关闭所有的中断
*
* @return none
*/
@@ -522,7 +522,7 @@ void DisableAllIRQ(void)
/*********************************************************************
* @fn Rec_OTA_IAP_DataDeal
*
* @brief 接收到OTA数据包处理
* @brief 接收到OTA数据包处理
*
* @return none
*/
@@ -530,7 +530,7 @@ void Rec_OTA_IAP_DataDeal(void)
{
switch(iap_rec_data.other.buf[0])
{
/* 编程 */
/* 编程 */
case CMD_IAP_PROM:
{
uint32_t i;
@@ -543,12 +543,12 @@ void Rec_OTA_IAP_DataDeal(void)
PRINT("IAP_PROM: %08x len:%d \r\n", (int)OpAdd, (int)OpParaDataLen);
/* 当前是ImageA,直接编程 */
/* 当前是ImageA,直接编程 */
status = FLASH_ROM_WRITE(OpAdd, iap_rec_data.program.buf, (uint16_t)OpParaDataLen);
OTA_IAP_SendCMDDealSta(status);
break;
}
/* 擦除 -- 蓝牙擦除由主机控制 */
/* 擦除 -- 蓝牙擦除由主机控制 */
case CMD_IAP_ERASE:
{
OpAdd = (uint32_t)(iap_rec_data.erase.addr[0]);
@@ -560,7 +560,7 @@ void Rec_OTA_IAP_DataDeal(void)
EraseAdd = OpAdd;
EraseBlockCnt = 0;
/* 检验就放在擦除里清0 */
/* 检验就放在擦除里清0 */
VerifyStatus = 0;
PRINT("IAP_ERASE start:%08x num:%d\r\n", (int)OpAdd, (int)EraseBlockNum);
@@ -571,15 +571,15 @@ void Rec_OTA_IAP_DataDeal(void)
}
else
{
/* 修改DataFlash,切换至ImageB */
/* 修改DataFlash,切换至ImageB */
SwitchImageFlag(IMAGE_B_FLAG);
/* 启动擦除 */
/* 启动擦除 */
tmos_set_event(Peripheral_TaskID, OTA_FLASH_ERASE_EVT);
}
break;
}
/* 校验 */
/* 校验 */
case CMD_IAP_VERIFY:
{
uint32_t i;
@@ -598,22 +598,22 @@ void Rec_OTA_IAP_DataDeal(void)
OTA_IAP_SendCMDDealSta(VerifyStatus);
break;
}
/* 编程结束 */
/* 编程结束 */
case CMD_IAP_END:
{
PRINT("IAP_END \r\n");
/* 关闭当前所有使用中断,或者方便一点直接全部关闭 */
/* 关闭当前所有使用中断,或者方便一点直接全部关闭 */
DisableAllIRQ();
/* 修改DataFlash,切换至ImageA */
/* 修改DataFlash,切换至ImageA */
SwitchImageFlag(IMAGE_A_FLAG);
/* 等待打印完成 ,跳转ImageB*/
/* 等待打印完成 ,跳转ImageB*/
mDelaymS(10);
jumpApp();
/* 不会执行到这 */
/* 不会执行到这 */
SYS_ResetExecute();
break;
@@ -639,9 +639,9 @@ void Rec_OTA_IAP_DataDeal(void)
send_buf[7] = CHIP_ID&0xFF;
send_buf[8] = (CHIP_ID>>8)&0xFF;
/* 有需要再增加 */
/* 有需要再增加 */
/* 发送信息 */
/* 发送信息 */
OTA_IAP_SendData(send_buf, 20);
break;
@@ -658,9 +658,9 @@ void Rec_OTA_IAP_DataDeal(void)
/*********************************************************************
* @fn OTA_IAPReadDataComplete
*
* @brief OTA 数据读取完成处理
* @brief OTA 数据读取完成处理
*
* @param index - OTA 通道序号
* @param index - OTA 通道序号
*
* @return none
*/
@@ -672,11 +672,11 @@ void OTA_IAPReadDataComplete(unsigned char index)
/*********************************************************************
* @fn OTA_IAPWriteData
*
* @brief OTA 通道数据接收完成处理
* @brief OTA 通道数据接收完成处理
*
* @param index - OTA 通道序号
* @param p_data - 写入的数据
* @param w_len - 写入的长度
* @param index - OTA 通道序号
* @param p_data - 写入的数据
* @param w_len - 写入的长度
*
* @return none
*/
@@ -3,7 +3,7 @@
* Author : WCH
* Version : V1.1
* Date : 2019/11/05
* Description : 升级从机应用主函数及任务系统初始化
* Description : 升级从机应用主函数及任务系统初始化
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
@@ -11,14 +11,14 @@
*******************************************************************************/
/******************************************************************************/
/* 头文件包含 */
/* 头文件包含 */
#include "CONFIG.h"
#include "HAL.h"
#include "Peripheral.h"
#include "OTA.h"
#include "OTAprofile.h"
/* 记录当前的Image */
/* 记录当前的Image */
unsigned char CurrImageFlag = 0xff;
/*********************************************************************
@@ -30,11 +30,11 @@ __attribute__((aligned(4))) uint32_t MEM_BUF[BLE_MEMHEAP_SIZE / 4];
const uint8_t MacAddr[6] = {0x84, 0xC2, 0xE4, 0x03, 0x02, 0x02};
#endif
/* 注意:关于程序升级后flash的操作必须先执行,不开启任何中断,防止操作中断和失败 */
/* 注意:关于程序升级后flash的操作必须先执行,不开启任何中断,防止操作中断和失败 */
/*********************************************************************
* @fn ReadImageFlag
*
* @brief 读取当前的程序的Image标志,DataFlash如果为空,就默认是ImageA,如果为ImageA,则跳转ImageA
* @brief 读取当前的程序的Image标志,DataFlash如果为空,就默认是ImageA,如果为ImageA,则跳转ImageA
*
* @return none
*/
@@ -45,7 +45,7 @@ void ReadImageFlag(void)
EEPROM_READ(OTA_DATAFLASH_ADD, &p_image_flash, 4);
CurrImageFlag = p_image_flash.ImageFlag;
/* 程序第一次执行,或者没有更新过,以后更新后在擦除DataFlash */
/* 程序第一次执行,或者没有更新过,以后更新后在擦除DataFlash */
if((CurrImageFlag != IMAGE_B_FLAG) && (CurrImageFlag != IMAGE_A_FLAG) && (CurrImageFlag != IMAGE_OTA_FLAG))
{
CurrImageFlag = IMAGE_A_FLAG;
@@ -64,7 +64,7 @@ void ReadImageFlag(void)
/*********************************************************************
* @fn Main_Circulation
*
* @brief 主循环
* @brief 主循环
*
* @return none
*/
@@ -81,7 +81,7 @@ void Main_Circulation()
/*********************************************************************
* @fn main
*
* @brief 主函数
* @brief 主函数
*
* @return none
*/
@@ -100,18 +100,18 @@ int main(void)
// GPIOA_ModeCfg(bTXD1, GPIO_ModeOut_PP_5mA);
// UART1_DefInit();
#endif
/* 配置串口0:先配置IO口模式,再配置串口 */
/* 配置串口0:先配置IO口模式,再配置串口 */
GPIOPinRemap(ENABLE, RB_PIN_UART0);
GPIOA_SetBits(GPIO_Pin_14);
GPIOA_ModeCfg(GPIO_Pin_15, GPIO_ModeIN_PU); // RXD-配置上拉输入
GPIOA_ModeCfg(GPIO_Pin_14, GPIO_ModeOut_PP_5mA); // TXD-配置推挽输出,注意先让IO口输出高电平
GPIOA_ModeCfg(GPIO_Pin_15, GPIO_ModeIN_PU); // RXD-配置上拉输入
GPIOA_ModeCfg(GPIO_Pin_14, GPIO_ModeOut_PP_5mA); // TXD-配置推挽输出,注意先让IO口输出高电平
UART0_DefInit();
PRINT("%s\n", VER_LIB);
ReadImageFlag();
if((R8_RESET_STATUS & RB_RESET_FLAG) == RST_FLAG_SW)
{
// 软复位不跳APP
// 软复位不跳APP
}
else
{
@@ -3,7 +3,7 @@
* Author : WCH
* Version : V1.0
* Date : 2018/12/10
* Description : OTA升级蓝牙通讯接口
* Description : OTA升级蓝牙通讯接口
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
@@ -137,11 +137,11 @@ gattServiceCBs_t OTAProfileCBs = {
/*********************************************************************
* @fn OTAProfile_AddService
*
* @brief OTA Profile初始化
* @brief OTA Profile初始化
*
* @param services - 服务控制字
* @param services - 服务控制字
*
* @return 初始化的状态
* @return 初始化的状态
*/
bStatus_t OTAProfile_AddService(uint32_t services)
{
@@ -162,11 +162,11 @@ bStatus_t OTAProfile_AddService(uint32_t services)
/*********************************************************************
* @fn OTAProfile_RegisterAppCBs
*
* @brief OTA Profile读写回调函数注册
* @brief OTA Profile读写回调函数注册
*
* @param appCallbacks - 函数结构体指针
* @param appCallbacks - 函数结构体指针
*
* @return 函数执行状态
* @return 函数执行状态
*/
bStatus_t OTAProfile_RegisterAppCBs(OTAProfileCBs_t *appCallbacks)
{
@@ -308,19 +308,19 @@ static bStatus_t OTAProfile_WriteAttrCB(uint16_t connHandle, gattAttribute_t *pA
/*********************************************************************
* @fn OTAProfile_SendData
*
* @brief OTA Profile通道发送数据
* @brief OTA Profile通道发送数据
*
* @param paramID - OTA通道选择
* @param p_data - 数据指针
* @param send_len - 发送数据长度
* @param paramID - OTA通道选择
* @param p_data - 数据指针
* @param send_len - 发送数据长度
*
* @return 函数执行状态
* @return 函数执行状态
*/
bStatus_t OTAProfile_SendData(unsigned char paramID, unsigned char *p_data, unsigned char send_len)
{
bStatus_t status = SUCCESS;
/* 数据长度超出范围 */
/* 数据长度超出范围 */
if(send_len > 20)
return 0xfe;
@@ -25,13 +25,13 @@ extern "C" {
* CONSTANTS
*/
// OTA Profile通道Index定义
// OTA Profile通道Index定义
#define OTAPROFILE_CHAR 0
// OTA 服务的UUID定义
// OTA 服务的UUID定义
#define OTAPROFILE_SERV_UUID 0xFEE0
// OTA 通讯通道UUID定义
// OTA 通讯通道UUID定义
#define OTAPROFILE_CHAR_UUID 0xFEE1
// Simple Keys Profile Services bit fields
@@ -49,7 +49,7 @@ extern "C" {
* Profile Callbacks
*/
// 读写操作函数回调
// 读写操作函数回调
typedef void (*OTAProfileRead_t)(unsigned char paramID);
typedef void (*OTAProfileWrite_t)(unsigned char paramID, unsigned char *p_data, unsigned char w_len);
@@ -64,31 +64,31 @@ typedef struct
*/
/**
* @brief OTA Profile初始化
* @brief OTA Profile初始化
*
* @param services - 服务控制字
* @param services - 服务控制字
*
* @return 初始化的状态
* @return 初始化的状态
*/
bStatus_t OTAProfile_AddService(uint32_t services);
/**
* @brief OTA Profile读写回调函数注册
* @brief OTA Profile读写回调函数注册
*
* @param appCallbacks - 函数结构体指针
* @param appCallbacks - 函数结构体指针
*
* @return 函数执行状态
* @return 函数执行状态
*/
bStatus_t OTAProfile_RegisterAppCBs(OTAProfileCBs_t *appCallbacks);
/**
* @brief OTA Profile通道发送数据
* @brief OTA Profile通道发送数据
*
* @param paramID - OTA通道选择
* @param p_data - 数据指针
* @param send_len - 发送数据长度
* @param paramID - OTA通道选择
* @param p_data - 数据指针
* @param send_len - 发送数据长度
*
* @return 函数执行状态
* @return 函数执行状态
*/
bStatus_t OTAProfile_SendData(unsigned char paramID, unsigned char *p_data, unsigned char send_len);