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>
This commit is contained in:
Kevin O'Connor 2023-12-17 11:31:58 -05:00
parent 3275614b89
commit 5ff555a705
2 changed files with 2 additions and 15 deletions

View File

@ -69,7 +69,7 @@ class MPU9250:
default_speed=400000) default_speed=400000)
self.mcu = mcu = self.i2c.get_mcu() self.mcu = mcu = self.i2c.get_mcu()
self.oid = oid = mcu.create_oid() 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 self.query_mpu9250_status_cmd = None
mcu.register_config_callback(self._build_config) mcu.register_config_callback(self._build_config)
self.bulk_queue = bulk_sensor.BulkDataQueue(mcu, "mpu9250_data", oid) self.bulk_queue = bulk_sensor.BulkDataQueue(mcu, "mpu9250_data", oid)
@ -95,10 +95,6 @@ class MPU9250:
% (self.oid,), on_restart=True) % (self.oid,), on_restart=True)
self.query_mpu9250_cmd = self.mcu.lookup_command( self.query_mpu9250_cmd = self.mcu.lookup_command(
"query_mpu9250 oid=%c clock=%u rest_ticks=%u", cq=cmdqueue) "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( self.query_mpu9250_status_cmd = self.mcu.lookup_query_command(
"query_mpu9250_status oid=%c", "query_mpu9250_status oid=%c",
"mpu9250_status oid=%c clock=%u query_ticks=%u next_sequence=%hu" "mpu9250_status oid=%c clock=%u query_ticks=%u next_sequence=%hu"
@ -193,7 +189,7 @@ class MPU9250:
self.last_error_count = 0 self.last_error_count = 0
def _finish_measurements(self): def _finish_measurements(self):
# Halt bulk reading # 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() self.bulk_queue.clear_samples()
logging.info("MPU9250 finished '%s' measurements", self.name) logging.info("MPU9250 finished '%s' measurements", self.name)
self.set_reg(REG_PWR_MGMT_1, SET_PWR_MGMT_1_SLEEP) self.set_reg(REG_PWR_MGMT_1, SET_PWR_MGMT_1_SLEEP)

View File

@ -192,16 +192,7 @@ mp9250_stop(struct mpu9250 *mp, uint8_t oid)
// disable accel FIFO // disable accel FIFO
uint8_t msg[2] = { AR_FIFO_EN, SET_DISABLE_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); 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 // Uncomment and rebuilt to check for FIFO overruns when tuning
//output("mpu9240 limit_count=%u fifo_max=%u", //output("mpu9240 limit_count=%u fifo_max=%u",