Prusa3d Marlin fork
system_timer.h
Go to the documentation of this file.
1 
3 #ifndef FIRMWARE_SYSTEM_TIMER_H_
4 #define FIRMWARE_SYSTEM_TIMER_H_
5 
6 #include "Arduino.h"
7 #include "macros.h"
8 #define SYSTEM_TIMER_2
9 
10 #ifdef SYSTEM_TIMER_2
11 #include "timer02.h"
12 #include "tone04.h"
13 #define _millis millis2
14 #define _micros micros2
15 #define _delay delay2
16 #define _tone tone4
17 #define _noTone noTone4
18 
19 #else //SYSTEM_TIMER_2
20 #define _millis millis
21 #define _micros micros
22 #define _delay delay
23 #define _tone tone
24 #define _noTone noTone
25 #endif //SYSTEM_TIMER_2
26 
27 // Timer counter, incremented by the 1ms Arduino timer.
28 // The standard Arduino timer() function returns this value atomically
29 // by disabling / enabling interrupts. This is costly, if the interrupts are known
30 // to be disabled.
31 #ifdef SYSTEM_TIMER_2
32 extern volatile unsigned long timer2_millis;
33 #else //SYSTEM_TIMER_2
34 extern volatile unsigned long timer0_millis;
35 #endif //SYSTEM_TIMER_2
36 
37 // An unsynchronized equivalent to a standard Arduino _millis() function.
38 // To be used inside an interrupt routine.
39 FORCE_INLINE unsigned long millis_nc() {
40 #ifdef SYSTEM_TIMER_2
41  return timer2_millis;
42 #else //SYSTEM_TIMER_2
43  return timer0_millis;
44 #endif //SYSTEM_TIMER_2
45 }
46 
47 #endif /* FIRMWARE_SYSTEM_TIMER_H_ */