From ca9756413f2793279b5ba1c1ecf274ce734b2087 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Fri, 26 May 2017 08:34:31 -0400 Subject: 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 --- src/sched.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/sched.c') 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) -- cgit v1.2.3-70-g09d2