TMP235 온도 센서 → IMU register direact read 대체

- rbb: 응답 패킷, 60초 주기 safety check 온도 소스를 TMP235에서 IMU TEMP_DATA 레지스터로 변경
- IMU 온도 레지스터를 4회 연속 read 후 평균값 사용
- rbb: 응답 패킷 포맷은 섭씨 x100 형식 유지
This commit is contained in:
2026-06-01 15:06:19 +09:00
parent aa8d8f698f
commit ba964a9301
7 changed files with 156 additions and 58 deletions
@@ -48,6 +48,7 @@ extern void battery_level_meas(void);
extern void pressure_all_level_meas(void);
extern void tmp235_voltage_level_meas(void);
extern int imu_read_direct(void);
extern int imu_read_temperature_x100(uint16_t *temp_x100, float *temp_c);
extern int imu_fifo_capture_start(void);
extern int imu_fifo_capture_stop_and_send_rim(void);
extern void battery_timer_stop(void);
@@ -80,7 +80,7 @@ int Cmd_msp(const ParsedCmd *cmd)
* single rbb: packet. SAADC measurements run asynchronously (callback), so
* dr_sd_delay_ms() is used to wait for completion.
*
* Order: battery -> IMU -> (Piezo TX/RX ON) -> temperature
* Order: battery -> IMU 6-axis + IMU temperature
* Response: rbb: [batt 2B] [IMU 6x2B] [temp 2B] = 20 bytes = 10 words
*============================================================================*/
void all_sensors(void)
@@ -98,23 +98,11 @@ void all_sensors(void)
dr_sd_delay_ms(1);
}
/* 2. IMU 6-axis single read -> info_imu[6] */
/* 2. IMU 6-axis single read + IMU die temperature -> info_imu[6], info_temp */
info_temp = 0xFFFF;
hw_i2c_init_once();
imu_read_direct();
/* 3. Temperature -> info_temp (TMP235 needs Piezo TX/RX power) */
if (!dr_piezo_is_power_on())
{
dr_piezo_power_on();
}
tmp235_saadc_done = false;
tmp235_voltage_level_meas();
for (timeout_cnt = 0; !tmp235_saadc_done && timeout_cnt < 100; timeout_cnt++)
{
dr_sd_delay_ms(1);
}
info4 = false;
/* Assemble and transmit the rbb: packet (dedicated buffer to avoid
@@ -134,6 +122,11 @@ void all_sensors(void)
buf[18] = (uint8_t)(info_temp >> 8);
buf[19] = (uint8_t)(info_temp & 0xFF);
DBG_PRINTF("[RBB] IMU temp_x100=%u (%u.%02u C)\r\n",
info_temp,
info_temp / 100,
info_temp % 100);
dr_binary_tx_safe(buf, 10); /* 20 bytes = 10 words */
}
@@ -143,7 +136,7 @@ void all_sensors(void)
* Emits rbb: [batt 2B] [temp 2B] = 8 bytes = 4 words (no IMU).
* Not used by mtb? anymore; kept for optional host/tests.
*
* Order: battery -> (Piezo TX/RX ON) -> temperature
* Order: battery -> IMU temperature
* Response: rbb: [batt 2B] [temp 2B] = 8 bytes = 4 words
* TX layer appends CRC 2B, so the BLE packet is 10B total.
*============================================================================*/
@@ -151,6 +144,7 @@ void all_sensors_batt_temp(void)
{
uint8_t *buf;
uint32_t timeout_cnt;
uint16_t imu_temp_x100;
info4 = true;
@@ -161,16 +155,13 @@ void all_sensors_batt_temp(void)
dr_sd_delay_ms(1);
}
if (!dr_piezo_is_power_on())
if (imu_read_temperature_x100(&imu_temp_x100, NULL) == 0)
{
dr_piezo_power_on();
info_temp = imu_temp_x100;
}
tmp235_saadc_done = false;
tmp235_voltage_level_meas();
for (timeout_cnt = 0; !tmp235_saadc_done && timeout_cnt < 100; timeout_cnt++)
else
{
dr_sd_delay_ms(1);
info_temp = 0xFFFF;
}
info4 = false;
@@ -183,6 +174,11 @@ void all_sensors_batt_temp(void)
buf[6] = (uint8_t)(info_temp >> 8);
buf[7] = (uint8_t)(info_temp & 0xFF);
DBG_PRINTF("[RBB] IMU temp_x100=%u (%u.%02u C)\r\n",
info_temp,
info_temp / 100,
info_temp % 100);
dr_binary_tx_safe(buf, 4); /* 8 bytes = 4 words, CRC appended by TX layer */
}