BLE 연결 실패 발생 시 추적을 위한 RTT 로그 추가

- 0: IMU 값 송신(msp)- 1: 배터리 SAADC 시작- 2: 배터리 콜백 완료(battery_event_handler)- 3: 배터리 대기 루프 탈출- 4: IMU 읽기 완료- 5: Piezo RX/TX Active- 6: 온도 SAADC 시작- 7: 온도 콜백 완료(tmp235_voltage_handler)- 8: 온도 대기 루프 탈출- 9: rbb: 패킷 전송- 10: Piezo 캡처 시작(maa_async_start)- 11: 전체 종료(mbb)
This commit is contained in:
jhChun
2026-03-30 15:22:59 +09:00
parent 91e294da5a
commit aaf22d942a
4 changed files with 16 additions and 3 deletions

View File

@@ -26,6 +26,7 @@
#include <string.h> #include <string.h>
#include "nrf_gpio.h" #include "nrf_gpio.h"
#include "debug_print.h"
#include "nrf_delay.h" #include "nrf_delay.h"
#include "dr_piezo.h" #include "dr_piezo.h"
#include "dr_util.h" #include "dr_util.h"
@@ -1010,23 +1011,28 @@ static void all_sensors(void)
info4 = true; /* 센서값을 전역 변수에 저장 (BLE 전송 안 함) */ info4 = true; /* 센서값을 전역 변수에 저장 (BLE 전송 안 함) */
/* 1. 배터리 전압 측정 → info_batt에 저장 */ /* 1. 배터리 전압 측정 → info_batt에 저장 */
DBG_PRINTF("1");
battery_saadc_done = false; battery_saadc_done = false;
battery_level_meas(); battery_level_meas();
for (timeout_cnt = 0; !battery_saadc_done && timeout_cnt < 100; timeout_cnt++) for (timeout_cnt = 0; !battery_saadc_done && timeout_cnt < 100; timeout_cnt++)
{ {
dr_sd_delay_ms(1); /* 콜백 오면 즉시 탈출, 최대 100ms */ dr_sd_delay_ms(1); /* 콜백 오면 즉시 탈출, 최대 100ms */
} }
DBG_PRINTF("3");
/* 2. IMU 6축 단발 읽기 → info_imu[6]에 저장 */ /* 2. IMU 6축 단발 읽기 → info_imu[6]에 저장 */
hw_i2c_init_once(); hw_i2c_init_once();
imu_read_direct(); imu_read_direct();
DBG_PRINTF("4");
/* 3. 온도 측정 → info_temp에 저장 (TMP235는 Piezo TX/RX 전원 필요) */ /* 3. 온도 측정 → info_temp에 저장 (TMP235는 Piezo TX/RX 전원 필요) */
if (!dr_piezo_is_power_on()) if (!dr_piezo_is_power_on())
{ {
dr_piezo_power_on(); dr_piezo_power_on();
} }
DBG_PRINTF("5");
DBG_PRINTF("6");
tmp235_saadc_done = false; tmp235_saadc_done = false;
tmp235_voltage_level_meas(); tmp235_voltage_level_meas();
@@ -1034,6 +1040,7 @@ static void all_sensors(void)
{ {
dr_sd_delay_ms(1); /* 콜백 오면 즉시 탈출, 최대 100ms, 타임아웃 시 이전 값 또는 쓰레기값.. */ dr_sd_delay_ms(1); /* 콜백 오면 즉시 탈출, 최대 100ms, 타임아웃 시 이전 값 또는 쓰레기값.. */
} }
DBG_PRINTF("8");
info4 = false; info4 = false;
@@ -1054,6 +1061,7 @@ static void all_sensors(void)
buf[19] = (uint8_t)(info_temp >> 8); buf[19] = (uint8_t)(info_temp >> 8);
dr_binary_tx_safe(buf, 10); /* 20바이트 = 10워드 */ dr_binary_tx_safe(buf, 10); /* 20바이트 = 10워드 */
DBG_PRINTF("9");
/* 배터리, IMU, 온도 확인용 로그 */ /* 배터리, IMU, 온도 확인용 로그 */
//if (g_plat.log) g_plat.log("-------------------------------------------------------------------------------------\r\n[Battery] %u\r\n[IMU] %d,%d,%d,%d,%d,%d\r\n[Temperature] %u\r\n\r\n", info_batt, (int16_t)info_imu[0], (int16_t)info_imu[1], (int16_t)info_imu[2], //if (g_plat.log) g_plat.log("-------------------------------------------------------------------------------------\r\n[Battery] %u\r\n[IMU] %d,%d,%d,%d,%d,%d\r\n[Temperature] %u\r\n\r\n", info_batt, (int16_t)info_imu[0], (int16_t)info_imu[1], (int16_t)info_imu[2],
@@ -1077,6 +1085,7 @@ static int Cmd_mbb(const ParsedCmd *cmd)
dr_adc_err_t err; dr_adc_err_t err;
all_sensors(); /* 배터리, IMU, 온도 센서 먼저 측정 */ all_sensors(); /* 배터리, IMU, 온도 센서 먼저 측정 */
DBG_PRINTF("10");
if (maa_async_is_busy()) if (maa_async_is_busy())
{ {
@@ -1111,6 +1120,7 @@ static int Cmd_mbb(const ParsedCmd *cmd)
dr_piezo_power_off(); dr_piezo_power_off();
return 1; return 1;
} }
DBG_PRINTF("11\n");
return 1; return 1;
} }

View File

@@ -143,6 +143,7 @@ void battery_event_handler( nrf_drv_saadc_evt_t const * p_event )
nrf_drv_saadc_uninit(); nrf_drv_saadc_uninit();
/* 콜백 완료 알림 (all_sensors 대기 해제용) */ /* 콜백 완료 알림 (all_sensors 대기 해제용) */
if (info4) DBG_PRINTF("2");
battery_saadc_done = true; battery_saadc_done = true;
/* ADC값 → mV 변환 (매크로: ADC x 600/1023 x 6) */ /* ADC값 → mV 변환 (매크로: ADC x 600/1023 x 6) */

View File

@@ -381,7 +381,7 @@ void imu_callback(inv_imu_sensor_event_t *event)
/* UART 모드: "Tp" 접두사로 6축 데이터를 텍스트 형식으로 출력 */ /* UART 모드: "Tp" 접두사로 6축 데이터를 텍스트 형식으로 출력 */
else if(cmd_type_t == CMD_UART) { else if(cmd_type_t == CMD_UART) {
DBG_PRINTF("Tp%d,%d,%d,%d,%d,%d\r\n\r\n", accel[0], accel[1], accel[2], gyro[0], gyro[1], gyro[2]); //DBG_PRINTF("Tp%d,%d,%d,%d,%d,%d\r\n\r\n", accel[0], accel[1], accel[2], gyro[0], gyro[1], gyro[2]);
} }
/* /*
@@ -399,7 +399,7 @@ void imu_callback(inv_imu_sensor_event_t *event)
ssp_data[5] = (uint16_t)gyro[2]; ssp_data[5] = (uint16_t)gyro[2];
format_data(imu_bin_buffer, "rsp:", ssp_data,12); format_data(imu_bin_buffer, "rsp:", ssp_data,12);
DBG_PRINTF("Tp%d,%d,%d,%d,%d,%d\r\n\r\n", accel[0], accel[1], accel[2], gyro[0], gyro[1], gyro[2]); //DBG_PRINTF("Tp%d,%d,%d,%d,%d,%d\r\n\r\n", accel[0], accel[1], accel[2], gyro[0], gyro[1], gyro[2]);
dr_binary_tx_safe(imu_bin_buffer,8); dr_binary_tx_safe(imu_bin_buffer,8);
if(custom_add_data==true) { if(custom_add_data==true) {
@@ -569,6 +569,7 @@ int imu_read_direct(void)
/* 일반 모드: "rsp:" 태그로 BLE 즉시 전송 */ /* 일반 모드: "rsp:" 태그로 BLE 즉시 전송 */
format_data(imu_bin_buffer, "rsp:", ssp_data, 12); format_data(imu_bin_buffer, "rsp:", ssp_data, 12);
dr_binary_tx_safe(imu_bin_buffer, 8); dr_binary_tx_safe(imu_bin_buffer, 8);
DBG_PRINTF("0");
} }
/* IMU 슬립 모드: PWR_MGMT0 = 0x00 → 가속도/자이로 모두 OFF (전력 절감) */ /* IMU 슬립 모드: PWR_MGMT0 = 0x00 → 가속도/자이로 모두 OFF (전력 절감) */

View File

@@ -164,6 +164,7 @@ void tmp235_voltage_handler(nrf_drv_saadc_evt_t const * p_event) /* TMP325 Vout
// data_tx_handler(ble_tx_buffer); // data_tx_handler(ble_tx_buffer);
} }
DBG_PRINTF("7");
tmp235_saadc_done = true; tmp235_saadc_done = true;
} }