aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2023-12-17 11:33:11 -0500
committerKevin O'Connor <kevin@koconnor.net>2024-01-19 11:55:15 -0500
commit95e1a290f125650f5131a960d685d53a1e2f5e4f (patch)
tree579e629fa0d91e21c047625e2ba1cd166fcff16e
parent5ff555a705b8d3a586f240eb7456b591ee928ac2 (diff)
downloadkutter-95e1a290f125650f5131a960d685d53a1e2f5e4f.tar.gz
kutter-95e1a290f125650f5131a960d685d53a1e2f5e4f.tar.xz
kutter-95e1a290f125650f5131a960d685d53a1e2f5e4f.zip
sensor_lis2dw: 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/lis2dw.py8
-rw-r--r--src/sensor_lis2dw.c21
2 files changed, 4 insertions, 25 deletions
diff --git a/klippy/extras/lis2dw.py b/klippy/extras/lis2dw.py
index 28591c21..a7fe54d7 100644
--- a/klippy/extras/lis2dw.py
+++ b/klippy/extras/lis2dw.py
@@ -48,7 +48,7 @@ class LIS2DW:
self.spi = bus.MCU_SPI_from_config(config, 3, default_speed=5000000)
self.mcu = mcu = self.spi.get_mcu()
self.oid = oid = mcu.create_oid()
- self.query_lis2dw_cmd = self.query_lis2dw_end_cmd = None
+ self.query_lis2dw_cmd = None
self.query_lis2dw_status_cmd = None
mcu.add_config_cmd("config_lis2dw oid=%d spi_oid=%d"
% (oid, self.spi.get_oid()))
@@ -75,10 +75,6 @@ class LIS2DW:
cmdqueue = self.spi.get_command_queue()
self.query_lis2dw_cmd = self.mcu.lookup_command(
"query_lis2dw oid=%c clock=%u rest_ticks=%u", cq=cmdqueue)
- self.query_lis2dw_end_cmd = self.mcu.lookup_query_command(
- "query_lis2dw oid=%c clock=%u rest_ticks=%u",
- "lis2dw_status oid=%c clock=%u query_ticks=%u next_sequence=%hu"
- " buffered=%c fifo=%c limit_count=%hu", oid=self.oid, cq=cmdqueue)
self.query_lis2dw_status_cmd = self.mcu.lookup_query_command(
"query_lis2dw_status oid=%c",
"lis2dw_status oid=%c clock=%u query_ticks=%u next_sequence=%hu"
@@ -179,7 +175,7 @@ class LIS2DW:
self.last_error_count = 0
def _finish_measurements(self):
# Halt bulk reading
- params = self.query_lis2dw_end_cmd.send([self.oid, 0, 0])
+ self.query_lis2dw_cmd.send_wait_ack([self.oid, 0, 0])
self.bulk_queue.clear_samples()
logging.info("LIS2DW finished '%s' measurements", self.name)
self.set_reg(REG_LIS2DW_FIFO_CTRL, 0x00)
diff --git a/src/sensor_lis2dw.c b/src/sensor_lis2dw.c
index 52612623..06dd3206 100644
--- a/src/sensor_lis2dw.c
+++ b/src/sensor_lis2dw.c
@@ -23,7 +23,7 @@ struct lis2dw {
uint32_t rest_ticks;
struct spidev_s *spi;
uint16_t sequence, limit_count;
- uint8_t flags, data_count, fifo_disable;
+ uint8_t flags, data_count;
uint8_t data[48];
};
@@ -117,7 +117,7 @@ lis2dw_query(struct lis2dw *ax, uint8_t oid)
ax->limit_count++;
// check if we need to run the task again (more packets in fifo?)
- if (!fifo_empty&&!(ax->fifo_disable)) {
+ if (!fifo_empty) {
// More data in fifo - wake this task again
sched_wake_task(&lis2dw_wake);
} else if (ax->flags & LIS_RUNNING) {
@@ -134,7 +134,6 @@ lis2dw_start(struct lis2dw *ax, uint8_t oid)
{
sched_del_timer(&ax->timer);
ax->flags = LIS_RUNNING;
- ax->fifo_disable = 0;
uint8_t ctrl[2] = {LIS_FIFO_CTRL , 0xC0};
spidev_transfer(ax->spi, 0, sizeof(ctrl), ctrl);
lis2dw_reschedule_timer(ax);
@@ -147,23 +146,8 @@ lis2dw_stop(struct lis2dw *ax, uint8_t oid)
// Disable measurements
sched_del_timer(&ax->timer);
ax->flags = 0;
- // Drain any measurements still in fifo
- ax->fifo_disable = 1;
- lis2dw_query(ax, oid);
-
uint8_t ctrl[2] = {LIS_FIFO_CTRL , 0};
- uint32_t end1_time = timer_read_time();
spidev_transfer(ax->spi, 0, sizeof(ctrl), ctrl);
- uint32_t end2_time = timer_read_time();
-
- uint8_t msg[2] = { LIS_FIFO_SAMPLES | LIS_AM_READ , 0};
- spidev_transfer(ax->spi, 1, sizeof(msg), msg);
- uint8_t fifo_status = msg[1]&0x1f;
-
- //Report final data
- if (ax->data_count)
- lis2dw_report(ax, oid);
- lis2dw_status(ax, oid, end1_time, end2_time, fifo_status);
}
void
@@ -183,7 +167,6 @@ command_query_lis2dw(uint32_t *args)
ax->flags = LIS_HAVE_START;
ax->sequence = ax->limit_count = 0;
ax->data_count = 0;
- ax->fifo_disable = 0;
sched_add_timer(&ax->timer);
}
DECL_COMMAND(command_query_lis2dw,