support rtc SPI I2C eeprom ADC
This commit is contained in:
@@ -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