Files
GPS-Navigator-/ETH/UdpServer/User/interface_etherent.h
2025-09-05 21:09:02 +08:00

93 lines
2.7 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* eth_drive.h
*
* Created on: 2023年1月5日
* Author: Administrator
*/
#ifndef USER_INTERFACE_ETHERENT_H_
#define USER_INTERFACE_ETHERENT_H_
#include "wchnet.h"
#include "debug.h"
#define DF_EthInfoWiteTime 1000
#define DF_SEND_Fail 1
#define DF_SEND_Success 0
#define UDP_RECE_BUF_LEN 1472
#define DF_EncryptionEnable 1
#define DF_DebugDesIPAdress 10
#define DF_SugarDesIPAdress 3
#define DF_DownloadDesIPAdress 183
#define DATA_START_ADDR ((uint32_t)0x0803FF00)//0x0803FF00 //最后256用于存放数据0x0803FF00- 0x0803FFFF 256K 注意地址对齐
#define DATA_Break_ADDR ((uint32_t)0x0803FE00)//0x0803FF10 //修改为另外256字节因为擦除会擦掉数据
#define KEEPALIVE_ENABLE 1 //Enable keep alive function
#define FLASH_PAGE_SIZE 256
//结构体
typedef struct {
volatile uint8_t canBootloaderUpgrade; //CAN升级标志位
uint8_t test1;
uint8_t test2;
uint8_t test3;
} SystemDataRecord;//这个结构体需与APP同步
typedef enum{
NORMAL_ON = 0,
CAN_BOOTLOADER_UPGRADE,
}UpgradeFlag;
//外部变量声明
extern u8 MACAddr[6];//MAC address
extern u8 IPAddr[4];//IP address
extern u8 GWIPAddr[4];//Gateway IP address
extern u8 IPMask[4];//subnet mask
extern u16 srcport;//source port
extern u8 SocketId;
extern u8 SocketRecvBuf[RECE_BUF_LEN];//socket receive buffer
extern u8 SocketRecvBuf2[RECE_BUF_LEN];//socket receive buffer
extern u8 SocketId2;
extern u8 DesIPAddr[4];//IP address
extern u16 Desport;
extern u32 ETHUDPTxLen;
extern u8 portableOcuTimeOutCnt;
extern u8 remoteOcuTimeOutCnt;
extern u8 OwnMasterTimCnt;
extern u8 OwnMasterOnline;
extern u8 portableOcuOnline;
extern u8 remoteOcuOnline;
//外部函数声明
void mStopIfError(u8 iError);
void WCHNET_UdpServerRecv(struct _SCOK_INF *socinf, u32 ipaddr, u16 port, u8 *buf, u32 len);
void WCHNET_CreateUdpSocket(void);
void WCHNET_CreateUdpClientSocket(void);
void WCHNET_CreateTcpSocket(void);
void WCHNET_HandleSockInt(u8 socketid, u8 intstat);
void WCHNET_HandleGlobalInt(void);
void WCHNET_GetMacAddr( uint8_t *p );
void WCHNET_TimeIsr( uint16_t timperiod );
void WCHNET_QueryPhySta(void);
u8 UdpSendToData(uint8_t socketid, uint8_t *buf, uint32_t *slen, uint8_t *sip, uint16_t port);//发送数据
void IAP_EEPROM_READ( u32 StartAddr, u8 *Buffer, u32 Length );
void IAP_EEPROM_WRITE( u32 StartAddr, u8 *Buffer, u32 Length );
void IAP_EEPROM_ERASE(uint32_t Page_Address, u32 Length);
void ethernetInterfaceInit(void);
#endif /* USER_INTERFACE_ETHERENT_H_ */