Compare commits
3 Commits
20251024-I
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 8cbe6f7005 | |||
| ef5126e4f4 | |||
| 2f580d0d3a |
@@ -7,7 +7,7 @@ PROVIDE( _stack_size = __stack_size );
|
|||||||
|
|
||||||
MEMORY
|
MEMORY
|
||||||
{
|
{
|
||||||
FLASH (rx) : ORIGIN = 0x0000000, LENGTH = 214K
|
FLASH (rx) : ORIGIN = 0x000A000, LENGTH = 214K
|
||||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K
|
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -185,6 +185,20 @@ void CAN2_RX1_IRQHandler(void)
|
|||||||
|
|
||||||
if(CanRxStructure.DLC > 0)//<2F><><EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD>0
|
if(CanRxStructure.DLC > 0)//<2F><><EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD>0
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// if (CanRxStructure.ExtId == DF_CanIDbattery)
|
||||||
|
// {
|
||||||
|
// memcpy((uint8_t *)&un_wheel_speed_input.,(uint8_t *)&(CanRxStructure.Data[0]),8);//<2F><><EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD>
|
||||||
|
// RgCanToBatteryCnt ++;
|
||||||
|
// }
|
||||||
|
// else if (CanRxStructure.ExtId == DF_CanIDRCH_3)
|
||||||
|
// {
|
||||||
|
// memcpy((uint8_t *)&UnRCH_3Signal_1.ArrData.ArrRx[0][0],(uint8_t *)&(CanRxStructure.Data[0]),8);//<2F><><EFBFBD><EFBFBD>ң<EFBFBD><D2A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
// RgCanRC6GSCnt ++;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CAN_Send_Msg(CAN2, 0x7F2, CAN_Id_Standard, CAN_RTR_Data, &CanRxStructure.Data[0], 8);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
|
CAN_Send_Msg(CAN2, 0x7F2, CAN_Id_Standard, CAN_RTR_Data, &CanRxStructure.Data[0], 8);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ StrRequestMessage str_RequestMessage = {0};//请求信息
|
|||||||
|
|
||||||
UnInfNavigationRS232Output navigation_rs232_output = {0};//串口输出数据
|
UnInfNavigationRS232Output navigation_rs232_output = {0};//串口输出数据
|
||||||
|
|
||||||
|
UnWheelSpeedInput un_wheel_speed_input = {0};//轮速输入
|
||||||
|
|
||||||
|
|
||||||
rtcmBuffer RTCM_Buffer1 = {0,0,0};
|
rtcmBuffer RTCM_Buffer1 = {0,0,0};
|
||||||
imuBuffer imu_buffer1 = {0,0,0};
|
imuBuffer imu_buffer1 = {0,0,0};
|
||||||
|
|||||||
@@ -185,8 +185,20 @@ typedef union _UnInfNavigationOutputC
|
|||||||
} UnInfNavigationOutputC;
|
} UnInfNavigationOutputC;
|
||||||
|
|
||||||
|
|
||||||
|
/* 车辆轮速输入数据结构体 */
|
||||||
|
typedef struct {
|
||||||
|
/* 四轮速度数据 (8字节) */
|
||||||
|
int16_t front_left_speed; // 左前轮速 单位:km/h
|
||||||
|
int16_t front_right_speed; // 右前轮速 单位:km/h
|
||||||
|
int16_t rear_left_speed; // 左后轮速 单位:km/h
|
||||||
|
int16_t rear_right_speed; // 右后轮速 单位:km/h
|
||||||
|
} StrVehicleWheelSpeedInput;
|
||||||
|
|
||||||
|
/* 轮速数据联合体(用于原始字节访问) */
|
||||||
|
typedef union {
|
||||||
|
StrVehicleWheelSpeedInput speed_data; // 结构化轮速数据
|
||||||
|
uint8_t arr[sizeof(StrVehicleWheelSpeedInput)]; // 原始字节数组
|
||||||
|
} UnWheelSpeedInput;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -244,13 +256,20 @@ typedef struct _StrRequestMessage
|
|||||||
// uint8_t data[4];
|
// uint8_t data[4];
|
||||||
// }YisDateFrame;
|
// }YisDateFrame;
|
||||||
|
|
||||||
|
typedef enum{
|
||||||
|
init = 0,
|
||||||
|
uart,
|
||||||
|
ethernet,
|
||||||
|
}rtcm_type;
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint8_t dma_buffer[2][RX_BUFFER_LEN]; // 双缓冲
|
uint8_t dma_buffer[2][RX_BUFFER_LEN]; // 双缓冲
|
||||||
volatile uint8_t active_buf; // 当前活跃缓冲区索引
|
volatile uint8_t active_buf; // 当前活跃缓冲区索引
|
||||||
volatile uint16_t buf_len; // 当前活跃缓冲区索引
|
volatile uint16_t buf_len; // 当前活跃缓冲区索引
|
||||||
|
volatile rtcm_type type; // 串口或者以太网
|
||||||
|
volatile uint8_t eth_cnt; // 当前活跃缓冲区索引
|
||||||
} rtcmBuffer;
|
} rtcmBuffer;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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_FilterNumber = 0;
|
||||||
CAN_FilterInitSturcture.CAN_FilterMode = CAN_FilterMode_IdMask;
|
CAN_FilterInitSturcture.CAN_FilterMode = CAN_FilterMode_IdMask;
|
||||||
CAN_FilterInitSturcture.CAN_FilterScale = CAN_FilterScale_32bit;
|
CAN_FilterInitSturcture.CAN_FilterScale = CAN_FilterScale_32bit;
|
||||||
CAN_FilterInitSturcture.CAN_FilterIdHigh = (uint16_t)((((DF_CanIDbattery|DF_CanIDRCH_3)<<DF_ExtIDShift)|0x04)>>16);//(uint16_t)(((0x10000001<<3)|0x04)>>16);//Ӧ<><D3A6><EFBFBD><EFBFBD>
|
CAN_FilterInitSturcture.CAN_FilterIdHigh = (uint16_t)((((DF_CanIDMotor1|DF_CanIDMotor2)<<DF_ExtIDShift)|0x04)>>16);//(uint16_t)(((0x10000001<<3)|0x04)>>16);//Ӧ<><D3A6><EFBFBD><EFBFBD>
|
||||||
CAN_FilterInitSturcture.CAN_FilterIdLow = (uint16_t)(((DF_CanIDbattery|DF_CanIDRCH_3)<<DF_ExtIDShift)|0x04);//(uint16_t)(((0x10000001<<3)|0x04));//
|
CAN_FilterInitSturcture.CAN_FilterIdLow = (uint16_t)(((DF_CanIDMotor1|DF_CanIDMotor2)<<DF_ExtIDShift)|0x04);//(uint16_t)(((0x10000001<<3)|0x04));//
|
||||||
CAN_FilterInitSturcture.CAN_FilterMaskIdHigh = (uint16_t)((((~(DF_CanIDbattery^DF_CanIDRCH_3))<<DF_ExtIDShift)|0x0E) >> 16);
|
CAN_FilterInitSturcture.CAN_FilterMaskIdHigh = (uint16_t)((((~(DF_CanIDMotor1^DF_CanIDMotor2))<<DF_ExtIDShift)|0x0E) >> 16);
|
||||||
CAN_FilterInitSturcture.CAN_FilterMaskIdLow = (uint16_t)(((~(DF_CanIDbattery^DF_CanIDRCH_3))<<DF_ExtIDShift)|0x0E);
|
CAN_FilterInitSturcture.CAN_FilterMaskIdLow = (uint16_t)(((~(DF_CanIDMotor1^DF_CanIDMotor2))<<DF_ExtIDShift)|0x0E);
|
||||||
CAN_FilterInitSturcture.CAN_FilterFIFOAssignment = CAN_Filter_FIFO0;
|
CAN_FilterInitSturcture.CAN_FilterFIFOAssignment = CAN_Filter_FIFO0;
|
||||||
CAN_FilterInitSturcture.CAN_FilterActivation = ENABLE;
|
CAN_FilterInitSturcture.CAN_FilterActivation = ENABLE;
|
||||||
CAN_FilterInit( &CAN_FilterInitSturcture );
|
CAN_FilterInit( &CAN_FilterInitSturcture );
|
||||||
@@ -151,10 +151,10 @@ void CAN2_Mode_Init( u8 tsjw, u8 tbs2, u8 tbs1, u16 brp, u8 mode )
|
|||||||
|
|
||||||
CAN_FilterInitSturcture.CAN_FilterMode = CAN_FilterMode_IdMask;
|
CAN_FilterInitSturcture.CAN_FilterMode = CAN_FilterMode_IdMask;
|
||||||
CAN_FilterInitSturcture.CAN_FilterScale = CAN_FilterScale_32bit;
|
CAN_FilterInitSturcture.CAN_FilterScale = CAN_FilterScale_32bit;
|
||||||
CAN_FilterInitSturcture.CAN_FilterIdHigh = (uint16_t)((((DF_CanIDMotor1|DF_CanIDMotor2)<<DF_StaIDShift))>>16);//(uint16_t)(((0x10000001<<3)|0x04)>>16);//Ӧ<><D3A6><EFBFBD><EFBFBD>
|
CAN_FilterInitSturcture.CAN_FilterIdHigh = (uint16_t)((((DF_CanIDMotor1|DF_CanIDMotor2)<<DF_ExtIDShift)|0x04)>>16);//(uint16_t)(((0x10000001<<3)|0x04)>>16);//Ӧ<><D3A6><EFBFBD><EFBFBD>
|
||||||
CAN_FilterInitSturcture.CAN_FilterIdLow = (uint16_t)(((DF_CanIDMotor1|DF_CanIDMotor2)<<DF_StaIDShift));//(uint16_t)(((0x10000001<<3)|0x04));//
|
CAN_FilterInitSturcture.CAN_FilterIdLow = (uint16_t)(((DF_CanIDMotor1|DF_CanIDMotor2)<<DF_ExtIDShift)|0x04);//(uint16_t)(((0x10000001<<3)|0x04));//
|
||||||
CAN_FilterInitSturcture.CAN_FilterMaskIdHigh = (uint16_t)((((~(DF_CanIDMotor1^DF_CanIDMotor2))<<DF_StaIDShift)|0x0E) >> 16);
|
CAN_FilterInitSturcture.CAN_FilterMaskIdHigh = (uint16_t)((((~(DF_CanIDMotor1^DF_CanIDMotor2))<<DF_ExtIDShift)|0x0E) >> 16);
|
||||||
CAN_FilterInitSturcture.CAN_FilterMaskIdLow = (uint16_t)(((~(DF_CanIDMotor1^DF_CanIDMotor2))<<DF_StaIDShift)|0x0E);
|
CAN_FilterInitSturcture.CAN_FilterMaskIdLow = (uint16_t)(((~(DF_CanIDMotor1^DF_CanIDMotor2))<<DF_ExtIDShift)|0x0E);
|
||||||
|
|
||||||
CAN_FilterInitSturcture.CAN_FilterFIFOAssignment = CAN_Filter_FIFO1;
|
CAN_FilterInitSturcture.CAN_FilterFIFOAssignment = CAN_Filter_FIFO1;
|
||||||
CAN_FilterInitSturcture.CAN_FilterActivation = ENABLE;
|
CAN_FilterInitSturcture.CAN_FilterActivation = ENABLE;
|
||||||
|
|||||||
@@ -36,8 +36,8 @@
|
|||||||
#define DF_CanIDbattery2 0x101//<2F><><EFBFBD>ؽ<EFBFBD><D8BD><EFBFBD>
|
#define DF_CanIDbattery2 0x101//<2F><><EFBFBD>ؽ<EFBFBD><D8BD><EFBFBD>
|
||||||
#define DF_CanIDRCH_3 0x12000023//<2F><><EFBFBD><EFBFBD>ң<EFBFBD><D2A3><EFBFBD><EFBFBD>
|
#define DF_CanIDRCH_3 0x12000023//<2F><><EFBFBD><EFBFBD>ң<EFBFBD><D2A3><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
#define DF_CanIDMotor1 0x101//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
#define DF_CanIDMotor1 0x98//20251025 <20>Ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
#define DF_CanIDMotor2 0x102//<EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
#define DF_CanIDMotor2 0x99//20251025 <20>Ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
#define DF_ExtIDShift 3//<2F><>չ֡<D5B9><D6A1>λ 32-29
|
#define DF_ExtIDShift 3//<2F><>չ֡<D5B9><D6A1>λ 32-29
|
||||||
#define DF_StaIDShift 21//<2F><>֡<D7BC><D6A1>λ 32-11
|
#define DF_StaIDShift 21//<2F><>֡<D7BC><D6A1>λ 32-11
|
||||||
|
|||||||
@@ -28,7 +28,10 @@ u16 Desport = 7900;
|
|||||||
|
|
||||||
u8 pc_ipAddr[4] = { 192, 168, 17, 2 }; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP address
|
u8 pc_ipAddr[4] = { 192, 168, 17, 2 }; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP address
|
||||||
|
|
||||||
u8 tcp_socket[WCHNET_NUM_TCP]; //Save the currently connected socket
|
u8 remote_base_ip[4] = { 192, 168, 10, 8 }; //Զ<>̻<EFBFBD>վIP address
|
||||||
|
u16 remote_port = 1008; //Զ<>̻<EFBFBD>վ<EFBFBD>˿<EFBFBD>
|
||||||
|
|
||||||
|
u8 tcp_socket[WCHNET_NUM_TCP]; //Save the currently connected socket
|
||||||
|
|
||||||
|
|
||||||
SystemDataRecord g_systemDataRecord = {0,0,0,0};
|
SystemDataRecord g_systemDataRecord = {0,0,0,0};
|
||||||
@@ -50,6 +53,8 @@ uint8_t portableOcuOnline = 0;
|
|||||||
uint8_t remoteOcuOnline = 0;
|
uint8_t remoteOcuOnline = 0;
|
||||||
|
|
||||||
Timer ethernet_timer_interface;
|
Timer ethernet_timer_interface;
|
||||||
|
|
||||||
|
Timer ethernet_timer_interface1;
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* @fn mStopIfError
|
* @fn mStopIfError
|
||||||
*
|
*
|
||||||
@@ -205,7 +210,7 @@ void WCHNET_UdpServerRecv1(struct _SCOK_INF *socinf, u32 ipaddr, u16 port, u8 *b
|
|||||||
if( (0x80 == buf[0]) && (0x00 == buf[1]) )
|
if( (0x80 == buf[0]) && (0x00 == buf[1]) )
|
||||||
{
|
{
|
||||||
memcpy((uint8_t *)&(un_request_frame.arr[0]),buf, sizeof(UnRequestFrame));
|
memcpy((uint8_t *)&(un_request_frame.arr[0]),buf, sizeof(UnRequestFrame));
|
||||||
printf("read_id = %d \r\n",request_read_id);
|
// printf("read_id = %d \r\n",request_read_id);
|
||||||
//20250412 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
//20250412 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||||
for (uint8_t i = 0; i < 4; i++)
|
for (uint8_t i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
@@ -277,6 +282,33 @@ void WCHNET_UdpServerRecv2(struct _SCOK_INF *socinf, u32 ipaddr, u16 port, u8 *b
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*********************************************************************
|
||||||
|
* @fn WCHNET_CreateTcpSocket
|
||||||
|
*
|
||||||
|
* @brief Create TCP Socket
|
||||||
|
*
|
||||||
|
* @return none
|
||||||
|
*/
|
||||||
|
void WCHNET_CreateTcpSocket(void)
|
||||||
|
{
|
||||||
|
u8 i;
|
||||||
|
SOCK_INF TmpSocketInf;
|
||||||
|
|
||||||
|
memset((void *) &TmpSocketInf, 0, sizeof(SOCK_INF));
|
||||||
|
memcpy((void *) TmpSocketInf.IPAddr, remote_base_ip, 4);
|
||||||
|
TmpSocketInf.DesPort = remote_port;
|
||||||
|
TmpSocketInf.SourPort = 1008;
|
||||||
|
TmpSocketInf.ProtoType = PROTO_TYPE_TCP;
|
||||||
|
TmpSocketInf.RecvBufLen = RECE_BUF_LEN;
|
||||||
|
i = WCHNET_SocketCreat(&SocketId3, &TmpSocketInf);
|
||||||
|
printf("SocketId %d\r\n", SocketId3);
|
||||||
|
mStopIfError(i);
|
||||||
|
i = WCHNET_SocketConnect(SocketId3); //make a TCP connection
|
||||||
|
mStopIfError(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* @fn WCHNET_CreateUdpSocket
|
* @fn WCHNET_CreateUdpSocket
|
||||||
*
|
*
|
||||||
@@ -286,7 +318,7 @@ void WCHNET_UdpServerRecv2(struct _SCOK_INF *socinf, u32 ipaddr, u16 port, u8 *b
|
|||||||
*/
|
*/
|
||||||
void WCHNET_CreateUdpSocket(void)
|
void WCHNET_CreateUdpSocket(void)
|
||||||
{
|
{
|
||||||
u8 i;
|
// u8 i;
|
||||||
SOCK_INF TmpSocketInf;
|
SOCK_INF TmpSocketInf;
|
||||||
|
|
||||||
// memset((void *) &TmpSocketInf, 0, sizeof(SOCK_INF));
|
// memset((void *) &TmpSocketInf, 0, sizeof(SOCK_INF));
|
||||||
@@ -310,14 +342,15 @@ void WCHNET_CreateUdpSocket(void)
|
|||||||
#endif
|
#endif
|
||||||
memset(tcp_socket, 0xff, WCHNET_NUM_TCP);
|
memset(tcp_socket, 0xff, WCHNET_NUM_TCP);
|
||||||
|
|
||||||
memset((void *) &TmpSocketInf, 0, sizeof(SOCK_INF));
|
WCHNET_CreateTcpSocket();
|
||||||
TmpSocketInf.SourPort = srcport;
|
// memset((void *) &TmpSocketInf, 0, sizeof(SOCK_INF));
|
||||||
TmpSocketInf.ProtoType = PROTO_TYPE_TCP;
|
// TmpSocketInf.SourPort = srcport;
|
||||||
i = WCHNET_SocketCreat(&SocketId, &TmpSocketInf);
|
// TmpSocketInf.ProtoType = PROTO_TYPE_TCP;
|
||||||
printf("SocketIdForListen %d\r\n", SocketId);
|
// i = WCHNET_SocketCreat(&SocketId, &TmpSocketInf);
|
||||||
mStopIfError(i);
|
// printf("SocketIdForListen %d\r\n", SocketId);
|
||||||
i = WCHNET_SocketListen(SocketId); //listen for connections
|
// mStopIfError(i);
|
||||||
mStopIfError(i);
|
// i = WCHNET_SocketListen(SocketId); //listen for connections
|
||||||
|
// mStopIfError(i);
|
||||||
|
|
||||||
//
|
//
|
||||||
memset((void *)&TmpSocketInf, 0, sizeof(SOCK_INF));
|
memset((void *)&TmpSocketInf, 0, sizeof(SOCK_INF));
|
||||||
@@ -336,21 +369,77 @@ void WCHNET_CreateUdpSocket(void)
|
|||||||
TmpSocketInf.RecvStartPoint = (u32) SocketRecvBuf2;
|
TmpSocketInf.RecvStartPoint = (u32) SocketRecvBuf2;
|
||||||
TmpSocketInf.RecvBufLen = RECE_BUF_LEN;
|
TmpSocketInf.RecvBufLen = RECE_BUF_LEN;
|
||||||
TmpSocketInf.AppCallBack = WCHNET_UdpServerRecv2;
|
TmpSocketInf.AppCallBack = WCHNET_UdpServerRecv2;
|
||||||
i = WCHNET_SocketCreat(&SocketId3, &TmpSocketInf);
|
WCHNET_SocketCreat(&SocketId3, &TmpSocketInf);
|
||||||
printf("WCHNET_SocketCreat %d\r\n", SocketId3);
|
printf("WCHNET_SocketCreat %d\r\n", SocketId3);
|
||||||
|
|
||||||
|
|
||||||
// mStopIfError(i);
|
// mStopIfError(i);
|
||||||
|
|
||||||
// memset((void *) &TmpSocketInf, 0, sizeof(SOCK_INF));
|
}
|
||||||
// memcpy((void *) TmpSocketInf.IPAddr, DESIP, 4);
|
|
||||||
// TmpSocketInf.DesPort = desport;
|
/*********************************************************************
|
||||||
// TmpSocketInf.SourPort = srcport++;
|
* @fn WCHNET_DataLoopback
|
||||||
// TmpSocketInf.ProtoType = PROTO_TYPE_TCP;
|
*
|
||||||
// TmpSocketInf.RecvBufLen = RECE_BUF_LEN;
|
* @brief Data loopback function.
|
||||||
// i = WCHNET_SocketCreat(&SocketId4, &TmpSocketInf);
|
*
|
||||||
// printf("SocketId4 %d\r\n", SocketId4);
|
* @param id - socket id.
|
||||||
// mStopIfError(i);
|
*
|
||||||
// i = WCHNET_SocketConnect(SocketId4); //make a TCP connection
|
* @return none
|
||||||
// mStopIfError(i);
|
*/
|
||||||
|
void WCHNET_DataLoopback(u8 id)
|
||||||
|
{
|
||||||
|
#if 1
|
||||||
|
u8 i;
|
||||||
|
u32 len;
|
||||||
|
u32 endAddr = SocketInf[id].RecvStartPoint + SocketInf[id].RecvBufLen; //Receive buffer end address
|
||||||
|
|
||||||
|
if ((SocketInf[id].RecvReadPoint + SocketInf[id].RecvRemLen) > endAddr)
|
||||||
|
{ //Calculate the length of the received data
|
||||||
|
len = endAddr - SocketInf[id].RecvReadPoint;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
len = SocketInf[id].RecvRemLen;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(remote_port == SocketInf[id].DesPort)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>Դ<EFBFBD>˿<EFBFBD><CBBF><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>̫<EFBFBD><CCAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>RTCM<43><4D><EFBFBD><EFBFBD>
|
||||||
|
{
|
||||||
|
memcpy(&RTCM_Buffer1.dma_buffer[RTCM_Buffer1.active_buf][0],(u8 *) SocketInf[id].RecvReadPoint,len);
|
||||||
|
RTCM_Buffer1.type = ethernet;
|
||||||
|
RTCM_Buffer1.buf_len = (uint16_t)len;
|
||||||
|
RTCM_Buffer1.active_buf ^= 1;
|
||||||
|
RTCM_Buffer1.eth_cnt ++;//<2F>ۼ<EFBFBD><DBBC>ж<EFBFBD>
|
||||||
|
publishMessage(&RTCM_Buffer1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// printf("Դ<>˿<EFBFBD>: %u, Ŀ<><C4BF><EFBFBD>˿<EFBFBD>: %u\n",
|
||||||
|
// SocketInf[id].SourPort, SocketInf[id].DesPort);
|
||||||
|
|
||||||
|
|
||||||
|
// i = WCHNET_SocketSend(id, (u8 *) SocketInf[id].RecvReadPoint, &len); //send data
|
||||||
|
|
||||||
|
if (i == WCHNET_ERR_SUCCESS) {
|
||||||
|
WCHNET_SocketRecv(id, NULL, &len); //Clear sent data
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
u32 len, totallen;
|
||||||
|
u8 *p = MyBuf, TransCnt = 255;
|
||||||
|
|
||||||
|
len = WCHNET_SocketRecvLen(id, NULL); //query length
|
||||||
|
printf("Receive Len = %d\r\n", len);
|
||||||
|
totallen = len;
|
||||||
|
WCHNET_SocketRecv(id, MyBuf, &len); //Read the data of the receive buffer into MyBuf
|
||||||
|
while(1){
|
||||||
|
len = totallen;
|
||||||
|
WCHNET_SocketSend(id, p, &len); //Send the data
|
||||||
|
totallen -= len; //Subtract the sent length from the total length
|
||||||
|
p += len; //offset buffer pointer
|
||||||
|
if( !--TransCnt ) break; //Timeout exit
|
||||||
|
if(totallen) continue; //If the data is not sent, continue to send
|
||||||
|
break; //After sending, exit
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
@@ -368,6 +457,7 @@ void WCHNET_HandleSockInt(u8 socketid, u8 intstat)
|
|||||||
u8 i;
|
u8 i;
|
||||||
if (intstat & SINT_STAT_RECV) //receive data
|
if (intstat & SINT_STAT_RECV) //receive data
|
||||||
{
|
{
|
||||||
|
WCHNET_DataLoopback(socketid);
|
||||||
}
|
}
|
||||||
if (intstat & SINT_STAT_CONNECT) //connect successfully
|
if (intstat & SINT_STAT_CONNECT) //connect successfully
|
||||||
{
|
{
|
||||||
@@ -403,6 +493,7 @@ void WCHNET_HandleSockInt(u8 socketid, u8 intstat)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("TCP Timeout\r\n");
|
printf("TCP Timeout\r\n");
|
||||||
|
WCHNET_CreateTcpSocket();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -498,7 +589,7 @@ uint8_t CalculateChecksum(const uint8_t* data, size_t len)
|
|||||||
static void ethernetInterfaceTimerProcess(void *signal_id)
|
static void ethernetInterfaceTimerProcess(void *signal_id)
|
||||||
{
|
{
|
||||||
static u_int32_t navigation_output_len = 0;
|
static u_int32_t navigation_output_len = 0;
|
||||||
static u_int32_t navigation_output_len1 = 0;
|
// static u_int32_t navigation_output_len1 = 0;
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
if (signal_id == &navigation_output1)
|
if (signal_id == &navigation_output1)
|
||||||
{
|
{
|
||||||
@@ -536,21 +627,21 @@ static void ethernetInterfaceTimerProcess(void *signal_id)
|
|||||||
navigation_outputC1.bit_data.crc1 = CalculateChecksum(&navigation_outputC1.arr[0],sizeof(UnInfNavigationOutputC)-1);
|
navigation_outputC1.bit_data.crc1 = CalculateChecksum(&navigation_outputC1.arr[0],sizeof(UnInfNavigationOutputC)-1);
|
||||||
|
|
||||||
|
|
||||||
for(uint8_t i = 0; i < WCHNET_NUM_TCP; i++)
|
// for(uint8_t i = 0; i < WCHNET_NUM_TCP; i++)
|
||||||
{
|
// {
|
||||||
if(tcp_socket[i] != 0xFF)
|
// if(tcp_socket[i] != 0xFF)
|
||||||
{
|
// {
|
||||||
if(0 == navigation_output_len1)
|
// if(0 == navigation_output_len1)
|
||||||
{
|
// {
|
||||||
navigation_output_len1 = sizeof(navigation_outputC1);
|
// navigation_output_len1 = sizeof(navigation_outputC1);
|
||||||
}
|
// }
|
||||||
|
|
||||||
i = WCHNET_SocketSend(tcp_socket[i], (uint8_t *)&navigation_outputC1, &navigation_output_len1); //send data
|
// i = WCHNET_SocketSend(tcp_socket[i], (uint8_t *)&navigation_outputC1, &navigation_output_len1); //send data
|
||||||
if (i == WCHNET_ERR_SUCCESS) {
|
// if (i == WCHNET_ERR_SUCCESS) {
|
||||||
WCHNET_SocketRecv(tcp_socket[i], NULL, &navigation_output_len1); //Clear sent data
|
// WCHNET_SocketRecv(tcp_socket[i], NULL, &navigation_output_len1); //Clear sent data
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
else if (signal_id == &navigation_output2)
|
else if (signal_id == &navigation_output2)
|
||||||
{
|
{
|
||||||
@@ -593,7 +684,7 @@ static void ethernetInterfaceTimerProcess(void *signal_id)
|
|||||||
}
|
}
|
||||||
UdpSendToData(SocketId2, (uint8_t *)&navigation_output2, &navigation_output_len, &str_RequestMessage.ip_adesser[0],str_RequestMessage.port);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
UdpSendToData(SocketId2, (uint8_t *)&navigation_output2, &navigation_output_len, &str_RequestMessage.ip_adesser[0],str_RequestMessage.port);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -614,6 +705,22 @@ void ethInterruptProcess(void *signal_id)
|
|||||||
timerStart(ðernet_timer_interface, 1,1); //1ms<6D><73><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
timerStart(ðernet_timer_interface, 1,1); //1ms<6D><73><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ethernetFaultProcess(void *signal_id)//<2F><>̫<EFBFBD><CCAB>RTCM<43><4D><EFBFBD><EFBFBD><EFBFBD>жϡ<D0B6>
|
||||||
|
{
|
||||||
|
static uint8_t eth_cnt_last = 0;
|
||||||
|
if( (RTCM_Buffer1.eth_cnt == eth_cnt_last) && (ethernet == RTCM_Buffer1.type) )//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>5s<35><73><EFBFBD>ǶϿ<C7B6><CFBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˡ<EFBFBD>
|
||||||
|
{
|
||||||
|
RTCM_Buffer1.type = init;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
eth_cnt_last = RTCM_Buffer1.eth_cnt;
|
||||||
|
}
|
||||||
|
timerStart(ðernet_timer_interface1, 8000,1); //8s<38><73><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ethernetInterfaceInit(void)
|
void ethernetInterfaceInit(void)
|
||||||
{
|
{
|
||||||
@@ -622,7 +729,14 @@ void ethernetInterfaceInit(void)
|
|||||||
subscribe(&navigation_output1, ethernetInterfaceTimerProcess);
|
subscribe(&navigation_output1, ethernetInterfaceTimerProcess);
|
||||||
subscribe(&navigation_output2, ethernetInterfaceTimerProcess);
|
subscribe(&navigation_output2, ethernetInterfaceTimerProcess);
|
||||||
subscribe(ðernet_timer_interface, ethInterruptProcess);
|
subscribe(ðernet_timer_interface, ethInterruptProcess);
|
||||||
|
subscribe(ðernet_timer_interface1, ethernetFaultProcess); //1ms<6D><73><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
||||||
|
|
||||||
timerStart(ðernet_timer_interface, 1,1); //1ms<6D><73><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
timerStart(ðernet_timer_interface, 1,1); //1ms<6D><73><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
||||||
|
|
||||||
|
timerStart(ðernet_timer_interface1, 5000,1); //5s<35><73><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
printf( "ethernetInterface: initial OK %d\n",getCurrentTime());
|
printf( "ethernetInterface: initial OK %d\n",getCurrentTime());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* eth_drive.c
|
* eth_drive.c
|
||||||
*
|
*
|
||||||
* Created on: 2023<EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>5<EFBFBD><EFBFBD>
|
* Created on: 2023??1??5??
|
||||||
* Author: Administrator
|
* Author: Administrator
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ static RingBuffer nmea_rx_buf;
|
|||||||
#define DMA_BUF_SIZE 1400
|
#define DMA_BUF_SIZE 1400
|
||||||
uint8_t dma_rx_buffer[DMA_BUF_SIZE] __attribute__((aligned(4)));
|
uint8_t dma_rx_buffer[DMA_BUF_SIZE] __attribute__((aligned(4)));
|
||||||
|
|
||||||
//__attribute__((aligned(4))) uint8_t dma_buffer[2048]; // GCC<EFBFBD>
|
//__attribute__((aligned(4))) uint8_t dma_buffer[2048]; // GCC??
|
||||||
|
|
||||||
|
|
||||||
//void USART2_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
|
//void USART2_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
|
||||||
@@ -48,7 +48,7 @@ void USART3_IRQHandler(void)
|
|||||||
{
|
{
|
||||||
imu_buffer1.buf_len = IMU_LEN - DMA_GetCurrDataCounter(IMU_RX_CH);
|
imu_buffer1.buf_len = IMU_LEN - DMA_GetCurrDataCounter(IMU_RX_CH);
|
||||||
|
|
||||||
if( (imu_buffer1.dma_buffer[imu_buffer1.active_buf][0] == IMU_IIM46234_HEADER1) && //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
if( (imu_buffer1.dma_buffer[imu_buffer1.active_buf][0] == IMU_IIM46234_HEADER1) && //??????????????
|
||||||
(imu_buffer1.dma_buffer[imu_buffer1.active_buf][1] == IMU_IIM46234_HEADER2) )
|
(imu_buffer1.dma_buffer[imu_buffer1.active_buf][1] == IMU_IIM46234_HEADER2) )
|
||||||
{
|
{
|
||||||
imu_buffer1.type = IIM46234;
|
imu_buffer1.type = IIM46234;
|
||||||
@@ -80,19 +80,24 @@ void UART4_IRQHandler(void)
|
|||||||
enter_critical_section();
|
enter_critical_section();
|
||||||
if(USART_GetITStatus(UART4, USART_IT_IDLE) != RESET)
|
if(USART_GetITStatus(UART4, USART_IT_IDLE) != RESET)
|
||||||
{
|
{
|
||||||
RTCM_Buffer1.buf_len = RX_BUFFER_LEN - DMA_GetCurrDataCounter(RTCM_RX_CH);
|
if(ethernet != RTCM_Buffer1.type)//ֻҪ<D6BB><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̫<EFBFBD><CCAB>״̬
|
||||||
RTCM_Buffer1.active_buf ^= 1;
|
{
|
||||||
|
RTCM_Buffer1.type = uart;//<2F><><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD>ģʽ
|
||||||
|
RTCM_Buffer1.buf_len = RX_BUFFER_LEN - DMA_GetCurrDataCounter(RTCM_RX_CH);
|
||||||
|
RTCM_Buffer1.active_buf ^= 1;
|
||||||
|
|
||||||
DMA_Cmd(RTCM_RX_CH, DISABLE);
|
DMA_Cmd(RTCM_RX_CH, DISABLE);
|
||||||
DMA_SetCurrDataCounter(RTCM_RX_CH, RX_BUFFER_LEN);
|
DMA_SetCurrDataCounter(RTCM_RX_CH, RX_BUFFER_LEN);
|
||||||
// Switch buffer
|
// Switch buffer
|
||||||
RTCM_RX_CH->MADDR = (uint32_t)(uintptr_t)&(RTCM_Buffer1.dma_buffer[RTCM_Buffer1.active_buf][0]);
|
RTCM_RX_CH->MADDR = (uint32_t)(uintptr_t)&(RTCM_Buffer1.dma_buffer[RTCM_Buffer1.active_buf][0]);
|
||||||
DMA_Cmd(RTCM_RX_CH, ENABLE);
|
DMA_Cmd(RTCM_RX_CH, ENABLE);
|
||||||
printf("rtcm receive\n");
|
printf("rtcm receive\n");
|
||||||
|
|
||||||
|
USART_ReceiveData(UART4); // clear IDLE flag
|
||||||
|
publishMessage(&RTCM_Buffer1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
USART_ReceiveData(UART4); // clear IDLE flag
|
|
||||||
|
|
||||||
publishMessage(&RTCM_Buffer1, 1);
|
|
||||||
}
|
}
|
||||||
exit_critical_section(0);
|
exit_critical_section(0);
|
||||||
}
|
}
|
||||||
@@ -103,9 +108,8 @@ void UART8_IRQHandler(void)
|
|||||||
enter_critical_section();
|
enter_critical_section();
|
||||||
if(USART_GetITStatus(UART8, USART_IT_RXNE) != RESET)
|
if(USART_GetITStatus(UART8, USART_IT_RXNE) != RESET)
|
||||||
{
|
{
|
||||||
uint8_t UART_temp = 0;
|
USART_ReceiveData(UART8);
|
||||||
UART_temp = USART_ReceiveData(UART8);
|
// printf("USART8:%d\n", UART_temp); // ????
|
||||||
// printf("USART8:%d\n", UART_temp); // <20><><EFBFBD><EFBFBD>
|
|
||||||
}
|
}
|
||||||
exit_critical_section(0);
|
exit_critical_section(0);
|
||||||
}
|
}
|
||||||
@@ -118,7 +122,7 @@ void UART6_IRQHandler(void)
|
|||||||
enter_critical_section();
|
enter_critical_section();
|
||||||
if(USART_GetITStatus(UART6, USART_IT_RXNE) != RESET)
|
if(USART_GetITStatus(UART6, USART_IT_RXNE) != RESET)
|
||||||
{
|
{
|
||||||
char ch = USART_ReceiveData(UART6);
|
USART_ReceiveData(UART6);
|
||||||
}
|
}
|
||||||
exit_critical_section(0);
|
exit_critical_section(0);
|
||||||
}
|
}
|
||||||
@@ -131,7 +135,7 @@ void UART7_IRQHandler(void)
|
|||||||
DMA_Cmd(UM982_RX_CH, DISABLE);
|
DMA_Cmd(UM982_RX_CH, DISABLE);
|
||||||
uint16_t received_len = DMA_BUF_SIZE - DMA_GetCurrDataCounter(UM982_RX_CH);
|
uint16_t received_len = DMA_BUF_SIZE - DMA_GetCurrDataCounter(UM982_RX_CH);
|
||||||
|
|
||||||
// 3. <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// 3. ??????????????<3F><>?????
|
||||||
for(uint16_t i = 0; i < received_len; i++)
|
for(uint16_t i = 0; i < received_len; i++)
|
||||||
{
|
{
|
||||||
uint16_t next_head = (nmea_rx_buf.head + 1) % RING_BUF_SIZE;
|
uint16_t next_head = (nmea_rx_buf.head + 1) % RING_BUF_SIZE;
|
||||||
@@ -166,7 +170,7 @@ void DMA1_Channel3_IRQHandler(void)
|
|||||||
enter_critical_section();
|
enter_critical_section();
|
||||||
imu_buffer1.buf_len = RX_BUFFER_LEN;
|
imu_buffer1.buf_len = RX_BUFFER_LEN;
|
||||||
|
|
||||||
DMA_ClearITPendingBit(DMA1_IT_TC3);//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
DMA_ClearITPendingBit(DMA1_IT_TC3);//?????<3F><>?
|
||||||
exit_critical_section(0);
|
exit_critical_section(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,7 +188,7 @@ void DMA2_Channel3_IRQHandler(void)
|
|||||||
enter_critical_section();
|
enter_critical_section();
|
||||||
RTCM_Buffer1.buf_len = RX_BUFFER_LEN;
|
RTCM_Buffer1.buf_len = RX_BUFFER_LEN;
|
||||||
|
|
||||||
DMA_ClearITPendingBit(DMA2_IT_TC3);//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
DMA_ClearITPendingBit(DMA2_IT_TC3);//?????<3F><>?
|
||||||
exit_critical_section(0);
|
exit_critical_section(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +202,7 @@ void DMA2_Channel3_IRQHandler(void)
|
|||||||
void DMA2_Channel9_IRQHandler(void)
|
void DMA2_Channel9_IRQHandler(void)
|
||||||
{
|
{
|
||||||
enter_critical_section();
|
enter_critical_section();
|
||||||
DMA_ClearITPendingBit(DMA2_IT_TC9);//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
DMA_ClearITPendingBit(DMA2_IT_TC9);//?????<3F><>?
|
||||||
exit_critical_section(0);
|
exit_critical_section(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,7 +246,7 @@ void dmaInit(void)
|
|||||||
DMA_Cmd(RTCM_RX_CH, ENABLE);
|
DMA_Cmd(RTCM_RX_CH, ENABLE);
|
||||||
USART_DMACmd(RTCM_UART, USART_DMAReq_Rx, ENABLE);
|
USART_DMACmd(RTCM_UART, USART_DMAReq_Rx, ENABLE);
|
||||||
|
|
||||||
//IMU DMA<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//IMU DMA????
|
||||||
DMA_DeInit(IMU_RX_CH);
|
DMA_DeInit(IMU_RX_CH);
|
||||||
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
|
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
|
||||||
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
|
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
|
||||||
@@ -270,7 +274,7 @@ void dmaInit(void)
|
|||||||
USART_DMACmd(IMU_UART, USART_DMAReq_Rx, ENABLE);
|
USART_DMACmd(IMU_UART, USART_DMAReq_Rx, ENABLE);
|
||||||
|
|
||||||
|
|
||||||
//982 DMA<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//982 DMA????
|
||||||
DMA_DeInit(UM982_RX_CH);
|
DMA_DeInit(UM982_RX_CH);
|
||||||
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
|
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
|
||||||
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
|
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
|
||||||
@@ -363,7 +367,7 @@ void initUart(void)
|
|||||||
NVIC_Init(&NVIC_InitStructure);
|
NVIC_Init(&NVIC_InitStructure);
|
||||||
USART_Cmd(UART4, ENABLE);
|
USART_Cmd(UART4, ENABLE);
|
||||||
|
|
||||||
/* UART6 TX-->C.0 RX-->C.1 */ //<EFBFBD>ӵ<EFBFBD>982<EFBFBD><EFBFBD>com1
|
/* UART6 TX-->C.0 RX-->C.1 */ //???982??com1
|
||||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
|
||||||
@@ -389,7 +393,7 @@ void initUart(void)
|
|||||||
NVIC_Init(&NVIC_InitStructure);
|
NVIC_Init(&NVIC_InitStructure);
|
||||||
USART_Cmd(UART6, ENABLE);
|
USART_Cmd(UART6, ENABLE);
|
||||||
|
|
||||||
/* UART7 TX-->C.2 RX-->C.3 *///<EFBFBD>ӵ<EFBFBD>982<EFBFBD><EFBFBD>com2
|
/* UART7 TX-->C.2 RX-->C.3 *///???982??com2 <20><>ȡGGA<47><41><EFBFBD><EFBFBD>
|
||||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
|
||||||
@@ -443,7 +447,7 @@ void initUart(void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void uartSendto(USART_TypeDef *USARTx, uint8_t * ucData, uint16_t len)//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><EFBFBD><EFBFBD>ͺ<EFBFBD><EFBFBD><EFBFBD>
|
void uartSendto(USART_TypeDef *USARTx, uint8_t * ucData, uint16_t len)//????2???????
|
||||||
{
|
{
|
||||||
for(uint16_t i = 0; i<len; i++)
|
for(uint16_t i = 0; i<len; i++)
|
||||||
{
|
{
|
||||||
@@ -457,9 +461,9 @@ void uartSendto(USART_TypeDef *USARTx, uint8_t * ucData, uint16_t len)//
|
|||||||
|
|
||||||
void rtcmProcess(void *signal_id)
|
void rtcmProcess(void *signal_id)
|
||||||
{
|
{
|
||||||
(void)signal_id; // <EFBFBD><EFBFBD><EFBFBD>DZ<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>ʹ<EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
(void)signal_id; // ??????????????????????????
|
||||||
|
|
||||||
uartSendto(UART6, (uint8_t *)&(RTCM_Buffer1.dma_buffer[RTCM_Buffer1.active_buf^1][0]), RTCM_Buffer1.buf_len);//ֱ<EFBFBD>ӷ<EFBFBD><EFBFBD>ͷǼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
|
uartSendto(UART6, (uint8_t *)&(RTCM_Buffer1.dma_buffer[RTCM_Buffer1.active_buf^1][0]), RTCM_Buffer1.buf_len);//?????????????
|
||||||
printf("rtcm forwarding\n");
|
printf("rtcm forwarding\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -468,25 +472,25 @@ void rtcmProcess(void *signal_id)
|
|||||||
|
|
||||||
void setDataProcess(void *signal_id)
|
void setDataProcess(void *signal_id)
|
||||||
{
|
{
|
||||||
(void)signal_id; // <EFBFBD><EFBFBD><EFBFBD>DZ<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>ʹ<EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
(void)signal_id; // ??????????????????????????
|
||||||
uartSendto(USART3, set_output_data, 20);
|
uartSendto(USART3, set_output_data, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setRateProcess(void *signal_id)
|
void setRateProcess(void *signal_id)
|
||||||
{
|
{
|
||||||
(void)signal_id; // <EFBFBD><EFBFBD><EFBFBD>DZ<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>ʹ<EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
(void)signal_id; // ??????????????????????????
|
||||||
uartSendto(USART3, set_rate, 20);
|
uartSendto(USART3, set_rate, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSaveProcess(void *signal_id)
|
void setSaveProcess(void *signal_id)
|
||||||
{
|
{
|
||||||
(void)signal_id; // <EFBFBD><EFBFBD><EFBFBD>DZ<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>ʹ<EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
(void)signal_id; // ??????????????????????????
|
||||||
uartSendto(USART3, save_cmd, 20);
|
uartSendto(USART3, save_cmd, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSteamProcess(void *signal_id)
|
void setSteamProcess(void *signal_id)
|
||||||
{
|
{
|
||||||
(void)signal_id; // <EFBFBD><EFBFBD><EFBFBD>DZ<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>ʹ<EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
(void)signal_id; // ??????????????????????????
|
||||||
uartSendto(USART3, stream_cmd, 20);
|
uartSendto(USART3, stream_cmd, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -494,18 +498,18 @@ void setSteamProcess(void *signal_id)
|
|||||||
|
|
||||||
|
|
||||||
/* /?**?
|
/* /?**?
|
||||||
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD>NMEA<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD>XOR<EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD>飩
|
* @brief ????NMEA????<3F><>????XOR???<3F><>?<3F><>
|
||||||
* @param nmea_str <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>NMEA<EFBFBD><EFBFBD><EFBFBD>䣨<EFBFBD><EFBFBD><EFBFBD><EFBFBD>$<24><>*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>β<EFBFBD><CEB2>CRLF<EFBFBD><EFBFBD>
|
* @param nmea_str ??????NMEA???????$??*??????????<3F><>??CRLF??
|
||||||
* @return <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>8λУ<EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD>0x00~0xFF<EFBFBD><EFBFBD>
|
* @return ???????8<>˧<EFBFBD>????0x00~0xFF??
|
||||||
*/
|
*/
|
||||||
uint8_t nmea_checksum(const char *nmea_str)
|
uint8_t nmea_checksum(const char *nmea_str)
|
||||||
{
|
{
|
||||||
uint8_t checksum = 0;
|
uint8_t checksum = 0;
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>'$'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>
|
// ?????????'$'??????????
|
||||||
if (*nmea_str == '$') nmea_str++;
|
if (*nmea_str == '$') nmea_str++;
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'*'<27><><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// ???????????????'*'???????????
|
||||||
while (*nmea_str && *nmea_str != '*') {
|
while (*nmea_str && *nmea_str != '*') {
|
||||||
checksum ^= (uint8_t)*nmea_str++;
|
checksum ^= (uint8_t)*nmea_str++;
|
||||||
}
|
}
|
||||||
@@ -514,24 +518,24 @@ uint8_t nmea_checksum(const char *nmea_str)
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief <EFBFBD><EFBFBD>֤NMEA<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
* @brief ???NMEA????<3F><>???
|
||||||
* @param nmea_str <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>NMEA<EFBFBD><EFBFBD><EFBFBD>䣨<EFBFBD><EFBFBD>"$GPGGA,...*2A\r\n"<EFBFBD><EFBFBD>
|
* @param nmea_str ??????NMEA?????"$GPGGA,...*2A\r\n"??
|
||||||
* @return У<EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>ʧ<EFBFBD>ܷ<EFBFBD><EFBFBD><EFBFBD>0
|
* @return <EFBFBD><EFBFBD>????????1????????0
|
||||||
*/
|
*/
|
||||||
bool nmea_validate_checksum(const char *nmea_str)
|
bool nmea_validate_checksum(const char *nmea_str)
|
||||||
{
|
{
|
||||||
const char *p = nmea_str;
|
const char *p = nmea_str;
|
||||||
uint8_t computed_cs, received_cs;
|
uint8_t computed_cs, received_cs;
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼλ<EFBFBD><EFBFBD>'*'
|
// ????<3F><>??????<3F><>??'*'
|
||||||
while (*p && *p != '*') p++;
|
while (*p && *p != '*') p++;
|
||||||
if (*p != '*') return 0; // <EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>
|
if (*p != '*') return 0; // ??<3F><>??????
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD>2λʮ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>
|
// ??????????<3F><>????2<><32>????????
|
||||||
if (!isxdigit(p[1]) || !isxdigit(p[2])) return 0;
|
if (!isxdigit(p[1]) || !isxdigit(p[2])) return 0;
|
||||||
received_cs = (uint8_t)strtol(p+1, NULL, 16);
|
received_cs = (uint8_t)strtol(p+1, NULL, 16);
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// ???????<3F><>???
|
||||||
computed_cs = nmea_checksum(nmea_str);
|
computed_cs = nmea_checksum(nmea_str);
|
||||||
|
|
||||||
return (computed_cs == received_cs);
|
return (computed_cs == received_cs);
|
||||||
@@ -542,95 +546,98 @@ void ProcessNMEAFrames(void *signal_id)
|
|||||||
static uint8_t parsing_buf[1024];
|
static uint8_t parsing_buf[1024];
|
||||||
static uint16_t parse_idx = 0;
|
static uint16_t parse_idx = 0;
|
||||||
bool frame_complete = false;
|
bool frame_complete = false;
|
||||||
static uint8_t debug1s_cnt = 0;
|
|
||||||
|
|
||||||
debug1s_cnt ++;
|
// debug1s_cnt ++;
|
||||||
if(debug1s_cnt >= 20)
|
// if(debug1s_cnt >= 20)
|
||||||
{
|
// {
|
||||||
debug1s_cnt = 0;
|
// debug1s_cnt = 0;
|
||||||
printf("nmea_buf tail:%d head:%d\n",
|
// printf("nmea_buf tail:%d head:%d\n",
|
||||||
nmea_rx_buf.tail, nmea_rx_buf.head);
|
// nmea_rx_buf.tail, nmea_rx_buf.head);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
while(nmea_rx_buf.tail != nmea_rx_buf.head && !frame_complete)
|
while(nmea_rx_buf.tail != nmea_rx_buf.head && !frame_complete)
|
||||||
{ // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
{ // ???????????<3F><>?????????
|
||||||
uint8_t ch = nmea_rx_buf.buffer[nmea_rx_buf.tail];
|
uint8_t ch = nmea_rx_buf.buffer[nmea_rx_buf.tail];
|
||||||
nmea_rx_buf.tail = (nmea_rx_buf.tail + 1) % RING_BUF_SIZE;
|
nmea_rx_buf.tail = (nmea_rx_buf.tail + 1) % RING_BUF_SIZE;
|
||||||
|
|
||||||
if(nmea_rx_buf.overflow) {
|
if(nmea_rx_buf.overflow) {
|
||||||
nmea_rx_buf.tail = nmea_rx_buf.head;
|
nmea_rx_buf.tail = nmea_rx_buf.head;
|
||||||
// 3. <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־
|
// 3. ??????????
|
||||||
nmea_rx_buf.overflow = 0;
|
nmea_rx_buf.overflow = 0;
|
||||||
// 4. <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>̣<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ط<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// 4. ????????????????????????
|
||||||
printf("Overflow recovery\n");
|
printf("Overflow recovery\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ֡ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// ?????
|
||||||
if(ch == '$') {
|
if(ch == '$') {
|
||||||
if(parse_idx > 0 && parsing_buf[parse_idx-1] == '\n')
|
if(parse_idx > 0 && parsing_buf[parse_idx-1] == '\n')
|
||||||
{
|
{
|
||||||
if (nmea_validate_checksum((char *)parsing_buf)) //У<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
if (nmea_validate_checksum((char *)parsing_buf)) //<2F><>?????
|
||||||
{
|
{
|
||||||
memcpy(&nema_output1.buffer[0],parsing_buf,parse_idx);
|
memcpy(&nema_output1.buffer[0],parsing_buf,parse_idx);
|
||||||
publishMessage(&nema_output1, 1);
|
publishMessage(&nema_output1, 1);
|
||||||
frame_complete = true; // <EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
frame_complete = true; // ???????????
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("nmea crc error");
|
printf("nmea crc error");
|
||||||
frame_complete = true; // <EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
frame_complete = true; // ???????????
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parse_idx = 0;
|
parse_idx = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// <EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// ?<3F><>????
|
||||||
if(parse_idx < RING_BUF_SIZE-1 && !frame_complete)
|
if(parse_idx < RING_BUF_SIZE-1 && !frame_complete)
|
||||||
{
|
{
|
||||||
parsing_buf[parse_idx++] = ch;
|
parsing_buf[parse_idx++] = ch;
|
||||||
|
|
||||||
// ֡β<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// ?<3F><>???
|
||||||
if(parse_idx >= 2 &&
|
if(parse_idx >= 2 &&
|
||||||
parsing_buf[parse_idx-2] == '\r' &&
|
parsing_buf[parse_idx-2] == '\r' &&
|
||||||
parsing_buf[parse_idx-1] == '\n')
|
parsing_buf[parse_idx-1] == '\n')
|
||||||
{
|
{
|
||||||
if (nmea_validate_checksum((char *)parsing_buf)) //У<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
if (nmea_validate_checksum((char *)parsing_buf)) //<2F><>?????
|
||||||
{
|
{
|
||||||
memcpy(&nema_output1.buffer[0],parsing_buf,parse_idx);
|
memcpy(&nema_output1.buffer[0],parsing_buf,parse_idx);
|
||||||
publishMessage(&nema_output1, 1);
|
publishMessage(&nema_output1, 1);
|
||||||
frame_complete = true; // <EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
frame_complete = true; // ???????????
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("nmea buf error");
|
printf("nmea buf error");
|
||||||
frame_complete = true; // <EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
frame_complete = true; // ???????????
|
||||||
}
|
}
|
||||||
parse_idx = 0;
|
parse_idx = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(!frame_complete)
|
else if(!frame_complete)
|
||||||
{
|
{
|
||||||
parse_idx = 0; // <EFBFBD><EFBFBD>ֹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
parse_idx = 0; // ??????
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
timerStart(&nmea_timer, 50, 1); // 100ms<EFBFBD><EFBFBD><EFBFBD>ٴδ<EFBFBD><EFBFBD><EFBFBD>
|
timerStart(&nmea_timer, 10, 1); // 100ms????<3F><>???
|
||||||
}
|
}
|
||||||
|
|
||||||
void navigationRs232Process(void *signal_id)
|
void navigationRs232Process(void *signal_id)
|
||||||
{
|
{
|
||||||
uartSendto(UART8, (uint8_t *)&navigation_rs232_output, sizeof(navigation_rs232_output));
|
uartSendto(UART8, (uint8_t *)&navigation_rs232_output, sizeof(navigation_rs232_output));
|
||||||
|
|
||||||
|
// uint32_t debubg_len = sizeof(navigation_rs232_output);
|
||||||
|
// uint8_t debug_ip[4] = {192,168,17,8};
|
||||||
|
// UdpSendToData(SocketId2, (uint8_t *)&navigation_rs232_output, &debubg_len,debug_ip,8011);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// APPģ<EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD>ʼ<EFBFBD><EFBFBD>
|
// APP????????
|
||||||
void interfaceUartInit(void)
|
void interfaceUartInit(void)
|
||||||
{
|
{
|
||||||
subscribe(&set_output_data, setDataProcess);
|
subscribe(&set_output_data, setDataProcess);
|
||||||
@@ -641,7 +648,7 @@ void interfaceUartInit(void)
|
|||||||
subscribe(&nmea_timer, ProcessNMEAFrames);
|
subscribe(&nmea_timer, ProcessNMEAFrames);
|
||||||
subscribe(&navigation_rs232_output, navigationRs232Process);
|
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());
|
printf("interface uart: initial OK %d\n",getCurrentTime());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
#define UM982_RX_IRQn DMA2_Channel9_IRQn
|
#define UM982_RX_IRQn DMA2_Channel9_IRQn
|
||||||
|
|
||||||
|
|
||||||
#define RING_BUF_SIZE 4096
|
#define RING_BUF_SIZE 6144
|
||||||
|
|
||||||
|
|
||||||
// <20><><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ṹ<EFBFBD>嶨<EFBFBD><E5B6A8>
|
// <20><><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ṹ<EFBFBD>嶨<EFBFBD><E5B6A8>
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ int main(void)
|
|||||||
|
|
||||||
bootInterfaceInit();
|
bootInterfaceInit();
|
||||||
appMonitorInit();
|
appMonitorInit();
|
||||||
// testAppInit();
|
testAppInit();
|
||||||
feedWatchdog();
|
feedWatchdog();
|
||||||
dataProcessingAppInit();
|
dataProcessingAppInit();
|
||||||
ethernetInterfaceInit();
|
ethernetInterfaceInit();
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ extern "C" {
|
|||||||
|
|
||||||
#define WCHNET_NUM_TCP 1 /* Number of TCP connections */
|
#define WCHNET_NUM_TCP 1 /* Number of TCP connections */
|
||||||
|
|
||||||
#define WCHNET_NUM_TCP_LISTEN 1 /* Number of TCP listening */
|
#define WCHNET_NUM_TCP_LISTEN 0 /* Number of TCP listening */
|
||||||
|
|
||||||
/* The number of sockets, the maximum is 31 */
|
/* The number of sockets, the maximum is 31 */
|
||||||
#define WCHNET_MAX_SOCKET_NUM (WCHNET_NUM_IPRAW+WCHNET_NUM_UDP+WCHNET_NUM_TCP+WCHNET_NUM_TCP_LISTEN)
|
#define WCHNET_MAX_SOCKET_NUM (WCHNET_NUM_IPRAW+WCHNET_NUM_UDP+WCHNET_NUM_TCP+WCHNET_NUM_TCP_LISTEN)
|
||||||
|
|||||||
@@ -353,13 +353,13 @@ void rs232Process(void)
|
|||||||
navigation_rs232_output.bit_data.gyro_z = (int16_t) (float_temp*32768/300.0f);
|
navigation_rs232_output.bit_data.gyro_z = (int16_t) (float_temp*32768/300.0f);
|
||||||
|
|
||||||
//<2F><><EFBFBD>ٶ<EFBFBD>
|
//<2F><><EFBFBD>ٶ<EFBFBD>
|
||||||
float_temp = (float) (yis321_data.bit_data.acc_x)*0.000001f/9.8;//<2F>ĵ<DEB8>λΪg
|
float_temp = (float) (yis321_data.bit_data.acc_x)*0.000001f;//<2F>ĵ<DEB8>λΪg
|
||||||
navigation_rs232_output.bit_data.accel_x = (int16_t) (float_temp*32768/12.0f);
|
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;//<2F>ĵ<DEB8>λΪg
|
float_temp = (float) (yis321_data.bit_data.acc_y)*0.000001f;//<2F>ĵ<DEB8>λΪg
|
||||||
navigation_rs232_output.bit_data.accel_y = (int16_t) (float_temp*32768/12.0f);
|
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;//<2F>ĵ<DEB8>λΪg
|
float_temp = (float) (yis321_data.bit_data.acc_z)*0.000001f;//<2F>ĵ<DEB8>λΪg
|
||||||
navigation_rs232_output.bit_data.accel_z = (int16_t) (float_temp*32768/12.0f);
|
navigation_rs232_output.bit_data.accel_z = (int16_t) (float_temp*32768/12.0f);
|
||||||
|
|
||||||
//gps<70><73>Ϣ
|
//gps<70><73>Ϣ
|
||||||
@@ -378,12 +378,6 @@ void rs232Process(void)
|
|||||||
navigation_rs232_output.bit_data.checksum = calculate_checksum(&navigation_rs232_output.arr[0],57);
|
navigation_rs232_output.bit_data.checksum = calculate_checksum(&navigation_rs232_output.arr[0],57);
|
||||||
publishMessage(&navigation_rs232_output, 1);
|
publishMessage(&navigation_rs232_output, 1);
|
||||||
|
|
||||||
// uint32_t debubg_len = 58;
|
|
||||||
// uint8_t debug_ip[4] = {192,168,17,77};
|
|
||||||
// UdpSendToData(SocketId2, (uint8_t *)&navigation_output2, &debubg_len,debug_ip,8011);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// timerStart(&rs232_output_timer, 20,1);//10ms
|
// timerStart(&rs232_output_timer, 20,1);//10ms
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,9 +426,6 @@ void imuInput(void *signal_id)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
publishMessage(&navigation_output1, 1);
|
publishMessage(&navigation_output1, 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -503,10 +494,8 @@ void nmeaPrintf(void *signal_id)
|
|||||||
// printf("ŷ<><C5B7><EFBFBD><EFBFBD>: (%.6f, %.6f, %.6f)\n",
|
// printf("ŷ<><C5B7><EFBFBD><EFBFBD>: (%.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);
|
// 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("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]);//ʹ<>ô<EFBFBD><C3B4>ڴ<EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD>ٶȣ<D9B6><C8A3><EFBFBD><EFBFBD>ٶ<EFBFBD><D9B6><EFBFBD><EFBFBD><EFBFBD>
|
// printf("GyroX:%f,GyroY:%f,GyroZ:%f\r\n",Gyro[0],Gyro[1],Gyro[2]);//ʹ<>ô<EFBFBD><C3B4>ڴ<EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD>ٶȣ<D9B6><C8A3><EFBFBD><EFBFBD>ٶ<EFBFBD><D9B6><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
timerStart(&data_processing_timer, 1000,1);//100ms
|
timerStart(&data_processing_timer, 1000,1);//100ms
|
||||||
}
|
}
|
||||||
@@ -522,6 +511,8 @@ void dataProcessingAppInit(void)
|
|||||||
timerInit(&rm3100_timer);
|
timerInit(&rm3100_timer);
|
||||||
timerInit(&data_processing_timer);
|
timerInit(&data_processing_timer);
|
||||||
timerInit(&rs232_output_timer);
|
timerInit(&rs232_output_timer);
|
||||||
|
|
||||||
|
RTCM_Buffer1.type = init;
|
||||||
|
|
||||||
rm3100Init();//<2F><>ʼ<EFBFBD><CABC>RM3100
|
rm3100Init();//<2F><>ʼ<EFBFBD><CABC>RM3100
|
||||||
// <20><><EFBFBD>Ķ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>źţ<C5BA><C5A3><EFBFBD><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD>GNGGA<47><41><EFBFBD><EFBFBD>
|
// <20><><EFBFBD>Ķ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>źţ<C5BA><C5A3><EFBFBD><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD>GNGGA<47><41><EFBFBD><EFBFBD>
|
||||||
|
|||||||
@@ -309,7 +309,7 @@ void OnParamSignal(void *data)
|
|||||||
uint16_t request_id = ((uint16_t)datagram[7] << 8) | (uint16_t)datagram[8];// 大端模式
|
uint16_t request_id = ((uint16_t)datagram[7] << 8) | (uint16_t)datagram[8];// 大端模式
|
||||||
|
|
||||||
// 调试输出
|
// 调试输出
|
||||||
printf("Received request ID: 0x%04X\n", request_id);
|
// printf("Received request ID: 0x%04X\n", request_id);
|
||||||
|
|
||||||
// 计算CRC
|
// 计算CRC
|
||||||
uint8_t calculatedCrc = calculateCRC(datagram, sizeof(UnParamRequest) - 1);
|
uint8_t calculatedCrc = calculateCRC(datagram, sizeof(UnParamRequest) - 1);
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ static void requestInput(void *signal_id)
|
|||||||
if(signal_id == &un_request_frame)
|
if(signal_id == &un_request_frame)
|
||||||
{
|
{
|
||||||
processRequestframe(REQUEST_READ_ID);
|
processRequestframe(REQUEST_READ_ID);
|
||||||
printf("request ID");
|
// printf("request ID");
|
||||||
}
|
}
|
||||||
else{}
|
else{}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,17 +18,17 @@ Timer test_timer;
|
|||||||
void testTimerProcess(void *signal_id)
|
void testTimerProcess(void *signal_id)
|
||||||
{
|
{
|
||||||
(void)signal_id; // 标记变量为已使用,避免编译器警告
|
(void)signal_id; // 标记变量为已使用,避免编译器警告
|
||||||
static uint32_t start_time = 0;
|
// static uint32_t start_time = 0;
|
||||||
// short hx,hy,hz=0;
|
// short hx,hy,hz=0;
|
||||||
|
|
||||||
|
printf("testAPP\n");
|
||||||
printf("testAPP: %d us \n",getCurrentTime() - start_time);
|
// printf("testAPP: %d us \n",getCurrentTime() - start_time);
|
||||||
|
|
||||||
// uint8_t arrtest4[10] = {0x56,0x56,0x04};
|
// uint8_t arrtest4[10] = {0x56,0x56,0x04};
|
||||||
|
|
||||||
printf("AccX:%f,AccY:%f,AccZ:%f,",Acc[0],Acc[1],Acc[2]);
|
// 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("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("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;
|
// uint8_t tesr1 = 0;
|
||||||
@@ -50,7 +50,7 @@ void testTimerProcess(void *signal_id)
|
|||||||
// UdpSendToData(SocketId,arrtest4,ÐUDPTxLen,IP1,8011);//测试
|
// UdpSendToData(SocketId,arrtest4,ÐUDPTxLen,IP1,8011);//测试
|
||||||
|
|
||||||
|
|
||||||
start_time = getCurrentTime();
|
// start_time = getCurrentTime();
|
||||||
|
|
||||||
// 再次启动定时器,实现周期定时
|
// 再次启动定时器,实现周期定时
|
||||||
timerStart(&test_timer, 1000,1);
|
timerStart(&test_timer, 1000,1);
|
||||||
|
|||||||
Reference in New Issue
Block a user