Skip to content

Commit

Permalink
zephyr: io: add 'io_led_set()'
Browse files Browse the repository at this point in the history
The static declaration of 'led0' was moved to 'io.c' which broke
building with the 'MCUBOOT_INDICATION_LED' enabled:

  mcuboot/boot/zephyr/main.c:380:22: error:
    'led0' undeclared (first use in this function)
      380 |     gpio_pin_set_dt(&led0, 1);
          |                      ^~~~

This adds simple function 'io_led_set()' for changing LED's value.

Fixes: 433b848 ("zephyr: Move IO functions out of main to separate file")
Signed-off-by: Piotr Dymacz <[email protected]>
  • Loading branch information
pepe2k committed Dec 6, 2023
1 parent b07b84a commit 1f3b103
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
5 changes: 5 additions & 0 deletions boot/zephyr/include/io/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ extern "C" {
*/
void io_led_init(void);

/*
* Sets value of the configured LED.
*/
void io_led_set(int value);

/*
* Checks if GPIO is set in the required way to remain in serial recovery mode
*
Expand Down
5 changes: 5 additions & 0 deletions boot/zephyr/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ void io_led_init(void)
gpio_pin_configure_dt(&led0, GPIO_OUTPUT);
gpio_pin_set_dt(&led0, 0);
}

void io_led_set(int value)
{
gpio_pin_set_dt(&led0, value);
}
#endif /* CONFIG_MCUBOOT_INDICATION_LED */

#if defined(CONFIG_BOOT_SERIAL_ENTRANCE_GPIO) || defined(CONFIG_BOOT_USB_DFU_GPIO) || \
Expand Down
8 changes: 4 additions & 4 deletions boot/zephyr/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ static void boot_serial_enter()
int rc;

#ifdef CONFIG_MCUBOOT_INDICATION_LED
gpio_pin_set_dt(&led0, 1);
io_led_set(1);
#endif

mcuboot_status_change(MCUBOOT_STATUS_SERIAL_DFU_ENTERED);
Expand Down Expand Up @@ -434,7 +434,7 @@ int main(void)
#if defined(CONFIG_BOOT_USB_DFU_GPIO)
if (io_detect_pin()) {
#ifdef CONFIG_MCUBOOT_INDICATION_LED
gpio_pin_set_dt(&led0, 1);
io_led_set(1);
#endif

mcuboot_status_change(MCUBOOT_STATUS_USB_DFU_ENTERED);
Expand Down Expand Up @@ -475,7 +475,7 @@ int main(void)
uint32_t start = k_uptime_get_32();

#ifdef CONFIG_MCUBOOT_INDICATION_LED
gpio_pin_set_dt(&led0, 1);
io_led_set(1);
#endif
#endif

Expand All @@ -499,7 +499,7 @@ int main(void)
boot_serial_check_start(&boot_funcs,timeout_in_ms);

#ifdef CONFIG_MCUBOOT_INDICATION_LED
gpio_pin_set_dt(&led0, 0);
io_led_set(0);
#endif
#endif

Expand Down

0 comments on commit 1f3b103

Please sign in to comment.