타이밍 최적화
- 온도 측정, Piezo 측정 사이 딜레이 줄이기 - Piezo 한 채널에서 평균화를 위한 반복 측정 사이 딜레이 줄이기 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -828,10 +828,10 @@ dr_adc_err_t dr_adc_capture_channel_only(uint8_t freq_option, uint16_t delay_us,
|
||||
/* Capture with averaging */
|
||||
for (uint16_t avg_iter = 0; avg_iter < averaging; avg_iter++) {
|
||||
if (avg_iter > 0) {
|
||||
nrf_delay_us(500); /* Echo decay time */
|
||||
//nrf_delay_us(500); /* Echo decay time */
|
||||
}
|
||||
|
||||
dr_piezo_select_channel(piezo_ch);
|
||||
//dr_piezo_select_channel(piezo_ch);
|
||||
|
||||
/* Execute piezo burst */
|
||||
switch (freq_option) {
|
||||
|
||||
@@ -53,6 +53,7 @@ extern void param_error(const char *cmd); /* 파라미터 오류 시 BLE로
|
||||
extern void single_format_data(uint8_t *buffer, const char *tag, uint16_t value); /* TAG(4바이트) + uint16 값(2바이트)을 buffer에 포맷팅 */
|
||||
extern void ascii_format_data(uint8_t *buffer, const char *tag, const char *ascii, uint8_t len); /* TAG(4바이트) + ASCII 문자열을 buffer에 포맷팅 */
|
||||
extern void dr_binary_tx_safe(const uint8_t *buffer, uint16_t length); /* BLE NUS를 통해 바이너리 데이터 전송 (length는 워드 단위) */
|
||||
extern volatile bool data_tx_in_progress; /* BLE TX 진행 중 플래그 */
|
||||
extern void dr_sd_delay_ms(uint32_t ms); /* SoftDevice 호환 딜레이 (BLE 스택 이벤트 처리 허용) */
|
||||
|
||||
/* FDS(Flash Data Storage) 설정 관련 */
|
||||
@@ -1076,7 +1077,7 @@ static void all_sensors(void)
|
||||
|
||||
/* 1) 배터리 전압 측정 → info_batt에 저장 */
|
||||
battery_level_meas();
|
||||
dr_sd_delay_ms(50); /* SAADC 콜백 완료 대기 */
|
||||
dr_sd_delay_ms(1); /* SAADC 콜백 완료 대기 */
|
||||
|
||||
/* 2) IMU 6축 단발 읽기 → info_imu[6]에 저장 */
|
||||
hw_i2c_init_once();
|
||||
@@ -1090,7 +1091,7 @@ static void all_sensors(void)
|
||||
}
|
||||
|
||||
tmp235_voltage_level_meas();
|
||||
dr_sd_delay_ms(50); /* SAADC 콜백 완료 대기 */
|
||||
dr_sd_delay_ms(1); /* SAADC 콜백 완료 대기 */
|
||||
|
||||
info4 = false;
|
||||
|
||||
@@ -1109,6 +1110,8 @@ static void all_sensors(void)
|
||||
|
||||
buf[18] = (uint8_t)(info_temp & 0xFF);
|
||||
buf[19] = (uint8_t)(info_temp >> 8);
|
||||
|
||||
if (g_plat.log) g_plat.log("[Cmd_mbb] rbb: TX before send, in_progress=%d\r\n", (int)data_tx_in_progress);
|
||||
dr_binary_tx_safe(buf, 10); /* 20바이트 = 10워드 */
|
||||
|
||||
if (g_plat.log) g_plat.log("[Cmd_mbb] rbb: sent (batt=%u temp=%u)\r\n", info_batt, info_temp);
|
||||
@@ -1157,8 +1160,6 @@ static int Cmd_mbb(const ParsedCmd *cmd)
|
||||
|
||||
all_sensors();
|
||||
|
||||
dr_sd_delay_ms(20); /* SoftDevice 이벤트 정리 후 캡처 시작 */
|
||||
|
||||
if (maa_async_is_busy())
|
||||
{
|
||||
dr_ble_return_1("raa:", 0xFFFE);
|
||||
@@ -1199,9 +1200,6 @@ static int Cmd_mbb(const ParsedCmd *cmd)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* 완료 시 자동 전원 OFF */
|
||||
//maa_async_set_auto_power(true);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user