第一次提交,修改保存刷写上位机IP
This commit is contained in:
673
interface_ethernet.c
Normal file
673
interface_ethernet.c
Normal file
@@ -0,0 +1,673 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include "debug.h"
|
||||
#include <string.h>
|
||||
#include <udelay/udelay.h>
|
||||
#include "interface_ethernet.h"
|
||||
#include "eth_cfg.h"
|
||||
#include "lwip/timeouts.h"
|
||||
#include "sdrv_eth.h"
|
||||
#include "app/app_param_manage.h"
|
||||
#include "app/app_differential_drive.h"
|
||||
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define MAX_BUFFER_SIZE (sizeof(((RequestContext *)0)->param_request->arr))
|
||||
#define MAX_PACKET_SIZE 1024 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>СΪ1K
|
||||
|
||||
Timer ethernet_timer_interface;
|
||||
Timer ethernet_timer_interface1;
|
||||
|
||||
struct udp_pcb *udpcb_1;
|
||||
struct udp_pcb *udpcb_2;
|
||||
struct udp_pcb *udpcb_3;
|
||||
struct udp_pcb *udpcb_4;
|
||||
struct udp_pcb *udpcb_5;
|
||||
|
||||
bool eth_pool_rx = false;
|
||||
|
||||
|
||||
UnEthernetFault ethernet_fault_Info = {
|
||||
.bit_data.auto_count = 0,
|
||||
.bit_data.manual_count = 0,
|
||||
.bit_data.auto_state = 0,
|
||||
.bit_data.manual_state = 0,
|
||||
};
|
||||
|
||||
|
||||
|
||||
StrEthernetParameter ethernet_parameter = {
|
||||
.local_ip = {192,168,17,20},
|
||||
.mask = {255,255,255,0},
|
||||
.computer_ip = {192,168,17,3},
|
||||
.local_communication_port = 8011,
|
||||
.Local_upper_port = 8000,
|
||||
.Local_download_port = 7811,
|
||||
.upper_ip = {192,168,17,3},
|
||||
.download_ip = {192,168,17,183},
|
||||
.target_upper_port = 8000,
|
||||
.target_download_port = 7811,
|
||||
.target_communication_port = 8011,
|
||||
};
|
||||
|
||||
|
||||
|
||||
static bool g_eth1_rx_pkt;
|
||||
|
||||
|
||||
|
||||
static void eth_dma_rx_int_cb(struct net_driver_s *dev)
|
||||
{
|
||||
if (dev == &g_eth1_dev)
|
||||
g_eth1_rx_pkt = true;
|
||||
|
||||
// printf("eth_dma_rx_int_cb\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void lwip_Ethernet(void *signal_id)
|
||||
{
|
||||
// uint32_t time_boot = getCurrentTime();//<2F><>¼<EFBFBD><C2BC>ǰʱ<C7B0><CAB1>
|
||||
(void)signal_id; // <20><><EFBFBD>DZ<EFBFBD><C7B1><EFBFBD>Ϊ<EFBFBD><CEAA>ʹ<EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD>ETH֡<48><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD>LWIPЭ<50><D0AD>ջ
|
||||
// <20><><EFBFBD><EFBFBD>ʹ<EFBFBD>ܽ<EFBFBD><DCBD><EFBFBD><EFBFBD>жϣ<D0B6><CFA3><EFBFBD>ΪISR<53><52><EFBFBD><EFBFBD>disable<6C><65><EFBFBD><EFBFBD><EFBFBD>жϣ<D0B6><CFA3><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20>жϽ<D0B6><CFBD>ձ<EFBFBD>־(g_eth1_rx_pkt)<29>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20>µĽ<C2B5><C4BD><EFBFBD><EFBFBD>жϱ<D0B6><CFB1><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD><D4A3><EFBFBD><EFBFBD>ﲻ<EFBFBD><EFB2BB><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⡣
|
||||
if ((!eth_pool_rx && g_eth1_rx_pkt) || eth_pool_rx)
|
||||
{
|
||||
g_eth1_rx_pkt = false;
|
||||
dwc_eth_rx(&g_eth1_dev, eth_pool_rx);
|
||||
}
|
||||
|
||||
// LWIPЭ<50><D0AD>ջ<EFBFBD>ӿڣ<D3BF><DAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>LWIP<49><50>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
||||
sys_check_timeouts();
|
||||
|
||||
timerStart(ðernet_timer_interface1, 10,1); //10ms<6D><73><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
||||
|
||||
// printf("lwipInterface spend time:%d\n",getCurrentTime() - time_boot);//<2F><><EFBFBD><EFBFBD>app<70><70><EFBFBD>˶ʱ<E0B3A4><CAB1>
|
||||
}
|
||||
|
||||
|
||||
//err_t
|
||||
//udp_bind(struct udp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port)
|
||||
|
||||
int8_t UdpSendToData(uint8_t udpcbID, uint8_t *buf, uint16_t len, uint8_t *sip, uint16_t port)
|
||||
{
|
||||
struct pbuf *DesPuff = NULL;
|
||||
ip4_addr_t Desaddr;
|
||||
int8_t SendState = 0;
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
IP4_ADDR(&Desaddr,sip[0],sip[1],sip[2],sip[3]);//<2F><>ֵַת<D6B5><D7AA>
|
||||
|
||||
DesPuff = pbuf_alloc(PBUF_TRANSPORT, len, PBUF_POOL); /* <20><><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD> */
|
||||
|
||||
pbuf_take(DesPuff, buf, len); /* <20><>g_lwip_demo_sendbuf<75>е<EFBFBD><D0B5><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD>pbuf<75>ṹ<EFBFBD><E1B9B9> */
|
||||
|
||||
if(UDPCB_1 == udpcbID)
|
||||
{
|
||||
SendState = udp_sendto(udpcb_1, DesPuff, &Desaddr, port);
|
||||
}
|
||||
else if(UDPCB_2 == udpcbID)
|
||||
{
|
||||
SendState = udp_sendto(udpcb_2, DesPuff, &Desaddr, port);
|
||||
}
|
||||
else if(UDPCB_3 == udpcbID)
|
||||
{
|
||||
SendState = udp_sendto(udpcb_3, DesPuff, &Desaddr, port);
|
||||
}
|
||||
else if(UDPCB_3 == udpcbID)
|
||||
{
|
||||
SendState = udp_sendto(udpcb_3, DesPuff, &Desaddr, port);
|
||||
}
|
||||
else if(UDPCB_4 == udpcbID)
|
||||
{
|
||||
SendState = udp_sendto(udpcb_4, DesPuff, &Desaddr, port);
|
||||
}
|
||||
else if(UDPCB_5 == udpcbID)
|
||||
{
|
||||
SendState = udp_sendto(udpcb_5, DesPuff, &Desaddr, port);
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
pbuf_free(DesPuff); /* <20>ͷ<EFBFBD><CDB7>ڴ<EFBFBD> */
|
||||
|
||||
return SendState;
|
||||
}
|
||||
|
||||
// udpcbID UDP<44><50><EFBFBD><EFBFBD>
|
||||
//recv <20>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>
|
||||
//port <20>˿<F3B6A8B6>
|
||||
void UDP_Echo_Init(uint8_t udpcbID, udp_recv_fn recv, uint16_t port)
|
||||
{
|
||||
//------------------------------------------
|
||||
if(UDPCB_1 == udpcbID)
|
||||
{
|
||||
/* <20>½<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ƿ<EFBFBD>*/
|
||||
udpcb_1 = udp_new();
|
||||
ASSERT(udpcb_1);
|
||||
/* <20>˿ں<CBBF> */
|
||||
udp_bind(udpcb_1, IP_ADDR_ANY, port);
|
||||
/* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݻص<DDBB><D8B5><EFBFBD><EFBFBD><EFBFBD> */
|
||||
udp_recv(udpcb_1, recv, (void *)udpcbID);
|
||||
}
|
||||
else if(UDPCB_2 == udpcbID)
|
||||
{
|
||||
/* <20>½<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ƿ<EFBFBD>*/
|
||||
udpcb_2 = udp_new();
|
||||
ASSERT(udpcb_2);
|
||||
/* <20>˿ں<CBBF> */
|
||||
udp_bind(udpcb_2, IP_ADDR_ANY, port);
|
||||
/* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݻص<DDBB><D8B5><EFBFBD><EFBFBD><EFBFBD> */
|
||||
udp_recv(udpcb_2, recv, (void *)udpcbID);
|
||||
}
|
||||
else if(UDPCB_3 == udpcbID)
|
||||
{
|
||||
/* <20>½<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ƿ<EFBFBD>*/
|
||||
udpcb_3 = udp_new();
|
||||
ASSERT(udpcb_3);
|
||||
/* <20>˿ں<CBBF> */
|
||||
udp_bind(udpcb_3, IP_ADDR_ANY, port);
|
||||
/* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݻص<DDBB><D8B5><EFBFBD><EFBFBD><EFBFBD> */
|
||||
udp_recv(udpcb_3, recv, (void *)udpcbID);
|
||||
}
|
||||
else if(UDPCB_4 == udpcbID)
|
||||
{
|
||||
/* <20>½<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ƿ<EFBFBD>*/
|
||||
udpcb_4 = udp_new();
|
||||
ASSERT(udpcb_4);
|
||||
/* <20>˿ں<CBBF> */
|
||||
udp_bind(udpcb_4, IP_ADDR_ANY, port);
|
||||
/* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݻص<DDBB><D8B5><EFBFBD><EFBFBD><EFBFBD> */
|
||||
udp_recv(udpcb_4, recv, (void *)udpcbID);
|
||||
}
|
||||
else if(UDPCB_5 == udpcbID)
|
||||
{
|
||||
/* <20>½<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ƿ<EFBFBD>*/
|
||||
udpcb_5 = udp_new();
|
||||
ASSERT(udpcb_5);
|
||||
/* <20>˿ں<CBBF> */
|
||||
udp_bind(udpcb_5, IP_ADDR_ANY, port);
|
||||
/* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݻص<DDBB><D8B5><EFBFBD><EFBFBD><EFBFBD> */
|
||||
udp_recv(udpcb_5, recv, (void *)udpcbID);
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void udp_Callback_1(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16_t port)
|
||||
{
|
||||
uint8_t *buf = (uint8_t *)(p->payload);
|
||||
uint16_t i = 0;
|
||||
uint16_t len = 0;
|
||||
uint16_t udp_temp = 0;
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
if( (0xFF == buf[0] ) && ( 0xBB == buf[1] ) )//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>ң<EFBFBD><D2A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6>ң<EFBFBD><D2A3><EFBFBD><EFBFBD>
|
||||
{
|
||||
ethernet_fault_Info.bit_data.manual_count ++;
|
||||
|
||||
if( (p->len) >= sizeof(UnManualComputerInput) )//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ȳ<EFBFBD><C8B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>С<EFBFBD><D0A1><EFBFBD><EFBFBD>
|
||||
{
|
||||
len = sizeof(UnManualComputerInput);
|
||||
}
|
||||
else
|
||||
{
|
||||
len = p->len;
|
||||
}
|
||||
|
||||
for(i = 0; i < len; i++)
|
||||
{
|
||||
un_manual_computer_input.arr[i] = buf[i];
|
||||
}
|
||||
publishMessage(&un_manual_computer_input, 1);
|
||||
|
||||
// p->len = len;
|
||||
// printf("Manualrecive len:%d\n",len);
|
||||
// udp_sendto(upcb, p, addr, port);
|
||||
}
|
||||
else if( (0xFF == buf[0] ) && (0xCC == buf[1] ) )//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Զ<EFBFBD>
|
||||
{
|
||||
ethernet_fault_Info.bit_data.auto_count ++;
|
||||
|
||||
if( (p->len) >= sizeof(UnAutoComputerInput) )//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ȳ<EFBFBD><C8B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>С<EFBFBD><D0A1><EFBFBD><EFBFBD>
|
||||
{
|
||||
len = sizeof(UnAutoComputerInput);
|
||||
}
|
||||
else
|
||||
{
|
||||
len = p->len;
|
||||
}
|
||||
|
||||
|
||||
// unsigned int frame_header : 16; // ֡ͷ <20>̶<EFBFBD>ֵ0xFFCC
|
||||
// unsigned int frame_type : 16; // ֡<><D6A1><EFBFBD><EFBFBD> <20>̶<EFBFBD>ֵ0x0001
|
||||
// unsigned int frame_length : 8; // ֡<><D6A1> <20>̶<EFBFBD>ֵ0x19
|
||||
// unsigned int heartbeat : 8; // <20><><EFBFBD><EFBFBD> <20><>֡<EFBFBD>ۼ<EFBFBD>
|
||||
// unsigned int set_speed : 16; // <20>趨<EFBFBD>ٶ<EFBFBD> ϵ<><CFB5>0.01<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>λm/s
|
||||
// unsigned int set_curvature : 16; // <20>趨<EFBFBD><E8B6A8><EFBFBD><EFBFBD> ϵ<><CFB5>0.0001<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>ת
|
||||
// unsigned int latitude : 32; // γ<><CEB3> ϵ<><CFB5>10^-7<><37>431234567<36><37>ʾ43.1234567<EFBFBD><EFBFBD>
|
||||
// unsigned int longitude : 32; // <20><><EFBFBD><EFBFBD> ϵ<><CFB5>10^-7<><37>431234567<36><37>ʾ43.1234567<EFBFBD><EFBFBD>
|
||||
// unsigned int altitude : 32; // <20>߶<EFBFBD> <20><>λmm
|
||||
// unsigned int heading : 16; // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>35999<39><39>ʾ359.99<EFBFBD><EFBFBD>
|
||||
// unsigned int crc : 8; // CRC <20><><EFBFBD>ֽ<EFBFBD><D6BD>ۼ<EFBFBD>֮<EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>8λ
|
||||
for(i = 0; i < len; i++)
|
||||
{
|
||||
un_auto_computer_input.arr[i] = buf[i];
|
||||
}
|
||||
|
||||
udp_temp = ((un_auto_computer_input.bit_data.set_speed << 8) | (un_auto_computer_input.bit_data.set_speed >> 8));//<2F>趨<EFBFBD>ٶ<EFBFBD> 20240928 <20>ĸߵ<C4B8>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
||||
un_auto_computer_input.bit_data.set_speed = udp_temp;
|
||||
|
||||
udp_temp = ((un_auto_computer_input.bit_data.set_curvature << 8) | (un_auto_computer_input.bit_data.set_curvature >> 8));//<2F>趨<EFBFBD><E8B6A8><EFBFBD><EFBFBD>
|
||||
un_auto_computer_input.bit_data.set_curvature = udp_temp;
|
||||
publishMessage(&un_auto_computer_input, 1);
|
||||
|
||||
// p->len = len;
|
||||
// printf("Autorecive len:%d\n",len);
|
||||
// udp_sendto(upcb, p, addr, port);
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
|
||||
pbuf_free(p);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void udp_Callback_2(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16_t port)
|
||||
{
|
||||
uint8_t *buf = (uint8_t *)(p->payload);
|
||||
uint8_t ip_addr[4] = {0,0,0,0};
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
||||
ip_addr[0] = addr->addr & 0xff; /* IADDR4 */
|
||||
ip_addr[1] = (addr->addr >> 8) & 0xff; /* IADDR3 */
|
||||
ip_addr[2] = (addr->addr >> 16) & 0xff; /* IADDR2 */
|
||||
ip_addr[3] = (addr->addr >> 24) & 0xff; /* IADDR1 */
|
||||
|
||||
ethernet_parameter.target_upper_port = port;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><D5B5>Ķ˿ں<CBBF>IP<49><50><EFBFBD>´η<C2B4><CEB7>Ͷ<EFBFBD>Ӧ<EFBFBD><D3A6>IP<49>Ͷ˿<CDB6>
|
||||
|
||||
ethernet_parameter.upper_ip[0] = ip_addr[0];
|
||||
ethernet_parameter.upper_ip[1] = ip_addr[1];
|
||||
ethernet_parameter.upper_ip[2] = ip_addr[2];
|
||||
ethernet_parameter.upper_ip[3] = ip_addr[3];
|
||||
|
||||
if( (0x80 == buf[0]) && (0x00 == buf[1]) )
|
||||
{
|
||||
memcpy((uint8_t *)&(un_request_frame.arr[0]),buf, sizeof(UnRequestFrame));
|
||||
publishMessage(&un_request_frame, 1);
|
||||
}
|
||||
|
||||
pbuf_free(p);
|
||||
}
|
||||
|
||||
|
||||
void udp_Callback_4(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16_t port)
|
||||
{
|
||||
uint8_t *buf = (uint8_t *)(p->payload);
|
||||
uint8_t ip_addr[4] = {0,0,0,0};
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
||||
//20250822 <20><><EFBFBD>ӱ<EFBFBD><D3B1><EFBFBD>ˢд<CBA2><D0B4>λ<EFBFBD><CEBB>IP
|
||||
ip_addr[0] = addr->addr & 0xff; /* IADDR4 */
|
||||
ip_addr[1] = (addr->addr >> 8) & 0xff; /* IADDR3 */
|
||||
ip_addr[2] = (addr->addr >> 16) & 0xff; /* IADDR2 */
|
||||
ip_addr[3] = (addr->addr >> 24) & 0xff; /* IADDR1 */
|
||||
|
||||
ethernet_parameter.download_ip[0] = ip_addr[0];
|
||||
ethernet_parameter.download_ip[1] = ip_addr[1];
|
||||
ethernet_parameter.download_ip[2] = ip_addr[2];
|
||||
ethernet_parameter.download_ip[3] = ip_addr[3];
|
||||
|
||||
|
||||
boot_eth_flag = true;
|
||||
FrameHeader = ( (buf[0] << 8) | (buf[1]) );
|
||||
printf("FrameHeader %d\n",FrameHeader);
|
||||
|
||||
pbuf_free(p);
|
||||
}
|
||||
|
||||
|
||||
void udp_Callback_5(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16_t port)
|
||||
{
|
||||
uint8_t *buf = (uint8_t *)(p->payload);
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
||||
if(FEEDDOG_HEADER == ( (buf[0] << 8) | (buf[1]) ))
|
||||
{
|
||||
WDTReFresh_flag = true;//<2F><><EFBFBD><EFBFBD>ι<EFBFBD><CEB9><EFBFBD><EFBFBD>־
|
||||
printf("Feed dog flag received %d\n",getCurrentTime());
|
||||
}
|
||||
|
||||
|
||||
pbuf_free(p);
|
||||
}
|
||||
|
||||
|
||||
//100ms <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
||||
void ethernetTimerProcess(void)
|
||||
{
|
||||
static uint8_t ethernet_timer = 0;
|
||||
static uint8_t ethernet_temp[4] = {0,0,0,0};//<2F>м<EFBFBD><D0BC>ж<EFBFBD>ֵ
|
||||
uint8_t temp = 0;
|
||||
|
||||
ethernet_timer ++;
|
||||
if(ethernet_timer >= 5)//500ms<6D>ж<EFBFBD>һ<EFBFBD><D2BB>
|
||||
{
|
||||
ethernet_timer = 0;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>------------------------------------------------------------
|
||||
if(ethernet_fault_Info.bit_data.auto_count == ethernet_temp[0])//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
||||
{
|
||||
ethernet_fault_Info.bit_data.auto_state = FAULT;
|
||||
}
|
||||
else
|
||||
{
|
||||
ethernet_fault_Info.bit_data.auto_state = NORMAL;
|
||||
ethernet_temp[0] = ethernet_fault_Info.bit_data.auto_count;//<2F><><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD>
|
||||
}
|
||||
|
||||
if(ethernet_fault_Info.bit_data.auto_state != ethernet_temp[1])
|
||||
{
|
||||
ethernet_temp[1] = ethernet_fault_Info.bit_data.auto_state;
|
||||
temp ++;
|
||||
}
|
||||
|
||||
|
||||
//<2F>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>------------------------------------------------------------
|
||||
if(ethernet_fault_Info.bit_data.manual_count == ethernet_temp[2])//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
||||
{
|
||||
ethernet_fault_Info.bit_data.manual_state = FAULT;
|
||||
}
|
||||
else
|
||||
{
|
||||
ethernet_fault_Info.bit_data.manual_state = NORMAL;
|
||||
ethernet_temp[2] = ethernet_fault_Info.bit_data.manual_count;//<2F><><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD>
|
||||
}
|
||||
|
||||
if(ethernet_fault_Info.bit_data.manual_state != ethernet_temp[3])
|
||||
{
|
||||
ethernet_temp[3] = ethernet_fault_Info.bit_data.manual_state;
|
||||
temp ++;
|
||||
}
|
||||
}
|
||||
|
||||
publishMessage(ðernet_fault_Info, 1);// ״̬<D7B4>仯 <20><><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
|
||||
}
|
||||
|
||||
|
||||
static void vehicleInfOoutput(void *signal_id)
|
||||
{
|
||||
(void)signal_id; // <20><><EFBFBD>DZ<EFBFBD><C7B1><EFBFBD>Ϊ<EFBFBD><CEAA>ʹ<EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
UdpSendToData(UDPCB_2,(uint8_t *)(&un_vehicle_Info_output), sizeof(un_vehicle_Info_output), (uint8_t *)ðernet_parameter.upper_ip[0], ethernet_parameter.target_upper_port);
|
||||
}
|
||||
|
||||
static void motorStatusOutput(void *signal_id)
|
||||
{
|
||||
(void)signal_id; // <20><><EFBFBD>DZ<EFBFBD><C7B1><EFBFBD>Ϊ<EFBFBD><CEAA>ʹ<EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
UdpSendToData(UDPCB_2,(uint8_t *)(&un_motor_status_output), sizeof(un_motor_status_output), (uint8_t *)ðernet_parameter.upper_ip[0], ethernet_parameter.target_upper_port);
|
||||
}
|
||||
|
||||
static void pidOutput(void *signal_id)
|
||||
{
|
||||
(void)signal_id; // <20><><EFBFBD>DZ<EFBFBD><C7B1><EFBFBD>Ϊ<EFBFBD><CEAA>ʹ<EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
UdpSendToData(UDPCB_2,(uint8_t *)(&un_pid_output), sizeof(un_pid_output), (uint8_t *)ðernet_parameter.upper_ip[0], ethernet_parameter.target_upper_port);
|
||||
}
|
||||
|
||||
static void remoteControlOutput(void *signal_id)
|
||||
{
|
||||
(void)signal_id; // <20><><EFBFBD>DZ<EFBFBD><C7B1><EFBFBD>Ϊ<EFBFBD><CEAA>ʹ<EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
UdpSendToData(UDPCB_2,(uint8_t *)(&un_remote_control_output), sizeof(un_remote_control_output), (uint8_t *)ðernet_parameter.upper_ip[0], ethernet_parameter.target_upper_port);
|
||||
}
|
||||
|
||||
static void manualControlOutput(void *signal_id)
|
||||
{
|
||||
(void)signal_id; // <20><><EFBFBD>DZ<EFBFBD><C7B1><EFBFBD>Ϊ<EFBFBD><CEAA>ʹ<EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
UdpSendToData(UDPCB_2,(uint8_t *)(&un_manual_control_output),sizeof(un_manual_control_output), (uint8_t *)ðernet_parameter.upper_ip[0], ethernet_parameter.target_upper_port);
|
||||
|
||||
}
|
||||
|
||||
static void autoControlOutput(void *signal_id)
|
||||
{
|
||||
(void)signal_id; // <20><><EFBFBD>DZ<EFBFBD><C7B1><EFBFBD>Ϊ<EFBFBD><CEAA>ʹ<EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
UdpSendToData(UDPCB_2,(uint8_t *)(&un_auto_control_output), sizeof(un_auto_control_output), (uint8_t *)ðernet_parameter.upper_ip[0], ethernet_parameter.target_upper_port);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//<2F><>̫<EFBFBD><CCAB> <20><><EFBFBD><EFBFBD>
|
||||
void ethernetSendAll(void *signal_id)
|
||||
{
|
||||
static uint8_t computer_output_cnt = 0;
|
||||
uint32_t crc_temp = 0;
|
||||
uint8_t i = 0;
|
||||
uint16_t Rg_Tmp = 0;
|
||||
float Rg_FloatTmp = 0;
|
||||
static uint8_t eth_cnt = 0;
|
||||
static uint8_t app_output_cnt = 0;
|
||||
uint8_t BOOT_Arr[2] = {0x01,0x02};//<2F>ϵ緢<CFB5><E7B7A2>app֡<70><D6A1><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
||||
//-------------------------------------------------------------------------
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̫<EFBFBD><CCAB>50ms<6D><73><EFBFBD><EFBFBD> 20210811<31><EFBFBD>Ϊ100ms<6D><73><EFBFBD><EFBFBD>
|
||||
//20210827<32><EFBFBD>Ϊ<EFBFBD><CEAA>λ<EFBFBD><CEBB>ǰ<EFBFBD><C7B0>λ<EFBFBD>ٺ<EFBFBD><D9BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
||||
computer_output_cnt ++;
|
||||
if(computer_output_cnt >= 1)
|
||||
{
|
||||
computer_output_cnt = 0;
|
||||
//<2F><><EFBFBD>ֽ<EFBFBD><D6BD>ۼӺͣ<D3BA>ע<EFBFBD>ⲻ<EFBFBD><E2B2BB><EFBFBD>ź<EFBFBD> 20210826<32>İ<DEB8><C4B0><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD>ۼ<EFBFBD>
|
||||
|
||||
// printf("left_motor_speed = %f\n",diff_data.left_motor_speed);
|
||||
// printf("right_motor_speed = %f\n",diff_data.right_motor_speed);
|
||||
|
||||
un_computer_output.bit_data.frame_header = 0xCCFF;
|
||||
un_computer_output.bit_data.frame_type = 0x1100;
|
||||
un_computer_output.bit_data.frame_length = 0x0B;
|
||||
un_computer_output.bit_data.accumulated = eth_cnt ++;
|
||||
|
||||
Rg_FloatTmp = (diff_data.left_motor_speed*(float)getParam("whl_dia") * M_PI*60)/1000.0/(float)getParam("gRatio");// ת/<2F><><EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD>km/h һȦ1.8<EFBFBD><EFBFBD>
|
||||
Rg_FloatTmp = Rg_FloatTmp*100;//,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>100<30><30> ,ϵ<><CFB5>0.01
|
||||
Rg_Tmp = (uint16_t)((int16_t)(Rg_FloatTmp));//<2F><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>Ϊ<EFBFBD><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>); //20231012<31><EFBFBD><DEB8><EFBFBD><EFBFBD>ٷ<EFBFBD><D9B7><EFBFBD> 20231226-3<>ų<EFBFBD><C5B3>ķ<DEB8><C4B7><EFBFBD>
|
||||
un_computer_output.bit_data.speed = ((Rg_Tmp << 8) | (Rg_Tmp >> 8));//<2F><>λ<EFBFBD><CEBB>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>λ<EFBFBD>ֺ<EFBFBD>
|
||||
|
||||
Rg_FloatTmp = (diff_data.right_motor_speed*(float)getParam("whl_dia") * M_PI*60)/1000.0/(float)getParam("gRatio");// ת/<2F><><EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD>km/h һȦ1.8<EFBFBD><EFBFBD>
|
||||
Rg_FloatTmp = Rg_FloatTmp*100;//,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>100<30><30> ,ϵ<><CFB5>0.01
|
||||
Rg_Tmp = (uint16_t)((int16_t)(Rg_FloatTmp));//<2F><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>Ϊ<EFBFBD><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>); //20231012<31><EFBFBD><DEB8><EFBFBD><EFBFBD>ٷ<EFBFBD><D9B7><EFBFBD> 20231226-3<>ų<EFBFBD><C5B3>ķ<DEB8><C4B7><EFBFBD>
|
||||
un_computer_output.bit_data.curvature = ((Rg_Tmp << 8) | (Rg_Tmp >> 8));//<2F><>λ<EFBFBD><CEBB>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>λ<EFBFBD>ֺ<EFBFBD>
|
||||
|
||||
crc_temp = 0;
|
||||
for(i = 0; i<10 ;i++)//<2F><><EFBFBD>ȹ̶<C8B9>
|
||||
{
|
||||
crc_temp = crc_temp + (un_computer_output.arr[i]);
|
||||
}
|
||||
un_computer_output.bit_data.crc = (uint8_t)crc_temp;
|
||||
|
||||
UdpSendToData(UDPCB_1,(uint8_t *)(&un_computer_output.arr[0]), 11, (uint8_t *)ðernet_parameter.computer_ip[0], COMMUNICATION_PORT);
|
||||
UdpSendToData(UDPCB_4,(uint8_t *)(&un_computer_output.arr[0]), 11, (uint8_t *)ðernet_parameter.computer_ip[0], COMMUNICATION_PORT);
|
||||
}
|
||||
|
||||
|
||||
if(app_output_cnt < 10)//20250109 100ms <20><><EFBFBD><EFBFBD>10֡app֡<70><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̫<EFBFBD><CCAB>û<EFBFBD>г<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ɾͷ<C9BE><CDB7>͵Ķ<CDB5>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>
|
||||
{
|
||||
app_output_cnt ++;
|
||||
UdpSendToData(UDPCB_4, BOOT_Arr, 2, (uint8_t *)ðernet_parameter.download_ip[0], BOOT_TX_PORT);
|
||||
}
|
||||
}
|
||||
|
||||
// <20><>̫<EFBFBD><CCAB><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>źŴ<C5BA><C5B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
static void ethernetInterfaceTimerProcess(void *signal_id)
|
||||
{
|
||||
uint32_t time_boot = getCurrentTime();//<2F><>¼<EFBFBD><C2BC>ǰʱ<C7B0><CAB1>
|
||||
(void)signal_id; // <20><><EFBFBD>DZ<EFBFBD><C7B1><EFBFBD>Ϊ<EFBFBD><CEAA>ʹ<EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
ethernetSendAll(signal_id);
|
||||
|
||||
ethernetTimerProcess();//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
||||
|
||||
timerStart(ðernet_timer_interface, 100,1); //100ms<6D><73><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
||||
|
||||
// printf("ethernetInterface spend time:%d\n",getCurrentTime() - time_boot);//<2F><><EFBFBD><EFBFBD>app<70><70><EFBFBD>˶ʱ<E0B3A4><CAB1>
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static unsigned char receive_buffer[MAX_BUFFER_SIZE];
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>
|
||||
void udp_Callback_3(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16_t port)
|
||||
{
|
||||
static unsigned int received_size = 0;
|
||||
uint8_t *buf = (uint8_t *)(p->payload);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>µ<EFBFBD>֡ͷ
|
||||
if ((0x80 == buf[1]) && (0xFF == buf[0]))
|
||||
{
|
||||
// <20><><EFBFBD>ý<EFBFBD><C3BD>չ<EFBFBD><D5B9><EFBFBD>
|
||||
received_size = 0;
|
||||
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>֡ͷ,<2C><><EFBFBD>ý<EFBFBD><C3BD>չ<EFBFBD><D5B9><EFBFBD>\n");
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>㹻<EFBFBD>Ŀռ<C4BF><D5BC><EFBFBD><EFBFBD>洢<EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (received_size + p->len <= MAX_BUFFER_SIZE)
|
||||
{
|
||||
printf("p->len %d :\n" , p->len);
|
||||
|
||||
memcpy(receive_buffer + received_size, buf, p->len);
|
||||
received_size += p->len;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (received_size >= sizeof(request_context.param_request->arr))
|
||||
{
|
||||
printf("received_size : %d :\n" , received_size);
|
||||
|
||||
for(u16_t i = 0; i< sizeof(request_context.param_request->arr); i++)
|
||||
{
|
||||
request_context.param_request->arr[i] = receive_buffer[i];
|
||||
}
|
||||
|
||||
memcpy(request_context.param_request->arr, receive_buffer, sizeof(request_context.param_request->arr));
|
||||
request_context.sender_ip = (unsigned int)addr->addr;
|
||||
request_context.sender_port = port;
|
||||
|
||||
// <20><>ӡ request_context.param_request->arr <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// printf("<22><><EFBFBD>յ<EFBFBD><D5B5><EFBFBD> param_request->arr <20><><EFBFBD><EFBFBD>:\n");
|
||||
// for (size_t i = 0; i < sizeof(request_context.param_request->arr); ++i)
|
||||
// {
|
||||
// printf("%02X ", request_context.param_request->arr[i]);
|
||||
// if ((i + 1) % 1024 == 0 || i == sizeof(request_context.param_request->arr) - 1)
|
||||
// {
|
||||
// printf("\n");
|
||||
// feedWatchdog();
|
||||
// }
|
||||
// }
|
||||
|
||||
publishMessage(&request_context, 1);
|
||||
|
||||
printf("received_size<EFBFBD><EFBFBD>%d \n" , received_size);
|
||||
// <20><><EFBFBD>ý<EFBFBD><C3BD>ջ<EFBFBD><D5BB><EFBFBD><EFBFBD><EFBFBD>
|
||||
received_size = 0;
|
||||
printf("<EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD>ý<EFBFBD><C3BD><EFBFBD>
|
||||
received_size = 0;
|
||||
printf("<EFBFBD><EFBFBD><EFBFBD>ջ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD>ݶ<EFBFBD><DDB6><EFBFBD>\n");
|
||||
}
|
||||
|
||||
unsigned int tmp_count = pbuf_free(p);
|
||||
printf("pbuf_free<EFBFBD>Ѿ<EFBFBD><EFBFBD>ͷţ<EFBFBD>tmp_count :%d \n" , tmp_count);
|
||||
p = NULL;
|
||||
}
|
||||
|
||||
void OnParamSend(void *data)
|
||||
{
|
||||
uint8_t ip_addr[4] = {0,0,0,0};
|
||||
RequestContext *signal = (RequestContext *)(data);
|
||||
|
||||
ip_addr[0] = signal->sender_ip & 0xff; /* IADDR4 */
|
||||
ip_addr[1] = (signal->sender_ip >> 8) & 0xff; /* IADDR3 */
|
||||
ip_addr[2] = (signal->sender_ip >> 16) & 0xff; /* IADDR2 */
|
||||
ip_addr[3] = (signal->sender_ip >> 24) & 0xff; /* IADDR1 */
|
||||
|
||||
uint32_t total_size = sizeof(signal->param_request->arr);
|
||||
uint32_t sent_size = 0;
|
||||
|
||||
|
||||
while (sent_size < total_size)
|
||||
{
|
||||
uint32_t remaining = total_size - sent_size;
|
||||
uint32_t packet_size = (remaining > MAX_PACKET_SIZE) ? MAX_PACKET_SIZE : remaining;
|
||||
|
||||
UdpSendToData(UDPCB_3,
|
||||
(uint8_t *)(signal->param_request->arr) + sent_size,
|
||||
packet_size,
|
||||
ip_addr,
|
||||
signal->sender_port);
|
||||
|
||||
sent_size += packet_size;
|
||||
// <20><><EFBFBD><EFBFBD>С<EFBFBD>ӳ<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ
|
||||
udelay(1000);
|
||||
}
|
||||
printf("<EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD>%d \n", sent_size);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// APPģ<50><C4A3><EFBFBD>ij<EFBFBD>ʼ<EFBFBD><CABC>
|
||||
void ethernetInterfaceInit(void)
|
||||
{
|
||||
//-----------------------------------
|
||||
if (!eth_pool_rx) {
|
||||
// ʹ<><CAB9>DMA Rx<52>жϡ<D0B6>Txδʹ<CEB4><CAB9><EFBFBD>жϣ<D0B6><CFA3><EFBFBD>ΪETH<54><48><EFBFBD>ʺܸߣ<DCB8>
|
||||
// Tx<54>жϴ<D0B6><CFB4><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٶȡ<D9B6>
|
||||
dwc_eth_enable_dma_rx_int(&g_eth1_dev, eth_dma_rx_int_cb);
|
||||
}
|
||||
|
||||
timerInit(ðernet_timer_interface1);
|
||||
timerInit(ðernet_timer_interface);
|
||||
|
||||
// <20><><EFBFBD>Ķ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>źţ<C5BA><C5A3><EFBFBD><EFBFBD>ڶ<EFBFBD>ʱ<EFBFBD>ɼ<EFBFBD>
|
||||
subscribe(ðernet_timer_interface, ethernetInterfaceTimerProcess);
|
||||
subscribe(ðernet_timer_interface1, lwip_Ethernet);
|
||||
|
||||
|
||||
subscribe(&un_vehicle_Info_output, vehicleInfOoutput);
|
||||
subscribe(&un_motor_status_output, motorStatusOutput);
|
||||
subscribe(&un_pid_output, pidOutput);
|
||||
subscribe(&un_remote_control_output, remoteControlOutput);
|
||||
subscribe(&un_manual_control_output, manualControlOutput);
|
||||
subscribe(&un_auto_control_output, autoControlOutput);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>ʹ<EFBFBD>þ<EFBFBD>̬<EFBFBD><CCAC>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>ص<EFBFBD>
|
||||
subscribe(&request_send, OnParamSend);
|
||||
|
||||
|
||||
timerStart(ðernet_timer_interface, 100,1); //100ms<6D><73><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
||||
timerStart(ðernet_timer_interface1, 10,1); //10ms<6D><73><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
||||
|
||||
printf( "ethernetInterface: initial OK %d\n",getCurrentTime());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user