Koduino
timebase.h
1 
19 #ifndef _timebase_h_
20 #define _timebase_h_
21 
22 #include "timer.h"
23 
24 #ifdef __cplusplus
25 extern "C"{
26 #endif // __cplusplus
27 
28 
33 // This is a general timer interrupt class, called as
34 //
35 // attachTimerInterrupt(i, ISR, freqHz)
36 //
37 // where i = 0,1,2 for user functions.
38 // i=3 is used for pwmIn
39 // i=4 is used for the system clock (millis / micros)
40 
41 // Make up Arduino-like functions
42 // Minimum freq ~= 0.061Hz, maximum ~= 36MHz)
43 
52 void attachTimerInterrupt(uint8_t i, ISRType ISR, int freqHz);
53 
60 void detachTimerInterrupt(uint8_t i);
61 
66 void noTimerInterrupts();
67 
72 void timerInterrupts();
73  // end of addtogroup
75 
76 
77 // General ISR for all timebase
78 static inline void timebaseISR(uint8_t i, uint8_t timer) __attribute__((always_inline, unused));
79 static inline void timebaseISR(uint8_t i, uint8_t timer) {
80  if (TIM_GetITStatus(TIMER_MAP[timer].TIMx, TIM_IT_Update) != RESET)
81  {
82  TIM_ClearITPendingBit(TIMER_MAP[timer].TIMx, TIM_IT_Update);
83  if (TIMEBASE_MAP[i].isr != 0)
84  TIMEBASE_MAP[i].isr();
85  }
86 }
87 // Specialized timer interrupt initialization functions
88 //
89 // Uses a basic timer to setup up millisecond interrupts such that the period is 1000. OLD...now SysTick
90 // void attachSysClkInterrupt(ISRType ISR);
91 // Highest resolution for PWM in
92 // TIM_TypeDef *attachHighResClkUpdate(ISRType ISR);
93 
94 
95 #ifdef __cplusplus
96 } // extern "C"
97 #endif // __cplusplus
98 
99 #endif
void timerInterrupts()
Re-enable timer interrupts.
Definition: timebase.c:89
Definition: types.h:108
void attachTimerInterrupt(uint8_t i, ISRType ISR, int freqHz)
Begin a timer interrupt.
Definition: timebase.c:61
void noTimerInterrupts()
Disable all timer interrupts.
Definition: timebase.c:83
void detachTimerInterrupt(uint8_t i)
Disable a timer interrupt.
Definition: timebase.c:77