diff --git a/ETH/UdpServer/Ld/Link.ld b/ETH/UdpServer/Ld/Link.ld index 0c48aca..38ecd27 100644 --- a/ETH/UdpServer/Ld/Link.ld +++ b/ETH/UdpServer/Ld/Link.ld @@ -7,7 +7,7 @@ PROVIDE( _stack_size = __stack_size ); MEMORY { - FLASH (rx) : ORIGIN = 0x0000000, LENGTH = 214K + FLASH (rx) : ORIGIN = 0x000A000, LENGTH = 214K RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K } diff --git a/ETH/UdpServer/User/ch32v30x_it.c b/ETH/UdpServer/User/ch32v30x_it.c index bc1506d..8c417a4 100644 --- a/ETH/UdpServer/User/ch32v30x_it.c +++ b/ETH/UdpServer/User/ch32v30x_it.c @@ -185,6 +185,20 @@ void CAN2_RX1_IRQHandler(void) if(CanRxStructure.DLC > 0)//长度大于0 { + + // if (CanRxStructure.ExtId == DF_CanIDbattery) + // { + // memcpy((uint8_t *)&un_wheel_speed_input.,(uint8_t *)&(CanRxStructure.Data[0]),8);//接受电池 + // RgCanToBatteryCnt ++; + // } + // else if (CanRxStructure.ExtId == DF_CanIDRCH_3) + // { + // memcpy((uint8_t *)&UnRCH_3Signal_1.ArrData.ArrRx[0][0],(uint8_t *)&(CanRxStructure.Data[0]),8);//接受遥控器数据 + // RgCanRC6GSCnt ++; + // } + + + CAN_Send_Msg(CAN2, 0x7F2, CAN_Id_Standard, CAN_RTR_Data, &CanRxStructure.Data[0], 8);//调试信息发送 } } diff --git a/ETH/UdpServer/User/interface.c b/ETH/UdpServer/User/interface.c index cdda314..522d116 100644 --- a/ETH/UdpServer/User/interface.c +++ b/ETH/UdpServer/User/interface.c @@ -23,6 +23,8 @@ StrRequestMessage str_RequestMessage = {0};//璇锋眰淇℃伅 UnInfNavigationRS232Output navigation_rs232_output = {0};//涓插彛杈撳嚭鏁版嵁 +UnWheelSpeedInput un_wheel_speed_input = {0};//杞熻緭鍏 + rtcmBuffer RTCM_Buffer1 = {0,0,0}; imuBuffer imu_buffer1 = {0,0,0}; diff --git a/ETH/UdpServer/User/interface.h b/ETH/UdpServer/User/interface.h index 1db7678..7a8b0cf 100644 --- a/ETH/UdpServer/User/interface.h +++ b/ETH/UdpServer/User/interface.h @@ -185,8 +185,20 @@ typedef union _UnInfNavigationOutputC } UnInfNavigationOutputC; +/* 杞﹁締杞熻緭鍏ユ暟鎹粨鏋勪綋 */ +typedef struct { + /* 鍥涜疆閫熷害鏁版嵁 (8瀛楄妭) */ + int16_t front_left_speed; // 宸﹀墠杞 鍗曚綅锛歬m/h + int16_t front_right_speed; // 鍙冲墠杞 鍗曚綅锛歬m/h + int16_t rear_left_speed; // 宸﹀悗杞 鍗曚綅锛歬m/h + int16_t rear_right_speed; // 鍙冲悗杞 鍗曚綅锛歬m/h +} StrVehicleWheelSpeedInput; - +/* 杞熸暟鎹仈鍚堜綋锛堢敤浜庡師濮嬪瓧鑺傝闂級 */ +typedef union { + StrVehicleWheelSpeedInput speed_data; // 缁撴瀯鍖栬疆閫熸暟鎹 + uint8_t arr[sizeof(StrVehicleWheelSpeedInput)]; // 鍘熷瀛楄妭鏁扮粍 +} UnWheelSpeedInput; diff --git a/ETH/UdpServer/User/interface_can.c b/ETH/UdpServer/User/interface_can.c index b8bef35..12f8c35 100644 --- a/ETH/UdpServer/User/interface_can.c +++ b/ETH/UdpServer/User/interface_can.c @@ -63,10 +63,10 @@ void CAN1_Mode_Init( u8 tsjw, u8 tbs2, u8 tbs1, u16 brp, u8 mode ) CAN_FilterInitSturcture.CAN_FilterNumber = 0; CAN_FilterInitSturcture.CAN_FilterMode = CAN_FilterMode_IdMask; CAN_FilterInitSturcture.CAN_FilterScale = CAN_FilterScale_32bit; - CAN_FilterInitSturcture.CAN_FilterIdHigh = (uint16_t)((((DF_CanIDbattery|DF_CanIDRCH_3)<>16);//(uint16_t)(((0x10000001<<3)|0x04)>>16);//应该是 - CAN_FilterInitSturcture.CAN_FilterIdLow = (uint16_t)(((DF_CanIDbattery|DF_CanIDRCH_3)<> 16); - CAN_FilterInitSturcture.CAN_FilterMaskIdLow = (uint16_t)(((~(DF_CanIDbattery^DF_CanIDRCH_3))<>16);//(uint16_t)(((0x10000001<<3)|0x04)>>16);//应该是 + CAN_FilterInitSturcture.CAN_FilterIdLow = (uint16_t)(((DF_CanIDMotor1|DF_CanIDMotor2)<> 16); + CAN_FilterInitSturcture.CAN_FilterMaskIdLow = (uint16_t)(((~(DF_CanIDMotor1^DF_CanIDMotor2))<>16);//(uint16_t)(((0x10000001<<3)|0x04)>>16);//应该是 - CAN_FilterInitSturcture.CAN_FilterIdLow = (uint16_t)(((DF_CanIDMotor1|DF_CanIDMotor2)<> 16); - CAN_FilterInitSturcture.CAN_FilterMaskIdLow = (uint16_t)(((~(DF_CanIDMotor1^DF_CanIDMotor2))<>16);//(uint16_t)(((0x10000001<<3)|0x04)>>16);//应该是 + CAN_FilterInitSturcture.CAN_FilterIdLow = (uint16_t)(((DF_CanIDMotor1|DF_CanIDMotor2)<> 16); + CAN_FilterInitSturcture.CAN_FilterMaskIdLow = (uint16_t)(((~(DF_CanIDMotor1^DF_CanIDMotor2))<C.0 RX-->C.1 */ //接的982的com1 +/* UART6 TX-->C.0 RX-->C.1 */ //锟接碉拷982锟斤拷com1 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; @@ -389,7 +389,7 @@ void initUart(void) NVIC_Init(&NVIC_InitStructure); USART_Cmd(UART6, ENABLE); -/* UART7 TX-->C.2 RX-->C.3 *///接的982的com2 +/* UART7 TX-->C.2 RX-->C.3 *///锟接碉拷982锟斤拷com2 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; @@ -443,7 +443,7 @@ void initUart(void) -void uartSendto(USART_TypeDef *USARTx, uint8_t * ucData, uint16_t len)//串口2发送函数 +void uartSendto(USART_TypeDef *USARTx, uint8_t * ucData, uint16_t len)//锟斤拷锟斤拷2锟斤拷锟酵猴拷锟斤拷 { for(uint16_t i = 0; i= 20) - { - debug1s_cnt = 0; - printf("nmea_buf tail:%d head:%d\n", - nmea_rx_buf.tail, nmea_rx_buf.head); - } + // debug1s_cnt ++; + // if(debug1s_cnt >= 20) + // { + // debug1s_cnt = 0; + // printf("nmea_buf tail:%d head:%d\n", + // nmea_rx_buf.tail, nmea_rx_buf.head); + // } while(nmea_rx_buf.tail != nmea_rx_buf.head && !frame_complete) - { // 缓冲区非空且未完成一帧解析 + { // 锟斤拷锟斤拷锟斤拷锟角匡拷锟斤拷未锟斤拷锟揭恢★拷锟斤拷锟 uint8_t ch = nmea_rx_buf.buffer[nmea_rx_buf.tail]; nmea_rx_buf.tail = (nmea_rx_buf.tail + 1) % RING_BUF_SIZE; if(nmea_rx_buf.overflow) { nmea_rx_buf.tail = nmea_rx_buf.head; - // 3. 重置溢出标志 + // 3. 锟斤拷锟斤拷锟斤拷锟斤拷锟街 nmea_rx_buf.overflow = 0; - // 4. 触发错误恢复流程(如重发请求) + // 4. 锟斤拷锟斤拷锟斤拷锟斤拷指锟斤拷锟斤拷蹋锟斤拷锟斤拷胤锟斤拷锟斤拷锟 printf("Overflow recovery\n"); } - // 帧头检测 + // 帧头锟斤拷锟 if(ch == '$') { if(parse_idx > 0 && parsing_buf[parse_idx-1] == '\n') { - if (nmea_validate_checksum((char *)parsing_buf)) //校验代码 + if (nmea_validate_checksum((char *)parsing_buf)) //校锟斤拷锟斤拷锟 { memcpy(&nema_output1.buffer[0],parsing_buf,parse_idx); publishMessage(&nema_output1, 1); - frame_complete = true; // 标记帧处理完成 + frame_complete = true; // 锟斤拷锟街★拷锟斤拷锟斤拷锟斤拷 } else { printf("nmea crc error"); - frame_complete = true; // 标记帧处理完成 + frame_complete = true; // 锟斤拷锟街★拷锟斤拷锟斤拷锟斤拷 } } parse_idx = 0; } - // 存储数据 + // 锟芥储锟斤拷锟斤拷 if(parse_idx < RING_BUF_SIZE-1 && !frame_complete) { parsing_buf[parse_idx++] = ch; - // 帧尾检测 + // 帧尾锟斤拷锟 if(parse_idx >= 2 && parsing_buf[parse_idx-2] == '\r' && parsing_buf[parse_idx-1] == '\n') { - if (nmea_validate_checksum((char *)parsing_buf)) //校验代码 + if (nmea_validate_checksum((char *)parsing_buf)) //校锟斤拷锟斤拷锟 { memcpy(&nema_output1.buffer[0],parsing_buf,parse_idx); publishMessage(&nema_output1, 1); - frame_complete = true; // 标记帧处理完成 + frame_complete = true; // 锟斤拷锟街★拷锟斤拷锟斤拷锟斤拷 } else { printf("nmea buf error"); - frame_complete = true; // 标记帧处理完成 + frame_complete = true; // 锟斤拷锟街★拷锟斤拷锟斤拷锟斤拷 } parse_idx = 0; } } else if(!frame_complete) { - parse_idx = 0; // 防止溢出 + parse_idx = 0; // 锟斤拷止锟斤拷锟 } } - timerStart(&nmea_timer, 50, 1); // 100ms后再次触发 + timerStart(&nmea_timer, 10, 1); // 100ms锟斤拷锟劫次达拷锟斤拷 } void navigationRs232Process(void *signal_id) @@ -630,7 +630,7 @@ void navigationRs232Process(void *signal_id) -// APP模块的初始化 +// APP模锟斤拷某锟绞硷拷锟 void interfaceUartInit(void) { subscribe(&set_output_data, setDataProcess); @@ -641,7 +641,7 @@ void interfaceUartInit(void) subscribe(&nmea_timer, ProcessNMEAFrames); subscribe(&navigation_rs232_output, navigationRs232Process); - timerStart(&nmea_timer, 50,1);//50ms + timerStart(&nmea_timer, 10,1);//50ms printf("interface uart: initial OK %d\n",getCurrentTime()); } diff --git a/ETH/UdpServer/User/interface_uart.h b/ETH/UdpServer/User/interface_uart.h index 03b3ca1..a6a6831 100644 --- a/ETH/UdpServer/User/interface_uart.h +++ b/ETH/UdpServer/User/interface_uart.h @@ -26,7 +26,7 @@ #define UM982_RX_IRQn DMA2_Channel9_IRQn -#define RING_BUF_SIZE 4096 +#define RING_BUF_SIZE 6144 // 环形缓冲区结构体定义 diff --git a/ETH/UdpServer/User/main.c b/ETH/UdpServer/User/main.c index 558b476..4bd8511 100644 --- a/ETH/UdpServer/User/main.c +++ b/ETH/UdpServer/User/main.c @@ -133,7 +133,7 @@ int main(void) bootInterfaceInit(); appMonitorInit(); -// testAppInit(); + testAppInit(); feedWatchdog(); dataProcessingAppInit(); ethernetInterfaceInit(); diff --git a/ETH/UdpServer/app/app_data_processing.c b/ETH/UdpServer/app/app_data_processing.c index ac34883..2c36e41 100644 --- a/ETH/UdpServer/app/app_data_processing.c +++ b/ETH/UdpServer/app/app_data_processing.c @@ -353,13 +353,13 @@ void rs232Process(void) navigation_rs232_output.bit_data.gyro_z = (int16_t) (float_temp*32768/300.0f); //加速度 - float_temp = (float) (yis321_data.bit_data.acc_x)*0.000001f/9.8;//修改单位为g + float_temp = (float) (yis321_data.bit_data.acc_x)*0.000001f;//修改单位为g navigation_rs232_output.bit_data.accel_x = (int16_t) (float_temp*32768/12.0f); - float_temp = (float) (yis321_data.bit_data.acc_y)*0.000001f/9.8;//修改单位为g + float_temp = (float) (yis321_data.bit_data.acc_y)*0.000001f;//修改单位为g navigation_rs232_output.bit_data.accel_y = (int16_t) (float_temp*32768/12.0f); - float_temp = (float) (yis321_data.bit_data.acc_z)*0.000001f/9.8;//修改单位为g + float_temp = (float) (yis321_data.bit_data.acc_z)*0.000001f;//修改单位为g navigation_rs232_output.bit_data.accel_z = (int16_t) (float_temp*32768/12.0f); //gps信息 @@ -432,9 +432,6 @@ void imuInput(void *signal_id) } - - - publishMessage(&navigation_output1, 1); } break; @@ -482,32 +479,30 @@ void iim6234Init(void *signal_id) void nmeaPrintf(void *signal_id) { - // printf("[THS] Heading:%.1f° Mode:%c\n", - // ths_data1.heading, ths_data1.mode); - // printf("[VTG] Course:%.1f° Speed:%.1fkm/h\n", - // vtg_data1.course_true, vtg_data1.speed_kmh); + printf("[THS] Heading:%.1f° Mode:%c\n", + ths_data1.heading, ths_data1.mode); + printf("[VTG] Course:%.1f° Speed:%.1fkm/h\n", + vtg_data1.course_true, vtg_data1.speed_kmh); - // printf("[GGA] Time:%.2f Lat:%.5f%c Lon:%.5f%c Alt:%.2f rtk_state:%d satellite:%d hdop:%2f\n", - // gga_data1.utc_time, - // gga_data1.latitude, gga_data1.lat_dir, - // gga_data1.longitude, gga_data1.lon_dir, - // gga_data1.altitude, // 假设高度单位为M(米) - // gga_data1.fix_quality, - // gga_data1.satellites, - // gga_data1.hdop - // ); + printf("[GGA] Time:%.2f Lat:%.5f%c Lon:%.5f%c Alt:%.2f rtk_state:%d satellite:%d hdop:%2f\n", + gga_data1.utc_time, + gga_data1.latitude, gga_data1.lat_dir, + gga_data1.longitude, gga_data1.lon_dir, + gga_data1.altitude, // 假设高度单位为M(米) + gga_data1.fix_quality, + gga_data1.satellites, + gga_data1.hdop + ); - // printf("四元数: (%.6f, %.6f, %.6f, %.6f)\n", - // yis321_data.bit_data.q0*0.000001, yis321_data.bit_data.q1*0.000001, yis321_data.bit_data.q2*0.000001, (int32_t)yis321_data.bit_data.q3*0.000001); + printf("四元数: (%.6f, %.6f, %.6f, %.6f)\n", + yis321_data.bit_data.q0*0.000001, yis321_data.bit_data.q1*0.000001, yis321_data.bit_data.q2*0.000001, (int32_t)yis321_data.bit_data.q3*0.000001); - // printf("欧拉角: (%.6f, %.6f, %.6f)\n", - // yis321_data.bit_data.pitch*0.000001, yis321_data.bit_data.roll*0.000001, yis321_data.bit_data.yaw*0.000001); + printf("欧拉角: (%.6f, %.6f, %.6f)\n", + yis321_data.bit_data.pitch*0.000001, yis321_data.bit_data.roll*0.000001, yis321_data.bit_data.yaw*0.000001); printf("AccX:%f,AccY:%f,AccZ:%f,",Acc[0],Acc[1],Acc[2]); printf("GyroX:%f,GyroY:%f,GyroZ:%f\r\n",Gyro[0],Gyro[1],Gyro[2]);//使用串口打印加速度,角速度数据 - - timerStart(&data_processing_timer, 1000,1);//100ms } diff --git a/ETH/UdpServer/app/app_test.c b/ETH/UdpServer/app/app_test.c index 746d285..5aaf61f 100644 --- a/ETH/UdpServer/app/app_test.c +++ b/ETH/UdpServer/app/app_test.c @@ -21,14 +21,14 @@ void testTimerProcess(void *signal_id) static uint32_t start_time = 0; // short hx,hy,hz=0; - - printf("testAPP: %d us \n",getCurrentTime() - start_time); + printf("testAPP\n"); +// printf("testAPP: %d us \n",getCurrentTime() - start_time); // uint8_t arrtest4[10] = {0x56,0x56,0x04}; - printf("AccX:%f,AccY:%f,AccZ:%f,",Acc[0],Acc[1],Acc[2]); - printf("GyroX:%f,GyroY:%f,GyroZ:%f\r\n",Gyro[0],Gyro[1],Gyro[2]);//浣跨敤涓插彛鎵撳嵃鍔犻熷害锛岃閫熷害鏁版嵁 - printf("RM3100 hx: %d, hy: %d, hz: %d\r\n", navigation_output1.bit_data.magnetic_x_axis, navigation_output1.bit_data.magnetic_y_axis, navigation_output1.bit_data.magnetic_z_axis); +// printf("AccX:%f,AccY:%f,AccZ:%f,",Acc[0],Acc[1],Acc[2]); + // printf("GyroX:%f,GyroY:%f,GyroZ:%f\r\n",Gyro[0],Gyro[1],Gyro[2]);//浣跨敤涓插彛鎵撳嵃鍔犻熷害锛岃閫熷害鏁版嵁 + // printf("RM3100 hx: %d, hy: %d, hz: %d\r\n", navigation_output1.bit_data.magnetic_x_axis, navigation_output1.bit_data.magnetic_y_axis, navigation_output1.bit_data.magnetic_z_axis); // uint8_t tesr1 = 0;