aboutsummaryrefslogtreecommitdiffstats
path: root/src/sched.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-05-26 08:34:31 -0400
committerKevin O'Connor <kevin@koconnor.net>2017-05-26 12:32:05 -0400
commitca9756413f2793279b5ba1c1ecf274ce734b2087 (patch)
tree292f855ec549f6b7355589af4c4a95c86444b4c5 /src/sched.c
parentb9940f0e0d7b5b4fae497cc80d14948a091d71c2 (diff)
downloadkutter-ca9756413f2793279b5ba1c1ecf274ce734b2087.tar.gz
kutter-ca9756413f2793279b5ba1c1ecf274ce734b2087.tar.xz
kutter-ca9756413f2793279b5ba1c1ecf274ce734b2087.zip
sched: Allow shutdown_reason to be uint8
Store the shutdown_reason code in an 8-bit integer - this produces better code on AVR. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/sched.c')
-rw-r--r--src/sched.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/sched.c b/src/sched.c
index ed23df26..f82b0060 100644
--- a/src/sched.c
+++ b/src/sched.c
@@ -8,6 +8,7 @@
#include "autoconf.h" // CONFIG_*
#include "board/irq.h" // irq_save
#include "board/misc.h" // timer_from_us
+#include "board/pgm.h" // READP
#include "command.h" // shutdown
#include "sched.h" // sched_check_periodic
#include "stepper.h" // stepper_event
@@ -181,8 +182,7 @@ DECL_SHUTDOWN(sched_timer_shutdown);
* Shutdown processing
****************************************************************/
-static uint16_t shutdown_reason;
-static uint8_t shutdown_status;
+static uint_fast8_t shutdown_status, shutdown_reason;
// Return true if the machine is in an emergency stop state
uint8_t
@@ -191,12 +191,6 @@ sched_is_shutdown(void)
return !!shutdown_status;
}
-uint16_t
-sched_shutdown_reason(void)
-{
- return shutdown_reason;
-}
-
// Transition out of shutdown state
void
sched_clear_shutdown(void)
@@ -226,9 +220,16 @@ run_shutdown(void)
sendf("shutdown clock=%u static_string_id=%hu", cur, shutdown_reason);
}
+// Report the last shutdown reason code
+void
+sched_report_shutdown(void)
+{
+ sendf("is_shutdown static_string_id=%hu", shutdown_reason);
+}
+
// Shutdown the machine if not already in the process of shutting down
void
-sched_try_shutdown(unsigned int reason)
+sched_try_shutdown(uint_fast8_t reason)
{
if (shutdown_status != 2)
sched_shutdown(reason);
@@ -238,7 +239,7 @@ static jmp_buf shutdown_jmp;
// Force the machine to immediately run the shutdown handlers
void
-sched_shutdown(unsigned int reason)
+sched_shutdown(uint_fast8_t reason)
{
irq_disable();
if (!shutdown_status)