부트 로그 수정
This commit is contained in:
@@ -17,17 +17,12 @@
|
||||
* - 전원: POWER_HOLD(P0.8) 자가유지 회로, POWER_BUTTON(P1.8) 입력
|
||||
*
|
||||
* [소프트웨어 부트 시퀀스 — main() 함수]
|
||||
* Phase 0: 전원 유지 (power_hold_init → P0.8 HIGH)
|
||||
* Phase 1: UART 초기화 (1Mbps), 로그 초기화
|
||||
* Phase 2: GPIO 초기화
|
||||
* Phase 3: 타이머 초기화 (app_timer, 배터리, 전원 시퀀스)
|
||||
* Phase 4: 설정 로드 (기본값 → FDS에서 덮어쓰기)
|
||||
* Phase 5: 버튼/LED BSP 초기화
|
||||
* Phase 6: BLE 스택 (SoftDevice → GAP → GATT → NUS → Advertising)
|
||||
* Phase 6.5: FDS(Flash Data Storage) 초기화 및 설정 로드
|
||||
* Phase 7: BLE 보안 (Peer Manager, LESC/정적 패스키)
|
||||
* Phase 8: 부트 완료 → 전원 버튼 상태머신(main_s) 시작
|
||||
* Phase 9: idle 루프 (nrf_pwr_mgmt_run)
|
||||
* Phase 1: 하드웨어 기본 (전원유지, 로그, GPIO, 타이머, 설정, 버튼/LED)
|
||||
* Phase 2: BLE 스택 (SoftDevice, 전원관리, DC-DC)
|
||||
* Phase 3: FDS + 설정 로드
|
||||
* Phase 4: BLE 프로토콜 (GAP, GATT, NUS, Advertising, 보안)
|
||||
* Phase 5: 애플리케이션 (파서, 피에조)
|
||||
* Boot 완료 → 전원 버튼 상태머신(main_s) → idle 루프
|
||||
*
|
||||
* [전원 버튼 상태머신 — main_s() 콜백, 5ms 간격]
|
||||
* - 짧은 눌림 (<1.5초, cnt_s<150): 전원 OFF
|
||||
@@ -1659,109 +1654,88 @@ int main(void)
|
||||
{
|
||||
bool erase_bonds_local = false;
|
||||
|
||||
// PHASE 0: 전원 유지
|
||||
/*──────────────────────────────────────────────────────────────
|
||||
* Phase 1: 하드웨어 기본 초기화 (BLE 무관)
|
||||
*────────────────────────────────────────────────────────────*/
|
||||
power_hold_init();
|
||||
|
||||
// PHASE 1: 기본 시스템
|
||||
if (power_off_duble_prohibit) return 0;
|
||||
cnt_s = 0;
|
||||
|
||||
//uart_init(); UART 비활성화
|
||||
log_init();
|
||||
|
||||
DBG_PRINTF("\r\n========================================\r\n");
|
||||
DBG_PRINTF(" Medithings v1.17\r\n");
|
||||
DBG_PRINTF("========================================\r\n");
|
||||
DBG_PRINTF("[0] PWR_HOLD\r\n");
|
||||
|
||||
// PHASE 2: GPIO
|
||||
DBG_PRINTF("[1] GPIO\r\n");
|
||||
DBG_PRINTF("[1] HW Init\r\n");
|
||||
gpio_init();
|
||||
|
||||
info4 = false;
|
||||
|
||||
// PHASE 3: 타이머
|
||||
DBG_PRINTF("[2] Timers\r\n");
|
||||
timers_init();
|
||||
|
||||
// PHASE 4: 설정 (기본값 로드)
|
||||
DBG_PRINTF("[3] Config (defaults)\r\n");
|
||||
load_default_config();
|
||||
|
||||
// PHASE 5: 버튼/LED
|
||||
DBG_PRINTF("[4] Buttons\r\n");
|
||||
buttons_leds_init(&erase_bonds_local);
|
||||
|
||||
#if FEATURE_SECURE_CONNECTION
|
||||
erase_bonds = erase_bonds_local;
|
||||
#endif
|
||||
DBG_PRINTF(" gpio/timer/config/btn OK\r\n");
|
||||
|
||||
// PHASE 6: BLE 스택
|
||||
DBG_PRINTF("[5] BLE\r\n");
|
||||
|
||||
/*──────────────────────────────────────────────────────────────
|
||||
* Phase 2: BLE 스택 초기화
|
||||
*────────────────────────────────────────────────────────────*/
|
||||
DBG_PRINTF("[2] BLE Stack\r\n");
|
||||
power_management_init();
|
||||
DBG_PRINTF(" pwr OK\r\n");
|
||||
|
||||
ble_stack_init();
|
||||
DBG_PRINTF(" stack OK\r\n");
|
||||
APP_ERROR_CHECK(sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE)); /* DC-DC: SD 이후 필수 */
|
||||
DBG_PRINTF(" pwr/stack/dcdc OK\r\n");
|
||||
|
||||
/* nRF52840 내장 DC-DC 활성화 — SoftDevice 초기화 후 호출 필수 */
|
||||
APP_ERROR_CHECK(sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE));
|
||||
DBG_PRINTF(" dcdc OK\r\n");
|
||||
|
||||
// PHASE 6.5: 내장 Flash (FDS) - BLE 스택 이후에 초기화해야 함
|
||||
DBG_PRINTF("[5.5] FDS\r\n");
|
||||
/*──────────────────────────────────────────────────────────────
|
||||
* Phase 3: FDS + 설정 로드 (BLE 스택 이후에 초기화해야 함)
|
||||
*────────────────────────────────────────────────────────────*/
|
||||
DBG_PRINTF("[3] FDS\r\n");
|
||||
fs_storage_init();
|
||||
config_load();
|
||||
load_flash_config();
|
||||
DBG_PRINTF(" fds OK\r\n");
|
||||
|
||||
/*──────────────────────────────────────────────────────────────
|
||||
* Phase 4: BLE 프로토콜 (GAP/GATT/NUS/Advertising/보안)
|
||||
*────────────────────────────────────────────────────────────*/
|
||||
DBG_PRINTF("[4] BLE Protocol\r\n");
|
||||
gap_params_init();
|
||||
DBG_PRINTF(" gap OK\r\n");
|
||||
|
||||
gatt_init();
|
||||
DBG_PRINTF(" gatt OK\r\n");
|
||||
|
||||
services_init();
|
||||
DBG_PRINTF(" svc OK\r\n");
|
||||
|
||||
advertising_init();
|
||||
DBG_PRINTF(" adv OK\r\n");
|
||||
|
||||
conn_params_init();
|
||||
DBG_PRINTF(" conn OK\r\n");
|
||||
|
||||
// PHASE 7: 보안
|
||||
DBG_PRINTF("[6] Security\r\n");
|
||||
#if FEATURE_SECURE_CONNECTION
|
||||
peer_manager_init();
|
||||
#endif
|
||||
DBG_PRINTF(" gap/gatt/svc/adv/conn/sec OK\r\n");
|
||||
|
||||
// PHASE 7.5: FDS 기본값 저장 (advertising 이후)
|
||||
/* FDS 기본값 저장 (advertising 이후) */
|
||||
if (m_need_save_defaults) {
|
||||
DBG_PRINTF("[FDS] Saving defaults after ADV\r\n");
|
||||
config_save();
|
||||
m_need_save_defaults = false;
|
||||
DBG_PRINTF(" fds defaults saved\r\n");
|
||||
}
|
||||
|
||||
// PHASE 7.6: 새 파서(dr_cmd_parser) 초기화
|
||||
/*──────────────────────────────────────────────────────────────
|
||||
* Phase 5: 애플리케이션 초기화
|
||||
*────────────────────────────────────────────────────────────*/
|
||||
DBG_PRINTF("[5] App\r\n");
|
||||
g_plat.log = log_printf;
|
||||
g_plat.tx_bin = dr_binary_tx_safe;
|
||||
g_plat.crc_check = true;
|
||||
g_log_enable = true;
|
||||
DBG_PRINTF(" parser OK\r\n");
|
||||
dr_piezo_init();
|
||||
DBG_PRINTF(" parser/piezo OK\r\n");
|
||||
|
||||
// PHASE 7.7: 피에조 드라이버 초기화 (GPIO/GPIOTE/Timer/PPI + 전원)
|
||||
//dr_piezo_system_init();
|
||||
dr_piezo_init(); // Piezo 초기화 (Active X)
|
||||
DBG_PRINTF(" piezo OK\r\n");
|
||||
|
||||
// PHASE 8: 완료
|
||||
/*──────────────────────────────────────────────────────────────
|
||||
* Boot 완료 → 전원 버튼 상태머신 시작
|
||||
*────────────────────────────────────────────────────────────*/
|
||||
DBG_PRINTF("\r\n========================================\r\n");
|
||||
DBG_PRINTF(" READY [%s]\r\n", SERIAL_NO);
|
||||
DBG_PRINTF("========================================\r\n\r\n");
|
||||
|
||||
// PHASE 9: 시작
|
||||
timers_start();
|
||||
|
||||
// MAIN LOOP
|
||||
|
||||
Reference in New Issue
Block a user