mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-07-21 21:58:05 -06:00
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>
This commit is contained in:
parent
b9940f0e0d
commit
ca9756413f
4 changed files with 17 additions and 16 deletions
21
src/sched.c
21
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue