diff --git a/Ubiquitous/XiZi_AIoT/services/net/net_server/arch/lwipopts.h b/Ubiquitous/XiZi_AIoT/services/net/net_server/arch/lwipopts.h index b61aac282..ef6e962b9 100644 --- a/Ubiquitous/XiZi_AIoT/services/net/net_server/arch/lwipopts.h +++ b/Ubiquitous/XiZi_AIoT/services/net/net_server/arch/lwipopts.h @@ -1,222 +1,217 @@ /* -* Copyright (c) 2001-2003 Swedish Institute of Computer Science. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* 1. Redistributions of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* 2. Redistributions in binary form must reproduce the above copyright notice, -* this list of conditions and the following disclaimer in the documentation -* and/or other materials provided with the distribution. -* 3. The name of the author may not be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED -* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT -* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING -* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY -* OF SUCH DAMAGE. -* -* This file is part of the lwIP TCP/IP stack. -* -* Author: Adam Dunkels -* -*/ + * Copyright (c) 2001-2003 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ #ifndef LWIP_LWIPOPTS_H #define LWIP_LWIPOPTS_H - /** +/** * SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain * critical regions during buffer allocation, deallocation and memory * allocation and deallocation. */ - #define SYS_LIGHTWEIGHT_PROT 1 +#define SYS_LIGHTWEIGHT_PROT 1 - /** +/** * NO_SYS==1: Provides VERY minimal functionality. Otherwise, * use lwIP facilities. */ - #define NO_SYS 0 +#define NO_SYS 0 - /** +/** * NO_SYS_NO_TIMERS==1: Drop support for sys_timeout when NO_SYS==1 * Mainly for compatibility to old versions. */ - #define NO_SYS_NO_TIMERS 0 +#define NO_SYS_NO_TIMERS 0 - /* ---------- Memory options ---------- */ - /* MEM_ALIGNMENT: should be set to the alignment of the CPU for which - lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2 - byte alignment -> define MEM_ALIGNMENT to 2. */ - #define MEM_ALIGNMENT 4 +/* ---------- Memory options ---------- */ +/* MEM_ALIGNMENT: should be set to the alignment of the CPU for which +lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2 +byte alignment -> define MEM_ALIGNMENT to 2. */ +#define MEM_ALIGNMENT 4 - /* 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 (15*1024) +/* 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 (15 * 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 25 - /* 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 6 - /* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP - connections. */ - #define MEMP_NUM_TCP_PCB_LISTEN 6 - /* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP - segments. */ - #define MEMP_NUM_TCP_SEG 150 - /* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active - timeouts. */ - #define MEMP_NUM_SYS_TIMEOUT 6 +/* 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 25 +/* 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 6 +/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP +connections. */ +#define MEMP_NUM_TCP_PCB_LISTEN 6 +/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP +segments. */ +#define MEMP_NUM_TCP_SEG 150 +/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active +timeouts. */ +#define MEMP_NUM_SYS_TIMEOUT 6 +/* ---------- Pbuf options ---------- */ +/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */ +#define PBUF_POOL_SIZE 45 +/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */ +#define PBUF_POOL_BUFSIZE \ + LWIP_MEM_ALIGN_SIZE(TCP_MSS + 40 + PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN) - /* ---------- Pbuf options ---------- */ - /* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */ - #define PBUF_POOL_SIZE 45 - /* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */ - #define PBUF_POOL_BUFSIZE \ - LWIP_MEM_ALIGN_SIZE(TCP_MSS+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN) +/* ---------- TCP options ---------- */ +#define LWIP_TCP 1 +#define TCP_TTL 255 - /* ---------- TCP options ---------- */ - #define LWIP_TCP 1 - #define TCP_TTL 255 +/* 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 - /* 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 +/* TCP Maximum segment size. */ +#define TCP_MSS (1500 - 40) - /* TCP Maximum segment size. */ - #define TCP_MSS (1500 - 40) +/* TCP sender buffer space (bytes). */ +#define TCP_SND_BUF (10 * TCP_MSS) - /* TCP sender buffer space (bytes). */ - #define TCP_SND_BUF (10*TCP_MSS) +/* TCP_SND_QUEUELEN: TCP sender buffer space (pbufs). This must be at least +as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work. */ - /* TCP_SND_QUEUELEN: TCP sender buffer space (pbufs). This must be at least - as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work. */ +#define TCP_SND_QUEUELEN (8 * TCP_SND_BUF / TCP_MSS) - #define TCP_SND_QUEUELEN (8* TCP_SND_BUF/TCP_MSS) +/* TCP receive window. */ +#define TCP_WND (11 * TCP_MSS) - /* TCP receive window. */ - #define TCP_WND (11*TCP_MSS) +/* ---------- ICMP options ---------- */ +#define LWIP_ICMP 1 +/* ---------- DHCP options ---------- */ +/* Define LWIP_DHCP to 1 if you want DHCP configuration of +interfaces. DHCP is not implemented in lwIP 0.5.1, however, so +turning this on does currently not work. */ +#define LWIP_DHCP 1 - /* ---------- ICMP options ---------- */ - #define LWIP_ICMP 1 +/* ---------- UDP options ---------- */ +#define LWIP_UDP 1 +#define UDP_TTL 255 +/* ---------- Statistics options ---------- */ +#define LWIP_STATS 0 +#define LWIP_PROVIDE_ERRNO 1 - /* ---------- DHCP options ---------- */ - /* Define LWIP_DHCP to 1 if you want DHCP configuration of - interfaces. DHCP is not implemented in lwIP 0.5.1, however, so - turning this on does currently not work. */ - #define LWIP_DHCP 1 - - - /* ---------- UDP options ---------- */ - #define LWIP_UDP 1 - #define UDP_TTL 255 - - - /* ---------- Statistics options ---------- */ - #define LWIP_STATS 0 - #define LWIP_PROVIDE_ERRNO 1 - - /* ---------- link callback options ---------- */ - /* LWIP_NETIF_LINK_CALLBACK==1: Support a callback function from an interface +/* ---------- link callback options ---------- */ +/* LWIP_NETIF_LINK_CALLBACK==1: Support a callback function from an interface * whenever the link changes (i.e., link down) */ - #define LWIP_NETIF_LINK_CALLBACK 0 - /* - -------------------------------------- - ---------- Checksum options ---------- - -------------------------------------- - */ +#define LWIP_NETIF_LINK_CALLBACK 0 +/* + -------------------------------------- + ---------- Checksum options ---------- + -------------------------------------- +*/ - /* The STM32F4x7 allows computing and verifying the IP, - UDP, TCP and ICMP checksums by hardware: - - To use this feature let the following define uncommented. - - To disable it and process by CPU comment the the checksum. - */ - #define CHECKSUM_BY_HARDWARE +/* The STM32F4x7 allows computing and verifying the IP, + UDP, TCP and ICMP checksums by hardware: +- To use this feature let the following define uncommented. +- To disable it and process by CPU comment the the checksum. +*/ +#define CHECKSUM_BY_HARDWARE - #ifdef CHECKSUM_BY_HARDWARE - /* CHECKSUM_GEN_IP==0: Generate checksums by hardware for outgoing IP packets.*/ - #define CHECKSUM_GEN_IP 0 - /* CHECKSUM_GEN_UDP==0: Generate checksums by hardware for outgoing UDP packets.*/ - #define CHECKSUM_GEN_UDP 0 - /* CHECKSUM_GEN_TCP==0: Generate checksums by hardware for outgoing TCP packets.*/ - #define CHECKSUM_GEN_TCP 0 - /* CHECKSUM_CHECK_IP==0: Check checksums by hardware for incoming IP packets.*/ - #define CHECKSUM_CHECK_IP 0 - /* CHECKSUM_CHECK_UDP==0: Check checksums by hardware for incoming UDP packets.*/ - #define CHECKSUM_CHECK_UDP 0 - /* CHECKSUM_CHECK_TCP==0: Check checksums by hardware for incoming TCP packets.*/ - #define CHECKSUM_CHECK_TCP 0 - /*CHECKSUM_CHECK_ICMP==0: Check checksums by hardware for incoming ICMP packets.*/ - #define CHECKSUM_GEN_ICMP 0 - #else - /* CHECKSUM_GEN_IP==1: Generate checksums in software for outgoing IP packets.*/ - #define CHECKSUM_GEN_IP 1 - /* CHECKSUM_GEN_UDP==1: Generate checksums in software for outgoing UDP packets.*/ - #define CHECKSUM_GEN_UDP 1 - /* CHECKSUM_GEN_TCP==1: Generate checksums in software for outgoing TCP packets.*/ - #define CHECKSUM_GEN_TCP 1 - /* CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets.*/ - #define CHECKSUM_CHECK_IP 1 - /* CHECKSUM_CHECK_UDP==1: Check checksums in software for incoming UDP packets.*/ - #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.*/ - #define CHECKSUM_GEN_ICMP 1 - #endif +#ifdef CHECKSUM_BY_HARDWARE +/* CHECKSUM_GEN_IP==0: Generate checksums by hardware for outgoing IP packets.*/ +#define CHECKSUM_GEN_IP 0 +/* CHECKSUM_GEN_UDP==0: Generate checksums by hardware for outgoing UDP packets.*/ +#define CHECKSUM_GEN_UDP 0 +/* CHECKSUM_GEN_TCP==0: Generate checksums by hardware for outgoing TCP packets.*/ +#define CHECKSUM_GEN_TCP 0 +/* CHECKSUM_CHECK_IP==0: Check checksums by hardware for incoming IP packets.*/ +#define CHECKSUM_CHECK_IP 0 +/* CHECKSUM_CHECK_UDP==0: Check checksums by hardware for incoming UDP packets.*/ +#define CHECKSUM_CHECK_UDP 0 +/* CHECKSUM_CHECK_TCP==0: Check checksums by hardware for incoming TCP packets.*/ +#define CHECKSUM_CHECK_TCP 0 +/*CHECKSUM_CHECK_ICMP==0: Check checksums by hardware for incoming ICMP packets.*/ +#define CHECKSUM_GEN_ICMP 0 +#else +/* CHECKSUM_GEN_IP==1: Generate checksums in software for outgoing IP packets.*/ +#define CHECKSUM_GEN_IP 1 +/* CHECKSUM_GEN_UDP==1: Generate checksums in software for outgoing UDP packets.*/ +#define CHECKSUM_GEN_UDP 1 +/* CHECKSUM_GEN_TCP==1: Generate checksums in software for outgoing TCP packets.*/ +#define CHECKSUM_GEN_TCP 1 +/* CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets.*/ +#define CHECKSUM_CHECK_IP 1 +/* CHECKSUM_CHECK_UDP==1: Check checksums in software for incoming UDP packets.*/ +#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.*/ +#define CHECKSUM_GEN_ICMP 1 +#endif - /* - ---------------------------------------------- - ---------- Sequential layer options ---------- - ---------------------------------------------- - */ - /** +/* + ---------------------------------------------- + ---------- Sequential layer options ---------- + ---------------------------------------------- +*/ +/** * LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c) */ - #define LWIP_NETCONN 1 +#define LWIP_NETCONN 1 - /* - ------------------------------------ - ---------- Socket options ---------- - ------------------------------------ - */ - /** +/* + ------------------------------------ + ---------- Socket options ---------- + ------------------------------------ +*/ +/** * LWIP_SOCKET==1: Enable Socket API (require to use sockets.c) */ - #define LWIP_SOCKET 1 +#define LWIP_SOCKET 1 - /* - --------------------------------- - ---------- OS options ---------- - --------------------------------- - */ +/* + --------------------------------- + ---------- OS options ---------- + --------------------------------- +*/ - #define DEFAULT_UDP_RECVMBOX_SIZE 10 - #define DEFAULT_TCP_RECVMBOX_SIZE 10 - #define DEFAULT_ACCEPTMBOX_SIZE 10 - #define DEFAULT_THREAD_STACKSIZE 1024 +#define DEFAULT_UDP_RECVMBOX_SIZE 10 +#define DEFAULT_TCP_RECVMBOX_SIZE 10 +#define DEFAULT_ACCEPTMBOX_SIZE 10 +#define DEFAULT_THREAD_STACKSIZE 1024 - #define TCPIP_THREAD_NAME "lwip" - #define TCPIP_THREAD_STACKSIZE 512 - #define TCPIP_MBOX_SIZE 8 - #define TCPIP_THREAD_PRIO 3 +#define TCPIP_THREAD_NAME "tcpip" +#define TCPIP_THREAD_STACKSIZE 512 +#define TCPIP_MBOX_SIZE 8 +#define TCPIP_THREAD_PRIO 3 /* ---------------------------------------- diff --git a/Ubiquitous/XiZi_AIoT/services/net/net_server/arch/sys_arch.c b/Ubiquitous/XiZi_AIoT/services/net/net_server/arch/sys_arch.c index f77de8396..f00de3d3f 100644 --- a/Ubiquitous/XiZi_AIoT/services/net/net_server/arch/sys_arch.c +++ b/Ubiquitous/XiZi_AIoT/services/net/net_server/arch/sys_arch.c @@ -25,8 +25,8 @@ #include #if !NO_SYS -#include "sys_arch.h" #include "libserial.h" +#include "sys_arch.h" #include "usyscall.h" #endif @@ -47,11 +47,10 @@ u32_t sys_jiffies(void) } u32_t sys_now(void) -{ - return 1; +{ + return 1; } - sys_prot_t sys_arch_protect(void) { return 1; @@ -65,13 +64,11 @@ void sys_arch_unprotect(sys_prot_t pval) err_t sys_sem_new(sys_sem_t* sem, u8_t count) { - struct Session sem_session; sem_t semaphore; - connect_session(&sem_session, sem_server_name, 4096); - sem_create(&sem_session, &semaphore, (int)count); + connect_session(&sem->sess, sem_server_name, 4096); + sem_create(&sem->sess, &semaphore, (int)count); sem->sem = semaphore; - sem->sess = sem_session; - #if SYS_STATS +#if SYS_STATS ++lwip_stats.sys.sem.used; if (lwip_stats.sys.sem.max < lwip_stats.sys.sem.used) { lwip_stats.sys.sem.max = lwip_stats.sys.sem.used; @@ -94,7 +91,7 @@ void sys_sem_free(sys_sem_t* sem) #if SYS_STATS --lwip_stats.sys.sem.used; #endif /* SYS_STATS */ - sem_delete(&sem->sess, &sem->sem); + sem_delete(&sem->sess, &sem->sem); free_session(&sem->sess); free(sem); sem = SYS_SEM_NULL; @@ -116,8 +113,9 @@ u32_t sys_arch_sem_wait(sys_sem_t* sem, u32_t timeout) if (sem->sem < 0) return SYS_ARCH_TIMEOUT; - + printf("%s wait %d, %d\n", __func__, sem->sem, __LINE__); sem_wait(&sem->sess, &sem->sem, 0); + printf("%s, %d\n", __func__, __LINE__); return 0; } @@ -140,14 +138,19 @@ void sys_mutex_set_invalid(sys_mutex_t* mutex) { sys_sem_set_invalid(mutex); } + void sys_mutex_lock(sys_mutex_t* mutex) { + printf("%s(mtx: %d)\n", __func__, *mutex); sys_arch_sem_wait(mutex, 0); + printf("%s(mtx: %d), return\n", __func__, *mutex); } void sys_mutex_unlock(sys_mutex_t* mutex) { + printf("%s(mtx: %d)\n", __func__, *mutex); sys_sem_signal(mutex); + printf("%s(mtx: %d), return\n", __func__, *mutex); } sys_thread_t sys_thread_new(const char* name, lwip_thread_fn function, void* arg, int stacksize, int prio) @@ -160,7 +163,7 @@ sys_thread_t sys_thread_new(const char* name, lwip_thread_fn function, void* arg err_t sys_mbox_new(sys_mbox_t* mbox, int size) { - + mbox->first = mbox->last = 0; sys_sem_t not_empty; @@ -174,7 +177,7 @@ err_t sys_mbox_new(sys_mbox_t* mbox, int size) sys_sem_t mutex; sys_sem_new(&mutex, 1); mbox->mutex = &mutex; - + mbox->wait_send = 0; #if SYS_STATS @@ -189,11 +192,11 @@ err_t sys_mbox_new(sys_mbox_t* mbox, int size) } printf("lw: [%s] alloc %d mbox %p ok!\n", __func__, size, mbox); - return ERR_OK; + return ERR_OK; } void sys_mbox_free(sys_mbox_t* mbox) { - if (mbox != SYS_MBOX_NULL){ + if (mbox != SYS_MBOX_NULL) { sys_arch_sem_wait(mbox->mutex, 0); sys_sem_free(mbox->not_empty); sys_sem_free(mbox->not_full); @@ -219,11 +222,11 @@ void sys_mbox_post(sys_mbox_t* q, void* msg) u8_t first; if (q == NULL) printf("lw: [%s] alloc %d mbox %p failed\n", __func__, q); - + sys_arch_sem_wait(q->mutex, 0); - - printf("sys_mbox_post: mbox %p msg %p\n", (void *)q, (void *)msg); - + + printf("sys_mbox_post: mbox %p msg %p\n", (void*)q, (void*)msg); + while ((q->last + 1) >= (q->first + SYS_MBOX_SIZE)) { q->wait_send++; sys_sem_signal(q->mutex); @@ -256,7 +259,7 @@ err_t sys_mbox_trypost(sys_mbox_t* q, void* msg) sys_arch_sem_wait(q->mutex, 0); - printf("sys_mbox_trypost: mbox %p msg %p\n",(void *)q, (void *)msg); + printf("sys_mbox_trypost: mbox %p msg %p\n", (void*)q, (void*)msg); if ((q->last + 1) >= (q->first + SYS_MBOX_SIZE)) { sys_sem_signal(q->mutex); @@ -291,21 +294,20 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t* q, void** msg, u32_t timeout) { if (q == NULL) printf("lw: [%s] alloc %d mbox %p failed\n", __func__, q); - + sys_arch_sem_wait(q->mutex, 0); while (q->first == q->last) { sys_sem_signal(q->mutex); sys_arch_sem_wait(q->not_empty, 0); sys_arch_sem_wait(q->mutex, 0); - } + } if (msg != NULL) { - printf("sys_mbox_fetch: mbox %p msg %p\n", (void *)q, *msg); + printf("sys_mbox_fetch: mbox %p msg %p\n", (void*)q, *msg); *msg = q->msgs[q->first % SYS_MBOX_SIZE]; - } - else{ - printf("sys_mbox_fetch: mbox %p, null msg\n", (void *)q); + } else { + printf("sys_mbox_fetch: mbox %p, null msg\n", (void*)q); } q->first++; @@ -322,7 +324,7 @@ u32_t sys_arch_mbox_tryfetch(sys_mbox_t* q, void** msg) { if (q == NULL) printf("lw: [%s] alloc %d mbox %p failed\n", __func__, q); - + sys_arch_sem_wait(q->mutex, 0); if (q->first == q->last) { @@ -331,11 +333,10 @@ u32_t sys_arch_mbox_tryfetch(sys_mbox_t* q, void** msg) } if (msg != NULL) { - printf("sys_mbox_tryfetch: mbox %p msg %p\n", (void *)q, *msg); + printf("sys_mbox_tryfetch: mbox %p msg %p\n", (void*)q, *msg); *msg = q->msgs[q->first % SYS_MBOX_SIZE]; - } - else{ - printf("sys_mbox_tryfetch: mbox %p, null msg\n", (void *)q); + } else { + printf("sys_mbox_tryfetch: mbox %p, null msg\n", (void*)q); } q->first++; @@ -371,24 +372,21 @@ int lwip_config_tcp(char* ip, char* mask, char* gw) tcpip_init(NULL, NULL); #ifndef NETIF_ENET_INIT_FUNC - printf("Not Netif driver for Eport 0\n"); - return 0; + printf("Not Netif driver for Eport 0\n"); + return 0; #endif #ifdef NETIF_ENET_INIT_FUNC netif_add(&gnetif, &net_ipaddr, &net_netmask, &net_gw, NULL, - NETIF_ENET_INIT_FUNC, &tcpip_input); + NETIF_ENET_INIT_FUNC, &tcpip_input); /* 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 */ + if (netif_is_link_up(&gnetif)) { + /*When the netif is fully configured this function must be called */ netif_set_up(&gnetif); - } - else - { + } else { /* When the netif link is down this function must be called */ netif_set_down(&gnetif); return -1; @@ -397,15 +395,12 @@ int lwip_config_tcp(char* ip, char* mask, char* gw) printf(" Network Configuration\r\n"); printf("************************************************\r\n"); printf(" 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]); + ((u8_t*)&net_ipaddr)[2], ((u8_t*)&net_ipaddr)[3]); printf(" 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]); + ((u8_t*)&net_netmask)[2], ((u8_t*)&net_netmask)[3]); printf(" 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]); + ((u8_t*)&net_gw)[2], ((u8_t*)&net_gw)[3]); printf("************************************************\r\n"); return 0; #endif } - - -