diff options
| author | Matt Johnston <[email protected]> | 2021-10-29 12:53:07 +0800 |
|---|---|---|
| committer | Matt Johnston <[email protected]> | 2021-10-29 13:49:15 +0800 |
| commit | 8e95b807f7250ec759389a4b0551f90419d14ac6 (patch) | |
| tree | 40b4c399fc1fe50d383cb4fd4e61408596b2572a | |
| parent | 39c7fa15961376fe84fc9c3818b271d4cc8c8d74 (diff) | |
samd21: Make LED_PIN and BUTTON_PIN optional
Some boards don't have them, just ignore
| -rw-r--r-- | hw/bsp/samd21/family.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/hw/bsp/samd21/family.c b/hw/bsp/samd21/family.c index eb5b55863..10e40e3f0 100644 --- a/hw/bsp/samd21/family.c +++ b/hw/bsp/samd21/family.c @@ -73,12 +73,16 @@ void board_init(void) SysTick_Config(CONF_CPU_FREQUENCY / 1000); // Led init +#ifdef LED_PIN gpio_set_pin_direction(LED_PIN, GPIO_DIRECTION_OUT); board_led_write(false); +#endif // Button init +#ifdef BUTTON_PIN gpio_set_pin_direction(BUTTON_PIN, GPIO_DIRECTION_IN); gpio_set_pin_pull_mode(BUTTON_PIN, BUTTON_STATE_ACTIVE ? GPIO_PULL_DOWN : GPIO_PULL_UP); +#endif #if CFG_TUSB_OS == OPT_OS_FREERTOS // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher ) @@ -119,12 +123,19 @@ void board_init(void) void board_led_write(bool state) { + (void)state; +#ifdef LED_PIN gpio_set_pin_level(LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON)); +#endif } uint32_t board_button_read(void) { +#ifdef BUTTON_PIN return BUTTON_STATE_ACTIVE == gpio_get_pin_level(BUTTON_PIN); +#else + return 0; +#endif } int board_uart_read(uint8_t* buf, int len) |
