Compare commits

..

2 Commits

Author SHA1 Message Date
jh.chun cda370b69d mtb? 정렬모드 중 IMU 주기 온도 읽기 비활성화
- 정렬모드(mtb?)일 때 FIFO가 활성화 상태, FW 내부 60초 주기 온도 점검을 위해 온도 레지스터 접근 시 오류 발생 가능
2026-06-16 10:40:44 +09:00
jh.chun 228f6da4a3 IMU ACC FSR 4g 통일
- 기존에는 direct read 8g, FIFO 4g
2026-06-16 10:33:35 +09:00
3 changed files with 32 additions and 9 deletions
@@ -183,6 +183,11 @@ void battery_event_handler(nrf_drv_saadc_evt_t const * p_event)
low_battery_check = false;
safety_batt_mv = batt_lvl_in_milli_volt_1;
if (imu_fifo_capture_is_active())
{
return;
}
if (imu_read_temperature_x100(NULL, &imu_temp_c) != 0)
{
DBG_PRINTF("[SAFETY] IMU temp read failed\r\n");
@@ -385,7 +385,7 @@ void imu_callback(inv_imu_sensor_event_t *event)
* Flow:
* 1) Check TWI initialization (first call only)
* 2) Gyro config: +/-2000dps, 100Hz ODR (GYRO_CONFIG0 = 0x09)
* 3) Accel config: +/-4g, 100Hz ODR (ACCEL_CONFIG0 = 0x29)
* 3) Accel config: +/-4g, 100Hz ODR (ACCEL_CONFIG0 = 0x49)
* 4) Power ON: accel+gyro low-noise mode (PWR_MGMT0 = 0x0F)
* 5) Wait 80ms (gyro startup: min 45ms + margin)
* 6) Read 14 consecutive bytes from TEMP_DATA1 (0x09) (temp 2 + accel 6 + gyro 6)
@@ -407,6 +407,7 @@ extern const nrfx_twi_t m_twi_icm42670;
#define IMU_TEMP_AVG_SAMPLES 4U
static bool s_direct_twi_ready = false;
static bool s_fifo_capture_active = false;
static void imu_direct_twi_init_once(void)
{
@@ -447,9 +448,9 @@ int imu_read_direct(void)
icm42670_twi_tx(IMU_I2C_ADDR, gyro_cfg, 2, false);
}
/* Accel config: ACCEL_CONFIG0(0x21) = 0x29 -> +/-4g FSR, 100Hz ODR */
/* Accel config: ACCEL_CONFIG0(0x21) = 0x49 -> +/-4g FSR, 100Hz ODR */
{
uint8_t accel_cfg[2] = { 0x21, 0x29 };
uint8_t accel_cfg[2] = { 0x21, 0x49 };
icm42670_twi_tx(IMU_I2C_ADDR, accel_cfg, 2, false);
}
@@ -569,6 +570,11 @@ int imu_read_temperature_x100(uint16_t *temp_x100, float *temp_c)
return -1;
}
if (s_fifo_capture_active)
{
return -4;
}
imu_direct_twi_init_once();
/* Power ON briefly so the temperature register is refreshed before reading. */
@@ -619,6 +625,11 @@ int imu_read_temperature_x100(uint16_t *temp_x100, float *temp_c)
return 0;
}
bool imu_fifo_capture_is_active(void)
{
return s_fifo_capture_active;
}
/* --------------------------------------------------------------------------------------
* mtb? FIFO capture support
*
@@ -642,8 +653,6 @@ int imu_read_temperature_x100(uint16_t *temp_x100, float *temp_c)
#define RIM_MAX_SAMPLE_BYTES (BLE_NUS_MAX_DATA_LEN - 2 - RIM_PACKET_HEADER_BYTES)
#define RIM_SAMPLES_PER_PACKET (RIM_MAX_SAMPLE_BYTES / RIM_SAMPLE_SIZE_BYTES)
static bool s_fifo_capture_active = false;
static void imu_serif_make(struct inv_imu_serif *serif)
{
serif->context = 0;
@@ -693,8 +702,8 @@ int imu_fifo_capture_start(void)
rc |= inv_imu_set_accel_fsr(&icm_driver, ACCEL_CONFIG0_FS_SEL_4g);
rc |= inv_imu_set_gyro_fsr(&icm_driver, GYRO_CONFIG0_FS_SEL_500dps);
rc |= inv_imu_set_accel_frequency(&icm_driver, ACCEL_CONFIG0_ODR_50_HZ);
rc |= inv_imu_set_gyro_frequency(&icm_driver, GYRO_CONFIG0_ODR_50_HZ);
rc |= inv_imu_set_accel_frequency(&icm_driver, ACCEL_CONFIG0_ODR_50_HZ); // FIFO ODR Accel 50Hz Setting
rc |= inv_imu_set_gyro_frequency(&icm_driver, GYRO_CONFIG0_ODR_50_HZ); // FIFO ODR Gyro 50Hz Setting
rc |= inv_imu_set_accel_ln_bw(&icm_driver, IMU_FIFO_MTB_ACCEL_LN_BW);
rc |= inv_imu_set_gyro_ln_bw(&icm_driver, IMU_FIFO_MTB_GYRO_LN_BW);
rc |= inv_imu_disable_high_resolution_fifo(&icm_driver);
@@ -707,8 +716,10 @@ int imu_fifo_capture_start(void)
rc |= inv_imu_write_reg(&icm_driver, FIFO_CONFIG1, 1, &fifo_cfg1);
}
rc |= inv_imu_reset_fifo(&icm_driver);
rc |= inv_imu_enable_accel_low_noise_mode(&icm_driver);
rc |= inv_imu_enable_gyro_low_noise_mode(&icm_driver);
rc |= inv_imu_enable_accel_low_noise_mode(&icm_driver); // FIFO Accel Low Noise Mode
//rc |= inv_imu_enable_accel_low_power_mode(&icm_driver); // FIFO Accel Low Power Mode TEST
rc |= inv_imu_enable_gyro_low_noise_mode(&icm_driver); // FIFO Gyro Low Noise Mode
imu_fifo_log_power_mode();
dr_sd_delay_ms(IMU_FIFO_ENABLE_SETTLE_MS);
rc |= inv_imu_reset_fifo(&icm_driver);
@@ -961,9 +972,11 @@ int imu_fifo_capture_stop_and_send_rim(void)
{
DBG_PRINTF("[IMU FIFO] drain fail %d\r\n", rc);
imu_fifo_send_rim_packets(0);
imu_fifo_power_off();
return rc;
}
imu_fifo_send_rim_packets(packet_count);
imu_fifo_power_off();
return 0;
}
@@ -105,6 +105,11 @@ int imu_read_direct(void);
*/
int imu_read_temperature_x100(uint16_t *temp_x100, float *temp_c);
/**
* \brief Return true while IMU FIFO capture is active.
*/
bool imu_fifo_capture_is_active(void);
/**
* \brief Start IMU internal FIFO capture for mtb? test flow.
* Configures accel/gyro 100 Hz and flushes FIFO before capture.