mocked timer test, EvseRead

This commit is contained in:
Janosch
2022-10-11 00:05:01 +01:00
parent 52877fb3ea
commit 7b038d5243
10 changed files with 133 additions and 79 deletions
+4 -2
View File
@@ -31,8 +31,10 @@ class AnaIn{
ANA_IN_LIST
#undef ANA_IN_ENTRY
bool Get() { return 1; }
void Set() {}
int val = 7;
int Get() { return val; }
void Set(int param) { val = param;}
};
+1
View File
@@ -21,6 +21,7 @@ int main() {
(TestCase){"test_disable_all", test_disable_all},
(TestCase){"test_calc_totals", test_calc_totals},
(TestCase){"test_check_timeout", test_check_timeout},
(TestCase){"test_evse_read", test_evse_read},
// Example:
//(TestCase){"Your tests name", function_name_without_brackets}
//...
BIN
View File
Binary file not shown.
+23
View File
@@ -50,3 +50,26 @@ void test_check_timeout()
res = CheckTimeout();
assert(res);
}
void test_evse_read()
{
// INP_MANUAL
Param::SetInt(Param::inputype, INP_MANUAL);
EvseRead();
assert(0 == Param::GetInt(Param::proximity));
assert(32 == Param::GetInt(Param::cablelim));
// INP_TYPE1
//under threshold
Param::SetInt(Param::inputype, INP_TYPE1);
EvseRead();
assert(1 == Param::GetInt(Param::proximity));
assert(40 == Param::GetInt(Param::cablelim));
//above
Param::SetInt(Param::inputype, INP_TYPE1);
AnaIn::cablelim.Set(2222);
EvseRead();
assert(0 == Param::GetInt(Param::proximity));
assert(0 == Param::GetInt(Param::cablelim));
}
+7
View File
@@ -3,3 +3,10 @@
uint32_t rtc_get_counter_val(){
return Param::Get(Param::test_time) >> 5;
}
bool timer_get_flag(uint32_t timer_peripheral, uint32_t flag){
return Param::Get(Param::test_timer_flag);
}
float timer_get_ic_value(uint32_t timer_peripheral, enum tim_ic_id ic_id){
return Param::GetFloat(Param::test_timer_icvalue);
}
+19
View File
@@ -1,3 +1,22 @@
#include <stdint.h>
#include "../libopeninv/include/params.h"
#ifndef TEST_TMOCK_H
#define TEST_TMOCK_H
#define TIM_SR_CC2IF (1 << 2)
#define PERIPH_BASE (0x40000000U)
#define PERIPH_BASE_APB1 (PERIPH_BASE + 0x00000)
#define TIM3_BASE (PERIPH_BASE_APB1 + 0x0400)
#define TIM3 TIM3_BASE
enum tim_ic_id {
TIM_IC1,
TIM_IC2,
TIM_IC3,
TIM_IC4,
};
uint32_t rtc_get_counter_val();
bool timer_get_flag(uint32_t timer_peripheral, uint32_t flag);
float timer_get_ic_value(uint32_t timer_peripheral, enum tim_ic_id ic_id);
#endif