timer mocking

This commit is contained in:
Janosch
2022-10-10 22:34:56 +01:00
parent 5c8f5694f0
commit d7673cd292
11 changed files with 53 additions and 15 deletions
+4 -11
View File
@@ -18,8 +18,12 @@
*/
#include <stdint.h>
#include <libopencm3/stm32/usart.h>
#ifdef TEST_COMMON_H
#include "../test/timer_mock.h"
#else
#include <libopencm3/stm32/timer.h>
#include <libopencm3/stm32/rtc.h>
#endif
#include <libopencm3/stm32/can.h>
#include <libopencm3/stm32/iwdg.h>
#include <libopencm3/stm32/crc.h>
@@ -42,7 +46,6 @@
static Stm32Scheduler* scheduler;
static Can* can;
static PiController dcCurController;
static uint32_t startTime;
static void EvseRead()
{
@@ -189,16 +192,6 @@ static bool CheckChargerFaults()
(active3 && ((Param::GetInt(Param::c3flag) & FLAG_FAULT) || timeouts[2]));
}
static bool CheckTimeout()
{
uint32_t now = rtc_get_counter_val();
uint32_t timeout = Param::GetInt(Param::timelim);
timeout *= 60;
return timeout > 0 && (now - startTime) > timeout;
}
static bool CheckDelay()
{
uint32_t now = rtc_get_counter_val();