Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zephyr: io: trivial fixes after I/O functions separation (if MCUBOOT_INDICATION_LED enabled) #1874

Merged
merged 3 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
8 changes: 8 additions & 0 deletions boot/zephyr/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <zephyr/linker/linker-defs.h>

#include "target.h"
#include "bootutil/bootutil_log.h"

#if defined(CONFIG_BOOT_SERIAL_PIN_RESET) || defined(CONFIG_BOOT_FIRMWARE_LOADER_PIN_RESET)
#include <zephyr/drivers/hwinfo.h>
Expand Down Expand Up @@ -78,6 +79,8 @@ static const struct gpio_dt_spec led0 = GPIO_DT_SPEC_GET(LED0_NODE, gpios);
#error "Unsupported board: led0 devicetree alias is not defined"
#endif

BOOT_LOG_MODULE_DECLARE(mcuboot);

void io_led_init(void)
{
if (!device_is_ready(led0.port)) {
Expand All @@ -88,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
10 changes: 5 additions & 5 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 @@ -407,7 +407,7 @@ int main(void)

#ifdef CONFIG_MCUBOOT_INDICATION_LED
/* LED init */
led_init();
io_led_init();
#endif

os_heap_init();
Expand All @@ -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
Loading