diff --git a/.gitignore b/.gitignore index e20fbe4..e0b9fc1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ build .vscode .trunk +.idea/ diff --git a/cli/node_dev.c b/cli/node_dev.c index c057adb..77c4b28 100644 --- a/cli/node_dev.c +++ b/cli/node_dev.c @@ -556,7 +556,7 @@ void uart1_set_data_callback(struct ush_object *self, struct ush_file_descriptor // dev directory files descriptor static const struct ush_file_descriptor dev_files[] = { -#if HW_USE_ONBOARD_LED && !defined(USING_PICOW) +#if HW_USE_ONBOARD_LED { .name = "led", // file name (required) .description = "onboard LED", // optional file description diff --git a/hardware/rp2040/hardware_config.c b/hardware/rp2040/hardware_config.c index c4052b4..7a55447 100644 --- a/hardware/rp2040/hardware_config.c +++ b/hardware/rp2040/hardware_config.c @@ -18,6 +18,9 @@ #include #include "hardware_config.h" +#ifdef USING_CYW43 +#include "pico/cyw43_arch.h" +#endif void hardware_init(void) { // mutexes for accessing hardware peripherals (created within each hw init function) @@ -33,6 +36,17 @@ void hardware_init(void) { // initialize the uart for cli/microshell first for status prints cli_uart_init(); + // on pico w, we need to initialize the wifi chip +#ifdef USING_CYW43 + if(cyw43_arch_init()) { + uart_puts(UART_ID_CLI, timestamp()); + uart_puts(UART_ID_CLI, "Failed to initialize CYW43 hardware.\r\n"); + } else { + uart_puts(UART_ID_CLI, timestamp()); + uart_puts(UART_ID_CLI, "Initialized onboard wireless module\r\n"); + } +#endif + // get the last reset reason string char *reset_reason_string = get_reset_reason_string(); @@ -66,7 +80,7 @@ void hardware_init(void) { } // initialize the onboard LED gpio (if not a Pico W board) - if (HW_USE_ONBOARD_LED && strcmp(xstr(BOARD), "pico_w") != 0) { + if (HW_USE_ONBOARD_LED) { onboard_led_init(); uart_puts(UART_ID_CLI, "led "); } diff --git a/hardware/rp2040/onboard_led.c b/hardware/rp2040/onboard_led.c index 00f15c0..197a0a8 100644 --- a/hardware/rp2040/onboard_led.c +++ b/hardware/rp2040/onboard_led.c @@ -19,6 +19,21 @@ #include "pico/stdlib.h" +#ifdef USING_CYW43 +#include "pico/cyw43_arch.h" + +void onboard_led_init(void) { + // no work to do with CYW43 LED pin +} + +void onboard_led_set(bool led_state) { + cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, led_state); +} + +bool onboard_led_get(void) { + return cyw43_arch_gpio_get(CYW43_WL_GPIO_LED_PIN); +} +#else void onboard_led_init(void) { gpio_init(PIN_NO_ONBOARD_LED); gpio_set_dir(PIN_NO_ONBOARD_LED, GPIO_OUT); @@ -30,4 +45,5 @@ void onboard_led_set(bool led_state) { bool onboard_led_get(void) { return gpio_get(PIN_NO_ONBOARD_LED); -} \ No newline at end of file +} +#endif diff --git a/hardware/rp2040/prebuild.cmake b/hardware/rp2040/prebuild.cmake index 8434d56..917051a 100644 --- a/hardware/rp2040/prebuild.cmake +++ b/hardware/rp2040/prebuild.cmake @@ -7,5 +7,6 @@ set(hardware_includes ${hardware_dir}) set(hardware_libs "pico_unique_id" "pico_stdlib") if(PICO_BOARD STREQUAL "pico_w") - list(APPEND hardware_libs "pico_cyw43_arch_none") + list(APPEND hardware_libs pico_cyw43_arch_none) + add_compile_definitions(USING_CYW43) endif()