121 lines
3.0 KiB
C
121 lines
3.0 KiB
C
#ifndef _INTERFACE_ETHERNET_H_
|
|
#define _INTERFACE_ETHERNET_H_
|
|
|
|
#include "interface_config.h"
|
|
#include "lwip/err.h"
|
|
#include "lwip/inet.h"
|
|
#include "lwip/tcp.h"
|
|
#include "lwip/udp.h"
|
|
|
|
#include "lwip/netif.h"
|
|
#include "lwip/ip.h"
|
|
#include "lwip/init.h"
|
|
#include "netif/etharp.h"
|
|
#include "lwip/pbuf.h"
|
|
|
|
|
|
|
|
|
|
|
|
//以太网故障信息
|
|
typedef struct _StrEthernetFault
|
|
{
|
|
uint8_t auto_count; //自动数据计数器
|
|
uint8_t manual_count; //手动数据计数器
|
|
uint8_t auto_state; // 自动状态 | 0故障 1正常
|
|
uint8_t manual_state; // 手动状态 | 0故障 1正常
|
|
} StrEthernetFault;
|
|
|
|
typedef union _UnEthernetFault
|
|
{
|
|
StrEthernetFault bit_data; // 使用定义的结构体变量名
|
|
uint8_t arr[sizeof(StrEthernetFault)]; // 通过结构体类型确定大小
|
|
} UnEthernetFault;
|
|
|
|
|
|
extern UnEthernetFault ethernet_fault_Info;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
{
|
|
uint8_t local_ip[4];
|
|
uint8_t mask[4];
|
|
uint16_t Local_upper_port;
|
|
uint16_t Local_download_port;
|
|
uint16_t local_communication_port;
|
|
uint8_t computer_ip[4];
|
|
uint8_t upper_ip[4];
|
|
uint8_t download_ip[4];
|
|
uint16_t target_upper_port;
|
|
uint16_t target_download_port;
|
|
uint16_t target_communication_port;
|
|
|
|
} StrEthernetParameter;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define UDPCB_1 1//通讯端口
|
|
#define UDPCB_2 2//上位机端口
|
|
#define UDPCB_3 3//参数上位机端口
|
|
#define UDPCB_4 4//参数上位机端口
|
|
#define UDPCB_5 5//参数上位机端口
|
|
|
|
|
|
|
|
#define COMMUNICATION_PORT 8011
|
|
#define UPPER_PORT 8000
|
|
#define PARAM_PORT 8080
|
|
|
|
#define DOWNLOAR_PORT 7812
|
|
#define BOOT_TX_PORT 7811 //发送时填写的端口,目标端口,发给谁
|
|
#define WDT_PORT 7813 //初始化时候的端口,接收端口
|
|
|
|
|
|
|
|
|
|
//外部函数
|
|
void UDP_Echo_Init(uint8_t udpcbID, udp_recv_fn recv, uint16_t port);
|
|
int8_t UdpSendToData(uint8_t udpcbID, uint8_t *buf, uint16_t len, uint8_t *sip, uint16_t port);
|
|
|
|
void udp_Callback_1(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16_t port);
|
|
void udp_Callback_2(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16_t port);
|
|
void udp_Callback_3(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16_t port);
|
|
void udp_Callback_4(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16_t port);
|
|
void udp_Callback_5(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16_t port);
|
|
|
|
void ethernetTimerProcess(void);
|
|
void ethernetInterfaceInit(void);
|
|
|
|
|
|
|
|
//外部变量
|
|
extern struct udp_pcb *udpcb_1;
|
|
extern StrEthernetParameter ethernet_parameter;
|
|
|
|
extern struct udp_pcb *udpcb_1;
|
|
extern struct udp_pcb *udpcb_2;
|
|
extern struct udp_pcb *udpcb_3;
|
|
extern struct udp_pcb *udpcb_4;
|
|
extern struct udp_pcb *udpcb_5;
|
|
|
|
extern bool eth_pool_rx;
|
|
|
|
|
|
|
|
#endif /*ETH_DEMO_H */ |