Skip to content
Open
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
2 changes: 1 addition & 1 deletion picoboard/button/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ add_executable(picoboard_button
)

# pull in common dependencies
target_link_libraries(picoboard_button pico_stdlib)
target_link_libraries(picoboard_button pico_stdlib pico_status_led)

# create map/bin/hex file etc.
pico_add_extra_outputs(picoboard_button)
Expand Down
14 changes: 9 additions & 5 deletions picoboard/button/button.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <stdio.h>
#include "pico/stdlib.h"
#include "pico/status_led.h"
#include "hardware/gpio.h"
#include "hardware/sync.h"
#include "hardware/structs/ioqspi.h"
Expand Down Expand Up @@ -58,13 +59,16 @@ bool __no_inline_not_in_flash_func(get_bootsel_button)() {
}

int main() {
#ifndef PICO_DEFAULT_LED_PIN
#warning picoboard/button example requires a board with a regular LED
#ifndef PICO_STATUS_LED_AVAILABLE
#warning picoboard/button example requires a board with status LED
#else
gpio_init(PICO_DEFAULT_LED_PIN);
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
int result = status_led_init();
hard_assert(result);
result = status_led_supported();
hard_assert(result);
while (true) {
gpio_put(PICO_DEFAULT_LED_PIN, get_bootsel_button() ^ PICO_DEFAULT_LED_PIN_INVERTED);
result = status_led_set_state(get_bootsel_button());
hard_assert(result);
sleep_ms(10);
}
#endif
Expand Down