mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
sys/riotboot: serial: add bootloader LED
This commit is contained in:
parent
f53a398bfb
commit
e6a06501b8
@ -1,3 +1,6 @@
|
||||
BOARD_INSUFFICIENT_MEMORY := \
|
||||
frdm-kw41z \
|
||||
pba-d-01-kw2x \
|
||||
phynode-kw41z \
|
||||
usb-kw41z \
|
||||
#
|
||||
|
@ -68,6 +68,18 @@ extern "C" {
|
||||
#define BTN_BOOTLOADER_INVERTED true
|
||||
#endif
|
||||
|
||||
/** @brief LED pin for bootloader indication
|
||||
*
|
||||
* This pin (typically connected to a LED) will be toggled while the bootloader is active.
|
||||
* It can be used to communicate the current bootloader state to the user.
|
||||
*/
|
||||
#if !defined(LED_BOOTLOADER_PIN) && defined(LED0_PIN) && !defined(LED_BOOTLOADER_NONE) || DOXYGEN
|
||||
#define LED_BOOTLOADER_PIN LED0_PIN
|
||||
#define LED_BOOTLOADER_ON LED0_ON /**< Turn the bootloader LED on */
|
||||
#define LED_BOOTLOADER_OFF LED0_OFF /**< Turn the bootloader LED off */
|
||||
#define LED_BOOTLOADER_TOGGLE LED0_TOGGLE /**< Toggle the bootloader LED */
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -69,6 +69,18 @@ static inline bool _boot_pin(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void _boot_led_toggle(void)
|
||||
{
|
||||
#ifdef LED_BOOTLOADER_PIN
|
||||
static unsigned count = RIOTBOOT_DELAY / 10;
|
||||
|
||||
if (--count == 0) {
|
||||
count = RIOTBOOT_DELAY / 10;
|
||||
LED_BOOTLOADER_TOGGLE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* send 'hello' byte until we get enter bootloader byte or timeout */
|
||||
static bool _bootdelay(unsigned tries, volatile bool *boot_default)
|
||||
{
|
||||
@ -88,6 +100,7 @@ static bool _bootdelay(unsigned tries, volatile bool *boot_default)
|
||||
if (_boot_pin()) {
|
||||
return false;
|
||||
}
|
||||
_boot_led_toggle();
|
||||
}
|
||||
|
||||
return *boot_default;
|
||||
@ -238,6 +251,10 @@ int riotboot_serial_loader(void)
|
||||
#ifdef BTN_BOOTLOADER_PIN
|
||||
gpio_init(BTN_BOOTLOADER_PIN, BTN_BOOTLOADER_MODE);
|
||||
#endif
|
||||
#ifdef LED_BOOTLOADER_PIN
|
||||
gpio_init(LED_BOOTLOADER_PIN, GPIO_OUT);
|
||||
LED_BOOTLOADER_OFF;
|
||||
#endif
|
||||
|
||||
uart_init(RIOTBOOT_UART_DEV, RIOTBOOT_UART_BAUDRATE,
|
||||
_uart_rx_cmd, (void *)&reading);
|
||||
@ -247,6 +264,10 @@ int riotboot_serial_loader(void)
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef LED_BOOTLOADER_ON
|
||||
LED_BOOTLOADER_ON;
|
||||
#endif
|
||||
|
||||
while (1) {
|
||||
|
||||
/* we can't use mutex in riotboot */
|
||||
|
Loading…
Reference in New Issue
Block a user