Merge branch 'lwip' of https://gitlink.org.cn/tuyuyang/xiuos into 2023_open_source_contest
This commit is contained in:
@@ -4,6 +4,7 @@ SRC_DIR += core
|
||||
SRC_DIR += netif
|
||||
SRC_DIR += include
|
||||
|
||||
SRC_DIR += apps
|
||||
|
||||
LWIP_DIR += api
|
||||
LWIP_DIR += arch
|
||||
@@ -11,5 +12,6 @@ LWIP_DIR += core
|
||||
LWIP_DIR += netif
|
||||
LWIP_DIR += include
|
||||
|
||||
LWIP_DIR += apps
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
|
||||
SRC_FILES += lwiperf/lwiperf.c http/http_client.c
|
||||
SRC_FILES += mqtt/mqtt.c
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
||||
@@ -64,7 +64,8 @@
|
||||
* HTTPC_DEBUG: Enable debugging for HTTP client.
|
||||
*/
|
||||
#ifndef HTTPC_DEBUG
|
||||
#define HTTPC_DEBUG LWIP_DBG_OFF
|
||||
#define HTTPC_DEBUG LWIP_DBG_ON
|
||||
// #define HTTPC_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
/** Set this to 1 to keep server name and uri in request state */
|
||||
|
||||
@@ -30,6 +30,195 @@
|
||||
#ifndef __LWIPOPTS_H__
|
||||
#define __LWIPOPTS_H__
|
||||
|
||||
/* ---------- Debug options ---------- */
|
||||
#ifndef LWIP_DEBUG
|
||||
#define LWIP_DEBUG 1
|
||||
#endif
|
||||
|
||||
// #define LWIP_SOCKETS_DEBUG 1
|
||||
|
||||
#ifdef LWIP_DEBUG
|
||||
#ifdef LWIP_SYS_DEBUG
|
||||
#define SYS_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define SYS_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_ETHARP_DEBUG
|
||||
#define ETHARP_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define ETHARP_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_PPP_DEBUG
|
||||
#define PPP_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define PPP_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_MEM_DEBUG
|
||||
#define MEM_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define MEM_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_MEMP_DEBUG
|
||||
#define MEMP_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define MEMP_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_PBUF_DEBUG
|
||||
#define PBUF_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define PBUF_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_API_LIB_DEBUG
|
||||
#define API_LIB_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define API_LIB_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_API_MSG_DEBUG
|
||||
#define API_MSG_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define API_MSG_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_TCPIP_DEBUG
|
||||
#define TCPIP_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define TCPIP_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_NETIF_DEBUG
|
||||
#define NETIF_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define NETIF_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_SOCKETS_DEBUG
|
||||
#define SOCKETS_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define SOCKETS_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_DNS_DEBUG
|
||||
#define DNS_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define DNS_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_AUTOIP_DEBUG
|
||||
#define AUTOIP_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define AUTOIP_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_DHCP_DEBUG
|
||||
#define DHCP_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define DHCP_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_IP_DEBUG
|
||||
#define IP_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define IP_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_IP_REASS_DEBUG
|
||||
#define IP_REASS_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define IP_REASS_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_ICMP_DEBUG
|
||||
#define ICMP_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define ICMP_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_IGMP_DEBUG
|
||||
#define IGMP_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define IGMP_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_UDP_DEBUG
|
||||
#define UDP_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define UDP_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_TCP_DEBUG
|
||||
#define TCP_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define TCP_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_TCP_INPUT_DEBUG
|
||||
#define TCP_INPUT_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define TCP_INPUT_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_TCP_OUTPUT_DEBUG
|
||||
#define TCP_OUTPUT_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_TCP_RTO_DEBUG
|
||||
#define TCP_RTO_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define TCP_RTO_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_TCP_CWND_DEBUG
|
||||
#define TCP_CWND_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define TCP_CWND_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_TCP_WND_DEBUG
|
||||
#define TCP_WND_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define TCP_WND_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_TCP_FR_DEBUG
|
||||
#define TCP_FR_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define TCP_FR_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_TCP_QLEN_DEBUG
|
||||
#define TCP_QLEN_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define TCP_QLEN_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_TCP_RST_DEBUG
|
||||
#define TCP_RST_DEBUG LWIP_DBG_ON
|
||||
#else
|
||||
#define TCP_RST_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_DEBUG */
|
||||
|
||||
|
||||
#define LWIP_TIMEVAL_PRIVATE 0
|
||||
#define LWIP_NO_UNISTD_H 0
|
||||
#define LWIP_NO_STDDEF_H 0
|
||||
#define LWIP_NO_STDINT_H 0
|
||||
#define LWIP_NO_INTTYPES_H 0
|
||||
#define LWIP_NO_LIMITS_H 0
|
||||
#define LWIP_NO_CTYPE_H 0
|
||||
#define LWIP_SOCKET_SELECT 1
|
||||
#define LWIP_SOCKET_POLL 1
|
||||
|
||||
/**
|
||||
* SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain
|
||||
* critical regions during buffer allocation, deallocation and memory
|
||||
@@ -57,35 +246,40 @@
|
||||
|
||||
/* MEM_SIZE: the size of the heap memory. If the application will send
|
||||
a lot of data that needs to be copied, this should be set high. */
|
||||
#define MEM_SIZE (25*1024)
|
||||
#define MEM_SIZE (64*1024)
|
||||
|
||||
/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application
|
||||
sends a lot of data out of ROM (or other static memory), this
|
||||
should be set high. */
|
||||
#define MEMP_NUM_PBUF 15
|
||||
#define MEMP_NUM_PBUF 32
|
||||
/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
|
||||
per active UDP "connection". */
|
||||
#define MEMP_NUM_UDP_PCB 4
|
||||
/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
|
||||
connections. */
|
||||
#define MEMP_NUM_TCP_PCB 4
|
||||
#define MEMP_NUM_TCP_PCB 64
|
||||
/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
|
||||
connections. */
|
||||
#define MEMP_NUM_TCP_PCB_LISTEN 2
|
||||
/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
|
||||
segments. */
|
||||
#define MEMP_NUM_TCP_SEG 20
|
||||
#define MEMP_NUM_TCP_SEG 256
|
||||
/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
|
||||
timeouts. */
|
||||
#define MEMP_NUM_SYS_TIMEOUT 6
|
||||
|
||||
// #define MEMP_NUM_SYS_TIMEOUT 6
|
||||
#define MEMP_NUM_SYS_TIMEOUT (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + PPP_SUPPORT + (LWIP_IPV6 ? (1 + (2*LWIP_IPV6)) : 0))
|
||||
|
||||
/* ---------- Pbuf options ---------- */
|
||||
/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
|
||||
#define PBUF_POOL_SIZE 20
|
||||
#define PBUF_POOL_SIZE 255
|
||||
/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
|
||||
// #define PBUF_POOL_BUFSIZE 1024
|
||||
#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN)
|
||||
|
||||
/* ---------- ARP options ---------- */
|
||||
#define LWIP_ARP 1
|
||||
#define ARP_TABLE_SIZE 10
|
||||
#define ARP_QUEUEING 1
|
||||
|
||||
/* ---------- TCP options ---------- */
|
||||
#define LWIP_TCP 1
|
||||
@@ -93,7 +287,7 @@ a lot of data that needs to be copied, this should be set high. */
|
||||
|
||||
/* Controls if TCP should queue segments that arrive out of
|
||||
order. Define to 0 if your device is low on memory. */
|
||||
#define TCP_QUEUE_OOSEQ 0
|
||||
#define TCP_QUEUE_OOSEQ 1
|
||||
|
||||
/* TCP Maximum segment size. */
|
||||
#define TCP_MSS (1500 - 40) /* TCP_MSS = (Ethernet MTU - IP header size - TCP header size) */
|
||||
@@ -107,9 +301,69 @@ a lot of data that needs to be copied, this should be set high. */
|
||||
#define TCP_SND_QUEUELEN (8* TCP_SND_BUF/TCP_MSS)
|
||||
|
||||
/* TCP receive window. */
|
||||
#define TCP_WND (12*TCP_MSS)
|
||||
#define TCP_WND 8192
|
||||
// #define TCP_WND (12 * TCP_MSS)
|
||||
|
||||
|
||||
/* Maximum number of retransmissions of data segments. */
|
||||
#define TCP_MAXRTX 12
|
||||
|
||||
/* Maximum number of retransmissions of SYN segments. */
|
||||
#define TCP_SYNMAXRTX 4
|
||||
|
||||
/**
|
||||
* LWIP_TCP_KEEPALIVE==1: Enable TCP_KEEPIDLE, TCP_KEEPINTVL and TCP_KEEPCNT
|
||||
* options processing. Note that TCP_KEEPIDLE and TCP_KEEPINTVL have to be set
|
||||
* in seconds. (does not require sockets.c, and will affect tcp.c)
|
||||
*/
|
||||
#ifndef LWIP_TCP_KEEPALIVE
|
||||
#define LWIP_TCP_KEEPALIVE 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* LWIP_NETIF_HOSTNAME==1: Support netif hostname
|
||||
*/
|
||||
#ifndef LWIP_NETIF_HOSTNAME
|
||||
#define LWIP_NETIF_HOSTNAME 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* LWIP_NETIF_API==1: Support netif api (in netifapi.c)
|
||||
*/
|
||||
#ifndef LWIP_NETIF_API
|
||||
#define LWIP_NETIF_API 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* LWIP_SO_SNDTIMEO==1: Enable send timeout for sockets/netconns and
|
||||
* SO_SNDTIMEO processing.
|
||||
*/
|
||||
#ifndef LWIP_SO_SNDTIMEO
|
||||
#define LWIP_SO_SNDTIMEO 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* LWIP_SO_RCVTIMEO==1: Enable receive timeout for sockets/netconns and
|
||||
* SO_RCVTIMEO processing.
|
||||
*/
|
||||
#ifndef LWIP_SO_RCVTIMEO
|
||||
#define LWIP_SO_RCVTIMEO 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* LWIP_SO_RCVBUF==1: Enable SO_RCVBUF processing.
|
||||
*/
|
||||
#ifndef LWIP_SO_RCVBUF
|
||||
#define LWIP_SO_RCVBUF 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* If LWIP_SO_RCVBUF is used, this is the default value for recv_bufsize.
|
||||
*/
|
||||
#ifndef RECV_BUFSIZE_DEFAULT
|
||||
#define RECV_BUFSIZE_DEFAULT 8192
|
||||
#endif
|
||||
|
||||
/* ---------- ICMP options ---------- */
|
||||
#define LWIP_ICMP 1
|
||||
|
||||
@@ -127,7 +381,6 @@ a lot of data that needs to be copied, this should be set high. */
|
||||
|
||||
|
||||
/* ---------- Statistics options ---------- */
|
||||
#define LWIP_STATS 0
|
||||
#define LWIP_PROVIDE_ERRNO 1
|
||||
|
||||
/* ---------- link callback options ---------- */
|
||||
@@ -146,7 +399,7 @@ The STM32F4x7 allows computing and verifying the IP, UDP, TCP and ICMP checksums
|
||||
- To use this feature let the following define uncommented.
|
||||
- To disable it and process by CPU comment the the checksum.
|
||||
*/
|
||||
//#define CHECKSUM_BY_HARDWARE
|
||||
#define CHECKSUM_BY_HARDWARE
|
||||
|
||||
#ifdef CHECKSUM_BY_HARDWARE
|
||||
/* CHECKSUM_GEN_IP==0: Generate checksums by hardware for outgoing IP packets.*/
|
||||
@@ -176,7 +429,7 @@ The STM32F4x7 allows computing and verifying the IP, UDP, TCP and ICMP checksums
|
||||
#define CHECKSUM_CHECK_UDP 1
|
||||
/* CHECKSUM_CHECK_TCP==1: Check checksums in software for incoming TCP packets.*/
|
||||
#define CHECKSUM_CHECK_TCP 1
|
||||
/* CHECKSUM_CHECK_ICMP==1: Check checksums by hardware for incoming ICMP packets.*/
|
||||
/* CHECKSUM_CHECK_ICMP==1: Check checksums by software for incoming ICMP packets.*/
|
||||
#define CHECKSUM_GEN_ICMP 1
|
||||
#endif
|
||||
|
||||
@@ -225,7 +478,50 @@ The STM32F4x7 allows computing and verifying the IP, UDP, TCP and ICMP checksums
|
||||
/**
|
||||
* LWIP_SO_LINGER==1: Enable SO_LINGER processing.
|
||||
*/
|
||||
#define LWIP_SO_LINGER 1
|
||||
// #define LWIP_SO_LINGER 1
|
||||
|
||||
/* ---------- IP options ---------- */
|
||||
/* Define IP_FORWARD to 1 if you wish to have the ability to forward
|
||||
IP packets across network interfaces. If you are going to run lwIP
|
||||
on a device with only one network interface, define this to 0. */
|
||||
#define IP_FORWARD 0
|
||||
|
||||
/* IP reassembly and segmentation.These are orthogonal even
|
||||
* if they both deal with IP fragments */
|
||||
#ifdef LWIP_REASSEMBLY_FRAG
|
||||
#define IP_REASSEMBLY 1
|
||||
#define IP_FRAG 1
|
||||
#define IP_REASS_MAX_PBUFS 10
|
||||
#define MEMP_NUM_REASSDATA 10
|
||||
#else
|
||||
#define IP_REASSEMBLY 0
|
||||
#define IP_FRAG 0
|
||||
#endif
|
||||
|
||||
/* ---------- ICMP options ---------- */
|
||||
#define ICMP_TTL 255
|
||||
|
||||
/* ---------- DHCP options ---------- */
|
||||
/* Define LWIP_DHCP to 1 if you want DHCP configuration of
|
||||
interfaces. */
|
||||
#define LWIP_DHCP 1
|
||||
|
||||
/* 1 if you want to do an ARP check on the offered address
|
||||
(recommended). */
|
||||
#define DHCP_DOES_ARP_CHECK (LWIP_DHCP)
|
||||
|
||||
/* ---------- AUTOIP options ------- */
|
||||
#define LWIP_AUTOIP 0
|
||||
#define LWIP_DHCP_AUTOIP_COOP (LWIP_DHCP && LWIP_AUTOIP)
|
||||
|
||||
|
||||
#define LWIP_UDPLITE 0
|
||||
#define UDP_TTL 255
|
||||
|
||||
|
||||
/* ---------- Statistics options ---------- */
|
||||
#define LWIP_STATS 1
|
||||
#define LWIP_STATS_DISPLAY 1
|
||||
|
||||
/*
|
||||
---------------------------------
|
||||
@@ -236,23 +532,21 @@ The STM32F4x7 allows computing and verifying the IP, UDP, TCP and ICMP checksums
|
||||
#define DEFAULT_RAW_RECVMBOX_SIZE 8
|
||||
#define DEFAULT_UDP_RECVMBOX_SIZE 8
|
||||
#define DEFAULT_TCP_RECVMBOX_SIZE 8
|
||||
#define DEFAULT_ACCEPTMBOX_SIZE 8
|
||||
#define DEFAULT_ACCEPTMBOX_SIZE 10
|
||||
|
||||
#define DEFAULT_THREAD_PRIO 20
|
||||
#define DEFAULT_THREAD_STACKSIZE 1024
|
||||
|
||||
#define TCPIP_THREAD_NAME "tcp"
|
||||
#define TCPIP_THREAD_STACKSIZE 8192
|
||||
#define TCPIP_MBOX_SIZE 8
|
||||
#define TCPIP_THREAD_PRIO 15
|
||||
#define TCPIP_THREAD_STACKSIZE 4096
|
||||
#define TCPIP_MBOX_SIZE 16
|
||||
#define TCPIP_THREAD_PRIO 20
|
||||
|
||||
/*
|
||||
----------------------------------------
|
||||
---------- Lwip Debug options ----------
|
||||
----------------------------------------
|
||||
*/
|
||||
#define LWIP_DEBUG 1
|
||||
|
||||
#define LWIP_IPV4 1
|
||||
#define LWIP_RAW 1
|
||||
#define LWIP_DNS 1
|
||||
|
||||
@@ -69,96 +69,58 @@
|
||||
#include "ethernet.h"
|
||||
#include "connect_ethernet.h"
|
||||
|
||||
char lwip_ipaddr[20] = {192, 168, 131, 77};
|
||||
char lwip_ipaddr[20] = {192, 168, 130, 77};
|
||||
char lwip_netmask[20] = {255, 255, 254, 0};
|
||||
char lwip_gwaddr[20] = {192, 168, 131, 23};
|
||||
char lwip_gwaddr[20] = {192, 168, 130, 1};
|
||||
|
||||
char lwip_eth0_ipaddr[20] = {192, 168, 131, 77};
|
||||
char lwip_eth0_ipaddr[20] = {192, 168, 130, 77};
|
||||
char lwip_eth0_netmask[20] = {255, 255, 254, 0};
|
||||
char lwip_eth0_gwaddr[20] = {192, 168, 131, 23};
|
||||
char lwip_eth0_gwaddr[20] = {192, 168, 130, 1};
|
||||
|
||||
char lwip_eth1_ipaddr[20] = {192, 168, 131, 99};
|
||||
char lwip_eth1_ipaddr[20] = {192, 168, 130, 99};
|
||||
char lwip_eth1_netmask[20] = {255, 255, 254, 0};
|
||||
char lwip_eth1_gwaddr[20] = {192, 168, 131, 23};
|
||||
char lwip_eth1_gwaddr[20] = {192, 168, 130, 23};
|
||||
|
||||
char lwip_flag = 0;
|
||||
|
||||
x_ticks_t lwip_sys_now;
|
||||
|
||||
struct sys_timeouts {
|
||||
struct sys_timeo *next;
|
||||
};
|
||||
|
||||
struct timeoutlist
|
||||
{
|
||||
struct sys_timeouts timeouts;
|
||||
int32 pid;
|
||||
};
|
||||
|
||||
#define SYS_THREAD_MAX 4
|
||||
|
||||
static struct timeoutlist s_timeoutlist[SYS_THREAD_MAX];
|
||||
struct netif gnetif;
|
||||
sys_sem_t* get_eth_recv_sem() {
|
||||
static sys_sem_t g_recv_sem = 0;
|
||||
return &g_recv_sem;
|
||||
}
|
||||
|
||||
static u16_t s_nextthread = 0;
|
||||
void sys_init(void) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
u32_t
|
||||
sys_jiffies(void)
|
||||
{
|
||||
sys_jiffies(void) {
|
||||
lwip_sys_now = CurrentTicksGain();
|
||||
return lwip_sys_now;
|
||||
}
|
||||
|
||||
u32_t
|
||||
sys_now(void)
|
||||
{
|
||||
sys_now(void) {
|
||||
lwip_sys_now = CurrentTicksGain();
|
||||
return lwip_sys_now;
|
||||
return CalculateTimeMsFromTick(lwip_sys_now);
|
||||
}
|
||||
|
||||
void
|
||||
sys_init(void)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < SYS_THREAD_MAX; i++)
|
||||
{
|
||||
s_timeoutlist[i].pid = 0;
|
||||
s_timeoutlist[i].timeouts.next = NULL;
|
||||
}
|
||||
s_nextthread = 0;
|
||||
}
|
||||
|
||||
struct sys_timeouts *sys_arch_timeouts(void)
|
||||
{
|
||||
int i;
|
||||
int32 pid;
|
||||
struct timeoutlist *tl;
|
||||
pid = (int32)GetKTaskDescriptor()->id.id;
|
||||
for(i = 0; i < s_nextthread; i++)
|
||||
{
|
||||
tl = &(s_timeoutlist[i]);
|
||||
if(tl->pid == pid)
|
||||
{
|
||||
return &(tl->timeouts);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sys_prot_t sys_arch_protect(void)
|
||||
{
|
||||
sys_prot_t sys_arch_protect(void) {
|
||||
return CriticalAreaLock();
|
||||
}
|
||||
|
||||
void sys_arch_unprotect(sys_prot_t pval)
|
||||
{
|
||||
void sys_arch_unprotect(sys_prot_t pval) {
|
||||
CriticalAreaUnLock(pval);
|
||||
}
|
||||
|
||||
#if !NO_SYS
|
||||
|
||||
err_t
|
||||
sys_sem_new(sys_sem_t *sem, u8_t count)
|
||||
{
|
||||
sys_sem_new(sys_sem_t *sem, u8_t count) {
|
||||
*sem = KSemaphoreCreate((uint16)count);
|
||||
|
||||
#if SYS_STATS
|
||||
@@ -170,8 +132,7 @@ sys_sem_new(sys_sem_t *sem, u8_t count)
|
||||
|
||||
if(*sem >= 0)
|
||||
return ERR_OK;
|
||||
else
|
||||
{
|
||||
else {
|
||||
#if SYS_STATS
|
||||
++lwip_stats.sys.sem.err;
|
||||
#endif /* SYS_STATS */
|
||||
@@ -181,8 +142,7 @@ sys_sem_new(sys_sem_t *sem, u8_t count)
|
||||
}
|
||||
|
||||
void
|
||||
sys_sem_free(sys_sem_t *sem)
|
||||
{
|
||||
sys_sem_free(sys_sem_t *sem) {
|
||||
#if SYS_STATS
|
||||
--lwip_stats.sys.sem.used;
|
||||
#endif /* SYS_STATS */
|
||||
@@ -190,19 +150,16 @@ sys_sem_free(sys_sem_t *sem)
|
||||
*sem = SYS_SEM_NULL;
|
||||
}
|
||||
|
||||
int sys_sem_valid(sys_sem_t *sem)
|
||||
{
|
||||
int sys_sem_valid(sys_sem_t *sem) {
|
||||
return (*sem > SYS_SEM_NULL);
|
||||
}
|
||||
|
||||
void
|
||||
sys_sem_set_invalid(sys_sem_t *sem)
|
||||
{
|
||||
sys_sem_set_invalid(sys_sem_t *sem) {
|
||||
*sem = SYS_SEM_NULL;
|
||||
}
|
||||
|
||||
u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout)
|
||||
{
|
||||
u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout) {
|
||||
x_ticks_t start_tick = 0 ;
|
||||
int32 wait_time = 0;
|
||||
|
||||
@@ -220,61 +177,51 @@ u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout)
|
||||
|
||||
|
||||
if(KSemaphoreObtain(*sem, wait_time) == EOK)
|
||||
return ((CurrentTicksGain()-start_tick)*MS_PER_SYSTICK);
|
||||
return CalculateTimeMsFromTick(CurrentTicksGain()-start_tick);
|
||||
else
|
||||
return SYS_ARCH_TIMEOUT;
|
||||
}
|
||||
|
||||
void sys_sem_signal(sys_sem_t *sem)
|
||||
{
|
||||
if(KSemaphoreAbandon( *sem ) != EOK)
|
||||
void sys_sem_signal(sys_sem_t *sem) {
|
||||
if(KSemaphoreAbandon(*sem) != EOK)
|
||||
KPrintf("[sys_arch]:sem signal fail!\n");
|
||||
}
|
||||
|
||||
err_t sys_mutex_new(sys_mutex_t *mutex)
|
||||
{
|
||||
err_t sys_mutex_new(sys_mutex_t *mutex) {
|
||||
*mutex = KMutexCreate();
|
||||
if(*mutex > SYS_MRTEX_NULL)
|
||||
if (*mutex > SYS_MRTEX_NULL)
|
||||
return ERR_OK;
|
||||
else
|
||||
{
|
||||
else {
|
||||
KPrintf("[sys_arch]:new mutex fail!\n");
|
||||
return ERR_MEM;
|
||||
}
|
||||
}
|
||||
|
||||
void sys_mutex_free(sys_mutex_t *mutex)
|
||||
{
|
||||
void sys_mutex_free(sys_mutex_t *mutex) {
|
||||
KMutexDelete(*mutex);
|
||||
}
|
||||
|
||||
void sys_mutex_set_invalid(sys_mutex_t *mutex)
|
||||
{
|
||||
void sys_mutex_set_invalid(sys_mutex_t *mutex) {
|
||||
*mutex = SYS_MRTEX_NULL;
|
||||
}
|
||||
|
||||
void sys_mutex_lock(sys_mutex_t *mutex)
|
||||
{
|
||||
KMutexObtain(*mutex,
|
||||
WAITING_FOREVER);
|
||||
void sys_mutex_lock(sys_mutex_t *mutex) {
|
||||
KMutexObtain(*mutex, WAITING_FOREVER);
|
||||
}
|
||||
|
||||
void sys_mutex_unlock(sys_mutex_t *mutex)
|
||||
{
|
||||
KMutexAbandon( *mutex );
|
||||
void sys_mutex_unlock(sys_mutex_t *mutex) {
|
||||
KMutexAbandon(*mutex);
|
||||
}
|
||||
|
||||
|
||||
sys_thread_t sys_thread_new(const char *name, lwip_thread_fn function, void *arg, int stacksize, int prio)
|
||||
{
|
||||
sys_thread_t sys_thread_new(const char *name, lwip_thread_fn function, void *arg, int stacksize, int prio) {
|
||||
sys_thread_t handle = -1;
|
||||
handle = KTaskCreate(name,
|
||||
function,
|
||||
arg,
|
||||
(uint32)stacksize,
|
||||
(uint8)prio);
|
||||
if (handle >= 0)
|
||||
{
|
||||
if (handle >= 0) {
|
||||
StartupKTask(handle);
|
||||
lw_print("lw: [%s] create %s handle %x\n", __func__, name, handle);
|
||||
return handle;
|
||||
@@ -283,8 +230,7 @@ sys_thread_t sys_thread_new(const char *name, lwip_thread_fn function, void *arg
|
||||
return -ERROR;
|
||||
}
|
||||
|
||||
err_t sys_mbox_new(sys_mbox_t *mbox, int size)
|
||||
{
|
||||
err_t sys_mbox_new(sys_mbox_t *mbox, int size) {
|
||||
*mbox = KCreateMsgQueue(sizeof(void *), size);
|
||||
|
||||
#if SYS_STATS
|
||||
@@ -293,8 +239,7 @@ err_t sys_mbox_new(sys_mbox_t *mbox, int size)
|
||||
lwip_stats.sys.mbox.max = lwip_stats.sys.mbox.used;
|
||||
}
|
||||
#endif /* SYS_STATS */
|
||||
if(*mbox < 0)
|
||||
{
|
||||
if(*mbox < 0) {
|
||||
lw_print("lw: [%s] alloc %d mbox %p failed\n", __func__, size, mbox);
|
||||
return ERR_MEM;
|
||||
}
|
||||
@@ -303,44 +248,38 @@ err_t sys_mbox_new(sys_mbox_t *mbox, int size)
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
void sys_mbox_free(sys_mbox_t *mbox)
|
||||
{
|
||||
void sys_mbox_free(sys_mbox_t *mbox) {
|
||||
KDeleteMsgQueue(*mbox);
|
||||
}
|
||||
|
||||
int sys_mbox_valid(sys_mbox_t *mbox)
|
||||
{
|
||||
int sys_mbox_valid(sys_mbox_t *mbox) {
|
||||
if (*mbox <= SYS_MBOX_NULL)
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
void sys_mbox_set_invalid(sys_mbox_t *mbox)
|
||||
{
|
||||
void sys_mbox_set_invalid(sys_mbox_t *mbox) {
|
||||
*mbox = SYS_MBOX_NULL;
|
||||
}
|
||||
|
||||
void sys_mbox_post(sys_mbox_t *q, void *msg)
|
||||
{
|
||||
while(KMsgQueueSendwait( *q, &msg, sizeof(void *), WAITING_FOREVER) != EOK);
|
||||
void sys_mbox_post(sys_mbox_t *q, void *msg) {
|
||||
KMsgQueueSendwait(*q, &msg, sizeof(void *), WAITING_FOREVER);
|
||||
}
|
||||
|
||||
err_t sys_mbox_trypost(sys_mbox_t *q, void *msg)
|
||||
{
|
||||
err_t sys_mbox_trypost(sys_mbox_t *q, void *msg) {
|
||||
// if(KMsgQueueSend(*q, &msg, sizeof(void *)) == EOK)
|
||||
if(KMsgQueueSend(*q, &msg, sizeof(void *)) == EOK)
|
||||
return ERR_OK;
|
||||
else
|
||||
return ERR_MEM;
|
||||
}
|
||||
|
||||
err_t sys_mbox_trypost_fromisr(sys_mbox_t *q, void *msg)
|
||||
{
|
||||
err_t sys_mbox_trypost_fromisr(sys_mbox_t *q, void *msg) {
|
||||
return sys_mbox_trypost(q, msg);
|
||||
}
|
||||
|
||||
u32_t sys_arch_mbox_fetch(sys_mbox_t *q, void **msg, u32_t timeout)
|
||||
{
|
||||
u32_t sys_arch_mbox_fetch(sys_mbox_t *q, void **msg, u32_t timeout) {
|
||||
x_ticks_t start_tick = 0 ;
|
||||
int32 wait_time = 0;
|
||||
|
||||
@@ -351,17 +290,15 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t *q, void **msg, u32_t timeout)
|
||||
else
|
||||
wait_time = timeout;
|
||||
|
||||
if(KMsgQueueRecv(*q, &(*msg), sizeof(void *), wait_time) == EOK)
|
||||
return ((CurrentTicksGain()-start_tick)*MS_PER_SYSTICK);
|
||||
else{
|
||||
*msg = NULL;
|
||||
if(KMsgQueueRecv(*q, &(*msg), sizeof(void *), wait_time) == EOK) {
|
||||
return CalculateTimeMsFromTick(CurrentTicksGain() - start_tick);
|
||||
} else {
|
||||
return SYS_ARCH_TIMEOUT;
|
||||
}
|
||||
}
|
||||
|
||||
u32_t sys_arch_mbox_tryfetch(sys_mbox_t *q, void **msg)
|
||||
{
|
||||
if(KMsgQueueRecv(*q, &(*msg), sizeof(void *), 0) == EOK)
|
||||
u32_t sys_arch_mbox_tryfetch(sys_mbox_t *q, void **msg) {
|
||||
if (KMsgQueueRecv(*q, &(*msg), sizeof(void *), 0) == EOK)
|
||||
return ERR_OK;
|
||||
else
|
||||
return SYS_MBOX_EMPTY;
|
||||
@@ -374,97 +311,15 @@ u32_t sys_arch_mbox_tryfetch(sys_mbox_t *q, void **msg)
|
||||
#endif /* !NO_SYS */
|
||||
|
||||
/* Variables Initialization */
|
||||
struct netif gnetif;
|
||||
ip4_addr_t ipaddr;
|
||||
ip4_addr_t netmask;
|
||||
ip4_addr_t gw;
|
||||
|
||||
void lwip_tcp_init(void)
|
||||
{
|
||||
tcpip_init(NULL, NULL);
|
||||
|
||||
/* IP addresses initialization */
|
||||
/* USER CODE BEGIN 0 */
|
||||
#if LWIP_DHCP
|
||||
ip_addr_set_zero_ip4(&ipaddr);
|
||||
ip_addr_set_zero_ip4(&netmask);
|
||||
ip_addr_set_zero_ip4(&gw);
|
||||
#else
|
||||
IP4_ADDR(&ipaddr, lwip_ipaddr[0], lwip_ipaddr[1], lwip_ipaddr[2], lwip_ipaddr[3]);
|
||||
IP4_ADDR(&netmask, lwip_netmask[0], lwip_netmask[1], lwip_netmask[2], lwip_netmask[3]);
|
||||
IP4_ADDR(&gw, lwip_gwaddr[0], lwip_gwaddr[1], lwip_gwaddr[2], lwip_gwaddr[3]);
|
||||
#endif /* USE_DHCP */
|
||||
/* USER CODE END 0 */
|
||||
/* Initilialize the LwIP stack without RTOS */
|
||||
/* add the network interface (IPv4/IPv6) without RTOS */
|
||||
#ifdef NETIF_ENET0_INIT_FUNC
|
||||
netif_add(&gnetif, &ipaddr, &netmask, &gw, NULL, NETIF_ENET0_INIT_FUNC, &tcpip_input);
|
||||
#endif
|
||||
|
||||
/* Registers the default network interface */
|
||||
netif_set_default(&gnetif);
|
||||
|
||||
if (netif_is_link_up(&gnetif))
|
||||
{
|
||||
/* When the netif is fully configured this function must be called */
|
||||
KPrintf("%s : netif_set_up\n", __func__);
|
||||
netif_set_up(&gnetif);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* When the netif link is down this function must be called */
|
||||
KPrintf("%s : netif_set_down\n", __func__);
|
||||
netif_set_down(&gnetif);
|
||||
}
|
||||
|
||||
#if LWIP_DHCP
|
||||
int err;
|
||||
/* Creates a new DHCP client for this interface on the first call.
|
||||
Note: you must call dhcp_fine_tmr() and dhcp_coarse_tmr() at
|
||||
the predefined regular intervals after starting the client.
|
||||
You can peek in the netif->dhcp struct for the actual DHCP status.*/
|
||||
|
||||
|
||||
err = dhcp_start(&gnetif);
|
||||
if(err == ERR_OK)
|
||||
KPrintf("lwip dhcp init success...\n\n");
|
||||
else
|
||||
KPrintf("lwip dhcp init fail...\n\n");
|
||||
while(ip_addr_cmp(&(gnetif.ip_addr),&ipaddr))
|
||||
{
|
||||
DelayKTask(1);
|
||||
}
|
||||
#endif
|
||||
KPrintf("\n\nIP:%d.%d.%d.%d\n\n", \
|
||||
((gnetif.ip_addr.addr)&0x000000ff), \
|
||||
(((gnetif.ip_addr.addr)&0x0000ff00)>>8), \
|
||||
(((gnetif.ip_addr.addr)&0x00ff0000)>>16), \
|
||||
((gnetif.ip_addr.addr)&0xff000000)>>24);
|
||||
}
|
||||
|
||||
// lwip input thread to get network packet
|
||||
void lwip_input_thread(void *param)
|
||||
{
|
||||
struct netif *net = param;
|
||||
|
||||
while (1)
|
||||
{
|
||||
#ifdef FSL_RTOS_XIUOS
|
||||
if (lwip_obtain_semaphore(net) == EOK)
|
||||
#endif
|
||||
{
|
||||
/* Poll the driver, get any outstanding frames */
|
||||
ethernetif_input(net);
|
||||
sys_check_timeouts(); /* Handle all system timeouts for all core protocols */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void lwip_config_input(struct netif *net)
|
||||
{
|
||||
void lwip_config_input(struct netif *net) {
|
||||
sys_thread_t th_id = 0;
|
||||
|
||||
th_id = sys_thread_new("eth_input", lwip_input_thread, net, LWIP_TASK_STACK_SIZE, 15);
|
||||
extern void ethernetif_input(void *netif_arg);
|
||||
th_id = sys_thread_new("eth_input", ethernetif_input, net, LWIP_TASK_STACK_SIZE, 20);
|
||||
|
||||
if (th_id >= 0) {
|
||||
lw_print("%s %d successfully!\n", __func__, th_id);
|
||||
@@ -473,15 +328,65 @@ void lwip_config_input(struct netif *net)
|
||||
}
|
||||
}
|
||||
|
||||
void lwip_config_net(uint8_t enet_port, char *ip, char *mask, char *gw)
|
||||
{
|
||||
void lwip_config_tcp(uint8_t enet_port, char *ip, char *mask, char *gw) {
|
||||
ip4_addr_t net_ipaddr, net_netmask, net_gw;
|
||||
char* eth_cfg;
|
||||
|
||||
eth_cfg = ethernetif_config_enet_set(enet_port);
|
||||
|
||||
if(chk_lwip_bit(LWIP_INIT_FLAG))
|
||||
{
|
||||
if(chk_lwip_bit(LWIP_INIT_FLAG)) {
|
||||
lw_print("lw: [%s] already ...\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
set_lwip_bit(LWIP_INIT_FLAG);
|
||||
|
||||
tcpip_init(NULL, NULL);
|
||||
|
||||
lw_print("lw: [%s] start ...\n", __func__);
|
||||
|
||||
IP4_ADDR(&net_ipaddr, ip[0], ip[1], ip[2], ip[3]);
|
||||
IP4_ADDR(&net_netmask, mask[0], mask[1], mask[2], mask[3]);
|
||||
IP4_ADDR(&net_gw, gw[0], gw[1], gw[2], gw[3]);
|
||||
|
||||
if (0 == enet_port) {
|
||||
#ifdef NETIF_ENET0_INIT_FUNC
|
||||
printf("[%s:%d] call netif_add\n", __func__, __LINE__);
|
||||
netif_add(&gnetif, &net_ipaddr, &net_netmask, &net_gw, eth_cfg, NETIF_ENET0_INIT_FUNC,
|
||||
tcpip_input);
|
||||
#endif
|
||||
} else if (1 == enet_port) {
|
||||
#ifdef NETIF_ENET1_INIT_FUNC
|
||||
netif_add(&gnetif, &net_ipaddr, &net_netmask, &net_gw, eth_cfg, NETIF_ENET1_INIT_FUNC,
|
||||
tcpip_input);
|
||||
#endif
|
||||
}
|
||||
|
||||
netif_set_default(&gnetif);
|
||||
netif_set_up(&gnetif);
|
||||
|
||||
lw_print("\r\n************************************************\r\n");
|
||||
lw_print(" Network Configuration\r\n");
|
||||
lw_print("************************************************\r\n");
|
||||
lw_print(" IPv4 Address : %u.%u.%u.%u\r\n", ((u8_t *)&net_ipaddr)[0], ((u8_t *)&net_ipaddr)[1],
|
||||
((u8_t *)&net_ipaddr)[2], ((u8_t *)&net_ipaddr)[3]);
|
||||
lw_print(" IPv4 Subnet mask : %u.%u.%u.%u\r\n", ((u8_t *)&net_netmask)[0], ((u8_t *)&net_netmask)[1],
|
||||
((u8_t *)&net_netmask)[2], ((u8_t *)&net_netmask)[3]);
|
||||
lw_print(" IPv4 Gateway : %u.%u.%u.%u\r\n", ((u8_t *)&net_gw)[0], ((u8_t *)&net_gw)[1],
|
||||
((u8_t *)&net_gw)[2], ((u8_t *)&net_gw)[3]);
|
||||
lw_print("************************************************\r\n");
|
||||
|
||||
lwip_config_input(&gnetif);
|
||||
}
|
||||
|
||||
|
||||
void lwip_config_net(uint8_t enet_port, char *ip, char *mask, char *gw) {
|
||||
ip4_addr_t net_ipaddr, net_netmask, net_gw;
|
||||
char* eth_cfg;
|
||||
|
||||
eth_cfg = ethernetif_config_enet_set(enet_port);
|
||||
|
||||
if(chk_lwip_bit(LWIP_INIT_FLAG)) {
|
||||
lw_print("lw: [%s] already ...\n", __func__);
|
||||
|
||||
IP4_ADDR(&net_ipaddr, ip[0], ip[1], ip[2], ip[3]);
|
||||
@@ -521,8 +426,7 @@ void lwip_config_net(uint8_t enet_port, char *ip, char *mask, char *gw)
|
||||
netif_set_default(&gnetif);
|
||||
netif_set_up(&gnetif);
|
||||
|
||||
if(chk_lwip_bit(LWIP_PRINT_FLAG))
|
||||
{
|
||||
if(chk_lwip_bit(LWIP_PRINT_FLAG)) {
|
||||
lw_notice("\r\n************************************************\r\n");
|
||||
lw_notice(" Network Configuration\r\n");
|
||||
lw_notice("************************************************\r\n");
|
||||
@@ -537,55 +441,3 @@ void lwip_config_net(uint8_t enet_port, char *ip, char *mask, char *gw)
|
||||
lwip_config_input(&gnetif);
|
||||
}
|
||||
|
||||
void lwip_config_tcp(uint8_t enet_port, char *ip, char *mask, char *gw)
|
||||
{
|
||||
ip4_addr_t net_ipaddr, net_netmask, net_gw;
|
||||
char* eth_cfg;
|
||||
|
||||
eth_cfg = ethernetif_config_enet_set(enet_port);
|
||||
|
||||
if(chk_lwip_bit(LWIP_INIT_FLAG))
|
||||
{
|
||||
lw_print("lw: [%s] already ...\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
set_lwip_bit(LWIP_INIT_FLAG);
|
||||
|
||||
tcpip_init(NULL, NULL);
|
||||
|
||||
lw_print("lw: [%s] start ...\n", __func__);
|
||||
|
||||
IP4_ADDR(&net_ipaddr, ip[0], ip[1], ip[2], ip[3]);
|
||||
IP4_ADDR(&net_netmask, mask[0], mask[1], mask[2], mask[3]);
|
||||
IP4_ADDR(&net_gw, gw[0], gw[1], gw[2], gw[3]);
|
||||
|
||||
if(0 == enet_port) {
|
||||
#ifdef NETIF_ENET0_INIT_FUNC
|
||||
netif_add(&gnetif, &net_ipaddr, &net_netmask, &net_gw, eth_cfg, NETIF_ENET0_INIT_FUNC,
|
||||
ethernet_input);
|
||||
#endif
|
||||
} else if (1 == enet_port) {
|
||||
#ifdef NETIF_ENET1_INIT_FUNC
|
||||
netif_add(&gnetif, &net_ipaddr, &net_netmask, &net_gw, eth_cfg, NETIF_ENET1_INIT_FUNC,
|
||||
ethernet_input);
|
||||
#endif
|
||||
}
|
||||
|
||||
netif_set_default(&gnetif);
|
||||
netif_set_up(&gnetif);
|
||||
|
||||
lw_print("\r\n************************************************\r\n");
|
||||
lw_print(" Network Configuration\r\n");
|
||||
lw_print("************************************************\r\n");
|
||||
lw_print(" IPv4 Address : %u.%u.%u.%u\r\n", ((u8_t *)&net_ipaddr)[0], ((u8_t *)&net_ipaddr)[1],
|
||||
((u8_t *)&net_ipaddr)[2], ((u8_t *)&net_ipaddr)[3]);
|
||||
lw_print(" IPv4 Subnet mask : %u.%u.%u.%u\r\n", ((u8_t *)&net_netmask)[0], ((u8_t *)&net_netmask)[1],
|
||||
((u8_t *)&net_netmask)[2], ((u8_t *)&net_netmask)[3]);
|
||||
lw_print(" IPv4 Gateway : %u.%u.%u.%u\r\n", ((u8_t *)&net_gw)[0], ((u8_t *)&net_gw)[1],
|
||||
((u8_t *)&net_gw)[2], ((u8_t *)&net_gw)[3]);
|
||||
lw_print("************************************************\r\n");
|
||||
|
||||
lwip_config_input(&gnetif);
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,8 @@ typedef int32 sys_mbox_t;
|
||||
typedef int32 sys_thread_t;
|
||||
typedef x_base sys_prot_t;
|
||||
|
||||
#define MS_PER_SYSTICK (1000 / TICK_PER_SECOND)
|
||||
#define MS_PER_SYSTICK (float)(1000 / TICK_PER_SECOND)
|
||||
#define TICKS_PER_MS (TICK_PER_SECOND / 1000)
|
||||
|
||||
//debug rtos with IRQ
|
||||
//#define FSL_RTOS_XIUOS
|
||||
@@ -99,6 +100,7 @@ extern char lwip_eth1_netmask[];
|
||||
extern char lwip_eth1_gwaddr[];
|
||||
|
||||
extern struct netif gnetif;
|
||||
extern sys_sem_t* get_eth_recv_sem();
|
||||
|
||||
void lwip_tcp_init(void);
|
||||
void lwip_config_net(uint8_t enet_port, char *ip, char *mask, char *gw);
|
||||
|
||||
@@ -32,9 +32,9 @@ int32_t transport_sendPacketBuffer( uint8_t* buf, int32_t buflen)
|
||||
int transport_getdata(unsigned char* buf, int count)
|
||||
{
|
||||
int32_t rc;
|
||||
//������������ﲻ����
|
||||
|
||||
rc = recv(mysock, buf, count, 0);
|
||||
lw_print("get data : %d\n",rc);
|
||||
lw_print("get data : %lx\n",rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
@@ -142,18 +142,22 @@
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_DEBUG
|
||||
#define LWIP_DEBUGF(debug, message) do { \
|
||||
#define LWIP_DEBUGF(debug_flag, message) do { \
|
||||
if ( \
|
||||
((debug) & LWIP_DBG_ON) && \
|
||||
((debug) & LWIP_DBG_TYPES_ON) && \
|
||||
((s16_t)((debug) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_MIN_LEVEL)) { \
|
||||
((debug_flag) & LWIP_DBG_ON) && \
|
||||
((debug_flag) & LWIP_DBG_TYPES_ON) && \
|
||||
(debug_flag)) { \
|
||||
LWIP_PLATFORM_DIAG(message); \
|
||||
if ((debug) & LWIP_DBG_HALT) { \
|
||||
if ((debug_flag) & LWIP_DBG_HALT) { \
|
||||
while(1); \
|
||||
} \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
// ((s16_t)((debug_flag) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_MIN_LEVEL)) { \
|
||||
// #define LWIP_DEBUGF(debug, message) do { \
|
||||
// LWIP_PLATFORM_DIAG(message); \
|
||||
// } while(0)
|
||||
#else /* LWIP_DEBUG */
|
||||
#define LWIP_DEBUGF(debug, message)
|
||||
#endif /* LWIP_DEBUG */
|
||||
|
||||
Reference in New Issue
Block a user