IMU FIFO 커맨드 mim? 추가

This commit is contained in:
2026-07-06 12:04:44 +09:00
parent 763abb0fcc
commit b75c99b125
7 changed files with 86 additions and 0 deletions
@@ -50,6 +50,8 @@ 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 int imu_fifo_capture_wait_samples_and_send_rim(uint16_t target_samples, uint32_t timeout_ms);
extern void imu_fifo_capture_disable(void);
extern void battery_timer_stop(void);
extern void main_timer_start(void);
extern void hw_i2c_init_once(void);
@@ -41,6 +41,7 @@ static const CmdEntry m_cmd_table[] = {
{ "msn?", true, Cmd_msn },
{ "mst?", true, Cmd_mst },
{ "msp?", true, Cmd_msp },
{ "mim?", true, Cmd_mim },
/* D. Piezo ultrasound */
{ "mpa?", true, Cmd_mpa },
@@ -4,6 +4,7 @@
* msn? -> rsn: battery ADC measurement
* mst? -> rso: IMU die temperature reading
* msp? -> rsp: IMU 6-axis single read
* mim? -> rim: IMU FIFO 15-sample read
* all_sensors() bulk-measurement helper used by the mbb? handler
*============================================================================*/
@@ -47,6 +48,7 @@ int Cmd_mst(const ParsedCmd *cmd)
/*==============================================================================
* msp? -> rsp: IMU 6-axis single read
* mim? -> rim: IMU FIFO 15-sample read
*
* Request: [TAG 4B "msp?"] [CRC 2B]
* Response: rsp: + accel(xyz) + gyro(xyz) (transmitted inside imu_read_direct)
@@ -61,6 +63,33 @@ int Cmd_msp(const ParsedCmd *cmd)
return 1;
}
/*==============================================================================
* mim? -> rim: IMU FIFO-only capture
*
* Request: [TAG 4B "mim?"] [CRC 2B]
* Response: rim: [total_sample_count u16 BE]
* [samples: 12B each ax,ay,az,gx,gy,gz ...]
*
* Uses the same FIFO/rim path as mtb? but without piezo reb:/raa: packets.
* At 50 Hz, 15 samples are about 300 ms; timeout leaves margin for startup.
*============================================================================*/
int Cmd_mim(const ParsedCmd *cmd)
{
int rc;
(void)cmd;
rc = imu_fifo_capture_start();
if (rc != 0)
{
(void)imu_fifo_capture_stop_and_send_rim();
imu_fifo_capture_disable();
return 1;
}
(void)imu_fifo_capture_wait_samples_and_send_rim(15, 500);
return 1;
}
/*==============================================================================
* all_sensors() - Bulk-measurement helper for the mbb? handler
*
@@ -9,6 +9,7 @@
int Cmd_msn(const ParsedCmd *cmd); /* msn? -> rsn: battery ADC measurement */
int Cmd_mst(const ParsedCmd *cmd); /* mst? -> rso: IMU die temperature */
int Cmd_msp(const ParsedCmd *cmd); /* msp? -> rsp: IMU 6-axis single read */
int Cmd_mim(const ParsedCmd *cmd); /* mim? -> rim: IMU FIFO 15 samples */
/* Helper for the mbb? handler: sequentially measures battery / IMU / temperature, then emits a single rbb: response.
* Called from Cmd_mbb() in cmd_piezo.c. */
void all_sensors(void);