Most of sam3x8e/timer.c is going to be platform agnostic for any board
with standard irq handling. Move the generic code into a new file
generic/timer.c.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
It's tricky to reschedule the timer irq correctly (due to race
conditions with the irq) and in practice it's very rarely needed.
Handle the special cases in the generic sched.c code so that the board
code doesn't have to handle it.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The hardware timer overflow bit can be used to optimize the conversion
from 16bit timers to 32bit timers.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add a DECL_CONSTANT macro to allow the firmware to define constants
that are to be exported to the host during the "identify" phase. This
replaces the existing hardcoded mechanism of scanning the Kconfig
header file for certain constants.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Rework the timer prioritization code so that is compares against the
current time instead of the number of repeat timers in a given
interrupt. This makes the code slightly faster and it should provide
better protection against task starvation.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The AVR wants a uint8_t return type for irq_save(), but other
architectures will generally prefer int. Allow the board to configure
the size of the flag by introducing an irqstatus_t typedef.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Some AVR chips ship with a 1/8th clock divisor set. Add a compile
time option to manually clear this field at startup.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>