Working libs tests and multi target compiling and flashing.
This commit is contained in:
parent
ef0a47827f
commit
5b7e4ad733
|
|
@ -67,6 +67,54 @@
|
||||||
"clear": true
|
"clear": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"label": "Flash Access Point",
|
||||||
|
"detail": "Build and flash access point",
|
||||||
|
"type": "shell",
|
||||||
|
"dependsOn": [
|
||||||
|
"Configure"
|
||||||
|
],
|
||||||
|
"command": "make",
|
||||||
|
"args": [
|
||||||
|
"-C",
|
||||||
|
"build",
|
||||||
|
"-j$(nproc)",
|
||||||
|
"Flash_Access_Point"
|
||||||
|
],
|
||||||
|
"group": "build",
|
||||||
|
"presentation": {
|
||||||
|
"echo": true,
|
||||||
|
"reveal": "always",
|
||||||
|
"focus": true,
|
||||||
|
"panel": "shared",
|
||||||
|
"showReuseMessage": true,
|
||||||
|
"clear": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Flash Station",
|
||||||
|
"detail": "Build and flash station",
|
||||||
|
"type": "shell",
|
||||||
|
"dependsOn": [
|
||||||
|
"Configure"
|
||||||
|
],
|
||||||
|
"command": "make",
|
||||||
|
"args": [
|
||||||
|
"-C",
|
||||||
|
"build",
|
||||||
|
"-j$(nproc)",
|
||||||
|
"Flash_Station"
|
||||||
|
],
|
||||||
|
"group": "build",
|
||||||
|
"presentation": {
|
||||||
|
"echo": true,
|
||||||
|
"reveal": "always",
|
||||||
|
"focus": true,
|
||||||
|
"panel": "shared",
|
||||||
|
"showReuseMessage": true,
|
||||||
|
"clear": true
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"label": "Clean",
|
"label": "Clean",
|
||||||
"detail": "Clean build directory and executable",
|
"detail": "Clean build directory and executable",
|
||||||
|
|
|
||||||
|
|
@ -15,29 +15,49 @@ set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
pico_sdk_init()
|
pico_sdk_init()
|
||||||
|
|
||||||
# Sources
|
# Executables and sources
|
||||||
add_executable(PicoW_UDP_Tests
|
add_executable(PicoW_Access_Point
|
||||||
src/main.c
|
src/main_access_point.c
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(PicoW_Station
|
||||||
|
src/main_station.c
|
||||||
)
|
)
|
||||||
|
|
||||||
# Libs
|
# Libs
|
||||||
add_subdirectory(lib/PicoW_WiFi_Operator)
|
add_subdirectory(lib/PicoW_WiFi_Operator)
|
||||||
add_subdirectory(lib/PicoW_UDP)
|
add_subdirectory(lib/PicoW_UDP)
|
||||||
target_link_libraries(PicoW_UDP_Tests
|
|
||||||
|
target_link_libraries(PicoW_Access_Point
|
||||||
|
pico_stdlib
|
||||||
|
PicoW_WiFi_Operator
|
||||||
|
PicoW_UDP
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(PicoW_Station
|
||||||
pico_stdlib
|
pico_stdlib
|
||||||
PicoW_WiFi_Operator
|
PicoW_WiFi_Operator
|
||||||
PicoW_UDP
|
PicoW_UDP
|
||||||
)
|
)
|
||||||
|
|
||||||
# Stdio configuration
|
# Stdio configuration
|
||||||
pico_enable_stdio_usb(PicoW_UDP_Tests 1)
|
pico_enable_stdio_usb(PicoW_Access_Point 1)
|
||||||
pico_enable_stdio_uart(PicoW_UDP_Tests 1)
|
pico_enable_stdio_uart(PicoW_Access_Point 1)
|
||||||
|
|
||||||
|
pico_enable_stdio_usb(PicoW_Station 1)
|
||||||
|
pico_enable_stdio_uart(PicoW_Station 1)
|
||||||
|
|
||||||
# Output
|
# Output
|
||||||
pico_add_extra_outputs(PicoW_UDP_Tests)
|
pico_add_extra_outputs(PicoW_Access_Point)
|
||||||
|
pico_add_extra_outputs(PicoW_Station)
|
||||||
|
|
||||||
# Flash target
|
# Flash target
|
||||||
add_custom_target(Flash
|
add_custom_target(Flash_Access_Point
|
||||||
DEPENDS PicoW_UDP_Tests
|
DEPENDS PicoW_Access_Point
|
||||||
COMMAND picotool load -f ${PROJECT_BINARY_DIR}/PicoW_UDP_Tests.uf2
|
COMMAND picotool load -f ${PROJECT_BINARY_DIR}/PicoW_Access_Point.uf2
|
||||||
|
)
|
||||||
|
|
||||||
|
add_custom_target(Flash_Station
|
||||||
|
DEPENDS PicoW_Station
|
||||||
|
COMMAND picotool load -f ${PROJECT_BINARY_DIR}/PicoW_Station.uf2
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit be22ab1cf48bd53b05e7380ab248f4a2749f2870
|
Subproject commit 66f06c7ef5301235230d57fe066ddfb1d0fdc692
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit db81c8ef1bba6bce966b779d1daf011af6c4d59c
|
Subproject commit 64ba1dcc72a3633eb93f071f438395526bea80e9
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
#include <pico/stdlib.h>
|
||||||
|
#include <pico/cyw43_arch.h>
|
||||||
|
#include "PicoW_WiFi_Operator.h"
|
||||||
|
#include "PicoW_UDP.h"
|
||||||
|
|
||||||
|
static inline void udp_client_callback(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port)
|
||||||
|
{
|
||||||
|
struct udp_client_t *udp_client = arg;
|
||||||
|
|
||||||
|
printf("Received udp data with len %d :\n", p->len);
|
||||||
|
|
||||||
|
for(uint16_t i = 0; i < p->len; i++)
|
||||||
|
{
|
||||||
|
printf("0x%02x ", ((uint8_t *)p->payload)[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
putchar('\n');
|
||||||
|
|
||||||
|
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, ((uint8_t *)p->payload)[0]);
|
||||||
|
|
||||||
|
pbuf_free(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
stdio_init_all();
|
||||||
|
|
||||||
|
if(cyw43_arch_init_with_country(CYW43_COUNTRY_FRANCE)) return PICO_ERROR_GENERIC;
|
||||||
|
|
||||||
|
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, true);
|
||||||
|
|
||||||
|
if(wifi_operator_init(WIFI_OPERATOR_MODE_ACCESS_POINT)) return PICO_ERROR_GENERIC;
|
||||||
|
|
||||||
|
struct udp_client_t udp_client;
|
||||||
|
|
||||||
|
if(udp_client_init(&udp_client, udp_client_callback)) return PICO_ERROR_GENERIC;
|
||||||
|
|
||||||
|
for(int i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, false);
|
||||||
|
sleep_ms(100);
|
||||||
|
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, true);
|
||||||
|
sleep_ms(100);
|
||||||
|
}
|
||||||
|
|
||||||
|
while(true)
|
||||||
|
{
|
||||||
|
cyw43_arch_poll();
|
||||||
|
|
||||||
|
tight_loop_contents();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(wifi_operator_exit()) return PICO_ERROR_GENERIC;
|
||||||
|
|
||||||
|
cyw43_arch_deinit();
|
||||||
|
|
||||||
|
return PICO_OK;
|
||||||
|
}
|
||||||
|
|
@ -13,6 +13,10 @@ int main(void)
|
||||||
|
|
||||||
if(wifi_operator_init(WIFI_OPERATOR_MODE_STATION)) return PICO_ERROR_GENERIC;
|
if(wifi_operator_init(WIFI_OPERATOR_MODE_STATION)) return PICO_ERROR_GENERIC;
|
||||||
|
|
||||||
|
struct udp_server_t udp_server;
|
||||||
|
|
||||||
|
if(udp_server_init(&udp_server)) return PICO_ERROR_GENERIC;
|
||||||
|
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
static uint64_t last_time = 0;
|
static uint64_t last_time = 0;
|
||||||
|
|
@ -25,6 +29,8 @@ int main(void)
|
||||||
led_state = !led_state;
|
led_state = !led_state;
|
||||||
|
|
||||||
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, led_state);
|
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, led_state);
|
||||||
|
|
||||||
|
if(udp_server_send(&udp_server, &led_state, sizeof(led_state))) return PICO_ERROR_GENERIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
cyw43_arch_poll();
|
cyw43_arch_poll();
|
||||||
Loading…
Reference in New Issue