rbb: 응답 시에도 IMU 온도 레지스터를 4회 연속 read 후 평균값 사용

+ 테스트 로그 삭제
This commit is contained in:
2026-06-01 15:18:04 +09:00
parent ba964a9301
commit 1ab6aa5558
4 changed files with 28 additions and 22 deletions
@@ -122,11 +122,6 @@ void all_sensors(void)
buf[18] = (uint8_t)(info_temp >> 8); buf[18] = (uint8_t)(info_temp >> 8);
buf[19] = (uint8_t)(info_temp & 0xFF); 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 */ dr_binary_tx_safe(buf, 10); /* 20 bytes = 10 words */
} }
@@ -174,11 +169,6 @@ void all_sensors_batt_temp(void)
buf[6] = (uint8_t)(info_temp >> 8); buf[6] = (uint8_t)(info_temp >> 8);
buf[7] = (uint8_t)(info_temp & 0xFF); 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 */ dr_binary_tx_safe(buf, 4); /* 8 bytes = 4 words, CRC appended by TX layer */
} }
@@ -1224,10 +1224,6 @@ static bool maa_async_send_header(void)
buf[5] = (uint8_t)(ch_info & 0xFF); buf[5] = (uint8_t)(ch_info & 0xFF);
buf[6] = (uint8_t)(ch->num_samples >> 8); buf[6] = (uint8_t)(ch->num_samples >> 8);
buf[7] = (uint8_t)(ch->num_samples & 0xFF); buf[7] = (uint8_t)(ch->num_samples & 0xFF);
ADC_LOG("reb ch_info: session=%u, ch=%u, value=0x%04X",
g_maa_ctx.ch_session,
g_maa_ctx.current_ch,
ch_info);
uint16_t dst_idx = MAA_REB_HEADER_LEN; uint16_t dst_idx = MAA_REB_HEADER_LEN;
uint16_t first_chunk = (total_data_bytes > MAA_REB_DATA_LEN) ? MAA_REB_DATA_LEN : total_data_bytes; uint16_t first_chunk = (total_data_bytes > MAA_REB_DATA_LEN) ? MAA_REB_DATA_LEN : total_data_bytes;
@@ -192,14 +192,6 @@ void battery_event_handler(nrf_drv_saadc_evt_t const * p_event)
{ {
DBG_PRINTF("[SAFETY] IMU temp read failed\r\n"); DBG_PRINTF("[SAFETY] IMU temp read failed\r\n");
} }
else
{
int temp_x100 = (int)(imu_temp_c * 100.0f);
DBG_PRINTF("[SAFETY] 60s IMU temp_x100=%d (%d.%02d C)\r\n",
temp_x100,
temp_x100 / 100,
temp_x100 % 100);
}
safety_check_complete(imu_temp_c); safety_check_complete(imu_temp_c);
} }
@@ -491,10 +491,13 @@ static uint16_t imu_temp_raw_to_x100(int16_t temp_raw)
int imu_read_direct(void) int imu_read_direct(void)
{ {
uint8_t raw[14]; /* temp 2 bytes + accel 6 bytes + gyro 6 bytes */ uint8_t raw[14]; /* temp 2 bytes + accel 6 bytes + gyro 6 bytes */
uint8_t temp_raw_bytes[2];
int32_t accel[3], gyro[3]; int32_t accel[3], gyro[3];
int16_t temp_raw; int16_t temp_raw;
int32_t temp_sum;
uint8_t reg; uint8_t reg;
uint32_t ret; uint32_t ret;
uint8_t i;
imu_direct_twi_init_once(); imu_direct_twi_init_once();
@@ -543,6 +546,7 @@ int imu_read_direct(void)
* raw[8..13] = gyro X,Y,Z (2 bytes each, MSB first) * raw[8..13] = gyro X,Y,Z (2 bytes each, MSB first)
*/ */
temp_raw = (int16_t)((raw[0] << 8) | raw[1]); temp_raw = (int16_t)((raw[0] << 8) | raw[1]);
temp_sum = temp_raw;
accel[0] = (int16_t)((raw[2] << 8) | raw[3]); accel[0] = (int16_t)((raw[2] << 8) | raw[3]);
accel[1] = (int16_t)((raw[4] << 8) | raw[5]); accel[1] = (int16_t)((raw[4] << 8) | raw[5]);
accel[2] = (int16_t)((raw[6] << 8) | raw[7]); accel[2] = (int16_t)((raw[6] << 8) | raw[7]);
@@ -564,6 +568,30 @@ int imu_read_direct(void)
if (info4 == true) if (info4 == true)
{ {
reg = REG_TEMP_DATA1;
for (i = 1; i < IMU_TEMP_AVG_SAMPLES; i++)
{
ret = icm42670_twi_tx(IMU_I2C_ADDR, &reg, 1, true);
if (ret)
{
DBG_PRINTF("[IMU] temp avg tx FAIL %u\r\n", ret);
break;
}
ret = icm42670_twi_rx(IMU_I2C_ADDR, temp_raw_bytes, sizeof(temp_raw_bytes));
if (ret)
{
DBG_PRINTF("[IMU] temp avg rx FAIL %u\r\n", ret);
break;
}
temp_sum += (int16_t)((temp_raw_bytes[0] << 8) | temp_raw_bytes[1]);
}
if (i == IMU_TEMP_AVG_SAMPLES)
{
temp_raw = (int16_t)(temp_sum / (int32_t)IMU_TEMP_AVG_SAMPLES);
}
uint16_t temp_x100 = imu_temp_raw_to_x100(temp_raw); uint16_t temp_x100 = imu_temp_raw_to_x100(temp_raw);
/* info4 mode: store in global array (sent as rbb: packet by mbb?) */ /* info4 mode: store in global array (sent as rbb: packet by mbb?) */