102 lines
2.4 KiB
C
102 lines
2.4 KiB
C
|
/// Agent<6E>ļ<EFBFBD>
|
|||
|
///
|
|||
|
/// ָ<><EFBFBD><EEB4A6>ģ<EFBFBD>顢<EFBFBD><E9A1A2><EFBFBD><EFBFBD><EFBFBD>ⲿ<EFBFBD><E2B2BF><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
|
|||
|
/// @file Agent.c
|
|||
|
/// @author LH
|
|||
|
/// @date 2022-04-22
|
|||
|
/// @version v1.0
|
|||
|
|
|||
|
#include "includes.h"
|
|||
|
#include "gd32f4xx.h"
|
|||
|
#include "enet_to_udp.h"
|
|||
|
#include "Lan8720.h"
|
|||
|
#include "lwip/tcpip.h"
|
|||
|
#include "lwip/raw.h"
|
|||
|
#include "lwip/icmp.h"
|
|||
|
#include "lwip/dhcp.h"
|
|||
|
#include "lwip/netif.h"
|
|||
|
#include "lwip/sys.h"
|
|||
|
#include "lwip/timers.h"
|
|||
|
#include "lwip/inet_chksum.h"
|
|||
|
#include "lwip/init.h"
|
|||
|
#include "netif/etharp.h"
|
|||
|
#include "pdebug.h"
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD>
|
|||
|
BSP_OS_SEM udp_send_data_mutex;
|
|||
|
struct sockaddr_in ptz_from;//IP<49>Ͷ˿<CDB6>
|
|||
|
struct sockaddr_in ptz_local;//<2F><><EFBFBD><EFBFBD>IP<49>Ͷ˿<CDB6>
|
|||
|
socklen_t ptz_fromlen;//<2F><><EFBFBD><EFBFBD>
|
|||
|
int ptz_sock_fd;//<2F><><EFBFBD><EFBFBD>
|
|||
|
BSP_OS_SEM udp_mutex;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4>
|
|||
|
|
|||
|
BSP_OS_SEM sem_enet_isr_recv;
|
|||
|
|
|||
|
static void task_create_recv_enet_isr (void);
|
|||
|
|
|||
|
extern struct netif fsl_netif0;
|
|||
|
|
|||
|
extern err_t ethernetif_input(struct netif *netif);
|
|||
|
|
|||
|
static void task_recv_enet_isr(void *p_arg)
|
|||
|
{
|
|||
|
CPU_INT08U err;
|
|||
|
|
|||
|
p_arg = p_arg;
|
|||
|
while(1)
|
|||
|
{
|
|||
|
OSSemPend(sem_enet_isr_recv,0,&err);
|
|||
|
ethernetif_input(&fsl_netif0);
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
static OS_STK task_recv_enet_isr_stk[TASK_RECV_ENET_ISR_STK_SIZE];
|
|||
|
static void task_create_recv_enet_isr (void)
|
|||
|
{
|
|||
|
|
|||
|
CPU_INT08U task_err;
|
|||
|
CPU_INT08U name_err;
|
|||
|
|
|||
|
task_err = OSTaskCreateExt((void (*)(void *)) task_recv_enet_isr,
|
|||
|
(void *) 0,
|
|||
|
(OS_STK *)&task_recv_enet_isr_stk[TASK_RECV_ENET_ISR_STK_SIZE - 1],
|
|||
|
(INT8U ) TASK_RECV_ENET_ISR_PRIO,
|
|||
|
(INT16U ) TASK_RECV_ENET_ISR_PRIO,
|
|||
|
(OS_STK *)&task_recv_enet_isr_stk[0],
|
|||
|
(INT32U ) TASK_RECV_ENET_ISR_STK_SIZE,
|
|||
|
(void *) 0,
|
|||
|
(INT16U )(OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR));
|
|||
|
#if (OS_TASK_NAME_EN > 0)
|
|||
|
OSTaskNameSet(TASK_RECV_ENET_ISR_PRIO, "task_recv_enet_isr", &name_err);
|
|||
|
#endif
|
|||
|
|
|||
|
if ((task_err == OS_ERR_NONE) && (name_err == OS_ERR_NONE)) {
|
|||
|
pdebug(DEBUG_LEVEL_INFO,"create init_udp_module success...\n\r");
|
|||
|
} else {
|
|||
|
pdebug(DEBUG_LEVEL_FATAL,"create init_udp_module failed...\n\r");
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
//=====<3D><>̫<EFBFBD><CCAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϳ<D0B6>ʼ<EFBFBD><CABC>=====
|
|||
|
void init_udp_module()
|
|||
|
{
|
|||
|
BSP_OS_SemCreate(&udp_mutex,1u,"udp_mutex");
|
|||
|
BSP_OS_SemCreate(&sem_enet_isr_recv,0u,"sem_enet_isr_recv");
|
|||
|
Lan8720_Init();
|
|||
|
task_create_recv_enet_isr();
|
|||
|
term_printf("\n Lwip Init begin \r\n\r\n");
|
|||
|
Lwip_init();
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|