kopia lustrzana https://github.com/luigifcruz/pico-stuff
Orgazine projects.
rodzic
d6a4fc9f85
commit
e080117154
|
@ -7,6 +7,5 @@ project(pico-stuff)
|
||||||
|
|
||||||
pico_sdk_init()
|
pico_sdk_init()
|
||||||
|
|
||||||
add_subdirectory(bmp180)
|
add_subdirectory(apps)
|
||||||
add_subdirectory(iperf_server)
|
add_subdirectory(lib)
|
||||||
add_subdirectory(tcp_server)
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
add_subdirectory(iperf_server)
|
||||||
|
add_subdirectory(tcp_server)
|
|
@ -13,10 +13,14 @@ target_link_libraries(tcp_server
|
||||||
tinyusb_host
|
tinyusb_host
|
||||||
tinyusb_board
|
tinyusb_board
|
||||||
tinyusb_net
|
tinyusb_net
|
||||||
|
hardware_i2c
|
||||||
lwip
|
lwip
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(tcp_server PRIVATE .)
|
target_include_directories(tcp_server PRIVATE
|
||||||
|
.
|
||||||
|
${CMAKE_SOURCE_DIR}/lib/bmp180
|
||||||
|
)
|
||||||
|
|
||||||
pico_enable_stdio_usb(tcp_server 1)
|
pico_enable_stdio_usb(tcp_server 1)
|
||||||
pico_enable_stdio_uart(tcp_server 0)
|
pico_enable_stdio_uart(tcp_server 0)
|
|
@ -50,9 +50,14 @@ try changing the first byte of tud_network_mac_address[] below from 0x02 to 0x00
|
||||||
#include "dnserver.h"
|
#include "dnserver.h"
|
||||||
#include "lwip/init.h"
|
#include "lwip/init.h"
|
||||||
#include "lwip/timeouts.h"
|
#include "lwip/timeouts.h"
|
||||||
|
#include "lwip/api.h"
|
||||||
|
#include "lwip/sys.h"
|
||||||
|
#include "lwip/udp.h"
|
||||||
|
|
||||||
#include "httpd.h"
|
#include "httpd.h"
|
||||||
|
|
||||||
|
#include "bmp180.h"
|
||||||
|
|
||||||
/* lwip context */
|
/* lwip context */
|
||||||
static struct netif netif_data;
|
static struct netif netif_data;
|
||||||
|
|
||||||
|
@ -220,6 +225,25 @@ void tud_network_init_cb(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bmp_t bmp;
|
||||||
|
|
||||||
|
static void udpecho_raw_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port)
|
||||||
|
{
|
||||||
|
if(p == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
struct pbuf *pr;
|
||||||
|
uint8_t buf[4];
|
||||||
|
|
||||||
|
pr = pbuf_alloc(PBUF_TRANSPORT, 4, PBUF_POOL);
|
||||||
|
pr->len = 4;
|
||||||
|
pr->tot_len = 4;
|
||||||
|
pr->payload = buf;
|
||||||
|
|
||||||
|
udp_sendto(pcb, pr, addr, port);
|
||||||
|
pbuf_free(p);
|
||||||
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
/* initialize TinyUSB */
|
/* initialize TinyUSB */
|
||||||
|
@ -231,6 +255,12 @@ int main(void)
|
||||||
while (!netif_is_up(&netif_data));
|
while (!netif_is_up(&netif_data));
|
||||||
while (dhserv_init(&dhcp_config) != ERR_OK);
|
while (dhserv_init(&dhcp_config) != ERR_OK);
|
||||||
while (dnserv_init(&ipaddr, 53, dns_query_proc) != ERR_OK);
|
while (dnserv_init(&ipaddr, 53, dns_query_proc) != ERR_OK);
|
||||||
|
|
||||||
|
struct udp_pcb *pcb;
|
||||||
|
pcb = udp_new();
|
||||||
|
udp_bind(pcb, IP_ADDR_ANY, 7777);
|
||||||
|
udp_recv(pcb , udpecho_raw_recv, pcb);
|
||||||
|
|
||||||
httpd_init();
|
httpd_init();
|
||||||
|
|
||||||
while (1)
|
while (1)
|
|
@ -0,0 +1 @@
|
||||||
|
add_subdirectory(bmp180)
|
Ładowanie…
Reference in New Issue