DFU activation 후 App 부팅 시 전원 OFF 처리 추가

This commit is contained in:
2026-06-26 11:42:32 +09:00
parent f3110c696f
commit 0d719751c4
6 changed files with 39 additions and 1 deletions
@@ -181,6 +181,7 @@
#define POWER_OFF_DELAY 3000 /* Power-off delay: 3s after LED indication */
#define POWER_RESET_DELAY 2000 /* Reset delay: 2s */
#define LED_NUM 24 /* LED pin number */
#define POST_DFU_APP_BOOT_GPREGRET2_MASK 0x02U /* Bootloader marker after DFU activation */
/*==============================================================================
* BLE Instances (statically allocated via SoftDevice macros)
@@ -2182,6 +2183,17 @@ int main(void)
*────────────────────────────────────────────────────────────*/
power_hold_init();
if ((NRF_POWER->GPREGRET2 & POST_DFU_APP_BOOT_GPREGRET2_MASK) != 0)
{
NRF_POWER->GPREGRET2 &= ~POST_DFU_APP_BOOT_GPREGRET2_MASK;
NRF_P0->OUTCLR = (1UL << 8);
NRF_P0->DIRSET = (1UL << 8);
while (true)
{
__WFE();
}
}
if (power_off_duble_prohibit)
{
return 0;
@@ -32,6 +32,8 @@ NOTICE: This file has been modified by Nordic Semiconductor ASA.
#include "system_nrf52_approtect.h"
#define __SYSTEM_CLOCK_64M (64000000UL)
#define POWER_HOLD_PIN 8UL
#define POWER_HOLD_PIN_MASK (1UL << POWER_HOLD_PIN)
#if defined ( __CC_ARM )
@@ -89,6 +91,15 @@ void SystemCoreClockUpdate(void)
void SystemInit(void)
{
/* Keep the external power latch asserted immediately after reset. */
NRF_P0->OUTSET = POWER_HOLD_PIN_MASK;
NRF_P0->DIRSET = POWER_HOLD_PIN_MASK;
NRF_P0->PIN_CNF[POWER_HOLD_PIN] =
(GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos) |
(GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_INPUT_Pos) |
(GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) |
(GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) |
(GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos);
/* Enable SWO trace functionality. If ENABLE_SWO is not defined, SWO pin will be used as GPIO (see Product
Specification to see which one). */
#if defined (ENABLE_SWO) && defined(CLOCK_TRACECONFIG_TRACEMUX_Pos)