fixed socket bug and optimize with lwip flag and other codes

This commit is contained in:
wlyu
2022-01-17 15:21:15 +08:00
parent c0de7ca44c
commit 169c3c3c5d
8 changed files with 746 additions and 783 deletions
@@ -84,11 +84,9 @@
char lwip_ipaddr[] = {192, 168, 250, 253};
char lwip_netmask[] = {255, 255, 255, 0};
char lwip_gwaddr[] = {192, 168, 250, 252};
int is_lwip_test = 0; //for lwip input thread
char lwip_flag = 0;
x_ticks_t lwip_sys_now;
static int lwip_init_flag = 0;
struct sys_timeouts {
struct sys_timeo *next;
@@ -491,7 +489,7 @@ void lwip_config_net(char *ip, char *mask, char *gw)
#endif /* FSL_FEATURE_SOC_LPC_ENET_COUNT */
};
if(lwip_init_flag)
if(chk_lwip_bit(LWIP_INIT_FLAG))
{
lw_print("lw: [%s] already ...\n", __func__);
@@ -507,7 +505,7 @@ void lwip_config_net(char *ip, char *mask, char *gw)
netif_set_up(&gnetif);
return;
}
lwip_init_flag = 1;
set_lwip_bit(LWIP_INIT_FLAG);
lw_print("lw: [%s] start ...\n", __func__);
@@ -522,7 +520,7 @@ void lwip_config_net(char *ip, char *mask, char *gw)
netif_set_default(&gnetif);
netif_set_up(&gnetif);
if(is_lwip_test)
if(chk_lwip_bit(LWIP_PRINT_FLAG))
{
lw_pr_info("\r\n************************************************\r\n");
lw_pr_info(" Network Configuration\r\n");
@@ -553,12 +551,13 @@ void lwip_config_tcp(char *ip, char *mask, char *gw)
#endif /* FSL_FEATURE_SOC_LPC_ENET_COUNT */
};
if(lwip_init_flag)
if(chk_lwip_bit(LWIP_INIT_FLAG))
{
lw_print("lw: [%s] already ...\n", __func__);
return;
}
lwip_init_flag = 1;
set_lwip_bit(LWIP_INIT_FLAG);
tcpip_init(NULL, NULL);
@@ -66,7 +66,7 @@
#define LWIP_DEMO_TIMES 3
#define LWIP_TASK_STACK_SIZE 4096
#define LWIP_TASK_PRIO 15
#define LWIP_DEMO_TASK_PRIO 20
/* MAC address configuration. */
#define configMAC_ADDR {0x02, 0x12, 0x13, 0x10, 0x15, 0x11}
@@ -82,16 +82,23 @@ typedef int32 sys_mbox_t;
typedef int32 sys_thread_t;
typedef x_base sys_prot_t;
#define MS_PER_SYSTICK_F407 1000/TICK_PER_SECOND
#define MS_PER_SYSTICK_F407 (1000 / TICK_PER_SECOND)
//debug rtos with IRQ
//#define FSL_RTOS_XIUOS
extern char lwip_flag;
#define LWIP_INIT_FLAG (1 << 0)
#define LWIP_PRINT_FLAG (1 << 1)
#define set_lwip_bit(__bit) lwip_flag |= (__bit)
#define clr_lwip_bit(__bit) lwip_flag &= ~(__bit)
#define chk_lwip_bit(__bit) ((lwip_flag & (__bit)) == (__bit))
extern char lwip_ipaddr[];
extern char lwip_netmask[];
extern char lwip_gwaddr[];
extern int is_lwip_test;
extern int lwip_sempahore;
extern struct netif gnetif;
void lwip_tcp_init(void);