aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/chelper/stepcompress.c
diff options
context:
space:
mode:
Diffstat (limited to 'klippy/chelper/stepcompress.c')
-rw-r--r--klippy/chelper/stepcompress.c98
1 files changed, 49 insertions, 49 deletions
diff --git a/klippy/chelper/stepcompress.c b/klippy/chelper/stepcompress.c
index 4847bf16..7b0fdfd7 100644
--- a/klippy/chelper/stepcompress.c
+++ b/klippy/chelper/stepcompress.c
@@ -261,6 +261,18 @@ stepcompress_free(struct stepcompress *sc)
free(sc);
}
+uint32_t
+stepcompress_get_oid(struct stepcompress *sc)
+{
+ return sc->oid;
+}
+
+int
+stepcompress_get_step_dir(struct stepcompress *sc)
+{
+ return sc->sdir;
+}
+
// Determine the "print time" of the last_step_clock
static void
calc_last_step_print_time(struct stepcompress *sc)
@@ -269,6 +281,16 @@ calc_last_step_print_time(struct stepcompress *sc)
sc->last_step_print_time = sc->mcu_time_offset + (lsc - .5) / sc->mcu_freq;
}
+// Set the conversion rate of 'print_time' to mcu clock
+static void
+stepcompress_set_time(struct stepcompress *sc
+ , double time_offset, double mcu_freq)
+{
+ sc->mcu_time_offset = time_offset;
+ sc->mcu_freq = mcu_freq;
+ calc_last_step_print_time(sc);
+}
+
// Convert previously scheduled steps into commands for the mcu
static int
stepcompress_flush(struct stepcompress *sc, uint64_t move_clock)
@@ -336,55 +358,6 @@ set_next_step_dir(struct stepcompress *sc, int sdir)
return 0;
}
-// Reset the internal state of the stepcompress object
-int __visible
-stepcompress_reset(struct stepcompress *sc, uint64_t last_step_clock)
-{
- int ret = stepcompress_flush(sc, UINT64_MAX);
- if (ret)
- return ret;
- sc->last_step_clock = last_step_clock;
- sc->sdir = -1;
- calc_last_step_print_time(sc);
- return 0;
-}
-
-// Queue an mcu command to go out in order with stepper commands
-int __visible
-stepcompress_queue_msg(struct stepcompress *sc, uint32_t *data, int len)
-{
- int ret = stepcompress_flush(sc, UINT64_MAX);
- if (ret)
- return ret;
-
- struct queue_message *qm = message_alloc_and_encode(data, len);
- qm->req_clock = sc->last_step_clock;
- list_add_tail(&qm->node, &sc->msg_queue);
- return 0;
-}
-
-// Set the conversion rate of 'print_time' to mcu clock
-static void
-stepcompress_set_time(struct stepcompress *sc
- , double time_offset, double mcu_freq)
-{
- sc->mcu_time_offset = time_offset;
- sc->mcu_freq = mcu_freq;
- calc_last_step_print_time(sc);
-}
-
-uint32_t
-stepcompress_get_oid(struct stepcompress *sc)
-{
- return sc->oid;
-}
-
-int
-stepcompress_get_step_dir(struct stepcompress *sc)
-{
- return sc->sdir;
-}
-
// Maximium clock delta between messages in the queue
#define CLOCK_DIFF_MAX (3<<28)
@@ -456,6 +429,33 @@ stepcompress_append(struct stepcompress *sc, int sdir
return 0;
}
+// Reset the internal state of the stepcompress object
+int __visible
+stepcompress_reset(struct stepcompress *sc, uint64_t last_step_clock)
+{
+ int ret = stepcompress_flush(sc, UINT64_MAX);
+ if (ret)
+ return ret;
+ sc->last_step_clock = last_step_clock;
+ sc->sdir = -1;
+ calc_last_step_print_time(sc);
+ return 0;
+}
+
+// Queue an mcu command to go out in order with stepper commands
+int __visible
+stepcompress_queue_msg(struct stepcompress *sc, uint32_t *data, int len)
+{
+ int ret = stepcompress_flush(sc, UINT64_MAX);
+ if (ret)
+ return ret;
+
+ struct queue_message *qm = message_alloc_and_encode(data, len);
+ qm->req_clock = sc->last_step_clock;
+ list_add_tail(&qm->node, &sc->msg_queue);
+ return 0;
+}
+
/****************************************************************
* Step compress synchronization