1 /* 2 * Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef LWIP_ADAPTER_H 17 #define LWIP_ADAPTER_H 18 19 #include "gd32f4xx.h" 20 #include "stdint.h" 21 22 void lwip_stack_init(void); 23 #define DHCP_TIMEOUT_S 30 24 #define ETH_THREAD_PRIORITY 5 25 #define ENET_TASK_STACK_SIZE 1024 26 #define ENET_TASK_PRIORITY 30 27 #define DHCP_TASK_STACK_SIZE 1024 28 #define DHCP_TASK_PRIORITY 29 29 30 #define USE_ENET_INTERRUPT 31 #define MAC_ADDR0 2 32 #define MAC_ADDR1 0xA 33 #define MAC_ADDR2 0xF 34 #define MAC_ADDR3 0xE 35 #define MAC_ADDR4 0xD 36 #define MAC_ADDR5 6 37 38 /* static IP address: IP_ADDR0.IP_ADDR1.IP_ADDR2.IP_ADDR3 */ 39 #define IP_ADDR0 192 40 #define IP_ADDR1 168 41 #define IP_ADDR2 100 42 #define IP_ADDR3 2 43 44 /* remote IP address: IP_S_ADDR0.IP_S_ADDR1.IP_S_ADDR2.IP_S_ADDR3 */ 45 #define IP_S_ADDR0 192 46 #define IP_S_ADDR1 168 47 #define IP_S_ADDR2 100 48 #define IP_S_ADDR3 3 49 50 /* net mask */ 51 #define NETMASK_ADDR0 255 52 #define NETMASK_ADDR1 255 53 #define NETMASK_ADDR2 255 54 #define NETMASK_ADDR3 0 55 56 /* gateway address */ 57 #define GW_ADDR0 192 58 #define GW_ADDR1 168 59 #define GW_ADDR2 100 60 #define GW_ADDR3 1 61 62 #define RMII_MODE // user have to provide the 50 MHz clock by soldering a 50 MHz oscillator 63 64 /* clock the PHY from external 25MHz crystal (only for MII mode) */ 65 #ifdef MII_MODE 66 #define PHY_CLOCK_MCO 67 #endif 68 69 typedef union { 70 UINT32 u32_addr; 71 UINT8 u8_addr[4]; 72 } IPUnion; 73 74 typedef struct { 75 unsigned char useStaticIp; 76 IPUnion ipaddr; 77 IPUnion netmask; 78 IPUnion gw; 79 unsigned char useStaticMac; 80 unsigned char macAddr[6]; 81 } EthLinkInfo; 82 83 typedef enum { 84 STATE_UPDATE_LINK_DOWN = 0, 85 STATE_UPDATE_LINK_UP = 1, 86 } EthLinkState; 87 88 typedef void (*net_state_callBack)(EthLinkState state); 89 90 #define PHY_STATUS_CALLBACK(func, val) \ 91 { \ 92 do { \ 93 if ((func) != NULL) { \ 94 (func)(val); \ 95 } \ 96 } while (0); \ 97 } 98 99 extern void enet_gpio_config(void); 100 101 #endif // end of #ifndef LWIP_ADAPTER_H