From 6d2358125ac33442de11b4221fb4d45db9969e7b Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Mon, 28 Jan 2019 19:29:31 +0100 Subject: [PATCH] Fix Timer_test broken by conditional translation for SYSTEM_TIMER_2. --- Firmware/Marlin.h | 19 +------------------ Firmware/Timer.cpp | 2 +- Firmware/TimerRemaining.h | 3 ++- Firmware/system_timer.h | 21 +++++++++++++++++++++ Tests/Timer_test.cpp | 5 +++++ 5 files changed, 30 insertions(+), 20 deletions(-) create mode 100644 Firmware/system_timer.h diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 29b1ae5a..11e0a10d 100644 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -16,24 +16,7 @@ #include #include #include - - -#define SYSTEM_TIMER_2 - -#ifdef SYSTEM_TIMER_2 -#include "timer02.h" -#define _millis millis2 -#define _micros micros2 -#define _delay delay2 -#else //SYSTEM_TIMER_2 -#define _millis millis -#define _micros micros -#define _delay delay -#define timer02_set_pwm0(pwm0) -#endif //SYSTEM_TIMER_2 - - - +#include "system_timer.h" #include "fastio.h" #include "Configuration.h" #include "pins.h" diff --git a/Firmware/Timer.cpp b/Firmware/Timer.cpp index a528ab57..a94a8586 100644 --- a/Firmware/Timer.cpp +++ b/Firmware/Timer.cpp @@ -4,7 +4,7 @@ */ #include "Timer.h" -#include "Marlin.h" +#include "system_timer.h" /** * @brief construct Timer diff --git a/Firmware/TimerRemaining.h b/Firmware/TimerRemaining.h index 46cea825..1a9138cb 100644 --- a/Firmware/TimerRemaining.h +++ b/Firmware/TimerRemaining.h @@ -7,7 +7,8 @@ #define TIMERREMAINING_H #include "Timer.h" -#include "Marlin.h" +#include "Arduino.h" +#include "system_timer.h" #include class TimerRemaining : public LongTimer diff --git a/Firmware/system_timer.h b/Firmware/system_timer.h new file mode 100644 index 00000000..045ce728 --- /dev/null +++ b/Firmware/system_timer.h @@ -0,0 +1,21 @@ +//! @file + +#ifndef FIRMWARE_SYSTEM_TIMER_H_ +#define FIRMWARE_SYSTEM_TIMER_H_ + +#include "Arduino.h" +#define SYSTEM_TIMER_2 + +#ifdef SYSTEM_TIMER_2 +#include "timer02.h" +#define _millis millis2 +#define _micros micros2 +#define _delay delay2 +#else //SYSTEM_TIMER_2 +#define _millis millis +#define _micros micros +#define _delay delay +#define timer02_set_pwm0(pwm0) +#endif //SYSTEM_TIMER_2 + +#endif /* FIRMWARE_SYSTEM_TIMER_H_ */ diff --git a/Tests/Timer_test.cpp b/Tests/Timer_test.cpp index 91c37e32..6f8ee75c 100644 --- a/Tests/Timer_test.cpp +++ b/Tests/Timer_test.cpp @@ -15,6 +15,11 @@ unsigned long millis() return now; } +unsigned long millis2() +{ + return now; +} + static void basicTimer() { LongTimer timer;