mirror of
https://github.com/polhenarejos/pico-keys-sdk
synced 2026-05-28 17:11:23 +02:00
Added support for LED in Pico W.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
@@ -184,7 +184,7 @@ else()
|
|||||||
${INCLUDES}
|
${INCLUDES}
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(pico_hsm_sdk INTERFACE pico_stdlib pico_multicore hardware_flash hardware_sync hardware_adc pico_unique_id hardware_rtc tinyusb_device tinyusb_board hardware_pio)
|
target_link_libraries(pico_hsm_sdk INTERFACE pico_stdlib pico_multicore hardware_flash hardware_sync hardware_adc pico_unique_id hardware_rtc tinyusb_device tinyusb_board hardware_pio pico_cyw43_arch_none)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
16
src/main.c
16
src/main.c
@@ -46,6 +46,9 @@
|
|||||||
#include "random.h"
|
#include "random.h"
|
||||||
#include "hsm.h"
|
#include "hsm.h"
|
||||||
#include "apdu.h"
|
#include "apdu.h"
|
||||||
|
#ifdef CYW43_WL_GPIO_LED_PIN
|
||||||
|
#include "pico/cyw43_arch.h"
|
||||||
|
#endif
|
||||||
#ifdef PICO_DEFAULT_WS2812_PIN
|
#ifdef PICO_DEFAULT_WS2812_PIN
|
||||||
#include "hardware/pio.h"
|
#include "hardware/pio.h"
|
||||||
#include "hardware/clocks.h"
|
#include "hardware/clocks.h"
|
||||||
@@ -205,7 +208,8 @@ void led_blinking_task() {
|
|||||||
#ifdef PICO_DEFAULT_LED_PIN
|
#ifdef PICO_DEFAULT_LED_PIN
|
||||||
static uint8_t led_color = PICO_DEFAULT_LED_PIN;
|
static uint8_t led_color = PICO_DEFAULT_LED_PIN;
|
||||||
#elif defined(PICO_DEFAULT_WS2812_PIN)
|
#elif defined(PICO_DEFAULT_WS2812_PIN)
|
||||||
|
#elif defined(CYW43_WL_GPIO_LED_PIN)
|
||||||
|
static uint8_t led_color = CYW43_WL_GPIO_LED_PIN;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Blink every interval ms
|
// Blink every interval ms
|
||||||
@@ -223,6 +227,8 @@ void led_blinking_task() {
|
|||||||
else {
|
else {
|
||||||
pio_sm_put_blocking(pio0, 0, 0xff000000);
|
pio_sm_put_blocking(pio0, 0, 0xff000000);
|
||||||
}
|
}
|
||||||
|
#elif defined(CYW43_WL_GPIO_LED_PIN)
|
||||||
|
cyw43_arch_gpio_put(led_color, led_state);
|
||||||
#endif
|
#endif
|
||||||
led_state ^= 1; // toggle
|
led_state ^= 1; // toggle
|
||||||
}
|
}
|
||||||
@@ -234,6 +240,8 @@ void led_off_all() {
|
|||||||
gpio_put(TINY2040_LED_B_PIN, 1);
|
gpio_put(TINY2040_LED_B_PIN, 1);
|
||||||
#elif defined(PICO_DEFAULT_LED_PIN)
|
#elif defined(PICO_DEFAULT_LED_PIN)
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, 0);
|
gpio_put(PICO_DEFAULT_LED_PIN, 0);
|
||||||
|
#elif defined(CYW43_WL_GPIO_LED_PIN)
|
||||||
|
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 0);
|
||||||
#endif
|
#endif
|
||||||
#if (PICO_DEFAULT_WS2812_PIN)
|
#if (PICO_DEFAULT_WS2812_PIN)
|
||||||
PIO pio = pio0;
|
PIO pio = pio0;
|
||||||
@@ -285,11 +293,11 @@ int main(void) {
|
|||||||
gpio_set_dir(TINY2040_LED_G_PIN, GPIO_OUT);
|
gpio_set_dir(TINY2040_LED_G_PIN, GPIO_OUT);
|
||||||
gpio_init(TINY2040_LED_B_PIN);
|
gpio_init(TINY2040_LED_B_PIN);
|
||||||
gpio_set_dir(TINY2040_LED_B_PIN, GPIO_OUT);
|
gpio_set_dir(TINY2040_LED_B_PIN, GPIO_OUT);
|
||||||
#else
|
#elif defined(PICO_DEFAULT_LED_PIN)
|
||||||
#ifdef PICO_DEFAULT_LED_PIN
|
|
||||||
gpio_init(PICO_DEFAULT_LED_PIN);
|
gpio_init(PICO_DEFAULT_LED_PIN);
|
||||||
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
||||||
#endif
|
#elif defined(CYW43_WL_GPIO_LED_PIN)
|
||||||
|
cyw43_arch_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
led_off_all();
|
led_off_all();
|
||||||
|
|||||||
Reference in New Issue
Block a user