aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2023-12-17 11:31:58 -0500
committerKevin O'Connor <kevin@koconnor.net>2024-01-19 11:55:15 -0500
commit5ff555a705b8d3a586f240eb7456b591ee928ac2 (patch)
tree8c52fd7df2946f6d411ba25ddbc220d9fae01972
parent3275614b895c409f30cc9520c02990b18abad3c6 (diff)
downloadkutter-5ff555a705b8d3a586f240eb7456b591ee928ac2.tar.gz
kutter-5ff555a705b8d3a586f240eb7456b591ee928ac2.tar.xz
kutter-5ff555a705b8d3a586f240eb7456b591ee928ac2.zip
sensor_mpu9250: No need to send messages when stopping queries
Simplify the mcu code as any messages are ignored by the host anyway. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--klippy/extras/mpu9250.py8
-rw-r--r--src/sensor_mpu9250.c9
2 files changed, 2 insertions, 15 deletions
diff --git a/klippy/extras/mpu9250.py b/klippy/extras/mpu9250.py
index 04a33eb2..41376dc3 100644
--- a/klippy/extras/mpu9250.py
+++ b/klippy/extras/mpu9250.py
@@ -69,7 +69,7 @@ class MPU9250:
default_speed=400000)
self.mcu = mcu = self.i2c.get_mcu()
self.oid = oid = mcu.create_oid()
- self.query_mpu9250_cmd = self.query_mpu9250_end_cmd = None
+ self.query_mpu9250_cmd = None
self.query_mpu9250_status_cmd = None
mcu.register_config_callback(self._build_config)
self.bulk_queue = bulk_sensor.BulkDataQueue(mcu, "mpu9250_data", oid)
@@ -95,10 +95,6 @@ class MPU9250:
% (self.oid,), on_restart=True)
self.query_mpu9250_cmd = self.mcu.lookup_command(
"query_mpu9250 oid=%c clock=%u rest_ticks=%u", cq=cmdqueue)
- self.query_mpu9250_end_cmd = self.mcu.lookup_query_command(
- "query_mpu9250 oid=%c clock=%u rest_ticks=%u",
- "mpu9250_status oid=%c clock=%u query_ticks=%u next_sequence=%hu"
- " buffered=%c fifo=%u limit_count=%hu", oid=self.oid, cq=cmdqueue)
self.query_mpu9250_status_cmd = self.mcu.lookup_query_command(
"query_mpu9250_status oid=%c",
"mpu9250_status oid=%c clock=%u query_ticks=%u next_sequence=%hu"
@@ -193,7 +189,7 @@ class MPU9250:
self.last_error_count = 0
def _finish_measurements(self):
# Halt bulk reading
- params = self.query_mpu9250_end_cmd.send([self.oid, 0, 0])
+ self.query_mpu9250_cmd.send_wait_ack([self.oid, 0, 0])
self.bulk_queue.clear_samples()
logging.info("MPU9250 finished '%s' measurements", self.name)
self.set_reg(REG_PWR_MGMT_1, SET_PWR_MGMT_1_SLEEP)
diff --git a/src/sensor_mpu9250.c b/src/sensor_mpu9250.c
index c535d097..7792b4d8 100644
--- a/src/sensor_mpu9250.c
+++ b/src/sensor_mpu9250.c
@@ -192,16 +192,7 @@ mp9250_stop(struct mpu9250 *mp, uint8_t oid)
// disable accel FIFO
uint8_t msg[2] = { AR_FIFO_EN, SET_DISABLE_FIFO };
- uint32_t end1_time = timer_read_time();
i2c_write(mp->i2c->i2c_config, sizeof(msg), msg);
- uint32_t end2_time = timer_read_time();
-
- // Report final data
- if (mp->data_count > 0)
- mp9250_report(mp, oid);
- uint16_t bytes_to_read = get_fifo_status(mp);
- mp9250_status(mp, oid, end1_time, end2_time,
- bytes_to_read / BYTES_PER_FIFO_ENTRY);
// Uncomment and rebuilt to check for FIFO overruns when tuning
//output("mpu9240 limit_count=%u fifo_max=%u",