Skip to content

Commit 2a74a2b

Browse files
pepe2knordicjm
authored andcommitted
zephyr: io: add 'io_led_set()'
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]>
1 parent 8c6c670 commit 2a74a2b

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

boot/zephyr/include/io/io.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ extern "C" {
3434
*/
3535
void io_led_init(void);
3636

37+
/*
38+
* Sets value of the configured LED.
39+
*/
40+
void io_led_set(int value);
41+
3742
/*
3843
* Checks if GPIO is set in the required way to remain in serial recovery mode
3944
*

boot/zephyr/io.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ void io_led_init(void)
9191
gpio_pin_configure_dt(&led0, GPIO_OUTPUT);
9292
gpio_pin_set_dt(&led0, 0);
9393
}
94+
95+
void io_led_set(int value)
96+
{
97+
gpio_pin_set_dt(&led0, value);
98+
}
9499
#endif /* CONFIG_MCUBOOT_INDICATION_LED */
95100

96101
#if defined(CONFIG_BOOT_SERIAL_ENTRANCE_GPIO) || defined(CONFIG_BOOT_USB_DFU_GPIO) || \

boot/zephyr/main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ static void boot_serial_enter()
377377
int rc;
378378

379379
#ifdef CONFIG_MCUBOOT_INDICATION_LED
380-
gpio_pin_set_dt(&led0, 1);
380+
io_led_set(1);
381381
#endif
382382

383383
mcuboot_status_change(MCUBOOT_STATUS_SERIAL_DFU_ENTERED);
@@ -434,7 +434,7 @@ int main(void)
434434
#if defined(CONFIG_BOOT_USB_DFU_GPIO)
435435
if (io_detect_pin()) {
436436
#ifdef CONFIG_MCUBOOT_INDICATION_LED
437-
gpio_pin_set_dt(&led0, 1);
437+
io_led_set(1);
438438
#endif
439439

440440
mcuboot_status_change(MCUBOOT_STATUS_USB_DFU_ENTERED);
@@ -475,7 +475,7 @@ int main(void)
475475
uint32_t start = k_uptime_get_32();
476476

477477
#ifdef CONFIG_MCUBOOT_INDICATION_LED
478-
gpio_pin_set_dt(&led0, 1);
478+
io_led_set(1);
479479
#endif
480480
#endif
481481

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

501501
#ifdef CONFIG_MCUBOOT_INDICATION_LED
502-
gpio_pin_set_dt(&led0, 0);
502+
io_led_set(0);
503503
#endif
504504
#endif
505505

0 commit comments

Comments
 (0)