From ca2b80f906fac2f3f547d20a73e608de07b737c2 Mon Sep 17 00:00:00 2001 From: embr Date: Sun, 23 Apr 2023 19:23:28 +0200 Subject: [PATCH] pico w go blinky! --- CMakeLists.txt | 5 ++++- README.md | 7 +++++++ src/main.c | 20 ++++++++++++++++++-- 3 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 README.md diff --git a/CMakeLists.txt b/CMakeLists.txt index 08bb3dc..15b988e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,10 @@ add_executable(vibe-check ) # Add pico_stdlib library which aggregates commonly used features -target_link_libraries(vibe-check pico_stdlib) +target_link_libraries(vibe-check + pico_stdlib + pico_cyw43_arch_none +) # create map/bin/hex/uf2 file in addition to ELF. pico_add_extra_outputs(vibe-check) diff --git a/README.md b/README.md new file mode 100644 index 0000000..57e4e78 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +## Build + +``` +# env -C lib/pico-sdk/ git submodule update --init +# env -C build/ cmake .. -G Ninja -DPICO_BOARD=pico_w -DWIFI_SSID=YOUR_SSID_HERE -DWIFI_PASSWORD="your password here" +# env -C build/ ninja +``` diff --git a/src/main.c b/src/main.c index bd67fad..2731f3e 100644 --- a/src/main.c +++ b/src/main.c @@ -1,8 +1,24 @@ #include #include "pico/stdlib.h" +#include "pico/cyw43_arch.h" + +#ifndef CYW43_WL_GPIO_LED_PIN + #error no WiFi LED on board, wrong -DPICO_BOARD? +#endif int main() { - setup_default_uart(); - printf("Hello, world!\n"); + stdio_init_all(); + if (cyw43_arch_init()) { + printf("Wi-Fi init failed"); + return -1; + } + while (true) { + printf("Hello, world!\n"); + cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 1); + sleep_ms(250); + printf("Goodbye, world!\n"); + cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 0); + sleep_ms(250); + } return 0; }