1 /* 2 * Copyright (c) 2022 Talkweb 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 _APP_ETHERNET_H 17 #define _APP_ETHERNET_H 18 19 #include "stm32f4xx_hal.h" 20 #include "cmsis_os2.h" 21 #include "ethernetif.h" 22 #include "lwip/sockets.h" 23 #include "lwip/ip_addr.h" 24 #include "lwip/dhcp.h" 25 #include "lwip/udp.h" 26 27 28 #define DHCP_TIMEOUT_S 30 29 30 #define ETH_THREAD_PRIORITY 5 31 32 typedef union { 33 ip_addr_t u32_addr; 34 unsigned char u8_addr[4]; 35 } IPUnion; 36 37 typedef enum { 38 STATE_UPDATE_LINK_DOWN = 0, 39 STATE_UPDATE_LINK_UP = 1, 40 } EthLinkState; 41 42 typedef struct { 43 unsigned char useStaticIp; 44 IPUnion ipaddr; 45 IPUnion netmask; 46 IPUnion gw; 47 unsigned char useStaticMac; 48 unsigned char macAddr[6]; 49 } EthLinkInfo; 50 51 void get_ethernet_link_info(EthLinkInfo *info); 52 53 void set_ethernet_link_info(EthLinkInfo *info); 54 55 typedef void (*eth_state_callBack)(EthLinkState state); 56 57 void ethernet_enable(eth_state_callBack callback); 58 59 #endif 60