mirror of https://github.com/Desuuuu/klipper.git
irq: Prefer irq_disable/enable instead of irq_save/restore in cmds/tasks
Task and command handlers always run with irqs enabled, so it is not necessary to save/restore the irq state when disabling irqs in these handlers. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
4fcf5a31f5
commit
9dd101c26f
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "basecmd.h" // alloc_oid
|
||||
#include "board/gpio.h" // struct gpio_adc
|
||||
#include "board/irq.h" // irq_save
|
||||
#include "board/irq.h" // irq_disable
|
||||
#include "command.h" // DECL_COMMAND
|
||||
#include "sched.h" // DECL_TASK
|
||||
|
||||
|
@ -90,15 +90,15 @@ analog_in_task(void)
|
|||
foreach_oid(oid, a, command_config_analog_in) {
|
||||
if (a->state != a->sample_count)
|
||||
continue;
|
||||
uint8_t flag = irq_save();
|
||||
irq_disable();
|
||||
if (a->state != a->sample_count) {
|
||||
irq_restore(flag);
|
||||
irq_enable();
|
||||
continue;
|
||||
}
|
||||
uint16_t value = a->value;
|
||||
uint32_t next_begin_time = a->next_begin_time;
|
||||
a->state++;
|
||||
irq_restore(flag);
|
||||
irq_enable();
|
||||
sendf("analog_in_state oid=%c next_clock=%u value=%hu"
|
||||
, oid, next_begin_time, value);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <stddef.h> // offsetof
|
||||
#include "basecmd.h" // alloc_oid
|
||||
#include "board/gpio.h" // struct gpio
|
||||
#include "board/irq.h" // irq_save
|
||||
#include "board/irq.h" // irq_disable
|
||||
#include "command.h" // DECL_COMMAND
|
||||
#include "sched.h" // struct timer
|
||||
#include "stepper.h" // stepper_stop
|
||||
|
@ -73,11 +73,11 @@ DECL_COMMAND(command_end_stop_home,
|
|||
static void
|
||||
end_stop_report(uint8_t oid, struct end_stop *e)
|
||||
{
|
||||
uint8_t flag = irq_save();
|
||||
irq_disable();
|
||||
uint32_t position = stepper_get_position(e->stepper);
|
||||
uint8_t eflags = e->flags;
|
||||
e->flags &= ~ESF_REPORT;
|
||||
irq_restore(flag);
|
||||
irq_enable();
|
||||
|
||||
sendf("end_stop_state oid=%c homing=%c pin=%c pos=%i"
|
||||
, oid, !!(eflags & ESF_HOMING), gpio_in_read(e->pin)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "basecmd.h" // alloc_oid
|
||||
#include "board/gpio.h" // struct gpio_out
|
||||
#include "board/irq.h" // irq_save
|
||||
#include "board/irq.h" // irq_disable
|
||||
#include "command.h" // DECL_COMMAND
|
||||
#include "sched.h" // sched_timer
|
||||
|
||||
|
@ -188,7 +188,7 @@ command_schedule_soft_pwm_out(uint32_t *args)
|
|||
if (s->max_duration)
|
||||
next_flags |= SPF_NEXT_CHECK_END;
|
||||
}
|
||||
uint8_t flag = irq_save();
|
||||
irq_disable();
|
||||
if (s->flags & SPF_CHECK_END && sched_is_before(s->end_time, time))
|
||||
shutdown("next soft pwm extends existing pwm");
|
||||
s->end_time = time;
|
||||
|
@ -204,7 +204,7 @@ command_schedule_soft_pwm_out(uint32_t *args)
|
|||
s->timer.func = soft_pwm_load_event;
|
||||
sched_timer(&s->timer);
|
||||
}
|
||||
irq_restore(flag);
|
||||
irq_enable();
|
||||
}
|
||||
DECL_COMMAND(command_schedule_soft_pwm_out,
|
||||
"schedule_soft_pwm_out oid=%c clock=%u value=%c");
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "autoconf.h" // CONFIG_*
|
||||
#include "basecmd.h" // alloc_oid
|
||||
#include "board/gpio.h" // gpio_out_write
|
||||
#include "board/irq.h" // irq_save
|
||||
#include "board/irq.h" // irq_disable
|
||||
#include "command.h" // DECL_COMMAND
|
||||
#include "sched.h" // struct timer
|
||||
#include "stepper.h" // command_config_stepper
|
||||
|
@ -113,7 +113,7 @@ command_queue_step(uint32_t *args)
|
|||
m->next = NULL;
|
||||
m->flags = 0;
|
||||
|
||||
uint8_t flag = irq_save();
|
||||
irq_disable();
|
||||
if (!!(s->flags & SF_LAST_DIR) != !!(s->flags & SF_NEXT_DIR)) {
|
||||
s->flags ^= SF_LAST_DIR;
|
||||
m->flags |= MF_DIR;
|
||||
|
@ -129,7 +129,7 @@ command_queue_step(uint32_t *args)
|
|||
stepper_load_next(s);
|
||||
sched_timer(&s->time);
|
||||
}
|
||||
irq_restore(flag);
|
||||
irq_enable();
|
||||
}
|
||||
DECL_COMMAND(command_queue_step,
|
||||
"queue_step oid=%c interval=%u count=%hu add=%hi");
|
||||
|
|
Loading…
Reference in New Issue