#ifndef __ETHERNETIF_H #define __ETHERNETIF_H #include "lwip/err.h" #include "lwip/netif.h" void phy_write_reg(uint8_t reg_add, uint16_t reg_val); uint16_t phy_read_reg(uint8_t reg_add); #define ROM_CFG_USERADR_ID 0x1FFFF7E8 #define ETH_DMARxDesc_FrameLengthShift 16 #define ETH_MAX_PACKET_SIZE \ 1536 /* ETH_HEADER + VLAN_TAG + MAX_ETH_PAYLOAD + ETH_CRC */ #define ETH_HEADER \ 14 /* 6 byte Dest addr, 6 byte Src addr, 2 byte length/type \ */ #define ETH_CRC 4 /* Ethernet CRC */ #define ETH_EXTRA 2 /* Extra bytes in some cases */ #define VLAN_TAG 4 /* optional 802.1q VLAN Tag */ #define MIN_ETH_PAYLOAD 46 /* Minimum Ethernet payload size */ #define MAX_ETH_PAYLOAD 1500 /* Maximum Ethernet payload size */ #define MIN_ETH_FRAME_SIZE (ETH_HEADER + MIN_ETH_PAYLOAD) /* 60 bytes */ typedef struct { uint32_t volatile Status; /* Status */ uint32_t ControlBufferSize; /* Control and Buffer1, Buffer2 lengths */ uint32_t Buffer1Addr; /* Buffer1 address pointer */ uint32_t Buffer2NextDescAddr; /* Buffer2 or next descriptor address pointer */ } ETH_DMADESCTypeDef; /** * @brief Initialize the ethernet interface and lwIP network stack. * This function should be passed as the init function to netif_add(). * * @param netif The lwIP network interface structure to be initialized. * @return ERR_OK if the loopif is initialized, ERR_MEM if private data couldn't * be allocated. */ err_t ethernetif_init(struct netif* netif); /** * @brief This function should be called periodically from your main loop * to check for incoming packets and pass them to lwIP. * * @param netif The lwIP network interface structure. */ void ethernetif_input(struct netif* netif); /** * @brief This function should be called periodically from your main loop * to check the link status and update lwIP accordingly. * * @param netif The lwIP network interface structure.. */ void ethernetif_link_poll(struct netif* netif); #endif /* __ETHERNETIF_H */