From 65dab6b180474d9fd69b9afd85873fe90a04ade4 Mon Sep 17 00:00:00 2001 From: Nico Tonnhofer Date: Fri, 20 Nov 2015 00:29:36 +0100 Subject: [PATCH] STM32F411: create timer-stm32.c Empty, so far. --- timer-stm32.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++ timer.c | 1 + 2 files changed, 64 insertions(+) create mode 100644 timer-stm32.c diff --git a/timer-stm32.c b/timer-stm32.c new file mode 100644 index 0000000..c17e06c --- /dev/null +++ b/timer-stm32.c @@ -0,0 +1,63 @@ + +/** \file + \brief Timer management, ARM specific part. + + To be included from timer.c. +*/ + +#if defined TEACUP_C_INCLUDE && defined __ARM_STM32F411__ + + +/** Timer initialisation. + + Initialise timer and enable system clock interrupt. Step interrupt is + enabled later, when we start using it. +*/ +void timer_init() { +} + +/** Specify how long until the step timer should fire. + + \param delay Delay for the next step interrupt, in CPU ticks. + + \param check_short Tell whether to check for impossibly short requests. This + should be set to 1 for calls from the step interrupt. Short requests + then return 1 and do not schedule a timer interrupt. The calling code + usually wants to handle this case. + + Calls from elsewhere should set it to 0. In this case a timer + interrupt is always scheduled. At the risk that this scheduling + doesn't delay the requested time, but up to a full timer counter + overflow ( = 65536 / F_CPU = 3 to 4 milliseconds). + + \return A flag whether the requested time was too short to allow scheduling + an interrupt. This is meaningful for ACCELERATION_TEMPORAL, where + requested delays can be zero or even negative. In this case, the + calling code should repeat the stepping code immediately and also + assume the timer to not change his idea of when the last step + happened. + + Strategy of this timer is to schedule timer interrupts not starting at the + time of the call, but starting at the time of the previous timer interrupt + fired. This ignores the processing time taken in the step interrupt so far, + offering smooth and even step distribution. Flipside of this coin is, + schedules issued at an arbitrary time can result in drastically wrong delays. + See also discussion of parameter check_short and the return value. + + This enables the step interrupt, but also disables interrupts globally. + So, if you use it from inside the step interrupt, make sure to do so + as late as possible. If you use it from outside the step interrupt, + do a sei() after it to make the interrupt actually fire. +*/ +uint8_t timer_set(int32_t delay, uint8_t check_short) { + return 0; +} + +/** Stop timers. + + This means to be an emergency stop. +*/ +void timer_stop() { +} + +#endif /* defined TEACUP_C_INCLUDE && defined __ARM_STM32F411__ */ diff --git a/timer.c b/timer.c index b9be039..d6cb973 100644 --- a/timer.c +++ b/timer.c @@ -11,6 +11,7 @@ #define TEACUP_C_INCLUDE #include "timer-avr.c" #include "timer-lpc.c" +#include "timer-stm32.c" #undef TEACUP_C_INCLUDE // No common code so far.