From fd15518da3775f851a54b78ecddf718e138e9ece Mon Sep 17 00:00:00 2001 From: maybe_404 <318900243@qq.com> Date: Mon, 18 Nov 2024 03:37:42 +0000 Subject: [PATCH 1/2] =?UTF-8?q?update=20User/src/bsp.c.=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=8D=95=E8=84=89=E5=86=B2=E6=A8=A1=E5=BC=8F=20?= =?UTF-8?q?=E8=84=89=E5=86=B2=E4=B8=AA=E6=95=B0=E5=BA=94=E7=AD=94=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: maybe_404 <318900243@qq.com> --- User/src/bsp.c | 317 +++++++++++++++++++++++++------------------------ 1 file changed, 159 insertions(+), 158 deletions(-) diff --git a/User/src/bsp.c b/User/src/bsp.c index 43246e7..cb930b1 100644 --- a/User/src/bsp.c +++ b/User/src/bsp.c @@ -11,16 +11,16 @@ DISPLAY display = {0 , 0}; union Union_TypeConversion Byte_TypeConversion; -unsigned short PauseTime = 1000; // 中断时间预设1s +unsigned short PauseTime = 1000; // 涓柇鏃堕棿棰勮1s -bool b_Random_EN = false; // 伪随机编码使能 +bool b_Random_EN = false; // 浼殢鏈虹紪鐮佷娇鑳 -union Union_Byte LaserControl; // 共用体,激光编码控制位 +union Union_Byte LaserControl; // 鍏辩敤浣擄紝婵鍏夌紪鐮佹帶鍒朵綅 -/*菜单索引值*/ +/*鑿滃崟绱㈠紩鍊*/ struct Menu_Index Menu_Indexs = {0, 0, 0}; /**/ -/*电机控制结构体*/ +/*鐢垫満鎺у埗缁撴瀯浣*/ MOTODATA Motodata = {0 , 0 , 0}; DataPoint podata[] = { @@ -73,7 +73,7 @@ unsigned char podatanum = sizeof(podata) / sizeof(podata[0]); * @param[in] * @param[out] * @return - * @note 拉格朗日插值 + * @note 鎷夋牸鏈楁棩鎻掑 */ double lagrangeInterpolate(DataPoint* data, int n, double x) { double result = 0.0; @@ -98,20 +98,20 @@ double lagrangeInterpolate(DataPoint* data, int n, double x) { * @param[in] * @param[out] * @return - * @note 分割函数 + * @note 鍒嗗壊鍑芥暟 */ float splitNumber(signed short int input) { - // 检查输入是否大于99 + // 妫鏌ヨ緭鍏ユ槸鍚﹀ぇ浜99 if (input > 99) { - // 只留下十位和个位 + // 鍙暀涓嬪崄浣嶅拰涓綅 int remainder = input % 100; - // 转换为浮点数,保留小数点后四位 - float result = remainder / 10.0; // 修改这里,除以 10.0 而不是 100.0 + // 杞崲涓烘诞鐐规暟锛屼繚鐣欏皬鏁扮偣鍚庡洓浣 + float result = remainder / 10.0; // 淇敼杩欓噷锛岄櫎浠 10.0 鑰屼笉鏄 100.0 result += (result / 0.01) * 0.0001; return result; } else { - // 输入小于等于99,直接返回 + // 杈撳叆灏忎簬绛変簬99锛岀洿鎺ヨ繑鍥 return input; } } @@ -122,7 +122,7 @@ float splitNumber(signed short int input) { * @param[in] * @param[out] * @return - * @note 脉宽计算公式 + * @note 鑴夊璁$畻鍏紡 */ unsigned int pulse_width_formula(unsigned int pw_xus) { @@ -140,7 +140,7 @@ unsigned int pulse_width_formula(unsigned int pw_xus) return uireturn; } -//设置衰减,将电机动作和向FPGA发送数据融合,输入 +//璁剧疆琛板噺锛屽皢鐢垫満鍔ㄤ綔鍜屽悜FPGA鍙戦佹暟鎹瀺鍚,杈撳叆 signed short int Set_Energy(uint16_t show) { signed short int ssiretrurn = 0; @@ -201,7 +201,7 @@ signed short int Set_Energy(uint16_t show) } else { - //20kj最大支持20db动态范围 + //20kj鏈澶ф敮鎸20db鍔ㄦ佽寖鍥 return 0; } } @@ -265,13 +265,13 @@ void Motor_Move_To(unsigned short position) //unsigned short data_1 = 1050; - if (Motodata.Motor_Current_Positon == position) //未改变 + if (Motodata.Motor_Current_Positon == position) //鏈敼鍙 return; if (Motodata.Motor_End_count) return; if (position >= 12) return; - Motodata.Motor_Next_Positon = position; //新值 + Motodata.Motor_Next_Positon = position; //鏂板 //0 -> any if(Motodata.Motor_Next_Positon != 0 && Motodata.Motor_Current_Positon == 0) { @@ -284,7 +284,7 @@ void Motor_Move_To(unsigned short position) /*any -> any */ else if(Motodata.Motor_Next_Positon != 0 && Motodata.Motor_Current_Positon != 0) { - if (Motodata.Motor_Current_Positon > position) //当前位置靠前了,需要往后退 + if (Motodata.Motor_Current_Positon > position) //褰撳墠浣嶇疆闈犲墠浜嗭紝闇瑕佸線鍚庨 { #ifdef DEBUGPR SEGGER_RTT_printf(0 , RTT_CTRL_TEXT_BRIGHT_YELLOW " now = %d " RTT_CTRL_TEXT_BRIGHT_YELLOW" old = %d\r\n" ,position, Motodata.Motor_Current_Positon); @@ -328,7 +328,7 @@ void Motor_Move_To(unsigned short position) * @param[in] * @param[out] * @return - * @note 外部光电传感器检测到位置到达零位 + * @note 澶栭儴鍏夌數浼犳劅鍣ㄦ娴嬪埌浣嶇疆鍒拌揪闆朵綅 */ void Position_In_Zero(void) { @@ -341,16 +341,16 @@ void Position_In_Zero(void) * @param[in] * @param[out] * @return - * @note 电机回零位 + * @note 鐢垫満鍥為浂浣 */ void Motor_Return_Zero(void) { - //挡住情形下,读到的数据是0; - //没挡住就是1,所以归零是下降沿 + //鎸′綇鎯呭舰涓嬶紝璇诲埌鐨勬暟鎹槸0锛 + //娌℃尅浣忓氨鏄1锛屾墍浠ュ綊闆舵槸涓嬮檷娌 if(IO_Read(Zero_Position) == 1) { - Dir_Down; //设置方向位回零方向 - Motor_Power_On; //使能运动 + Dir_Down; //璁剧疆鏂瑰悜浣嶅洖闆舵柟鍚 + Motor_Power_On; //浣胯兘杩愬姩 } } @@ -363,16 +363,16 @@ uint8_t IO_Read(GPIO_TypeDef* GPIOx , uint16_t GPIO_Pin_x) extern DataPoint podata[]; /** - * @brief 串口指令应答 + * @brief 涓插彛鎸囦护搴旂瓟 * - * 这里可以提供关于函数的高级概述,包括它的输入和输出。 + * 杩欓噷鍙互鎻愪緵鍏充簬鍑芥暟鐨勯珮绾ф杩帮紝鍖呮嫭瀹冪殑杈撳叆鍜岃緭鍑恒 * - * @param[in] 参数1 参数1的描述,包括数据类型和含义 - * @param[out] 参数2 参数2的描述,包括数据类型和含义 + * @param[in] 鍙傛暟1 鍙傛暟1鐨勬弿杩帮紝鍖呮嫭鏁版嵁绫诲瀷鍜屽惈涔 + * @param[out] 鍙傛暟2 鍙傛暟2鐨勬弿杩帮紝鍖呮嫭鏁版嵁绫诲瀷鍜屽惈涔 * - * @return 函数返回值的描述,包括数据类型和含义,如果适用的话。 + * @return 鍑芥暟杩斿洖鍊肩殑鎻忚堪锛屽寘鎷暟鎹被鍨嬪拰鍚箟锛屽鏋滈傜敤鐨勮瘽銆 * - * @note 任何特殊注意事项或用法示例都可以在这里添加。 + * @note 浠讳綍鐗规畩娉ㄦ剰浜嬮」鎴栫敤娉曠ず渚嬮兘鍙互鍦ㄨ繖閲屾坊鍔犮 */ unsigned char UART_RemoteCMD_Process(void) { @@ -380,12 +380,12 @@ unsigned char UART_RemoteCMD_Process(void) unsigned short i = 0 , Temp_int16 = 0; unsigned int *p_u32 = 0; static unsigned short RandomIndex = 0; - static unsigned char RandomRxError = 0; // 伪随机编码接收时的出错计数器 + static unsigned char RandomRxError = 0; // 浼殢鏈虹紪鐮佹帴鏀舵椂鐨勫嚭閿欒鏁板櫒 uint8_t temp_energy_int = 0; - /*输出电流设置*/ + /*杈撳嚭鐢垫祦璁剧疆*/ unsigned char uc_sbuffer[] = {0x5a , 0xa5 , 0x03 ,0x00}; - /*新增 输出脉冲个数设置 默认为1 */ + /*鏂板 杈撳嚭鑴夊啿涓暟璁剧疆 榛樿涓1 */ uint16_t PulseNumber = 1; if(RemoteDataPacket.RX_BUF[0] > 2) @@ -394,9 +394,9 @@ unsigned char UART_RemoteCMD_Process(void) { CheckSum = CheckSum + RemoteDataPacket.RX_BUF[i]; } - if(CheckSum == RemoteDataPacket.RX_BUF[RemoteDataPacket.RX_BUF[0]]) // 相等则表示校验和正确 + if(CheckSum == RemoteDataPacket.RX_BUF[RemoteDataPacket.RX_BUF[0]]) // 鐩哥瓑鍒欒〃绀烘牎楠屽拰姝g‘ { - /*下位机下发数据光芯*/ + /*涓嬩綅鏈轰笅鍙戞暟鎹厜鑺*/ if((RemoteDataPacket.RX_BUF[2] >= 0x43) & (RemoteDataPacket.RX_BUF[2] <= 0x59)) { memcpy(Uart_Tx_Buffer3, RemoteDataPacket.RX_BUF, Number_Rx_Buffer1); @@ -404,13 +404,13 @@ unsigned char UART_RemoteCMD_Process(void) Uart_Tx_Buffer3[Number_Rx_Buffer1 - 1] = 0XED; DMA_Tx(USART3 , Number_Rx_Buffer1); } - /*光芯数据报告下位机*/ + /*鍏夎姱鏁版嵁鎶ュ憡涓嬩綅鏈*/ else if((RemoteDataPacket.RX_BUF[2] >= 0xA3) & (RemoteDataPacket.RX_BUF[2] <= 0xB0)) { #if (VERSION_SELECTION == Ver_2_1_0) - //校验计算 - RemoteDataPacket.RX_BUF[2] += 0x20; //2023年9月6日修改 光芯的应答ID透传后由下位机从 ID + 60改为 ID + 80 - //增加校验,2023年9月6日修改 光芯的应答ID透传后由下位机从 ID + 60改为 ID + 80 + //鏍¢獙璁$畻 + RemoteDataPacket.RX_BUF[2] += 0x20; //2023骞9鏈6鏃ヤ慨鏀 鍏夎姱鐨勫簲绛擨D閫忎紶鍚庣敱涓嬩綅鏈轰粠 ID + 60鏀逛负 ID + 80 + //澧炲姞鏍¢獙,2023骞9鏈6鏃ヤ慨鏀 鍏夎姱鐨勫簲绛擨D閫忎紶鍚庣敱涓嬩綅鏈轰粠 ID + 60鏀逛负 ID + 80 RemoteDataPacket.RX_BUF[Number_Rx_Buffer3 - 2] = RemoteDataPacket.RX_BUF[Number_Rx_Buffer3 - 2] + 0x20; #elif (VERSION_SELECTION == Ver_2_1_1) @@ -427,36 +427,36 @@ unsigned char UART_RemoteCMD_Process(void) switch(RemoteDataPacket.RX_BUF[2]) { - /*程控模式通讯握手*/ + /*绋嬫帶妯″紡閫氳鎻℃墜*/ case 0x00: - if(RemoteDataPacket.RX_BUF[0] == 3)//长度检查 + if(RemoteDataPacket.RX_BUF[0] == 3)//闀垮害妫鏌 { retdata.Mode = 0x80; UART_Answer_LightData(USART1 , &retdata); } break; - /*上位机端口 激光脉冲启动 - *因为这里是确定的要开激光,并且是从上位机下发的指令,实体按键不会产生变化, - *所以这里不能使用系统变量进行调用,因为没有实体按键动作,变量也不会发生变化的,因此这里要给一个确定的值 - *对于1535激光器来说,上位机这里的0x01还是持续激光模式,所以调用出光的函数还是用的Laser_StateTurn + /*涓婁綅鏈虹鍙 婵鍏夎剦鍐插惎鍔 + *鍥犱负杩欓噷鏄‘瀹氱殑瑕佸紑婵鍏夛紝骞朵笖鏄粠涓婁綅鏈轰笅鍙戠殑鎸囦护锛屽疄浣撴寜閿笉浼氫骇鐢熷彉鍖栵紝 + *鎵浠ヨ繖閲屼笉鑳戒娇鐢ㄧ郴缁熷彉閲忚繘琛岃皟鐢紝鍥犱负娌℃湁瀹炰綋鎸夐敭鍔ㄤ綔锛屽彉閲忎篃涓嶄細鍙戠敓鍙樺寲鐨勶紝鍥犳杩欓噷瑕佺粰涓涓‘瀹氱殑鍊 + *瀵逛簬1535婵鍏夊櫒鏉ヨ锛屼笂浣嶆満杩欓噷鐨0x01杩樻槸鎸佺画婵鍏夋ā寮忥紝鎵浠ヨ皟鐢ㄥ嚭鍏夌殑鍑芥暟杩樻槸鐢ㄧ殑Laser_StateTurn */ case 0x01: if(RemoteDataPacket.RX_BUF[0] == 3) { retdata.Mode = 0x81; UART_Answer_LightData(USART1 , &retdata); - /*关脉冲激光,*/ + /*鍏宠剦鍐叉縺鍏夛紝*/ Laser_StateTurn(DISABLE); - /*2024.05.06新增 持续输出脉冲 默认65535*/ + /*2024.05.06鏂板 鎸佺画杈撳嚭鑴夊啿 榛樿65535*/ PulseNumber = 65535; - //24 11 13 修改这部分代码将脉冲个数 - 1 + //24 11 13 淇敼杩欓儴鍒嗕唬鐮佸皢鑴夊啿涓暟 - 1 FSMC_WR(5) = PulseNumber; RemoteDataPacket.RX_BUF[1]++; } break; - /*上位机端口 激光脉冲关闭*/ + /*涓婁綅鏈虹鍙 婵鍏夎剦鍐插叧闂*/ case 0x2: if(RemoteDataPacket.RX_BUF[0] == 3) { @@ -466,7 +466,7 @@ unsigned char UART_RemoteCMD_Process(void) } break; - /*红色十字光点亮*/ + /*绾㈣壊鍗佸瓧鍏夌偣浜*/ case 0x3: if(RemoteDataPacket.RX_BUF[0] == 3) { @@ -476,7 +476,7 @@ unsigned char UART_RemoteCMD_Process(void) } break; - /*红色十字光关闭*/ + /*绾㈣壊鍗佸瓧鍏夊叧闂*/ case 0x4: if(RemoteDataPacket.RX_BUF[0] == 3) { @@ -486,7 +486,7 @@ unsigned char UART_RemoteCMD_Process(void) } break; - /*用以模拟按键上翻操作*/ + /*鐢ㄤ互妯℃嫙鎸夐敭涓婄炕鎿嶄綔*/ case 0x6: if(RemoteDataPacket.RX_BUF[0] == 3) { @@ -495,7 +495,7 @@ unsigned char UART_RemoteCMD_Process(void) } break; - /*用以模拟按键下翻操作*/ + /*鐢ㄤ互妯℃嫙鎸夐敭涓嬬炕鎿嶄綔*/ case 0x7: if(RemoteDataPacket.RX_BUF[0] == 3) { @@ -504,7 +504,7 @@ unsigned char UART_RemoteCMD_Process(void) } break; - /*用以模拟按键OK操作*/ + /*鐢ㄤ互妯℃嫙鎸夐敭OK鎿嶄綔*/ case 0x8: if(RemoteDataPacket.RX_BUF[0] == 3) { @@ -513,7 +513,7 @@ unsigned char UART_RemoteCMD_Process(void) } break; - /*用以模拟按键Cancel操作*/ + /*鐢ㄤ互妯℃嫙鎸夐敭Cancel鎿嶄綔*/ case 0x9: if(RemoteDataPacket.RX_BUF[0] == 3) { @@ -522,7 +522,7 @@ unsigned char UART_RemoteCMD_Process(void) } break; - /*中断1秒*/ + /*涓柇1绉*/ case 0x10: if(RemoteDataPacket.RX_BUF[0] == 5) {// @@ -531,16 +531,16 @@ unsigned char UART_RemoteCMD_Process(void) Byte_TypeConversion.TC_byte[1] = RemoteDataPacket.RX_BUF[3]; PauseTime = Byte_TypeConversion.TC_uint16_t; Pulse_StateTurn(DISABLE); - TIM_Cmd(TIM2 , ENABLE); //使能定时器2,产生1ms的短触发脉冲,这里使用定时器主要是为了以后更改其余宽度时比较方便, - //因为只产生一次中断,也不会太占用资源 + TIM_Cmd(TIM2 , ENABLE); //浣胯兘瀹氭椂鍣2,浜х敓1ms鐨勭煭瑙﹀彂鑴夊啿,杩欓噷浣跨敤瀹氭椂鍣ㄤ富瑕佹槸涓轰簡浠ュ悗鏇存敼鍏朵綑瀹藉害鏃舵瘮杈冩柟渚匡紝 + //鍥犱负鍙骇鐢熶竴娆′腑鏂紝涔熶笉浼氬お鍗犵敤璧勬簮 retdata.Mode = 0x90; UART_Answer_LightData(USART1 , &retdata); } break; - /*固定编码周期装订*/ + /*鍥哄畾缂栫爜鍛ㄦ湡瑁呰*/ case 0x11: - if(RemoteDataPacket.RX_BUF[0] == 6) // 首先进行命令包长度检查 + if(RemoteDataPacket.RX_BUF[0] == 6) // 棣栧厛杩涜鍛戒护鍖呴暱搴︽鏌 { Byte_TypeConversion.TC_uint64_t = 0; Byte_TypeConversion.TC_byte[0] = RemoteDataPacket.RX_BUF[5]; @@ -554,28 +554,28 @@ unsigned char UART_RemoteCMD_Process(void) // CycleCodeTime = 120000; // }else if(CycleCodeTime < 50000) // { -// //2024.3.26 , 加入限制周期设定 +// //2024.3.26 , 鍔犲叆闄愬埗鍛ㄦ湡璁惧畾 // CycleCodeTime = 50000; // } if(b_Random_EN) - {//如果此前处于伪随机模式,则退出伪随机模式 + {//濡傛灉姝ゅ墠澶勪簬浼殢鏈烘ā寮忥紝鍒欓鍑轰吉闅忔満妯″紡 b_Random_EN = false; } if(LaserControl.bits.b0 == 1) - {//如果之前已经是开激光状态,则重新更新一次开光指令, - //如果之前是关激光状态,则什么也不变,只保存数据,待下一次手动打开激光即可 - Laser_StateTurn(DISABLE); //打开激光 + {//濡傛灉涔嬪墠宸茬粡鏄紑婵鍏夌姸鎬侊紝鍒欓噸鏂版洿鏂颁竴娆″紑鍏夋寚浠わ紝 + //濡傛灉涔嬪墠鏄叧婵鍏夌姸鎬侊紝鍒欎粈涔堜篃涓嶅彉锛屽彧淇濆瓨鏁版嵁锛屽緟涓嬩竴娆℃墜鍔ㄦ墦寮婵鍏夊嵆鍙 + Laser_StateTurn(DISABLE); //鎵撳紑婵鍏 } - unsigned int my_ms = 0; /*应小刘要求加入周期数值显示*/ + unsigned int my_ms = 0; /*搴斿皬鍒樿姹傚姞鍏ュ懆鏈熸暟鍊兼樉绀*/ my_ms = RemoteDataPacket.RX_BUF[3] << 16 | RemoteDataPacket.RX_BUF[4] << 8 | RemoteDataPacket.RX_BUF[5]; - //FSMC_WR(4) = (uint16_t)((double)(my_ms * 14.7456 * 2)); /*应老板要求将上位机的ms输入变为给cpld的脉宽参数输出*/ + //FSMC_WR(4) = (uint16_t)((double)(my_ms * 14.7456 * 2)); /*搴旇佹澘瑕佹眰灏嗕笂浣嶆満鐨刴s杈撳叆鍙樹负缁檆pld鐨勮剦瀹藉弬鏁拌緭鍑*/ retdata.cycle[0] = RemoteDataPacket.RX_BUF[3]; retdata.cycle[1] = RemoteDataPacket.RX_BUF[4]; retdata.cycle[2] = RemoteDataPacket.RX_BUF[5]; - if(cn.Program_control_mode_2 == 0xff)/*将数值拷贝值返回数据中*/ + if(cn.Program_control_mode_2 == 0xff)/*灏嗘暟鍊兼嫹璐濆艰繑鍥炴暟鎹腑*/ { - /*此处由于显示屏尺寸有限 当数据大于99.999时为100.000时即7位时会遮挡ms单位所以去点ms单位*/ + /*姝ゅ鐢变簬鏄剧ず灞忓昂瀵告湁闄 褰撴暟鎹ぇ浜99.999鏃朵负100.000鏃跺嵆7浣嶆椂浼氶伄鎸s鍗曚綅鎵浠ュ幓鐐筸s鍗曚綅*/ if(my_ms > 0x1869F) { display.discycle = 1; @@ -594,7 +594,7 @@ unsigned char UART_RemoteCMD_Process(void) } break; - /*伪随机编码数量检查*/ + /*浼殢鏈虹紪鐮佹暟閲忔鏌*/ case 0x20: if(RemoteDataPacket.RX_BUF[0] == 7) { @@ -602,26 +602,26 @@ unsigned char UART_RemoteCMD_Process(void) Byte_TypeConversion.TC_uint64_t = 0; Byte_TypeConversion.TC_byte[0] = RemoteDataPacket.RX_BUF[4]; Byte_TypeConversion.TC_byte[1] = RemoteDataPacket.RX_BUF[3]; - u16_RandomData[7] = Byte_TypeConversion.TC_uint16_t; // 编码位数 + u16_RandomData[7] = Byte_TypeConversion.TC_uint16_t; // 缂栫爜浣嶆暟 Byte_TypeConversion.TC_byte[0] = RemoteDataPacket.RX_BUF[6]; Byte_TypeConversion.TC_byte[1] = RemoteDataPacket.RX_BUF[5]; - u16_RandomData[6] = Byte_TypeConversion.TC_uint16_t; // 基频 + u16_RandomData[6] = Byte_TypeConversion.TC_uint16_t; // 鍩洪 RandomIndex = 0; RandomRxError = 0; if(u16_RandomData[7] > 0 && u16_RandomData[7] < 1017) - { //数据有效范围1~1016 + { //鏁版嵁鏈夋晥鑼冨洿1~1016 UART_Answer_RandomNumber(USART1, u16_RandomData[7]); } else if(u16_RandomData[7] >= 1017 || u16_RandomData[7] == 0) { retdata.Mode = 0xAE; - UART_Answer_LightData(USART1 , &retdata); //上报0xAE错误码 + UART_Answer_LightData(USART1 , &retdata); //涓婃姤0xAE閿欒鐮 } #endif } break; - /*伪随机编码数据*/ + /*浼殢鏈虹紪鐮佹暟鎹*/ case 0x21: if(RemoteDataPacket.RX_BUF[0] == 7) { @@ -629,43 +629,43 @@ unsigned char UART_RemoteCMD_Process(void) Byte_TypeConversion.TC_uint64_t = 0; Temp_u8 = RemoteDataPacket.RX_BUF[3]; Byte_TypeConversion.TC_byte[0] = RemoteDataPacket.RX_BUF[4]; - Byte_TypeConversion.TC_byte[1] = Temp_u8 & 0x0F; // 取低4位,这里代码是老板写的,我也不知道为什么他要这么写? - Temp_int16 = Byte_TypeConversion.TC_uint16_t; // 读取伪随机数据序号 + Byte_TypeConversion.TC_byte[1] = Temp_u8 & 0x0F; // 鍙栦綆4浣嶏紝杩欓噷浠g爜鏄佹澘鍐欑殑锛屾垜涔熶笉鐭ラ亾涓轰粈涔堜粬瑕佽繖涔堝啓锛 + Temp_int16 = Byte_TypeConversion.TC_uint16_t; // 璇诲彇浼殢鏈烘暟鎹簭鍙 Byte_TypeConversion.TC_byte[0] = RemoteDataPacket.RX_BUF[6]; Byte_TypeConversion.TC_byte[1] = RemoteDataPacket.RX_BUF[5]; - Byte_TypeConversion.TC_byte[2] = (Temp_u8 >> 4) & 0x0F; // 取高4位, - u16_RandomData[Temp_int16 + 7] = (uint16_t)(Byte_TypeConversion.TC_uint32_t - u16_RandomData[6]); // 将伪随机数据填入对应序号的数组中 + Byte_TypeConversion.TC_byte[2] = (Temp_u8 >> 4) & 0x0F; // 鍙栭珮4浣嶏紝 + u16_RandomData[Temp_int16 + 7] = (uint16_t)(Byte_TypeConversion.TC_uint32_t - u16_RandomData[6]); // 灏嗕吉闅忔満鏁版嵁濉叆瀵瑰簲搴忓彿鐨勬暟缁勪腑 - // 为节省空间,数据按照16Bit存储,用最小数据为基频,数据减基频存储 + // 涓鸿妭鐪佺┖闂达紝鏁版嵁鎸夌収16Bit瀛樺偍锛岀敤鏈灏忔暟鎹负鍩洪锛屾暟鎹噺鍩洪瀛樺偍 if((Temp_int16 != (RandomIndex + 1)) || (Byte_TypeConversion.TC_uint32_t > 120000) ||(Byte_TypeConversion.TC_uint32_t < 40000)) { RandomRxError++; UART_AnswerError(USART1, RandomIndex); } RandomIndex = Temp_int16; - //为提高速度,数据部分不应答,等全部完毕再做应答 + //涓烘彁楂橀熷害锛屾暟鎹儴鍒嗕笉搴旂瓟锛岀瓑鍏ㄩ儴瀹屾瘯鍐嶅仛搴旂瓟 //UART_Answer_RandomData(USART1, Temp_int16, Int32_RandomData[Temp_int16]); #endif } break; - /*伪随机编码发送完毕检查*/ + /*浼殢鏈虹紪鐮佸彂閫佸畬姣曟鏌*/ case 0x22: - if(RandomRxError == 0) // =0说明接收到的数据序号都对 - {//伪随机编码序列发送完毕后的检查 + if(RandomRxError == 0) // =0璇存槑鎺ユ敹鍒扮殑鏁版嵁搴忓彿閮藉 + {//浼殢鏈虹紪鐮佸簭鍒楀彂閫佸畬姣曞悗鐨勬鏌 #if (VERSION_SELECTION != Ver_2_3_0) if(RandomCode_Check()) { retdata.Mode = 0xA2; UART_Answer_LightData(USART1 , &retdata); - Laser_StateTurn(ENABLE); //关闭激光输出,该指令上位机会下发一次,为稳妥起见,这里也做一次处理, - //在主函数while循环里会根据b_Random_EN状态自动进入伪随机状态 - b_Random_EN = true; //进入伪随机模式 + Laser_StateTurn(ENABLE); //鍏抽棴婵鍏夎緭鍑猴紝璇ユ寚浠や笂浣嶆満浼氫笅鍙戜竴娆★紝涓虹ǔ濡ヨ捣瑙侊紝杩欓噷涔熷仛涓娆″鐞嗭紝 + //鍦ㄤ富鍑芥暟while寰幆閲屼細鏍规嵁b_Random_EN鐘舵佽嚜鍔ㄨ繘鍏ヤ吉闅忔満鐘舵 + b_Random_EN = true; //杩涘叆浼殢鏈烘ā寮 } else { retdata.Mode = 0xAE; - UART_Answer_LightData(USART1 , &retdata); //上报错误代码 + UART_Answer_LightData(USART1 , &retdata); //涓婃姤閿欒浠g爜 } #endif } @@ -675,14 +675,14 @@ unsigned char UART_RemoteCMD_Process(void) } break; - /*伪随机编码存储*/ + /*浼殢鏈虹紪鐮佸瓨鍌*/ case 0x23: if(RemoteDataPacket.RX_BUF[0] == 11) { #if (VERSION_SELECTION != Ver_2_3_0) uint8_t SaveCH = RemoteDataPacket.RX_BUF[3]; - /*2组设置为武汉高德红外,4组设定为通用版本*/ - if((SaveCH > 0) && (SaveCH < 5)) //V3.01 改伪随机长度,原代码:if((SaveCH >0) && (SaveCH <5)) + /*2缁勮缃负姝︽眽楂樺痉绾㈠锛4缁勮瀹氫负閫氱敤鐗堟湰*/ + if((SaveCH > 0) && (SaveCH < 5)) //V3.01 鏀逛吉闅忔満闀垮害锛屽師浠g爜锛歩f((SaveCH >0) && (SaveCH <5)) { Byte_TypeConversion.TC_uint64_t = 0; Byte_TypeConversion.TC_byte[0] = RemoteDataPacket.RX_BUF[4]; @@ -705,13 +705,13 @@ unsigned char UART_RemoteCMD_Process(void) //UART_Answer_NoData(USART1); retdata.Mode = 0xA3; UART_Answer_LightData(USART1 , &retdata); - //V3.01 改伪随机长度,存储应答,原代码:UART_Answer_NoData(USART1); + //V3.01 鏀逛吉闅忔満闀垮害锛屽瓨鍌ㄥ簲绛旓紝鍘熶唬鐮侊細UART_Answer_NoData(USART1); } #endif } break; - /*伪随机编码删除*/ + /*浼殢鏈虹紪鐮佸垹闄*/ case 0x24: if(RemoteDataPacket.RX_BUF[0] == 4) { @@ -731,13 +731,13 @@ unsigned char UART_RemoteCMD_Process(void) STMFLASH_Write(FLASH_USER_START_ADDR, u32_FlashBuff, 2048*4); //UART_Answer_NoData(USART1); retdata.Mode = 0xA4; - UART_Answer_LightData(USART1 , &retdata); //V3.01 改伪随机长度,删除应答,原代码:UART_Answer_NoData(USART1); + UART_Answer_LightData(USART1 , &retdata); //V3.01 鏀逛吉闅忔満闀垮害锛屽垹闄ゅ簲绛旓紝鍘熶唬鐮侊細UART_Answer_NoData(USART1); } #endif } break; - /*能量设置*/ + /*鑳介噺璁剧疆*/ case 0x41: if(RemoteDataPacket.RX_BUF[0] == 7 && flag_lightN_F == false) { @@ -750,13 +750,13 @@ unsigned char UART_RemoteCMD_Process(void) #if (VERSION_SELECTION == Ver_2_1_0) UART_RemoteEncode(USART3, RemoteDataPacket.TX_BUF); #elif (VERSION_SELECTION == Ver_2_1_1) - static unsigned short temp = 0; /*2023 9 7 日 要求增加固定DB 2000*/ + static unsigned short temp = 0; /*2023 9 7 鏃 瑕佹眰澧炲姞鍥哄畾DB 2000*/ static unsigned char SendRemotBuff[16] = {0}; memset(SendRemotBuff , 0 , sizeof(SendRemotBuff)); memcpy(SendRemotBuff , RemoteDataPacket.TX_BUF , 16); temp = RemoteDataPacket.TX_BUF[5] << 8 | RemoteDataPacket.TX_BUF[6]; temp += 2000; - SendRemotBuff[6]= temp; //先高后低 + SendRemotBuff[6]= temp; //鍏堥珮鍚庝綆 SendRemotBuff[5]= temp >> 8; UART_RemoteEncode(USART3, SendRemotBuff); #elif (VERSION_SELECTION == Ver_2_2_0) @@ -767,18 +767,18 @@ unsigned char UART_RemoteCMD_Process(void) retdata.energy[0] = RemoteDataPacket.RX_BUF[5]; retdata.energy[1] = RemoteDataPacket.RX_BUF[6]; - /*测试时发现,第一次总是不给上位机回复衰减值,这里强制复制一次*/ + /*娴嬭瘯鏃跺彂鐜帮紝绗竴娆℃绘槸涓嶇粰涓婁綅鏈哄洖澶嶈“鍑忓硷紝杩欓噷寮哄埗澶嶅埗涓娆*/ retdata.energy[0] = RemoteDataPacket.TX_BUF[5]; retdata.energy[1] = RemoteDataPacket.TX_BUF[6]; UART_Answer_LightData(USART1 , &retdata); - attenuation_number(&cn , &RemoteDataPacket); /*2022 8 3 应小刘要求加入衰减数值显示*/ + attenuation_number(&cn , &RemoteDataPacket); /*2022 8 3 搴斿皬鍒樿姹傚姞鍏ヨ“鍑忔暟鍊兼樉绀*/ unsigned short show = 0; - unsigned char bit_point = 0; //显示的位数 - unsigned char decimal_point = 0; //显示的小数点位数 + unsigned char bit_point = 0; //鏄剧ず鐨勪綅鏁 + unsigned char decimal_point = 0; //鏄剧ず鐨勫皬鏁扮偣浣嶆暟 show = cn.control_number_hight | cn.control_number_low << 8; - if(show >= 0x3E8 ) /*数值大于三位数*/ + if(show >= 0x3E8 ) /*鏁板煎ぇ浜庝笁浣嶆暟*/ { bit_point = 3; decimal_point = 1; @@ -790,7 +790,7 @@ unsigned char UART_RemoteCMD_Process(void) decimal_point = 1; show = show / 10; } - //主要用于小数显示 + //涓昏鐢ㄤ簬灏忔暟鏄剧ず if(cn.Program_control_mode_1 == 0xff) { display.disenergy = 1; @@ -798,7 +798,7 @@ unsigned char UART_RemoteCMD_Process(void) display.decimal_point = decimal_point; display.disenergyshow = show; } - #elif (VERSION_SELECTION == Ver_2_3_0) //上位机激光能量设置 + #elif (VERSION_SELECTION == Ver_2_3_0) //涓婁綅鏈烘縺鍏夎兘閲忚缃 UART_RemoteEncode(USART3, RemoteDataPacket.TX_BUF); UART_RemoteEncode(USART3, RemoteDataPacket.TX_BUF); RemoteDataPacket.RX_BUF[1]++; @@ -807,26 +807,26 @@ unsigned char UART_RemoteCMD_Process(void) retdata.energy[0] = RemoteDataPacket.RX_BUF[5]; retdata.energy[1] = RemoteDataPacket.RX_BUF[6]; - /*测试时发现,第一次总是不给上位机回复衰减值,这里强制复制一次*/ + /*娴嬭瘯鏃跺彂鐜帮紝绗竴娆℃绘槸涓嶇粰涓婁綅鏈哄洖澶嶈“鍑忓硷紝杩欓噷寮哄埗澶嶅埗涓娆*/ retdata.energy[0] = RemoteDataPacket.TX_BUF[5]; retdata.energy[1] = RemoteDataPacket.TX_BUF[6]; //UART_Answer_LightData(USART1 , &retdata); - attenuation_number(&cn , &RemoteDataPacket); /*2022 8 3 应小刘要求加入衰减数值显示*/ + attenuation_number(&cn , &RemoteDataPacket); /*2022 8 3 搴斿皬鍒樿姹傚姞鍏ヨ“鍑忔暟鍊兼樉绀*/ unsigned short show = 0; - unsigned char bit_point = 0; //显示的位数 - unsigned char decimal_point = 0; //显示的小数点位数 + unsigned char bit_point = 0; //鏄剧ず鐨勪綅鏁 + unsigned char decimal_point = 0; //鏄剧ず鐨勫皬鏁扮偣浣嶆暟 show = cn.control_number_hight | cn.control_number_low << 8; TIM_Cmd(TIM4 , ENABLE); static unsigned short getdata = 0; - getdata = (show / 10); //针对于1553版本修改 + getdata = (show / 10); //閽堝浜1553鐗堟湰淇敼 #ifdef DEBUGPR SEGGER_RTT_printf(0 , RTT_CTRL_TEXT_BRIGHT_GREEN "getdata = %d\r\n" , getdata); #endif - signed short int temp_dB_Loss = Set_Energy(getdata); /*机械调整*/ + signed short int temp_dB_Loss = Set_Energy(getdata); /*鏈烘璋冩暣*/ #ifdef SETPW SEGGER_RTT_printf(0 , RTT_CTRL_TEXT_BRIGHT_RED "dB_Loss = %d \r\n" , temp_dB_Loss); @@ -836,7 +836,7 @@ unsigned char UART_RemoteCMD_Process(void) double interpolatedValue = linearInterpolation(truncatedInt, podata, podatanum); int number = (int)(interpolatedValue); SEGGER_RTT_printf(0 , RTT_CTRL_TEXT_BRIGHT_GREEN " number = %d \r\n" , number); - FSMC_WR(4) = pulse_width_formula(number); /*电控调整*/ + FSMC_WR(4) = pulse_width_formula(number); /*鐢垫帶璋冩暣*/ #endif if(getdata < GEAR_2) @@ -879,7 +879,7 @@ unsigned char UART_RemoteCMD_Process(void) { return 0; } - if(show >= 0x3E8 ) /*数值大于三位数*/ + if(show >= 0x3E8 ) /*鏁板煎ぇ浜庝笁浣嶆暟*/ { bit_point = 3; decimal_point = 1; @@ -889,7 +889,7 @@ unsigned char UART_RemoteCMD_Process(void) decimal_point = 1; show = show / 10; } - //主要用于小数显示 + //涓昏鐢ㄤ簬灏忔暟鏄剧ず if(cn.Program_control_mode_1 == 0xff) { display.disenergy = 1; @@ -901,7 +901,7 @@ unsigned char UART_RemoteCMD_Process(void) } break; - /*仿真速率设定*/ + /*浠跨湡閫熺巼璁惧畾*/ case 0x42: if(RemoteDataPacket.RX_BUF[0] == 4) { @@ -918,10 +918,10 @@ unsigned char UART_RemoteCMD_Process(void) } break; - /*输出脉宽设定,该项只针对于20kw和100kw两款激光器*/ + /*杈撳嚭鑴夊璁惧畾锛岃椤瑰彧閽堝浜20kw鍜100kw涓ゆ婵鍏夊櫒*/ case 0x43: #if (VERSION_SELECTION == Ver_2_3_0) - /*光芯指令发送 5A A5 02 电流*/ + /*鍏夎姱鎸囦护鍙戦 5A A5 02 鐢垫祦*/ uc_sbuffer[3] = RemoteDataPacket.RX_BUF[3]; memset(Uart_Tx_Buffer3, 0, sizeof(Uart_Tx_Buffer3)); memcpy(Uart_Tx_Buffer3, uc_sbuffer, sizeof(uc_sbuffer)); @@ -929,49 +929,49 @@ unsigned char UART_RemoteCMD_Process(void) #endif break; - /*2024.05.06新增功能 输出脉冲个数设置 */ + /*2024.05.06鏂板鍔熻兘 杈撳嚭鑴夊啿涓暟璁剧疆 */ case 0x51: -// /*接收上位机数据*/ +// /*鎺ユ敹涓婁綅鏈烘暟鎹*/ // PulseNumber = RemoteDataPacket.RX_BUF[4]; // if(PulseNumber == 0) // { -// /* 关闭激光 */ +// /* 鍏抽棴婵鍏 */ // Laser_StateTurn(ENABLE); // FSMC_WR(5) = 0; // } // else // { -// /* 开启激光 */ +// /* 寮鍚縺鍏 */ // Laser_StateTurn(DISABLE); -// /* 输出脉冲个数写入CPLD*/ +// /* 杈撳嚭鑴夊啿涓暟鍐欏叆CPLD*/ // FSMC_WR(5) = PulseNumber; // } -// /* 指令应答 */ +// /* 鎸囦护搴旂瓟 */ // retdata.Mode = 0xd1; // UART_Answer_LightData(USART1 , &retdata); - /*接收上位机数据*/ + /*鎺ユ敹涓婁綅鏈烘暟鎹*/ PulseNumber = RemoteDataPacket.RX_BUF[4] & 0xff; PulseNumber = PulseNumber | RemoteDataPacket.RX_BUF[3] << 8; if(PulseNumber == 0) { FSMC_WR(5) = 0; - /* 关闭激光 */ + /* 鍏抽棴婵鍏 */ //Laser_StateTurn(ENABLE); - /* 24.11.13发现这里用的是普通出激光的函数,切换为单脉冲模式激光 - 需要测试上位机此功能是否正确*/ + /* 24.11.13鍙戠幇杩欓噷鐢ㄧ殑鏄櫘閫氬嚭婵鍏夌殑鍑芥暟,鍒囨崲涓哄崟鑴夊啿妯″紡婵鍏 + 闇瑕佹祴璇曚笂浣嶆満姝ゅ姛鑳芥槸鍚︽纭*/ Laser_StateTurn_OnePulse(ENABLE); } else { - /* 输出脉冲个数写入CPLD ,24 11 13 修改这部分代码将脉冲个数 - 1*/ + /* 杈撳嚭鑴夊啿涓暟鍐欏叆CPLD 锛24 11 13 淇敼杩欓儴鍒嗕唬鐮佸皢鑴夊啿涓暟 - 1*/ FSMC_WR(5) = PulseNumber - 1; - /* 开启激光 */ + /* 寮鍚縺鍏 */ //Laser_StateTurn(DISABLE); - /* 24.11.13发现这里用的是普通出激光的函数,切换为单脉冲模式激光 - 需要测试上位机此功能是否正确*/ + /* 24.11.13鍙戠幇杩欓噷鐢ㄧ殑鏄櫘閫氬嚭婵鍏夌殑鍑芥暟,鍒囨崲涓哄崟鑴夊啿妯″紡婵鍏 + 闇瑕佹祴璇曚笂浣嶆満姝ゅ姛鑳芥槸鍚︽纭*/ Laser_StateTurn_OnePulse(DISABLE); } - /* 指令应答 */ + /* 鎸囦护搴旂瓟 */ retdata.Mode = 0xd1; retdata.pluse_num[0] = (PulseNumber&0xff) << 8; retdata.pluse_num[1] = PulseNumber&0xff; @@ -986,12 +986,12 @@ unsigned char UART_RemoteCMD_Process(void) } else { - return 0x1; //退出,报告校验和错误 + return 0x1; //閫鍑猴紝鎶ュ憡鏍¢獙鍜岄敊璇 } } else { - return 0x2; //退出,报告数据长度不够 + return 0x2; //閫鍑猴紝鎶ュ憡鏁版嵁闀垮害涓嶅 } } @@ -999,16 +999,16 @@ unsigned char UART_RemoteCMD_Process(void) /** - * @brief 串口单字节指令发送,屎山代码,不想自己找麻烦就别动他 + * @brief 涓插彛鍗曞瓧鑺傛寚浠ゅ彂閫侊紝灞庡北浠g爜锛屼笉鎯宠嚜宸辨壘楹荤儲灏卞埆鍔ㄤ粬 * - * 这里可以提供关于函数的高级概述,包括它的输入和输出。 + * 杩欓噷鍙互鎻愪緵鍏充簬鍑芥暟鐨勯珮绾ф杩帮紝鍖呮嫭瀹冪殑杈撳叆鍜岃緭鍑恒 * - * @param[in] 参数1 参数1的描述,包括数据类型和含义 - * @param[out] 参数2 参数2的描述,包括数据类型和含义 + * @param[in] 鍙傛暟1 鍙傛暟1鐨勬弿杩帮紝鍖呮嫭鏁版嵁绫诲瀷鍜屽惈涔 + * @param[out] 鍙傛暟2 鍙傛暟2鐨勬弿杩帮紝鍖呮嫭鏁版嵁绫诲瀷鍜屽惈涔 * - * @return 函数返回值的描述,包括数据类型和含义,如果适用的话。 + * @return 鍑芥暟杩斿洖鍊肩殑鎻忚堪锛屽寘鎷暟鎹被鍨嬪拰鍚箟锛屽鏋滈傜敤鐨勮瘽銆 * - * @note 任何特殊注意事项或用法示例都可以在这里添加。 + * @note 浠讳綍鐗规畩娉ㄦ剰浜嬮」鎴栫敤娉曠ず渚嬮兘鍙互鍦ㄨ繖閲屾坊鍔犮 */ void UART_Answer_LightData(USART_TypeDef* USARTx , RETDATA* rd) { @@ -1016,22 +1016,23 @@ void UART_Answer_LightData(USART_TypeDef* USARTx , RETDATA* rd) unsigned char ctmmp = rd->temp; unsigned char ccyle[5] = {rd->cycle[0] , rd->cycle[1] , rd->cycle[2]}; unsigned char cenergy[5] = {rd->energy[0] , rd->energy[1] , rd->energy[2]}; - RemoteDataPacket.TX_BUF[0] = 0; // Buff清零 - UART_SendInbuff(RemoteDataPacket.TX_BUF , RemoteDataPacket.RX_BUF[1]); /*返回对应的包序号*/ + unsigned char pulse_num[2] = {rd->pluse_num[0],rd->pluse_num[1]}; + RemoteDataPacket.TX_BUF[0] = 0; // Buff娓呴浂 + UART_SendInbuff(RemoteDataPacket.TX_BUF , RemoteDataPacket.RX_BUF[1]); /*杩斿洖瀵瑰簲鐨勫寘搴忓彿*/ switch(cmode) { - case 0x80://握手 + case 0x80://鎻℃墜 UART_SendInbuff(RemoteDataPacket.TX_BUF , cmode); UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); UART_SendInbuff(RemoteDataPacket.TX_BUF , ctmmp); - /*1535激光器*/ + /*1535婵鍏夊櫒*/ UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x23); UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x12); break; - case 0x81://激光开 + case 0x81://婵鍏夊紑 UART_SendInbuff(RemoteDataPacket.TX_BUF , cmode); UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); @@ -1039,7 +1040,7 @@ void UART_Answer_LightData(USART_TypeDef* USARTx , RETDATA* rd) UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); break; - case 0x82://激光关 + case 0x82://婵鍏夊叧 UART_SendInbuff(RemoteDataPacket.TX_BUF , cmode); UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); @@ -1047,7 +1048,7 @@ void UART_Answer_LightData(USART_TypeDef* USARTx , RETDATA* rd) UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); break; - case 0x83://开红光 + case 0x83://寮绾㈠厜 UART_SendInbuff(RemoteDataPacket.TX_BUF , cmode); UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); @@ -1055,7 +1056,7 @@ void UART_Answer_LightData(USART_TypeDef* USARTx , RETDATA* rd) UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); break; - case 0x84://关红光 + case 0x84://鍏崇孩鍏 UART_SendInbuff(RemoteDataPacket.TX_BUF , cmode); UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); @@ -1063,7 +1064,7 @@ void UART_Answer_LightData(USART_TypeDef* USARTx , RETDATA* rd) UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); break; - case 0x89://程控模式 + case 0x89://绋嬫帶妯″紡 UART_SendInbuff(RemoteDataPacket.TX_BUF , cmode); UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); @@ -1071,7 +1072,7 @@ void UART_Answer_LightData(USART_TypeDef* USARTx , RETDATA* rd) UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); break; - case 0x90://暂停 + case 0x90://鏆傚仠 UART_SendInbuff(RemoteDataPacket.TX_BUF , cmode); UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); @@ -1079,7 +1080,7 @@ void UART_Answer_LightData(USART_TypeDef* USARTx , RETDATA* rd) UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); break; - case 0x91://频率装订 + case 0x91://棰戠巼瑁呰 UART_SendInbuff(RemoteDataPacket.TX_BUF , cmode); UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); UART_SendInbuff(RemoteDataPacket.TX_BUF , ccyle[0]); @@ -1088,7 +1089,7 @@ void UART_Answer_LightData(USART_TypeDef* USARTx , RETDATA* rd) break; - case 0xc1://能量装订 + case 0xc1://鑳介噺瑁呰 UART_SendInbuff(RemoteDataPacket.TX_BUF , cmode); UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); UART_SendInbuff(RemoteDataPacket.TX_BUF , cenergy[0]); @@ -1096,14 +1097,14 @@ void UART_Answer_LightData(USART_TypeDef* USARTx , RETDATA* rd) UART_SendInbuff(RemoteDataPacket.TX_BUF , cenergy[2]); break; - case 0xd1://脉冲个数装订 + case 0xd1://鑴夊啿涓暟瑁呰 UART_SendInbuff(RemoteDataPacket.TX_BUF , cmode); UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); - UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); - UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); + UART_SendInbuff(RemoteDataPacket.TX_BUF , pulse_num[0]); + UART_SendInbuff(RemoteDataPacket.TX_BUF , pulse_num[1]); break; - case 0xA2://伪随机成功 + case 0xA2://浼殢鏈烘垚鍔 UART_SendInbuff(RemoteDataPacket.TX_BUF , cmode); UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); @@ -1111,7 +1112,7 @@ void UART_Answer_LightData(USART_TypeDef* USARTx , RETDATA* rd) UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); break; - case 0xAE://伪随机错误 + case 0xAE://浼殢鏈洪敊璇 UART_SendInbuff(RemoteDataPacket.TX_BUF , cmode); UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); @@ -1119,7 +1120,7 @@ void UART_Answer_LightData(USART_TypeDef* USARTx , RETDATA* rd) UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); break; - case 0xA3://V3.01 改伪随机长度,伪随机存储成功 + case 0xA3://V3.01 鏀逛吉闅忔満闀垮害锛屼吉闅忔満瀛樺偍鎴愬姛 UART_SendInbuff(RemoteDataPacket.TX_BUF , cmode); UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); @@ -1127,7 +1128,7 @@ void UART_Answer_LightData(USART_TypeDef* USARTx , RETDATA* rd) UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); break; - case 0xA4://V3.01 改伪随机长度,伪随机删除成功 + case 0xA4://V3.01 鏀逛吉闅忔満闀垮害锛屼吉闅忔満鍒犻櫎鎴愬姛 UART_SendInbuff(RemoteDataPacket.TX_BUF , cmode); UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); UART_SendInbuff(RemoteDataPacket.TX_BUF , 0x00); -- Gitee From 2558b30d76a7a0dec58a8fffd5e691c4f5d133b3 Mon Sep 17 00:00:00 2001 From: maybe_404 <318900243@qq.com> Date: Mon, 18 Nov 2024 03:54:05 +0000 Subject: [PATCH 2/2] =?UTF-8?q?update=20User/src/bsp.c.=20line=20976~978?= =?UTF-8?q?=20=E4=BF=AE=E6=94=B9=20BUG=20=E5=8E=9F=E5=A7=8B=E5=86=99?= =?UTF-8?q?=E6=B3=95=EF=BC=8C=E6=AD=A3=E7=A1=AE=E5=BA=94=E8=AF=A5byte[0]?= =?UTF-8?q?=E4=B8=BA=E9=AB=988=E4=BD=8D=20=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20retdata.pluse=5Fnum[0]=20=3D=20(PulseNumber&0xff)=20<<=208;?= =?UTF-8?q?=20=E6=9B=B4=E6=AD=A3=E5=90=8E=E7=9A=84=E5=86=99=E6=B3=95=20=20?= =?UTF-8?q?=20=20=20=20=20=20=20=20=20=20retdata.pluse=5Fnum[0]=20=3D=20(P?= =?UTF-8?q?ulseNumber=20>>=208)=20&=200xff;=20//=E9=AB=988=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: maybe_404 <318900243@qq.com> --- User/src/bsp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/User/src/bsp.c b/User/src/bsp.c index cb930b1..e8e1fa2 100644 --- a/User/src/bsp.c +++ b/User/src/bsp.c @@ -973,8 +973,9 @@ unsigned char UART_RemoteCMD_Process(void) } /* 鎸囦护搴旂瓟 */ retdata.Mode = 0xd1; - retdata.pluse_num[0] = (PulseNumber&0xff) << 8; - retdata.pluse_num[1] = PulseNumber&0xff; + //retdata.pluse_num[0] = (PulseNumber&0xff) << 8; //閿欒鍐欐硶 + retdata.pluse_num[0] = (PulseNumber >> 8) & 0xff; //楂8 + retdata.pluse_num[1] = PulseNumber&0xff;//浣8 UART_Answer_LightData(USART1 , &retdata); break; -- Gitee