support rtc SPI I2C eeprom ADC
This commit is contained in:
@@ -29,17 +29,6 @@
|
||||
* Author: Simon Goldschmidt
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file sys_arch.c
|
||||
@@ -463,9 +452,9 @@ void lwip_input_thread(void *param)
|
||||
|
||||
void lwip_config_input(struct netif *net)
|
||||
{
|
||||
pthread_t th_id = 0;
|
||||
sys_thread_t th_id = 0;
|
||||
|
||||
th_id = sys_thread_new("eth_input", lwip_input_thread, net, 4096, 15);
|
||||
th_id = sys_thread_new("eth_input", lwip_input_thread, net, LWIP_TASK_STACK_SIZE, 15);
|
||||
|
||||
if (th_id >= 0) {
|
||||
lw_print("%s %d successfully!\n", __func__, th_id);
|
||||
@@ -489,6 +478,8 @@ void lwip_config_net(char *ip, char *mask, char *gw)
|
||||
#endif /* FSL_FEATURE_SOC_LPC_ENET_COUNT */
|
||||
};
|
||||
|
||||
ETH_BSP_Config();
|
||||
|
||||
if(chk_lwip_bit(LWIP_INIT_FLAG))
|
||||
{
|
||||
lw_print("lw: [%s] already ...\n", __func__);
|
||||
@@ -551,6 +542,8 @@ void lwip_config_tcp(char *ip, char *mask, char *gw)
|
||||
#endif /* FSL_FEATURE_SOC_LPC_ENET_COUNT */
|
||||
};
|
||||
|
||||
ETH_BSP_Config();
|
||||
|
||||
if(chk_lwip_bit(LWIP_INIT_FLAG))
|
||||
{
|
||||
lw_print("lw: [%s] already ...\n", __func__);
|
||||
|
||||
@@ -29,17 +29,6 @@
|
||||
* Author: Simon Goldschmidt
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file sys_arch.h
|
||||
|
||||
@@ -25,31 +25,17 @@
|
||||
#include "lwip/sys.h"
|
||||
#include "tcpecho_raw.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
#define MSG_SIZE 128
|
||||
|
||||
/*******************************************************************************
|
||||
* Prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables
|
||||
******************************************************************************/
|
||||
|
||||
// this is for test in shell, in fact, shell restrict the length of input string, which is less then 128
|
||||
char tcp_send_msg[MSG_SIZE] = {0};
|
||||
char tcp_target[] = {192, 168, 250, 252};
|
||||
|
||||
/*******************************************************************************
|
||||
* Code
|
||||
******************************************************************************/
|
||||
/******************************************************************************/
|
||||
|
||||
static void lwip_tcp_send_thread(void *arg)
|
||||
static void LwipTcpSendTask(void *arg)
|
||||
{
|
||||
lw_print("lwip_tcp_send_thread start.\n");
|
||||
lw_print("LwipTcpSendTask start.\n");
|
||||
|
||||
int fd = -1;
|
||||
fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
@@ -85,7 +71,7 @@ __exit:
|
||||
return;
|
||||
}
|
||||
|
||||
void lwip_tcp_send_run(int argc, char *argv[])
|
||||
void LwipTcpSendTest(int argc, char *argv[])
|
||||
{
|
||||
memset(tcp_send_msg, 0, MSG_SIZE);
|
||||
if(argc >= 2)
|
||||
@@ -103,21 +89,19 @@ void lwip_tcp_send_run(int argc, char *argv[])
|
||||
sscanf(argv[2], "%d.%d.%d.%d", &tcp_target[0], &tcp_target[1], &tcp_target[2], &tcp_target[3]);
|
||||
}
|
||||
|
||||
ETH_BSP_Config();
|
||||
lwip_config_tcp(lwip_ipaddr, lwip_netmask, lwip_gwaddr);
|
||||
sys_thread_new("tcp send", lwip_tcp_send_thread, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
|
||||
sys_thread_new("tcp send", LwipTcpSendTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
|
||||
}
|
||||
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3),
|
||||
TCPSend, lwip_tcp_send_run, TCP Send message);
|
||||
TCPSend, LwipTcpSendTest, TCP Send message);
|
||||
|
||||
void lwip_tcp_recv_run(void)
|
||||
void LwipTcpRecvTest(void)
|
||||
{
|
||||
ETH_BSP_Config();
|
||||
lwip_config_net(lwip_ipaddr, lwip_netmask, lwip_gwaddr);
|
||||
tcpecho_raw_init();
|
||||
}
|
||||
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(0),
|
||||
TCPRecv, lwip_tcp_recv_run, TCP Recv message);
|
||||
TCPRecv, LwipTcpRecvTest, TCP Recv message);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* Copyright (c) 2021 AIIT XUOS Lab
|
||||
* XiUOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
@@ -11,7 +11,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file tcp_echo_socket_demo.c
|
||||
* @file lwip_udp_demo.c
|
||||
* @brief One UDP demo based on LwIP
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
@@ -25,33 +25,18 @@
|
||||
#include <lwip/sockets.h>
|
||||
#include "lwip/sys.h"
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
#define UDP_TASK_STACK_SIZE 4096
|
||||
#define UDP_TASK_PRIO 15
|
||||
#define PBUF_SIZE 27
|
||||
|
||||
/*******************************************************************************
|
||||
* Prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables
|
||||
******************************************************************************/
|
||||
|
||||
static struct udp_pcb *udpecho_raw_pcb;
|
||||
char udp_target[] = {192, 168, 250, 252};
|
||||
char hello_str[] = {"hello world\r\n"};
|
||||
char udp_send_msg[] = "\n\nThis one is UDP pkg. Congratulations on you.\n\n";
|
||||
|
||||
/*******************************************************************************
|
||||
* Code
|
||||
******************************************************************************/
|
||||
/******************************************************************************/
|
||||
|
||||
static void lwip_udp_send(void *arg)
|
||||
static void LwipUDPSendTask(void *arg)
|
||||
{
|
||||
int cnt = LWIP_DEMO_TIMES;
|
||||
|
||||
@@ -92,11 +77,10 @@ __exit:
|
||||
return;
|
||||
}
|
||||
|
||||
void *lwip_udp_send_run(int argc, char *argv[])
|
||||
void *LwipUdpSendTest(int argc, char *argv[])
|
||||
{
|
||||
int result = 0;
|
||||
pthread_t th_id;
|
||||
pthread_attr_t attr;
|
||||
sys_thread_t th_id;
|
||||
|
||||
memset(udp_send_msg, 0, sizeof(udp_send_msg));
|
||||
|
||||
@@ -116,15 +100,14 @@ void *lwip_udp_send_run(int argc, char *argv[])
|
||||
}
|
||||
lw_print("lw: [%s] gw %d.%d.%d.%d\n", __func__, udp_target[0], udp_target[1], udp_target[2], udp_target[3]);
|
||||
|
||||
ETH_BSP_Config();
|
||||
lwip_config_tcp(lwip_ipaddr, lwip_netmask, lwip_gwaddr);
|
||||
sys_thread_new("udp socket send", lwip_udp_send, NULL, 4096, 25);
|
||||
sys_thread_new("udp socket send", LwipUDPSendTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
|
||||
}
|
||||
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3),
|
||||
UDPSend, lwip_udp_send_run, UDP send echo);
|
||||
UDPSend, LwipUdpSendTest, UDP send echo);
|
||||
|
||||
static void udpecho_raw_recv(void *arg, struct udp_pcb *upcb, struct pbuf *p,
|
||||
static void LwipUdpRecvTask(void *arg, struct udp_pcb *upcb, struct pbuf *p,
|
||||
const ip_addr_t *addr, u16_t port)
|
||||
{
|
||||
int udp_len;
|
||||
@@ -159,10 +142,11 @@ static void udpecho_raw_recv(void *arg, struct udp_pcb *upcb, struct pbuf *p,
|
||||
pbuf_free(udp_buf);
|
||||
}
|
||||
|
||||
void udpecho_raw_init(void)
|
||||
void LwipUdpRecvTest(void)
|
||||
{
|
||||
err_t err;
|
||||
lw_print("udpecho_raw_init\r\n");
|
||||
|
||||
lwip_config_net(lwip_ipaddr, lwip_netmask, lwip_gwaddr);
|
||||
|
||||
udpecho_raw_pcb = udp_new_ip_type(IPADDR_TYPE_ANY);
|
||||
if (udpecho_raw_pcb == NULL)
|
||||
@@ -173,18 +157,10 @@ void udpecho_raw_init(void)
|
||||
err = udp_bind(udpecho_raw_pcb, IP_ANY_TYPE, LWIP_LOCAL_PORT);
|
||||
if (err == ERR_OK)
|
||||
{
|
||||
udp_recv(udpecho_raw_pcb, udpecho_raw_recv, NULL);
|
||||
udp_recv(udpecho_raw_pcb, LwipUdpRecvTask, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void lwip_udp_server(void)
|
||||
{
|
||||
lw_print("lwip_udp_server\r\n");
|
||||
ETH_BSP_Config();
|
||||
lwip_config_net(lwip_ipaddr, lwip_netmask, lwip_gwaddr);
|
||||
udpecho_raw_init();
|
||||
}
|
||||
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(0),
|
||||
UDPRecv, lwip_udp_server, UDP server echo);
|
||||
UDPRecv, LwipUdpRecvTest, UDP server echo);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user