Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #11 - Onboard LED for pico_w not working #21

Merged
merged 4 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build
.vscode
.trunk
.idea/
2 changes: 1 addition & 1 deletion cli/node_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 15 additions & 1 deletion hardware/rp2040/hardware_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
#include <string.h>
#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)
Expand All @@ -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");
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add

else {
    uart_puts(UART_ID_CLI, timestamp());
    uart_puts(UART_ID_CLI, "Initialized onboard wireless module\r\n");
}

to print a success status message at boot.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HAH! I thought I did. Must only be on my wifi branch. :D

#endif

// get the last reset reason string
char *reset_reason_string = get_reset_reason_string();

Expand Down Expand Up @@ -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 ");
}
Expand Down
18 changes: 17 additions & 1 deletion hardware/rp2040/onboard_led.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -30,4 +45,5 @@ void onboard_led_set(bool led_state) {

bool onboard_led_get(void) {
return gpio_get(PIN_NO_ONBOARD_LED);
}
}
#endif
3 changes: 2 additions & 1 deletion hardware/rp2040/prebuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()