From 4e880bca86f017045348ec4f0db261b6ca69d30d Mon Sep 17 00:00:00 2001 From: jhChun Date: Tue, 24 Mar 2026 17:59:58 +0900 Subject: [PATCH] =?UTF-8?q?=EC=98=A8=EB=8F=84=20=EC=84=BC=EC=84=9C=20?= =?UTF-8?q?=EC=BD=9C=EB=B0=B1=20=EB=8C=80=EA=B8=B0=20=EC=A1=B0=EA=B1=B4=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - parser.c: 콜백 완료 플래그 무한대기 -> 최대 100ms 대기, 콜백 오면 즉시 탈출 --- pc_firm/parser.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pc_firm/parser.c b/pc_firm/parser.c index 448b14b..a2f9d48 100644 --- a/pc_firm/parser.c +++ b/pc_firm/parser.c @@ -92,6 +92,7 @@ extern int imu_read_direct(void); /* IMU 레지스터 직접 읽기 + BLE 전 extern volatile uint16_t info_batt; /* 배터리 전압 (mV) */ extern volatile uint16_t info_temp; /* 온도 (°C x 100) */ extern volatile uint16_t info_imu[6]; /* IMU 6축 (accel XYZ + gyro XYZ) */ +extern volatile bool tmp235_saadc_done; /* TMP235 SAADC 콜백 완료 플래그 */ extern void pressure_all_level_meas(void); /* 압력 센서 전체 측정 */ extern void battery_timer_stop(void); /* 배터리 타이머 중지 */ @@ -1003,6 +1004,9 @@ static int Cmd_maa(const ParsedCmd *cmd) */ static void all_sensors(void) { + uint8_t *buf; + uint32_t timeout_cnt; + info4 = true; /* 센서값을 전역 변수에 저장 (BLE 전송 안 함) */ /* 1. 배터리 전압 측정 → info_batt에 저장 */ @@ -1019,15 +1023,18 @@ static void all_sensors(void) dr_piezo_power_on(); } - extern volatile bool tmp235_saadc_done; tmp235_saadc_done = false; tmp235_voltage_level_meas(); - while (!tmp235_saadc_done) { dr_sd_delay_ms(1); } /* SAADC 콜백 완료 대기 */ + + for (timeout_cnt = 0; !tmp235_saadc_done && timeout_cnt < 100; timeout_cnt++) + { + dr_sd_delay_ms(1); /* 콜백 오면 즉시 탈출, 최대 100ms, 타임아웃 시 이전 값 또는 쓰레기값.. */ + } info4 = false; - + /* rbb: 패킷 조립 및 전송 : [TAG 4B] [배터리 2B] [IMU 12B] [온도 2B] = 20바이트 = 10워드 */ - uint8_t *buf = ble_bin_buffer; + buf = ble_bin_buffer; buf[0] = 'r'; buf[1] = 'b'; buf[2] = 'b'; buf[3] = ':'; buf[4] = (uint8_t)(info_batt & 0xFF);