aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/stepcompress.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2016-12-30 17:02:28 -0500
committerKevin O'Connor <kevin@koconnor.net>2016-12-30 20:14:48 -0500
commit6bd5f4e44ec4898a6082c12df4ca7e4408a9df93 (patch)
tree19909ceb9b5efe15c64a199eab9e610c59e7df11 /klippy/stepcompress.c
parent6138d18f4bf5bdb2eb2639f4f9da40a1d52121ad (diff)
downloadkutter-6bd5f4e44ec4898a6082c12df4ca7e4408a9df93.tar.gz
kutter-6bd5f4e44ec4898a6082c12df4ca7e4408a9df93.tar.xz
kutter-6bd5f4e44ec4898a6082c12df4ca7e4408a9df93.zip
stepcompress: Using normal message priority system during homing
The endstop homing system requires all queue_step commands be in the MCU's 'move queue' before endstop checking starts. Use the normal message priority system to request that stepper queue_step commands are received prior to the start of the end_stop_home command. This simplifies the code and removes the need for special serial queue flushing. This also fixes a bug in homing operations that take longer than 2^31 clock ticks. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/stepcompress.c')
-rw-r--r--klippy/stepcompress.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/klippy/stepcompress.c b/klippy/stepcompress.c
index 6bcdb284..2100aa3e 100644
--- a/klippy/stepcompress.c
+++ b/klippy/stepcompress.c
@@ -34,7 +34,7 @@ struct stepcompress {
// Error checking
uint32_t errors;
// Message generation
- uint64_t last_step_clock;
+ uint64_t last_step_clock, homing_clock;
struct list_head msg_queue;
uint32_t queue_step_msgid, set_next_step_dir_msgid, oid;
int sdir, invert_sdir;
@@ -339,6 +339,9 @@ stepcompress_flush(struct stepcompress *sc, uint64_t move_clock)
uint32_t ticks = move.add*addfactor + move.interval*move.count;
sc->last_step_clock += ticks;
}
+ if (sc->homing_clock)
+ // When homing, all steps should be sent prior to homing_clock
+ qm->min_clock = qm->req_clock = sc->homing_clock;
list_add_tail(&qm->node, &sc->msg_queue);
if (sc->queue_pos + move.count >= sc->queue_next) {
@@ -359,7 +362,7 @@ set_next_step_dir(struct stepcompress *sc, int sdir)
sc->set_next_step_dir_msgid, sc->oid, sdir ^ sc->invert_sdir
};
struct queue_message *qm = message_alloc_and_encode(msg, 3);
- qm->req_clock = sc->last_step_clock;
+ qm->req_clock = sc->homing_clock ?: sc->last_step_clock;
list_add_tail(&qm->node, &sc->msg_queue);
}
@@ -557,6 +560,14 @@ stepcompress_reset(struct stepcompress *sc, uint64_t last_step_clock)
sc->sdir = -1;
}
+// Indicate the stepper is in homing mode (or done homing if zero)
+void
+stepcompress_set_homing(struct stepcompress *sc, uint64_t homing_clock)
+{
+ stepcompress_flush(sc, UINT64_MAX);
+ sc->homing_clock = homing_clock;
+}
+
// Queue an mcu command to go out in order with stepper commands
void
stepcompress_queue_msg(struct stepcompress *sc, uint32_t *data, int len)
@@ -564,7 +575,7 @@ stepcompress_queue_msg(struct stepcompress *sc, uint32_t *data, int len)
stepcompress_flush(sc, UINT64_MAX);
struct queue_message *qm = message_alloc_and_encode(data, len);
- qm->req_clock = sc->last_step_clock;
+ qm->req_clock = sc->homing_clock ?: sc->last_step_clock;
list_add_tail(&qm->node, &sc->msg_queue);
}