mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-07-20 21:27:53 -06:00
sched: Support adding timers to the start of timer_list
If sched_add_timer() is called on a timer that would make it the new head of the list, then add it and signal the board code that the timer should be rescheduled. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
62f77f6bc5
commit
6a63c27542
7 changed files with 62 additions and 45 deletions
|
@ -1,6 +1,6 @@
|
|||
// AVR timer interrupt scheduling code.
|
||||
//
|
||||
// Copyright (C) 2016 Kevin O'Connor <kevin@koconnor.net>
|
||||
// Copyright (C) 2016,2017 Kevin O'Connor <kevin@koconnor.net>
|
||||
//
|
||||
// This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
|||
#include "board/misc.h" // timer_from_us
|
||||
#include "command.h" // shutdown
|
||||
#include "irq.h" // irq_save
|
||||
#include "sched.h" // sched_timer_kick
|
||||
#include "sched.h" // sched_timer_dispatch
|
||||
|
||||
|
||||
/****************************************************************
|
||||
|
@ -77,16 +77,13 @@ timer_repeat_set(uint16_t next)
|
|||
TIFR1 = 1<<OCF1B;
|
||||
}
|
||||
|
||||
// Reset the timer - clear settings and dispatch next timer immediately
|
||||
// Activate timer dispatch as soon as possible
|
||||
void
|
||||
timer_reset(void)
|
||||
timer_kick(void)
|
||||
{
|
||||
uint16_t now = timer_get();
|
||||
timer_set(now + 50);
|
||||
timer_set(timer_get() + 50);
|
||||
TIFR1 = 1<<OCF1A;
|
||||
timer_repeat_set(now + 50);
|
||||
}
|
||||
DECL_SHUTDOWN(timer_reset);
|
||||
|
||||
void
|
||||
timer_init(void)
|
||||
|
@ -97,7 +94,8 @@ timer_init(void)
|
|||
TCCR1B = 1<<CS10;
|
||||
// Setup for first irq
|
||||
irqstatus_t flag = irq_save();
|
||||
timer_reset();
|
||||
timer_kick();
|
||||
timer_repeat_set(timer_get() + 50);
|
||||
TIFR1 = 1<<TOV1;
|
||||
// enable interrupt
|
||||
TIMSK1 = 1<<OCIE1A;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue