Skip to content
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
7 changes: 6 additions & 1 deletion boot/zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,13 @@ elseif(CONFIG_BOOT_SIGNATURE_TYPE_ED25519 OR CONFIG_BOOT_ENCRYPT_X25519)
${FIAT_DIR}/src/curve25519.c
)
else()
if(MBEDTLS_ASN1_DIR)
zephyr_library_sources(
${MBEDTLS_ASN1_DIR}/src/asn1parse.c
)
endif()

zephyr_library_sources(
${MBEDTLS_ASN1_DIR}/src/asn1parse.c
${BOOT_DIR}/bootutil/src/ed25519_psa.c
)
endif()
Expand Down
45 changes: 9 additions & 36 deletions boot/zephyr/io_bm.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,31 +89,13 @@ void io_led_set(int value)

bool io_detect_pin(void)
{
int rc;
bool pin_active;

rc = bm_buttons_init(
&(struct bm_buttons_config){
.pin_number = BOARD_PIN_BTN_0,
.active_state = BM_BUTTONS_ACTIVE_LOW,
.pull_config = BM_BUTTONS_PIN_PULLUP,
},
1,
BM_BUTTONS_DETECTION_DELAY_MIN_US);
if (rc) {
BOOT_LOG_ERR("Failed to initialize buttons: %d", rc);
return false;
}
nrf_gpio_cfg_input(BOARD_PIN_BTN_0, BM_BUTTONS_PIN_PULLUP);

rc = bm_buttons_enable();
if (rc) {
BOOT_LOG_ERR("Failed to enable button detection: %d", rc);
return false;
}
pin_active = (bool)nrf_gpio_pin_read(BOARD_PIN_BTN_0);

pin_active = bm_buttons_is_pressed(BOARD_PIN_BTN_0);

if (pin_active) {
if (!pin_active) {
if (BUTTON_0_DETECT_DELAY > 0) {
#ifdef CONFIG_MULTITHREADING
k_sleep(K_MSEC(50));
Expand All @@ -125,13 +107,15 @@ bool io_detect_pin(void)
int64_t timestamp = k_uptime_get();

for(;;) {
pin_active = bm_buttons_is_pressed(BOARD_PIN_BTN_0);
uint32_t delta;

pin_active = (bool)nrf_gpio_pin_read(BOARD_PIN_BTN_0);

/* Get delta from when this started */
uint32_t delta = k_uptime_get() - timestamp;
delta = k_uptime_get() - timestamp;

/* If not pressed OR if pressed > debounce period, stop. */
if (delta >= BUTTON_0_DETECT_DELAY || !pin_active) {
if (delta >= BUTTON_0_DETECT_DELAY || pin_active) {
break;
}

Expand All @@ -145,18 +129,7 @@ bool io_detect_pin(void)
}
}

rc = bm_buttons_disable();

if (rc) {
BOOT_LOG_ERR("Failed to disable buttons: %d", rc);
}

rc = bm_buttons_deinit();
if (rc) {
BOOT_LOG_ERR("Failed to de-initialize buttons: %d", rc);
}

return (bool)pin_active;
return (bool)!pin_active;
}
#endif

Expand Down
Loading