2019-01-28 19:29:31 +01:00
|
|
|
//! @file
|
|
|
|
|
|
|
|
#ifndef FIRMWARE_SYSTEM_TIMER_H_
|
|
|
|
#define FIRMWARE_SYSTEM_TIMER_H_
|
|
|
|
|
|
|
|
#include "Arduino.h"
|
2022-05-14 17:41:17 +02:00
|
|
|
#include "macros.h"
|
2019-07-08 16:42:21 +02:00
|
|
|
#define SYSTEM_TIMER_2
|
2019-01-28 19:29:31 +01:00
|
|
|
|
|
|
|
#ifdef SYSTEM_TIMER_2
|
|
|
|
#include "timer02.h"
|
2020-06-01 18:58:15 +03:00
|
|
|
#include "tone04.h"
|
2019-01-28 19:29:31 +01:00
|
|
|
#define _millis millis2
|
|
|
|
#define _micros micros2
|
|
|
|
#define _delay delay2
|
2020-06-01 18:58:15 +03:00
|
|
|
#define _tone tone4
|
|
|
|
#define _noTone noTone4
|
2019-07-08 16:42:21 +02:00
|
|
|
|
|
|
|
#define timer02_set_pwm0(pwm0)
|
|
|
|
|
2019-01-28 19:29:31 +01:00
|
|
|
#else //SYSTEM_TIMER_2
|
|
|
|
#define _millis millis
|
|
|
|
#define _micros micros
|
|
|
|
#define _delay delay
|
2019-07-30 16:05:40 +03:00
|
|
|
#define _tone tone
|
|
|
|
#define _noTone noTone
|
2019-01-28 19:29:31 +01:00
|
|
|
#define timer02_set_pwm0(pwm0)
|
|
|
|
#endif //SYSTEM_TIMER_2
|
|
|
|
|
2022-05-14 17:41:17 +02:00
|
|
|
// Timer counter, incremented by the 1ms Arduino timer.
|
|
|
|
// The standard Arduino timer() function returns this value atomically
|
|
|
|
// by disabling / enabling interrupts. This is costly, if the interrupts are known
|
|
|
|
// to be disabled.
|
|
|
|
#ifdef SYSTEM_TIMER_2
|
|
|
|
extern volatile unsigned long timer2_millis;
|
|
|
|
#else //SYSTEM_TIMER_2
|
|
|
|
extern volatile unsigned long timer0_millis;
|
|
|
|
#endif //SYSTEM_TIMER_2
|
|
|
|
|
|
|
|
// An unsynchronized equivalent to a standard Arduino _millis() function.
|
|
|
|
// To be used inside an interrupt routine.
|
|
|
|
FORCE_INLINE unsigned long millis_nc() {
|
|
|
|
#ifdef SYSTEM_TIMER_2
|
|
|
|
return timer2_millis;
|
|
|
|
#else //SYSTEM_TIMER_2
|
|
|
|
return timer0_millis;
|
|
|
|
#endif //SYSTEM_TIMER_2
|
|
|
|
}
|
|
|
|
|
2019-01-28 19:29:31 +01:00
|
|
|
#endif /* FIRMWARE_SYSTEM_TIMER_H_ */
|