Repo unification
This commit is contained in:
8
firmware/tests/Units_Tests.workspace
Normal file
8
firmware/tests/Units_Tests.workspace
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_workspace_file>
|
||||
<Workspace title="Workspace">
|
||||
<Project filename="uDCCD_Unit_Tests_BSP.cbp" />
|
||||
<Project filename="uDCCD_Unit_Tests_HW.cbp" />
|
||||
<Project filename="uDCCD_Unit_Tests_Logic.cbp" />
|
||||
</Workspace>
|
||||
</CodeBlocks_workspace_file>
|
||||
6
firmware/tests/Units_Tests.workspace.layout
Normal file
6
firmware/tests/Units_Tests.workspace.layout
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_workspace_layout_file>
|
||||
<FileVersion major="1" minor="0" />
|
||||
<ActiveProject path="uDCCD_Unit_Tests_Logic.cbp" />
|
||||
<PreferredTarget name="Debug" />
|
||||
</CodeBlocks_workspace_layout_file>
|
||||
147
firmware/tests/bsp_main.c
Normal file
147
firmware/tests/bsp_main.c
Normal file
@@ -0,0 +1,147 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "ut_utils/ut_utils.h"
|
||||
#include "ut_utils/ut_fault.h"
|
||||
#include "ut_utils/ut_fuses.h"
|
||||
|
||||
#include "ut_board/ut_ain.h"
|
||||
#include "ut_board/ut_din.h"
|
||||
#include "ut_board/ut_dout.h"
|
||||
#include "ut_board/ut_halfbridge.h"
|
||||
#include "ut_board/ut_odout.h"
|
||||
#include "ut_board/ut_setup.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
int tr;
|
||||
int pass = 1;
|
||||
|
||||
/* UTILITIES TESTS */
|
||||
printf("******************************************************\n");
|
||||
|
||||
tr = ut_util_invert_8b_test();
|
||||
if(!tr) pass = 0;
|
||||
|
||||
tr = ut_util_sat_add_8b_test();
|
||||
if(!tr) pass = 0;
|
||||
|
||||
tr = ut_util_sat_subtract_8b_test();
|
||||
if(!tr) pass = 0;
|
||||
|
||||
tr = ut_util_sat_util_sat_add_16b_test();
|
||||
if(!tr) pass = 0;
|
||||
|
||||
tr = ut_util_sat_subtract_16b_test();
|
||||
if(!tr) pass = 0;
|
||||
|
||||
tr = ut_util_limit_u32b_to_u16b_test();
|
||||
if(!tr) pass = 0;
|
||||
|
||||
tr = ut_util_limit_s32b_to_u16b_test();
|
||||
if(!tr) pass = 0;
|
||||
|
||||
tr = ut_util_convert_muldivoff_test();
|
||||
if(!tr) pass = 0;
|
||||
|
||||
tr = ut_util_sat_mul_kilo_test();
|
||||
if(!tr) pass = 0;
|
||||
|
||||
tr = ut_util_sat_div_kilo_test();
|
||||
if(!tr) pass = 0;
|
||||
|
||||
tr = ut_util_sat_ratio_16b_test();
|
||||
if(!tr) pass = 0;
|
||||
|
||||
tr = ut_util_percent_to_16b_test();
|
||||
if(!tr) pass = 0;
|
||||
|
||||
/* FAULT TESTS */
|
||||
printf("******************************************************\n");
|
||||
|
||||
tr = ut_fault_process_test();
|
||||
if(!tr) pass = 0;
|
||||
|
||||
tr = ut_fault_is_active_test();
|
||||
if(!tr) pass = 0;
|
||||
|
||||
tr = ut_fault_is_warning_test();
|
||||
if(!tr) pass = 0;
|
||||
|
||||
tr = ut_fault_reset_test();
|
||||
if(!tr) pass = 0;
|
||||
|
||||
/* FUSE TESTS */
|
||||
printf("******************************************************\n");
|
||||
|
||||
tr = ut_fuse_reset_test();
|
||||
if(!tr) pass = 0;
|
||||
|
||||
/* AIN TESTS */
|
||||
printf("******************************************************\n");
|
||||
|
||||
tr = ut_bsp_ain_read_test();
|
||||
if(!tr) pass = 0;
|
||||
|
||||
/* DIN TESTS */
|
||||
printf("******************************************************\n");
|
||||
|
||||
tr = ut_bsp_din_read_test();
|
||||
if(!tr) pass = 0;
|
||||
|
||||
/* DOUT TESTS */
|
||||
printf("******************************************************\n");
|
||||
|
||||
tr = ut_bsp_dout_write_test();
|
||||
if(!tr) pass = 0;
|
||||
|
||||
/* HALFBRIDGE TESTS */
|
||||
printf("******************************************************\n");
|
||||
|
||||
tr = ut_bsp_hb_write_low_test();
|
||||
if(!tr) pass = 0;
|
||||
|
||||
tr = ut_bsp_hb_write_pwm_test();
|
||||
if(!tr) pass = 0;
|
||||
|
||||
tr = ut_bsp_hb_read_meas_test();
|
||||
if(!tr) pass = 0;
|
||||
|
||||
/* ODOUT TESTS */
|
||||
printf("******************************************************\n");
|
||||
|
||||
tr = ut_bsp_odout_write_test();
|
||||
if(!tr) pass = 0;
|
||||
|
||||
tr = ut_bsp_odout_write_common_test();
|
||||
if(!tr) pass = 0;
|
||||
|
||||
/* SETUP TESTS */
|
||||
printf("******************************************************\n");
|
||||
|
||||
tr = ut_bsp_startup_test();
|
||||
if(!tr) pass = 0;
|
||||
|
||||
/* FINAL RESULT */
|
||||
printf("******************************************************\n");
|
||||
|
||||
tr = ut_util_interpolate_1d_u16b_test();
|
||||
if(!tr) pass = 0;
|
||||
|
||||
tr = ut_util_interpolate_2d_u16b_test();
|
||||
if(!tr) pass = 0;
|
||||
|
||||
|
||||
if(pass)
|
||||
{
|
||||
printf("ALL PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("SOME FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
102
firmware/tests/hw_main.c
Normal file
102
firmware/tests/hw_main.c
Normal file
@@ -0,0 +1,102 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "ut_hw/ut_analog.h"
|
||||
#include "ut_hw/ut_buttons.h"
|
||||
#include "ut_hw/ut_hb_control.h"
|
||||
#include "ut_hw/ut_led_display.h"
|
||||
#include "ut_hw/ut_startup.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
int tr;
|
||||
int pass = 1;
|
||||
int t_cnt = 0;
|
||||
int f_cnt = 0;
|
||||
|
||||
/* ANALOG TESTS */
|
||||
printf("******************************************************\n");
|
||||
|
||||
tr = ut_analog_ch_get_test();
|
||||
t_cnt++;
|
||||
if(!tr){ pass = 0; f_cnt++;};
|
||||
|
||||
/* BUTTON TESTS */
|
||||
printf("******************************************************\n");
|
||||
|
||||
tr = ut_btn_reset_test();
|
||||
t_cnt++;
|
||||
if(!tr){ pass = 0; f_cnt++;};
|
||||
|
||||
tr = ut_btn_process_test();
|
||||
t_cnt++;
|
||||
if(!tr){ pass = 0; f_cnt++;};
|
||||
|
||||
tr = ut_btn_ch_process_test();
|
||||
t_cnt++;
|
||||
if(!tr){ pass = 0; f_cnt++;};
|
||||
|
||||
tr = ut_btn_ch_set_pull_test();
|
||||
t_cnt++;
|
||||
if(!tr){ pass = 0; f_cnt++;};
|
||||
|
||||
/* HALFBRIDGE CONTROL TESTS */
|
||||
printf("******************************************************\n");
|
||||
|
||||
tr = ut_hb_is_equal_fb_struct_test();
|
||||
t_cnt++;
|
||||
if(!tr){ pass = 0; f_cnt++;};
|
||||
|
||||
tr = ut_hb_is_equal_ctrl_struct_test();
|
||||
t_cnt++;
|
||||
if(!tr){ pass = 0; f_cnt++;};
|
||||
|
||||
tr = ut_hb_init_test();
|
||||
t_cnt++;
|
||||
if(!tr){ pass = 0; f_cnt++;};
|
||||
|
||||
tr = ut_hb_enable_test();
|
||||
t_cnt++;
|
||||
if(!tr){ pass = 0; f_cnt++;};
|
||||
|
||||
tr = ut_hb_disable_test();
|
||||
t_cnt++;
|
||||
if(!tr){ pass = 0; f_cnt++;};
|
||||
|
||||
tr = ut_hb_process_test();
|
||||
t_cnt++;
|
||||
if(!tr){ pass = 0; f_cnt++;};
|
||||
|
||||
/* DISPLAY TESTS */
|
||||
printf("******************************************************\n");
|
||||
|
||||
tr = ut_led_dsp_set_image_test();
|
||||
t_cnt++;
|
||||
if(!tr){ pass = 0; f_cnt++;};
|
||||
|
||||
tr = ut_led_dsp_backligth_set_test();
|
||||
t_cnt++;
|
||||
if(!tr){ pass = 0; f_cnt++;};
|
||||
|
||||
/* STARTUP TESTS */
|
||||
printf("******************************************************\n");
|
||||
|
||||
tr = ut_hw_startup_test();
|
||||
t_cnt++;
|
||||
if(!tr){ pass = 0; f_cnt++;};
|
||||
|
||||
printf("******************************************************\n");
|
||||
printf("\n%d TESTS DONE\n", t_cnt);
|
||||
if(pass)
|
||||
{
|
||||
printf("ALL PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("%d FAILED\n\n", f_cnt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
98
firmware/tests/logic_main.c
Normal file
98
firmware/tests/logic_main.c
Normal file
@@ -0,0 +1,98 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "ut_logic/ut_coil.h"
|
||||
#include "ut_logic/ut_display.h"
|
||||
#include "ut_logic/ut_force.h"
|
||||
#include "ut_logic/ut_pot.h"
|
||||
#include "ut_logic/ut_user_force.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
int tr;
|
||||
int pass = 1;
|
||||
int t_cnt = 0;
|
||||
int f_cnt = 0;
|
||||
|
||||
/* COIL TESTS */
|
||||
printf("******************************************************\n");
|
||||
|
||||
tr = ut_coil_target_test();
|
||||
t_cnt++;
|
||||
if(!tr){ pass = 0; f_cnt++;};
|
||||
|
||||
/* DISPLAY TESTS */
|
||||
printf("******************************************************\n");
|
||||
|
||||
tr = ut_dsp_init_ctrl_test();
|
||||
t_cnt++;
|
||||
if(!tr){ pass = 0; f_cnt++;};
|
||||
|
||||
tr = ut_dsp_set_lock_test();
|
||||
t_cnt++;
|
||||
if(!tr){ pass = 0; f_cnt++;};
|
||||
|
||||
tr = ut_dsp_reset_lock_test();
|
||||
t_cnt++;
|
||||
if(!tr){ pass = 0; f_cnt++;};
|
||||
|
||||
tr = ut_dsp_img_percent_test();
|
||||
t_cnt++;
|
||||
if(!tr){ pass = 0; f_cnt++;};
|
||||
|
||||
tr = ut_dsp_img_raw_test();
|
||||
t_cnt++;
|
||||
if(!tr){ pass = 0; f_cnt++;};
|
||||
|
||||
tr = ut_dsp_get_act_img_test();
|
||||
t_cnt++;
|
||||
if(!tr){ pass = 0; f_cnt++;};
|
||||
|
||||
tr = ut_dsp_backlight_test();
|
||||
t_cnt++;
|
||||
if(!tr){ pass = 0; f_cnt++;};
|
||||
|
||||
/* FORCE TESTS */
|
||||
printf("******************************************************\n");
|
||||
|
||||
tr = ut_force_cycle_bmode_test();
|
||||
t_cnt++;
|
||||
if(!tr){ pass = 0; f_cnt++;};
|
||||
|
||||
tr = ut_force_next_test();
|
||||
t_cnt++;
|
||||
if(!tr){ pass = 0; f_cnt++;};
|
||||
|
||||
/* POT TESTS */
|
||||
printf("******************************************************\n");
|
||||
|
||||
tr = ut_pot_mv_to_percent_test();
|
||||
t_cnt++;
|
||||
if(!tr){ pass = 0; f_cnt++;};
|
||||
|
||||
/* USER FORCE TESTS */
|
||||
printf("******************************************************\n");
|
||||
|
||||
tr = ut_user_force_btn_test();
|
||||
t_cnt++;
|
||||
if(!tr){ pass = 0; f_cnt++;};
|
||||
|
||||
tr = ut_user_force_pot_test();
|
||||
t_cnt++;
|
||||
if(!tr){ pass = 0; f_cnt++;};
|
||||
|
||||
printf("******************************************************\n");
|
||||
printf("\n%d TESTS DONE\n", t_cnt);
|
||||
if(pass)
|
||||
{
|
||||
printf("ALL PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("%d FAILED\n\n", f_cnt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
32
firmware/tests/mock_board/mock_board_ain.c
Normal file
32
firmware/tests/mock_board/mock_board_ain.c
Normal file
@@ -0,0 +1,32 @@
|
||||
#include "mock_board_ain.h"
|
||||
|
||||
#define AIN_CH_CNT 5
|
||||
static uint8_t ain_ch = 0;
|
||||
static uint16_t ain_data[AIN_CH_CNT+1];
|
||||
|
||||
uint16_t bsp_ain_read(uint8_t ch)
|
||||
{
|
||||
if(ch > AIN_CH_CNT) return 0;
|
||||
ain_ch = ch;
|
||||
return ain_data[ch];
|
||||
}
|
||||
|
||||
uint8_t mock_board_ain_read_ch(void)
|
||||
{
|
||||
return ain_ch;
|
||||
}
|
||||
|
||||
void mock_board_ain_write_ch(uint8_t ch)
|
||||
{
|
||||
ain_ch = ch;
|
||||
}
|
||||
|
||||
uint16_t mock_board_ain_read_data(uint8_t ch)
|
||||
{
|
||||
return ain_data[ch];
|
||||
}
|
||||
|
||||
void mock_board_ain_write_data(uint8_t ch, uint16_t value)
|
||||
{
|
||||
ain_data[ch] = value;
|
||||
}
|
||||
14
firmware/tests/mock_board/mock_board_ain.h
Normal file
14
firmware/tests/mock_board/mock_board_ain.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef MOCK_BOARD_AIN_
|
||||
#define MOCK_BOARD_AIN_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "..\..\src\hw\board\ain.h"
|
||||
|
||||
uint8_t mock_board_ain_read_ch(void);
|
||||
void mock_board_ain_write_ch(uint8_t ch);
|
||||
uint16_t mock_board_ain_read_data(uint8_t ch);
|
||||
void mock_board_ain_write_data(uint8_t ch, uint16_t value);
|
||||
|
||||
#endif /* MOCK_BOARD_AIN_ */
|
||||
32
firmware/tests/mock_board/mock_board_din.c
Normal file
32
firmware/tests/mock_board/mock_board_din.c
Normal file
@@ -0,0 +1,32 @@
|
||||
#include "mock_board_din.h"
|
||||
|
||||
#define DIN_CH_CNT 9
|
||||
static uint8_t din_ch = 0;
|
||||
static uint8_t din_data[DIN_CH_CNT];
|
||||
|
||||
uint8_t bsp_din_read(uint8_t ch)
|
||||
{
|
||||
if(ch >= DIN_CH_CNT) return BSP_DIN_LOW;
|
||||
din_ch = ch;
|
||||
return din_data[ch];
|
||||
}
|
||||
|
||||
uint8_t mock_board_din_read_ch(void)
|
||||
{
|
||||
return din_ch;
|
||||
}
|
||||
|
||||
void mock_board_din_write_ch(uint8_t ch)
|
||||
{
|
||||
din_ch = ch;
|
||||
}
|
||||
|
||||
uint8_t mock_board_din_read_data(uint8_t ch)
|
||||
{
|
||||
return din_data[ch];
|
||||
}
|
||||
|
||||
void mock_board_din_write_data(uint8_t ch, uint8_t value)
|
||||
{
|
||||
din_data[ch] = value;
|
||||
}
|
||||
14
firmware/tests/mock_board/mock_board_din.h
Normal file
14
firmware/tests/mock_board/mock_board_din.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef MOCK_BOARD_DIN_
|
||||
#define MOCK_BOARD_DIN_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "..\..\src\hw\board\din.h"
|
||||
|
||||
uint8_t mock_board_din_read_ch(void);
|
||||
void mock_board_din_write_ch(uint8_t ch);
|
||||
uint8_t mock_board_din_read_data(uint8_t ch);
|
||||
void mock_board_din_write_data(uint8_t ch, uint8_t value);
|
||||
|
||||
#endif /* MOCK_BOARD_DIN_ */
|
||||
31
firmware/tests/mock_board/mock_board_dout.c
Normal file
31
firmware/tests/mock_board/mock_board_dout.c
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "mock_board_dout.h"
|
||||
|
||||
#define DOUT_CH_CNT 7
|
||||
static uint8_t dout_ch = 0;
|
||||
static int8_t dout_data[DOUT_CH_CNT];
|
||||
|
||||
void bsp_dout_write(uint8_t ch, int8_t lvl)
|
||||
{
|
||||
if(ch < DOUT_CH_CNT) dout_data[ch] = lvl;
|
||||
dout_ch = ch;
|
||||
}
|
||||
|
||||
uint8_t mock_board_dout_read_ch(void)
|
||||
{
|
||||
return dout_ch;
|
||||
}
|
||||
|
||||
void mock_board_dout_write_ch(uint8_t ch)
|
||||
{
|
||||
dout_ch = ch;
|
||||
}
|
||||
|
||||
int8_t mock_board_dout_read_data(uint8_t ch)
|
||||
{
|
||||
return dout_data[ch];
|
||||
}
|
||||
|
||||
void mock_board_dout_write_data(uint8_t ch, int8_t lvl)
|
||||
{
|
||||
dout_data[ch] = lvl;
|
||||
}
|
||||
14
firmware/tests/mock_board/mock_board_dout.h
Normal file
14
firmware/tests/mock_board/mock_board_dout.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef MOCK_BOARD_DOUT_
|
||||
#define MOCK_BOARD_DOUT_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "..\..\src\hw\board\dout.h"
|
||||
|
||||
uint8_t mock_board_dout_read_ch(void);
|
||||
void mock_board_dout_write_ch(uint8_t ch);
|
||||
int8_t mock_board_dout_read_data(uint8_t ch);
|
||||
void mock_board_dout_write_data(uint8_t ch, int8_t lvl);
|
||||
|
||||
#endif /* MOCK_BOARD_DOUT_ */
|
||||
76
firmware/tests/mock_board/mock_board_halfbridge.c
Normal file
76
firmware/tests/mock_board/mock_board_halfbridge.c
Normal file
@@ -0,0 +1,76 @@
|
||||
#include "mock_board_halfbridge.h"
|
||||
|
||||
#define DOUT_CH_CNT 6
|
||||
static uint8_t low_ctrl = 0;
|
||||
static uint16_t pwm_ctrl = 0;
|
||||
static hb_meas_t feedback;
|
||||
|
||||
void bsp_hb_write_low(uint8_t state)
|
||||
{
|
||||
low_ctrl = state;
|
||||
}
|
||||
|
||||
void bsp_hb_write_pwm(uint16_t pwm)
|
||||
{
|
||||
pwm_ctrl = pwm;
|
||||
}
|
||||
|
||||
void bsp_hb_read_meas(hb_meas_t* measurements)
|
||||
{
|
||||
measurements->out_voltage = feedback.out_voltage;
|
||||
measurements->out_current = feedback.out_current;
|
||||
measurements->sup_voltage = feedback.sup_voltage;
|
||||
measurements->sup_current = feedback.sup_current;
|
||||
measurements->out_power = feedback.out_power;
|
||||
measurements->sup_power = feedback.sup_power;
|
||||
measurements->out_impedance = feedback.out_impedance;
|
||||
measurements->low_side_ctrl = feedback.low_side_ctrl;
|
||||
measurements->pwm = feedback.pwm;
|
||||
}
|
||||
|
||||
|
||||
uint8_t mock_board_halfbridge_read_low(void)
|
||||
{
|
||||
return low_ctrl;
|
||||
}
|
||||
|
||||
void mock_board_halfbridge_write_low(uint8_t state)
|
||||
{
|
||||
low_ctrl = state;
|
||||
}
|
||||
|
||||
uint16_t mock_board_halfbridge_read_pwm(void)
|
||||
{
|
||||
return pwm_ctrl;
|
||||
}
|
||||
|
||||
void mock_board_halfbridge_write_pwm(uint16_t pwm)
|
||||
{
|
||||
pwm_ctrl = pwm;
|
||||
}
|
||||
|
||||
void mock_board_halfbridge_read_feedback(hb_meas_t* measurements)
|
||||
{
|
||||
measurements->out_voltage = feedback.out_voltage;
|
||||
measurements->out_current = feedback.out_current;
|
||||
measurements->sup_voltage = feedback.sup_voltage;
|
||||
measurements->sup_current = feedback.sup_current;
|
||||
measurements->out_power = feedback.out_power;
|
||||
measurements->sup_power = feedback.sup_power;
|
||||
measurements->out_impedance = feedback.out_impedance;
|
||||
measurements->low_side_ctrl = feedback.low_side_ctrl;
|
||||
measurements->pwm = feedback.pwm;
|
||||
}
|
||||
|
||||
void mock_board_halfbridge_write_feedback(hb_meas_t* new_fb)
|
||||
{
|
||||
feedback.out_voltage = new_fb->out_voltage;
|
||||
feedback.out_current = new_fb->out_current;
|
||||
feedback.sup_voltage = new_fb->sup_voltage;
|
||||
feedback.sup_current = new_fb->sup_current;
|
||||
feedback.out_power = new_fb->out_power;
|
||||
feedback.sup_power = new_fb->sup_power;
|
||||
feedback.out_impedance = new_fb->out_impedance;
|
||||
feedback.low_side_ctrl = new_fb->low_side_ctrl;
|
||||
feedback.pwm = new_fb->pwm;
|
||||
}
|
||||
18
firmware/tests/mock_board/mock_board_halfbridge.h
Normal file
18
firmware/tests/mock_board/mock_board_halfbridge.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef MOCK_BOARD_HALFBRIDGE_
|
||||
#define MOCK_BOARD_HALFBRIDGE_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "..\..\src\hw\board\halfbridge.h"
|
||||
|
||||
uint8_t mock_board_halfbridge_read_low(void);
|
||||
void mock_board_halfbridge_write_low(uint8_t state);
|
||||
|
||||
uint16_t mock_board_halfbridge_read_pwm(void);
|
||||
void mock_board_halfbridge_write_pwm(uint16_t pwm);
|
||||
|
||||
void mock_board_halfbridge_read_feedback(hb_meas_t* measurements);
|
||||
void mock_board_halfbridge_write_feedback(hb_meas_t* new_fb);
|
||||
|
||||
#endif /* MOCK_BOARD_HALFBRIDGE_ */
|
||||
47
firmware/tests/mock_board/mock_board_odout.c
Normal file
47
firmware/tests/mock_board/mock_board_odout.c
Normal file
@@ -0,0 +1,47 @@
|
||||
#include "mock_board_odout.h"
|
||||
|
||||
#define ODOUT_CH_CNT 7
|
||||
static uint8_t odout_ch = 0;
|
||||
static int8_t odout_data[ODOUT_CH_CNT];
|
||||
static uint8_t common_pwm = 0;
|
||||
|
||||
void bsp_odout_write(uint8_t ch, int8_t lvl)
|
||||
{
|
||||
if(ch < ODOUT_CH_CNT) odout_data[ch] = lvl;
|
||||
odout_ch = ch;
|
||||
}
|
||||
|
||||
void bsp_odout_write_common(uint8_t percent)
|
||||
{
|
||||
common_pwm = percent;
|
||||
}
|
||||
|
||||
uint8_t mock_board_odout_read_ch(void)
|
||||
{
|
||||
return odout_ch;
|
||||
}
|
||||
|
||||
void mock_board_odout_write_ch(uint8_t ch)
|
||||
{
|
||||
odout_ch = ch;
|
||||
}
|
||||
|
||||
int8_t mock_board_odout_read_data(uint8_t ch)
|
||||
{
|
||||
return odout_data[ch];
|
||||
}
|
||||
|
||||
void mock_board_odout_write_data(uint8_t ch, int8_t lvl)
|
||||
{
|
||||
odout_data[ch] = lvl;
|
||||
}
|
||||
|
||||
uint8_t mock_board_odout_read_pwm(void)
|
||||
{
|
||||
return common_pwm;
|
||||
}
|
||||
|
||||
void mock_board_odout_write_pwm(uint8_t percent)
|
||||
{
|
||||
common_pwm = percent;
|
||||
}
|
||||
16
firmware/tests/mock_board/mock_board_odout.h
Normal file
16
firmware/tests/mock_board/mock_board_odout.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef MOCK_BOARD_ODOUT_
|
||||
#define MOCK_BOARD_ODOUT_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "..\..\src\hw\board\odout.h"
|
||||
|
||||
uint8_t mock_board_odout_read_ch(void);
|
||||
void mock_board_odout_write_ch(uint8_t ch);
|
||||
int8_t mock_board_odout_read_data(uint8_t ch);
|
||||
void mock_board_odout_write_data(uint8_t ch, int8_t lvl);
|
||||
uint8_t mock_board_odout_read_pwm(void);
|
||||
void mock_board_odout_write_pwm(uint8_t percent);
|
||||
|
||||
#endif /* MOCK_BOARD_ODOUT_ */
|
||||
18
firmware/tests/mock_board/mock_board_setup.c
Normal file
18
firmware/tests/mock_board/mock_board_setup.c
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "mock_board_setup.h"
|
||||
|
||||
static uint8_t setup_called = 0;
|
||||
|
||||
void bsp_startup(void)
|
||||
{
|
||||
setup_called = 1;
|
||||
}
|
||||
|
||||
uint8_t mock_board_setup_read_called(void)
|
||||
{
|
||||
return setup_called;
|
||||
}
|
||||
|
||||
void mock_board_setup_reset_called(void)
|
||||
{
|
||||
setup_called = 0;
|
||||
}
|
||||
12
firmware/tests/mock_board/mock_board_setup.h
Normal file
12
firmware/tests/mock_board/mock_board_setup.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef MOCK_BOARD_SETUP_
|
||||
#define MOCK_BOARD_SETUP_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "..\..\src\hw\board\setup.h"
|
||||
|
||||
uint8_t mock_board_setup_read_called(void);
|
||||
void mock_board_setup_reset_called(void);
|
||||
|
||||
#endif /* MOCK_BOARD_SETUP_ */
|
||||
178
firmware/tests/mock_mcu/mock_mcu_hal_r8.c
Normal file
178
firmware/tests/mock_mcu/mock_mcu_hal_r8.c
Normal file
@@ -0,0 +1,178 @@
|
||||
#include "..\..\src\hw\board\mcu\mcu_hal.h"
|
||||
#include "mock_mcu_hal_r8.h"
|
||||
|
||||
// Startup-Configuration functions
|
||||
static startupCfg_t saved_hwCfg;
|
||||
|
||||
void mcu_startup(startupCfg_t* hwCfg)
|
||||
{
|
||||
saved_hwCfg.adc_clk = hwCfg->adc_clk;
|
||||
saved_hwCfg.pwm_clk = hwCfg->pwm_clk;
|
||||
saved_hwCfg.pwm_top = hwCfg->pwm_top;
|
||||
saved_hwCfg.pwm_chb_en = hwCfg->pwm_chb_en;
|
||||
}
|
||||
|
||||
void mock_mcu_startup_read_cfg(startupCfg_t* cfg_out)
|
||||
{
|
||||
cfg_out->adc_clk = saved_hwCfg.adc_clk;
|
||||
cfg_out->pwm_clk = saved_hwCfg.pwm_clk;
|
||||
cfg_out->pwm_top = saved_hwCfg.pwm_top;
|
||||
cfg_out->pwm_chb_en = saved_hwCfg.pwm_chb_en;
|
||||
}
|
||||
|
||||
void mock_mcu_startup_write_cfg(startupCfg_t* cfg_in)
|
||||
{
|
||||
saved_hwCfg.adc_clk = cfg_in->adc_clk;
|
||||
saved_hwCfg.pwm_clk = cfg_in->pwm_clk;
|
||||
saved_hwCfg.pwm_top = cfg_in->pwm_top;
|
||||
saved_hwCfg.pwm_chb_en = cfg_in->pwm_chb_en;
|
||||
}
|
||||
|
||||
// ADC Interface functions
|
||||
#define ADC_CH_CNT 16
|
||||
static uint8_t adc_ch = 0;
|
||||
static uint16_t adc_raw[ADC_CH_CNT];
|
||||
|
||||
uint16_t mcu_adc_read(uint8_t ch)
|
||||
{
|
||||
adc_ch = ch;
|
||||
|
||||
//Safe guard mux
|
||||
if(ch > (ADC_CH_CNT-1)) return 0xFFFF;
|
||||
// Not available channels
|
||||
if((ch > 8) && (ch<14)) return 0xFFFF;
|
||||
|
||||
return adc_raw[ch];
|
||||
}
|
||||
|
||||
uint8_t mock_mcu_adc_read_ch(void)
|
||||
{
|
||||
return adc_ch;
|
||||
}
|
||||
|
||||
void mock_mcu_adc_set_ch(uint8_t new_ch)
|
||||
{
|
||||
adc_ch = new_ch;
|
||||
}
|
||||
|
||||
uint16_t mock_mcu_adc_read_raw(uint8_t ch)
|
||||
{
|
||||
return adc_raw[ch];
|
||||
}
|
||||
|
||||
void mock_mcu_adc_set_raw(uint16_t new_adc_out, uint8_t ch)
|
||||
{
|
||||
adc_raw[ch] = new_adc_out;
|
||||
}
|
||||
|
||||
// PWM Timer Interface functions
|
||||
#define PWM_CH_CNT 2
|
||||
static uint8_t pwm_ch = 0;
|
||||
static uint16_t pwm_raw[PWM_CH_CNT];
|
||||
|
||||
void mcu_pwm_write(uint8_t ch, uint16_t dc)
|
||||
{
|
||||
pwm_ch = ch;
|
||||
if(ch < PWM_CH_CNT) pwm_raw[ch] = dc;
|
||||
}
|
||||
|
||||
uint16_t mcu_pwm_read(uint8_t ch)
|
||||
{
|
||||
pwm_ch = ch;
|
||||
if(ch < PWM_CH_CNT) return pwm_raw[ch];
|
||||
else return 0;
|
||||
}
|
||||
|
||||
uint8_t mock_mcu_pwm_read_ch(void)
|
||||
{
|
||||
return pwm_ch;
|
||||
}
|
||||
|
||||
void mock_mcu_pwm_set_ch(uint8_t new_ch)
|
||||
{
|
||||
pwm_ch = new_ch;
|
||||
}
|
||||
|
||||
uint16_t mock_mcu_pwm_read_raw(uint8_t ch)
|
||||
{
|
||||
return pwm_raw[ch];
|
||||
}
|
||||
|
||||
void mock_mcu_pwm_set_raw(uint16_t new_pwm, uint8_t ch)
|
||||
{
|
||||
pwm_raw[ch] = new_pwm;
|
||||
}
|
||||
|
||||
// GPIO Functions
|
||||
#define GPIO_CH_CNT 18
|
||||
static uint8_t gpio_ch = 0;
|
||||
static uint8_t gpio_input_lvl[GPIO_CH_CNT];
|
||||
static int8_t gpio_output_lvl[GPIO_CH_CNT];
|
||||
|
||||
uint8_t mcu_gpio_read(uint8_t ch)
|
||||
{
|
||||
gpio_ch = ch;
|
||||
if(ch < GPIO_CH_CNT) return gpio_input_lvl[ch];
|
||||
else return 0;
|
||||
}
|
||||
|
||||
void mcu_gpio_write(uint8_t ch, int8_t lvl)
|
||||
{
|
||||
gpio_ch = ch;
|
||||
if(ch < GPIO_CH_CNT) gpio_output_lvl[ch] = lvl;
|
||||
}
|
||||
|
||||
uint8_t mock_mcu_gpio_read_ch(void)
|
||||
{
|
||||
return gpio_ch;
|
||||
}
|
||||
|
||||
void mock_mcu_gpio_set_ch(uint8_t new_ch)
|
||||
{
|
||||
gpio_ch = new_ch;
|
||||
}
|
||||
|
||||
int8_t mock_mcu_gpio_read_output_lvl(uint8_t ch)
|
||||
{
|
||||
return gpio_output_lvl[ch];
|
||||
}
|
||||
|
||||
void mock_mcu_gpio_set_output_lvl(int8_t new_output_lvl, uint8_t ch)
|
||||
{
|
||||
gpio_output_lvl[ch] = new_output_lvl;
|
||||
}
|
||||
|
||||
void mock_mcu_gpio_set_input_lvl(uint8_t new_in_lvl, uint8_t ch)
|
||||
{
|
||||
gpio_input_lvl[ch] = new_in_lvl;
|
||||
}
|
||||
|
||||
// EEPROM functions
|
||||
uint8_t mcu_ee_read8b(uint16_t address)
|
||||
{
|
||||
return 0x00;
|
||||
}
|
||||
|
||||
uint16_t mcu_ee_read16b(uint16_t address)
|
||||
{
|
||||
return 0x0000;
|
||||
}
|
||||
|
||||
uint32_t mcu_ee_read32b(uint16_t address)
|
||||
{
|
||||
return 0x00000000;
|
||||
}
|
||||
|
||||
void mcu_ee_write8b(uint16_t address, uint8_t value)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void mcu_ee_write16b(uint16_t address, uint16_t value)
|
||||
{
|
||||
}
|
||||
|
||||
void mcu_ee_write32b(uint16_t address, uint32_t value)
|
||||
{
|
||||
|
||||
}
|
||||
28
firmware/tests/mock_mcu/mock_mcu_hal_r8.h
Normal file
28
firmware/tests/mock_mcu/mock_mcu_hal_r8.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef MOCK_MCU_HAL_R8_
|
||||
#define MOCK_MCU_HAL_R8_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "../../src/hw/board/mcu/mcu_hal.h"
|
||||
|
||||
void mock_mcu_startup_read_cfg(startupCfg_t* cfg_out);
|
||||
void mock_mcu_startup_write_cfg(startupCfg_t* cfg_in);
|
||||
|
||||
uint8_t mock_mcu_adc_read_ch(void);
|
||||
void mock_mcu_adc_set_ch(uint8_t ch);
|
||||
uint16_t mock_mcu_adc_read_raw(uint8_t ch);
|
||||
void mock_mcu_adc_set_raw(uint16_t new_adc_out, uint8_t ch);
|
||||
|
||||
uint8_t mock_mcu_pwm_read_ch(void);
|
||||
void mock_mcu_pwm_set_ch(uint8_t new_ch);
|
||||
uint16_t mock_mcu_pwm_read_raw(uint8_t ch);
|
||||
void mock_mcu_pwm_set_raw(uint16_t new_pwm, uint8_t ch);
|
||||
|
||||
uint8_t mock_mcu_gpio_read_ch(void);
|
||||
void mock_mcu_gpio_set_ch(uint8_t new_ch);
|
||||
int8_t mock_mcu_gpio_read_output_lvl(uint8_t ch);
|
||||
void mock_mcu_gpio_set_output_lvl(int8_t new_output_lvl, uint8_t ch);
|
||||
void mock_mcu_gpio_set_input_lvl(uint8_t new_in_lvl, uint8_t ch);
|
||||
|
||||
#endif /* MOCK_MCU_HAL_R8_ */
|
||||
106
firmware/tests/uDCCD_Unit_Tests_BSP.cbp
Normal file
106
firmware/tests/uDCCD_Unit_Tests_BSP.cbp
Normal file
@@ -0,0 +1,106 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="6" />
|
||||
<Project>
|
||||
<Option title="uDCCD_Unit_Tests_BSP" />
|
||||
<Option pch_mode="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Build>
|
||||
<Target title="Debug">
|
||||
<Option output="bin/Debug/uDCCD_Unit_Tests_BSP" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj/Debug/" />
|
||||
<Option type="1" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-g" />
|
||||
</Compiler>
|
||||
</Target>
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add option="-Wall" />
|
||||
</Compiler>
|
||||
<Unit filename="../src/hw/board/ain.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../src/hw/board/ain.h" />
|
||||
<Unit filename="../src/hw/board/din.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../src/hw/board/din.h" />
|
||||
<Unit filename="../src/hw/board/dout.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../src/hw/board/dout.h" />
|
||||
<Unit filename="../src/hw/board/halfbridge.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../src/hw/board/halfbridge.h" />
|
||||
<Unit filename="../src/hw/board/mcu/mcu_hal.h" />
|
||||
<Unit filename="../src/hw/board/odout.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../src/hw/board/odout.h" />
|
||||
<Unit filename="../src/hw/board/setup.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../src/hw/board/setup.h" />
|
||||
<Unit filename="../src/hw/board/utils/faults.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../src/hw/board/utils/faults.h" />
|
||||
<Unit filename="../src/hw/board/utils/fuses.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../src/hw/board/utils/fuses.h" />
|
||||
<Unit filename="../src/hw/board/utils/utils.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../src/hw/board/utils/utils.h" />
|
||||
<Unit filename="bsp_main.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="mock_mcu/mock_mcu_hal_r8.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="mock_mcu/mock_mcu_hal_r8.h" />
|
||||
<Unit filename="ut_board/ut_ain.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="ut_board/ut_ain.h" />
|
||||
<Unit filename="ut_board/ut_din.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="ut_board/ut_din.h" />
|
||||
<Unit filename="ut_board/ut_dout.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="ut_board/ut_dout.h" />
|
||||
<Unit filename="ut_board/ut_halfbridge.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="ut_board/ut_halfbridge.h" />
|
||||
<Unit filename="ut_board/ut_odout.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="ut_board/ut_odout.h" />
|
||||
<Unit filename="ut_board/ut_setup.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="ut_board/ut_setup.h" />
|
||||
<Unit filename="ut_utils/ut_fault.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="ut_utils/ut_fault.h" />
|
||||
<Unit filename="ut_utils/ut_fuses.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="ut_utils/ut_fuses.h" />
|
||||
<Unit filename="ut_utils/ut_utils.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="ut_utils/ut_utils.h" />
|
||||
<Extensions>
|
||||
<lib_finder disable_auto="1" />
|
||||
</Extensions>
|
||||
</Project>
|
||||
</CodeBlocks_project_file>
|
||||
348
firmware/tests/uDCCD_Unit_Tests_BSP.depend
Normal file
348
firmware/tests/uDCCD_Unit_Tests_BSP.depend
Normal file
@@ -0,0 +1,348 @@
|
||||
# depslib dependency file v1.0
|
||||
1698696655 source:f:\microrally\udccd_controller\src\hw\board\ain.c
|
||||
"utils/utils.h"
|
||||
"mcu/mcu_hal.h"
|
||||
"ain.h"
|
||||
|
||||
1699031869 f:\microrally\udccd_controller\src\hw\board\utils\utils.h
|
||||
<stdint.h>
|
||||
|
||||
1698776270 f:\microrally\udccd_controller\src\hw\board\mcu\mcu_hal.h
|
||||
<stdint.h>
|
||||
|
||||
1699031869 f:\microrally\udccd_controller\src\hw\board\ain.h
|
||||
<stdint.h>
|
||||
|
||||
1698336545 source:f:\microrally\udccd_controller\src\hw\board\din.c
|
||||
"utils/utils.h"
|
||||
"mcu/mcu_hal.h"
|
||||
"din.h"
|
||||
|
||||
1699031869 f:\microrally\udccd_controller\src\hw\board\din.h
|
||||
<stdint.h>
|
||||
|
||||
1698740890 source:f:\microrally\udccd_controller\src\hw\board\dout.c
|
||||
"utils/utils.h"
|
||||
"mcu/mcu_hal.h"
|
||||
"dout.h"
|
||||
|
||||
1699031869 f:\microrally\udccd_controller\src\hw\board\dout.h
|
||||
<stdint.h>
|
||||
|
||||
1698575529 source:f:\microrally\udccd_controller\src\hw\board\halfbridge.c
|
||||
"utils/utils.h"
|
||||
"mcu/mcu_hal.h"
|
||||
"halfbridge.h"
|
||||
|
||||
1699031869 f:\microrally\udccd_controller\src\hw\board\halfbridge.h
|
||||
<stdint.h>
|
||||
|
||||
1697628825 source:f:\microrally\udccd_controller\src\hw\board\odout.c
|
||||
"utils/utils.h"
|
||||
"mcu/mcu_hal.h"
|
||||
"odout.h"
|
||||
|
||||
1699197585 f:\microrally\udccd_controller\src\hw\board\odout.h
|
||||
<stdint.h>
|
||||
|
||||
1698336545 source:f:\microrally\udccd_controller\src\hw\board\setup.c
|
||||
"utils/utils.h"
|
||||
"mcu/mcu_hal.h"
|
||||
"setup.h"
|
||||
|
||||
1699031869 f:\microrally\udccd_controller\src\hw\board\setup.h
|
||||
<stdint.h>
|
||||
|
||||
1699031869 source:f:\microrally\udccd_controller\src\hw\board\utils\faults.c
|
||||
"faults.h"
|
||||
"utils.h"
|
||||
|
||||
1699031869 f:\microrally\udccd_controller\src\hw\board\utils\faults.h
|
||||
<stdint.h>
|
||||
|
||||
1699031869 source:f:\microrally\udccd_controller\src\hw\board\utils\fuses.c
|
||||
"fuses.h"
|
||||
"utils.h"
|
||||
|
||||
1699031869 f:\microrally\udccd_controller\src\hw\board\utils\fuses.h
|
||||
<stdint.h>
|
||||
|
||||
1699031869 source:f:\microrally\udccd_controller\src\hw\board\utils\utils.c
|
||||
"utils.h"
|
||||
|
||||
1699205020 source:f:\microrally\udccd_controller\tests\bsp_main.c
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
"ut_utils/ut_utils.h"
|
||||
"ut_utils/ut_fault.h"
|
||||
"ut_utils/ut_fuses.h"
|
||||
"ut_board/ut_ain.h"
|
||||
"ut_board/ut_din.h"
|
||||
"ut_board/ut_dout.h"
|
||||
"ut_board/ut_halfbridge.h"
|
||||
"ut_board/ut_odout.h"
|
||||
"ut_board/ut_setup.h"
|
||||
|
||||
1699204674 f:\microrally\udccd_controller\tests\ut_utils\ut_utils.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
||||
1698870535 f:\microrally\udccd_controller\tests\ut_utils\ut_fault.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
||||
1698959419 f:\microrally\udccd_controller\tests\ut_utils\ut_fuses.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
||||
1699031869 f:\microrally\udccd_controller\tests\ut_board\ut_ain.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
||||
1699041803 f:\microrally\udccd_controller\tests\ut_board\ut_din.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
||||
1699042443 f:\microrally\udccd_controller\tests\ut_board\ut_dout.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
||||
1699051096 f:\microrally\udccd_controller\tests\ut_board\ut_halfbridge.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
||||
1699200555 source:f:\microrally\udccd_controller\tests\mock_mcu\mock_mcu_hal_r8.c
|
||||
"..\..\src\hw\board\mcu\mcu_hal.h"
|
||||
"mock_mcu_hal_r8.h"
|
||||
|
||||
1699200561 f:\microrally\udccd_controller\tests\mock_mcu\mock_mcu_hal_r8.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
"../../src/hw/board/mcu/mcu_hal.h"
|
||||
|
||||
1699196285 source:f:\microrally\udccd_controller\tests\ut_board\ut_ain.c
|
||||
"ut_ain.h"
|
||||
"..\mock_mcu\mock_mcu_hal_r8.h"
|
||||
"..\..\src\hw\board\ain.h"
|
||||
|
||||
1699196304 source:f:\microrally\udccd_controller\tests\ut_board\ut_din.c
|
||||
"ut_din.h"
|
||||
"..\mock_mcu\mock_mcu_hal_r8.h"
|
||||
"..\..\src\hw\board\din.h"
|
||||
|
||||
1699196320 source:f:\microrally\udccd_controller\tests\ut_board\ut_dout.c
|
||||
"ut_dout.h"
|
||||
"..\mock_mcu\mock_mcu_hal_r8.h"
|
||||
"..\..\src\hw\board\dout.h"
|
||||
|
||||
1699196359 source:f:\microrally\udccd_controller\tests\ut_board\ut_halfbridge.c
|
||||
"ut_dout.h"
|
||||
"..\mock_mcu\mock_mcu_hal_r8.h"
|
||||
"..\..\src\hw\board\halfbridge.h"
|
||||
|
||||
1699196427 source:f:\microrally\udccd_controller\tests\ut_utils\ut_fault.c
|
||||
"ut_fault.h"
|
||||
"..\..\src\hw\board\utils\faults.h"
|
||||
|
||||
1699196445 source:f:\microrally\udccd_controller\tests\ut_utils\ut_fuses.c
|
||||
"ut_fuses.h"
|
||||
"..\..\src\hw\board\utils\fuses.h"
|
||||
|
||||
1699203820 source:f:\microrally\udccd_controller\tests\ut_utils\ut_utils.c
|
||||
"ut_utils.h"
|
||||
"..\..\src\hw\board\utils\utils.h"
|
||||
|
||||
1699200030 f:\microrally\udccd_controller\tests\ut_board\ut_odout.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
||||
1699200020 source:f:\microrally\udccd_controller\tests\ut_board\ut_odout.c
|
||||
"ut_odout.h"
|
||||
"..\mock_mcu\mock_mcu_hal_r8.h"
|
||||
"..\..\src\hw\board\odout.h"
|
||||
|
||||
1699201018 f:\microrally\udccd_controller\tests\ut_board\ut_setup.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
||||
1699201095 source:f:\microrally\udccd_controller\tests\ut_board\ut_setup.c
|
||||
"ut_odout.h"
|
||||
"..\mock_mcu\mock_mcu_hal_r8.h"
|
||||
"..\..\src\hw\board\setup.h"
|
||||
|
||||
1699018375 source:d:\microrally\udccd_controller\src\hw\board\ain.c
|
||||
"utils/utils.h"
|
||||
"mcu/mcu_hal.h"
|
||||
"ain.h"
|
||||
|
||||
1699007962 d:\microrally\udccd_controller\src\hw\board\utils\utils.h
|
||||
<stdint.h>
|
||||
|
||||
1699017409 d:\microrally\udccd_controller\src\hw\board\mcu\mcu_hal.h
|
||||
<stdint.h>
|
||||
|
||||
1699535273 d:\microrally\udccd_controller\src\hw\board\ain.h
|
||||
<stdint.h>
|
||||
"config.h"
|
||||
|
||||
1698333216 source:d:\microrally\udccd_controller\src\hw\board\din.c
|
||||
"utils/utils.h"
|
||||
"mcu/mcu_hal.h"
|
||||
"din.h"
|
||||
|
||||
1699535289 d:\microrally\udccd_controller\src\hw\board\din.h
|
||||
<stdint.h>
|
||||
|
||||
1698673847 source:d:\microrally\udccd_controller\src\hw\board\dout.c
|
||||
"utils/utils.h"
|
||||
"mcu/mcu_hal.h"
|
||||
"dout.h"
|
||||
|
||||
1699535296 d:\microrally\udccd_controller\src\hw\board\dout.h
|
||||
<stdint.h>
|
||||
|
||||
1698656931 source:d:\microrally\udccd_controller\src\hw\board\halfbridge.c
|
||||
"utils/utils.h"
|
||||
"mcu/mcu_hal.h"
|
||||
"halfbridge.h"
|
||||
|
||||
1699535318 d:\microrally\udccd_controller\src\hw\board\halfbridge.h
|
||||
<stdint.h>
|
||||
"config.h"
|
||||
|
||||
1697618884 source:d:\microrally\udccd_controller\src\hw\board\odout.c
|
||||
"utils/utils.h"
|
||||
"mcu/mcu_hal.h"
|
||||
"odout.h"
|
||||
|
||||
1699257917 d:\microrally\udccd_controller\src\hw\board\odout.h
|
||||
<stdint.h>
|
||||
|
||||
1698328348 source:d:\microrally\udccd_controller\src\hw\board\setup.c
|
||||
"utils/utils.h"
|
||||
"mcu/mcu_hal.h"
|
||||
"setup.h"
|
||||
|
||||
1699017683 d:\microrally\udccd_controller\src\hw\board\setup.h
|
||||
<stdint.h>
|
||||
|
||||
1699007034 source:d:\microrally\udccd_controller\src\hw\board\utils\faults.c
|
||||
"faults.h"
|
||||
"utils.h"
|
||||
|
||||
1699007033 d:\microrally\udccd_controller\src\hw\board\utils\faults.h
|
||||
<stdint.h>
|
||||
|
||||
1699007093 source:d:\microrally\udccd_controller\src\hw\board\utils\fuses.c
|
||||
"fuses.h"
|
||||
"utils.h"
|
||||
|
||||
1699007094 d:\microrally\udccd_controller\src\hw\board\utils\fuses.h
|
||||
<stdint.h>
|
||||
|
||||
1699264217 source:d:\microrally\udccd_controller\src\hw\board\utils\utils.c
|
||||
"utils.h"
|
||||
|
||||
1699257917 source:d:\microrally\udccd_controller\tests\bsp_main.c
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
"ut_utils/ut_utils.h"
|
||||
"ut_utils/ut_fault.h"
|
||||
"ut_utils/ut_fuses.h"
|
||||
"ut_board/ut_ain.h"
|
||||
"ut_board/ut_din.h"
|
||||
"ut_board/ut_dout.h"
|
||||
"ut_board/ut_halfbridge.h"
|
||||
"ut_board/ut_odout.h"
|
||||
"ut_board/ut_setup.h"
|
||||
|
||||
1699257917 d:\microrally\udccd_controller\tests\ut_utils\ut_utils.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
||||
1698921312 d:\microrally\udccd_controller\tests\ut_utils\ut_fault.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
||||
1699004735 d:\microrally\udccd_controller\tests\ut_utils\ut_fuses.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
||||
1699018575 d:\microrally\udccd_controller\tests\ut_board\ut_ain.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
||||
1699257917 d:\microrally\udccd_controller\tests\ut_board\ut_din.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
||||
1699257917 d:\microrally\udccd_controller\tests\ut_board\ut_dout.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
||||
1699257917 d:\microrally\udccd_controller\tests\ut_board\ut_halfbridge.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
||||
1699257917 d:\microrally\udccd_controller\tests\ut_board\ut_odout.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
||||
1699257917 d:\microrally\udccd_controller\tests\ut_board\ut_setup.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
||||
1699257917 source:d:\microrally\udccd_controller\tests\mock_mcu\mock_mcu_hal_r8.c
|
||||
"..\..\src\hw\board\mcu\mcu_hal.h"
|
||||
"mock_mcu_hal_r8.h"
|
||||
|
||||
1699257917 d:\microrally\udccd_controller\tests\mock_mcu\mock_mcu_hal_r8.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
"../../src/hw/board/mcu/mcu_hal.h"
|
||||
|
||||
1699257917 source:d:\microrally\udccd_controller\tests\ut_board\ut_ain.c
|
||||
"ut_ain.h"
|
||||
"..\mock_mcu\mock_mcu_hal_r8.h"
|
||||
"..\..\src\hw\board\ain.h"
|
||||
|
||||
1699257917 source:d:\microrally\udccd_controller\tests\ut_board\ut_din.c
|
||||
"ut_din.h"
|
||||
"..\mock_mcu\mock_mcu_hal_r8.h"
|
||||
"..\..\src\hw\board\din.h"
|
||||
|
||||
1699257917 source:d:\microrally\udccd_controller\tests\ut_board\ut_dout.c
|
||||
"ut_dout.h"
|
||||
"..\mock_mcu\mock_mcu_hal_r8.h"
|
||||
"..\..\src\hw\board\dout.h"
|
||||
|
||||
1699257917 source:d:\microrally\udccd_controller\tests\ut_board\ut_halfbridge.c
|
||||
"ut_dout.h"
|
||||
"..\mock_mcu\mock_mcu_hal_r8.h"
|
||||
"..\..\src\hw\board\halfbridge.h"
|
||||
|
||||
1699257917 source:d:\microrally\udccd_controller\tests\ut_board\ut_odout.c
|
||||
"ut_odout.h"
|
||||
"..\mock_mcu\mock_mcu_hal_r8.h"
|
||||
"..\..\src\hw\board\odout.h"
|
||||
|
||||
1699257917 source:d:\microrally\udccd_controller\tests\ut_board\ut_setup.c
|
||||
"ut_odout.h"
|
||||
"..\mock_mcu\mock_mcu_hal_r8.h"
|
||||
"..\..\src\hw\board\setup.h"
|
||||
|
||||
1699257917 source:d:\microrally\udccd_controller\tests\ut_utils\ut_fault.c
|
||||
"ut_fault.h"
|
||||
"..\..\src\hw\board\utils\faults.h"
|
||||
|
||||
1699257917 source:d:\microrally\udccd_controller\tests\ut_utils\ut_fuses.c
|
||||
"ut_fuses.h"
|
||||
"..\..\src\hw\board\utils\fuses.h"
|
||||
|
||||
1699264250 source:d:\microrally\udccd_controller\tests\ut_utils\ut_utils.c
|
||||
"ut_utils.h"
|
||||
"..\..\src\hw\board\utils\utils.h"
|
||||
|
||||
1699535389 d:\microrally\udccd_controller\src\hw\board\config.h
|
||||
<stdint.h>
|
||||
|
||||
90
firmware/tests/uDCCD_Unit_Tests_BSP.layout
Normal file
90
firmware/tests/uDCCD_Unit_Tests_BSP.layout
Normal file
@@ -0,0 +1,90 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_layout_file>
|
||||
<FileVersion major="1" minor="0" />
|
||||
<ActiveTarget name="Debug" />
|
||||
<File name="ut_utils\ut_utils.c" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="-1" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="30322" topLine="1293" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="ut_board\ut_ain.c" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1582" topLine="41" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="ut_board\ut_odout.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="169" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="mock_mcu\mock_mcu_hal_r8.c" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="1" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="2789" topLine="117" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="ut_board\ut_dout.c" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="4236" topLine="87" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\src\hw\board\mcu\mcu_hal.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="844" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="mock_mcu\mock_mcu_hal_r8.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="231" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="ut_board\ut_setup.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="4" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="715" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\src\hw\board\utils\utils.c" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="1" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="5492" topLine="188" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="ut_utils\ut_utils.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="4" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="664" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="ut_utils\ut_fuses.c" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1650" topLine="24" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="ut_board\ut_setup.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="8" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="122" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="bsp_main.c" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="5" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="3165" topLine="121" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="ut_board\ut_halfbridge.c" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="5" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="2947" topLine="90" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="ut_utils\ut_fault.c" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="29993" topLine="896" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="ut_board\ut_odout.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="6" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="5245" topLine="172" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="ut_board\ut_din.c" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="815" topLine="135" />
|
||||
</Cursor>
|
||||
</File>
|
||||
</CodeBlocks_layout_file>
|
||||
105
firmware/tests/uDCCD_Unit_Tests_HW.cbp
Normal file
105
firmware/tests/uDCCD_Unit_Tests_HW.cbp
Normal file
@@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="6" />
|
||||
<Project>
|
||||
<Option title="uDCCD_Unit_Tests_HW" />
|
||||
<Option pch_mode="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Build>
|
||||
<Target title="Debug">
|
||||
<Option output="bin/Debug/uDCCD_Unit_Tests_HW" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj/Debug/" />
|
||||
<Option type="1" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-g" />
|
||||
<Add option="-DTESTING" />
|
||||
</Compiler>
|
||||
</Target>
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add option="-Wall" />
|
||||
<Add option="-DTESTING" />
|
||||
</Compiler>
|
||||
<Unit filename="../src/hw/analog.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../src/hw/analog.h" />
|
||||
<Unit filename="../src/hw/board/utils/faults.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../src/hw/board/utils/faults.h" />
|
||||
<Unit filename="../src/hw/board/utils/fuses.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../src/hw/board/utils/fuses.h" />
|
||||
<Unit filename="../src/hw/board/utils/utils.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../src/hw/board/utils/utils.h" />
|
||||
<Unit filename="../src/hw/buttons.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../src/hw/buttons.h" />
|
||||
<Unit filename="../src/hw/hb_control.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../src/hw/hb_control.h" />
|
||||
<Unit filename="../src/hw/led_display.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../src/hw/led_display.h" />
|
||||
<Unit filename="../src/hw/startup.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../src/hw/startup.h" />
|
||||
<Unit filename="hw_main.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="mock_board/mock_board_ain.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="mock_board/mock_board_ain.h" />
|
||||
<Unit filename="mock_board/mock_board_din.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="mock_board/mock_board_din.h" />
|
||||
<Unit filename="mock_board/mock_board_dout.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="mock_board/mock_board_dout.h" />
|
||||
<Unit filename="mock_board/mock_board_halfbridge.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="mock_board/mock_board_halfbridge.h" />
|
||||
<Unit filename="mock_board/mock_board_odout.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="mock_board/mock_board_odout.h" />
|
||||
<Unit filename="mock_board/mock_board_setup.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="mock_board/mock_board_setup.h" />
|
||||
<Unit filename="ut_hw/ut_analog.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="ut_hw/ut_analog.h" />
|
||||
<Unit filename="ut_hw/ut_buttons.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="ut_hw/ut_buttons.h" />
|
||||
<Unit filename="ut_hw/ut_hb_control.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="ut_hw/ut_hb_control.h" />
|
||||
<Unit filename="ut_hw/ut_led_display.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="ut_hw/ut_led_display.h" />
|
||||
<Unit filename="ut_hw/ut_startup.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="ut_hw/ut_startup.h" />
|
||||
<Extensions />
|
||||
</Project>
|
||||
</CodeBlocks_project_file>
|
||||
378
firmware/tests/uDCCD_Unit_Tests_HW.depend
Normal file
378
firmware/tests/uDCCD_Unit_Tests_HW.depend
Normal file
@@ -0,0 +1,378 @@
|
||||
# depslib dependency file v1.0
|
||||
1699007034 source:d:\microrally\udccd_controller\src\hw\board\utils\faults.c
|
||||
"faults.h"
|
||||
"utils.h"
|
||||
|
||||
1699007033 d:\microrally\udccd_controller\src\hw\board\utils\faults.h
|
||||
<stdint.h>
|
||||
|
||||
1699007962 d:\microrally\udccd_controller\src\hw\board\utils\utils.h
|
||||
<stdint.h>
|
||||
|
||||
1699007093 source:d:\microrally\udccd_controller\src\hw\board\utils\fuses.c
|
||||
"fuses.h"
|
||||
"utils.h"
|
||||
|
||||
1699007094 d:\microrally\udccd_controller\src\hw\board\utils\fuses.h
|
||||
<stdint.h>
|
||||
|
||||
1699264217 source:d:\microrally\udccd_controller\src\hw\board\utils\utils.c
|
||||
"utils.h"
|
||||
|
||||
1698741271 source:d:\microrally\udccd_controller\src\hw\analog.c
|
||||
"board/utils/utils.h"
|
||||
"board/ain.h"
|
||||
"analog.h"
|
||||
|
||||
1699535273 d:\microrally\udccd_controller\src\hw\board\ain.h
|
||||
<stdint.h>
|
||||
"config.h"
|
||||
|
||||
1699017683 d:\microrally\udccd_controller\src\hw\analog.h
|
||||
<stdint.h>
|
||||
|
||||
1699283768 source:d:\microrally\udccd_controller\tests\mock_board\mock_board_dout.c
|
||||
"mock_board_dout.h"
|
||||
|
||||
1699535296 d:\microrally\udccd_controller\src\hw\board\dout.h
|
||||
<stdint.h>
|
||||
|
||||
1699272290 d:\microrally\udccd_controller\tests\mock_board\mock_board_dout.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
"..\..\src\hw\board\dout.h"
|
||||
|
||||
1699283776 source:d:\microrally\udccd_controller\tests\mock_board\mock_board_odout.c
|
||||
"mock_board_odout.h"
|
||||
|
||||
1699257917 d:\microrally\udccd_controller\src\hw\board\odout.h
|
||||
<stdint.h>
|
||||
|
||||
1699272272 d:\microrally\udccd_controller\tests\mock_board\mock_board_odout.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
"..\..\src\hw\board\odout.h"
|
||||
|
||||
1699272265 source:d:\microrally\udccd_controller\tests\mock_board\mock_board_setup.c
|
||||
"mock_board_setup.h"
|
||||
|
||||
1699017683 d:\microrally\udccd_controller\src\hw\board\setup.h
|
||||
<stdint.h>
|
||||
|
||||
1699272264 d:\microrally\udccd_controller\tests\mock_board\mock_board_setup.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
"..\..\src\hw\board\setup.h"
|
||||
|
||||
1699516357 source:d:\microrally\udccd_controller\tests\hw_main.c
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
"ut_hw/ut_analog.h"
|
||||
"ut_hw/ut_buttons.h"
|
||||
"ut_hw/ut_hb_control.h"
|
||||
"ut_hw/ut_led_display.h"
|
||||
"ut_hw/ut_startup.h"
|
||||
|
||||
1699271694 d:\microrally\udccd_controller\tests\ut_hw\ut_analog.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
||||
1699272372 source:d:\microrally\udccd_controller\tests\mock_board\mock_board_ain.c
|
||||
"mock_board_ain.h"
|
||||
|
||||
1699272245 d:\microrally\udccd_controller\tests\mock_board\mock_board_ain.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
"..\..\src\hw\board\ain.h"
|
||||
|
||||
1699283758 source:d:\microrally\udccd_controller\tests\mock_board\mock_board_din.c
|
||||
"mock_board_din.h"
|
||||
|
||||
1699535289 d:\microrally\udccd_controller\src\hw\board\din.h
|
||||
<stdint.h>
|
||||
|
||||
1699272297 d:\microrally\udccd_controller\tests\mock_board\mock_board_din.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
"..\..\src\hw\board\din.h"
|
||||
|
||||
1699535318 d:\microrally\udccd_controller\src\hw\board\halfbridge.h
|
||||
<stdint.h>
|
||||
"config.h"
|
||||
|
||||
1699272285 source:d:\microrally\udccd_controller\tests\mock_board\mock_board_halfbridge.c
|
||||
"mock_board_halfbridge.h"
|
||||
|
||||
1699287859 d:\microrally\udccd_controller\tests\mock_board\mock_board_halfbridge.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
"..\..\src\hw\board\halfbridge.h"
|
||||
|
||||
1699276363 source:d:\microrally\udccd_controller\tests\ut_hw\ut_analog.c
|
||||
"ut_analog.h"
|
||||
"..\mock_board\mock_board_ain.h"
|
||||
"..\..\src\hw\analog.h"
|
||||
|
||||
1699284536 source:d:\microrally\udccd_controller\tests\ut_hw\ut_buttons.c
|
||||
"ut_buttons.h"
|
||||
"..\mock_board\mock_board_din.h"
|
||||
"..\mock_board\mock_board_dout.h"
|
||||
"..\..\src\hw\buttons.h"
|
||||
|
||||
1699284495 d:\microrally\udccd_controller\tests\ut_hw\ut_buttons.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
||||
1699535453 d:\microrally\udccd_controller\src\hw\buttons.h
|
||||
<stdint.h>
|
||||
"config.h"
|
||||
|
||||
1699516357 source:d:\microrally\udccd_controller\src\hw\buttons.c
|
||||
"board/utils/utils.h"
|
||||
"board/din.h"
|
||||
"board/dout.h"
|
||||
"buttons.h"
|
||||
|
||||
1699373886 source:d:\microrally\udccd_controller\src\hw\hb_control.c
|
||||
"board/utils/utils.h"
|
||||
"board/halfbridge.h"
|
||||
"hb_control.h"
|
||||
|
||||
1699351840 d:\microrally\udccd_controller\src\hw\hb_control.h
|
||||
<stdint.h>
|
||||
"board/utils/faults.h"
|
||||
"board/utils/fuses.h"
|
||||
"board/halfbridge.h"
|
||||
|
||||
1699286008 source:d:\microrally\udccd_controller\src\hw\led_display.c
|
||||
"board/odout.h"
|
||||
"led_display.h"
|
||||
|
||||
1699017683 d:\microrally\udccd_controller\src\hw\led_display.h
|
||||
<stdint.h>
|
||||
|
||||
1698328349 source:d:\microrally\udccd_controller\src\hw\startup.c
|
||||
"board/utils/utils.h"
|
||||
"board/setup.h"
|
||||
"startup.h"
|
||||
|
||||
1699017682 d:\microrally\udccd_controller\src\hw\startup.h
|
||||
<stdint.h>
|
||||
|
||||
1699285771 d:\microrally\udccd_controller\tests\ut_hw\ut_startup.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
||||
1699285777 source:d:\microrally\udccd_controller\tests\ut_hw\ut_startup.c
|
||||
"ut_startup.h"
|
||||
"..\mock_board\mock_board_setup.h"
|
||||
"..\..\src\hw\startup.h"
|
||||
|
||||
1699286754 source:d:\microrally\udccd_controller\tests\ut_hw\ut_led_display.c
|
||||
"ut_led_display.h"
|
||||
"..\mock_board\mock_board_odout.h"
|
||||
"..\..\src\hw\led_display.h"
|
||||
|
||||
1699286570 d:\microrally\udccd_controller\tests\ut_hw\ut_led_display.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
||||
1699375169 source:d:\microrally\udccd_controller\tests\ut_hw\ut_hb_control.c
|
||||
"ut_hb_control.h"
|
||||
"..\mock_board\mock_board_halfbridge.h"
|
||||
"..\..\src\hw\hb_control.h"
|
||||
|
||||
1699371510 d:\microrally\udccd_controller\tests\ut_hw\ut_hb_control.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
||||
1699031869 source:f:\microrally\udccd_controller\src\hw\board\utils\faults.c
|
||||
"faults.h"
|
||||
"utils.h"
|
||||
|
||||
1699031869 f:\microrally\udccd_controller\src\hw\board\utils\faults.h
|
||||
<stdint.h>
|
||||
|
||||
1699031869 f:\microrally\udccd_controller\src\hw\board\utils\utils.h
|
||||
<stdint.h>
|
||||
|
||||
1699031869 source:f:\microrally\udccd_controller\src\hw\board\utils\fuses.c
|
||||
"fuses.h"
|
||||
"utils.h"
|
||||
|
||||
1699031869 f:\microrally\udccd_controller\src\hw\board\utils\fuses.h
|
||||
<stdint.h>
|
||||
|
||||
1698697335 source:f:\microrally\udccd_controller\src\hw\analog.c
|
||||
"board/utils/utils.h"
|
||||
"board/ain.h"
|
||||
"analog.h"
|
||||
|
||||
1699476816 f:\microrally\udccd_controller\src\hw\board\ain.h
|
||||
<stdint.h>
|
||||
|
||||
1699031869 f:\microrally\udccd_controller\src\hw\analog.h
|
||||
<stdint.h>
|
||||
|
||||
1699298687 source:f:\microrally\udccd_controller\src\hw\board\utils\utils.c
|
||||
"utils.h"
|
||||
|
||||
1699298687 source:f:\microrally\udccd_controller\src\hw\buttons.c
|
||||
"board/utils/utils.h"
|
||||
"board/din.h"
|
||||
"board/dout.h"
|
||||
"buttons.h"
|
||||
|
||||
1699031869 f:\microrally\udccd_controller\src\hw\board\din.h
|
||||
<stdint.h>
|
||||
|
||||
1699031869 f:\microrally\udccd_controller\src\hw\board\dout.h
|
||||
<stdint.h>
|
||||
|
||||
1699477045 f:\microrally\udccd_controller\src\hw\buttons.h
|
||||
<stdint.h>
|
||||
|
||||
1699298687 source:f:\microrally\udccd_controller\src\hw\led_display.c
|
||||
"board/odout.h"
|
||||
"led_display.h"
|
||||
|
||||
1699197585 f:\microrally\udccd_controller\src\hw\board\odout.h
|
||||
<stdint.h>
|
||||
|
||||
1699031869 f:\microrally\udccd_controller\src\hw\led_display.h
|
||||
<stdint.h>
|
||||
|
||||
1698336545 source:f:\microrally\udccd_controller\src\hw\startup.c
|
||||
"board/utils/utils.h"
|
||||
"board/setup.h"
|
||||
"startup.h"
|
||||
|
||||
1699031869 f:\microrally\udccd_controller\src\hw\board\setup.h
|
||||
<stdint.h>
|
||||
|
||||
1699031869 f:\microrally\udccd_controller\src\hw\startup.h
|
||||
<stdint.h>
|
||||
|
||||
1699474639 source:f:\microrally\udccd_controller\tests\hw_main.c
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
"ut_hw/ut_analog.h"
|
||||
"ut_hw/ut_buttons.h"
|
||||
"ut_hw/ut_hb_control.h"
|
||||
"ut_hw/ut_led_display.h"
|
||||
"ut_hw/ut_startup.h"
|
||||
|
||||
1699298688 f:\microrally\udccd_controller\tests\ut_hw\ut_analog.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
||||
1699298688 f:\microrally\udccd_controller\tests\ut_hw\ut_buttons.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
||||
1699298688 f:\microrally\udccd_controller\tests\ut_hw\ut_startup.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
||||
1699298687 source:f:\microrally\udccd_controller\tests\mock_board\mock_board_ain.c
|
||||
"mock_board_ain.h"
|
||||
|
||||
1699298687 f:\microrally\udccd_controller\tests\mock_board\mock_board_ain.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
"..\..\src\hw\board\ain.h"
|
||||
|
||||
1699298687 source:f:\microrally\udccd_controller\tests\mock_board\mock_board_din.c
|
||||
"mock_board_din.h"
|
||||
|
||||
1699298687 f:\microrally\udccd_controller\tests\mock_board\mock_board_din.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
"..\..\src\hw\board\din.h"
|
||||
|
||||
1699298687 source:f:\microrally\udccd_controller\tests\mock_board\mock_board_dout.c
|
||||
"mock_board_dout.h"
|
||||
|
||||
1699298687 f:\microrally\udccd_controller\tests\mock_board\mock_board_dout.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
"..\..\src\hw\board\dout.h"
|
||||
|
||||
1699298687 source:f:\microrally\udccd_controller\tests\mock_board\mock_board_halfbridge.c
|
||||
"mock_board_halfbridge.h"
|
||||
|
||||
1699298687 f:\microrally\udccd_controller\tests\mock_board\mock_board_halfbridge.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
"..\..\src\hw\board\halfbridge.h"
|
||||
|
||||
1699476970 f:\microrally\udccd_controller\src\hw\board\halfbridge.h
|
||||
<stdint.h>
|
||||
|
||||
1699298687 source:f:\microrally\udccd_controller\tests\mock_board\mock_board_odout.c
|
||||
"mock_board_odout.h"
|
||||
|
||||
1699298687 f:\microrally\udccd_controller\tests\mock_board\mock_board_odout.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
"..\..\src\hw\board\odout.h"
|
||||
|
||||
1699298687 source:f:\microrally\udccd_controller\tests\mock_board\mock_board_setup.c
|
||||
"mock_board_setup.h"
|
||||
|
||||
1699298688 f:\microrally\udccd_controller\tests\mock_board\mock_board_setup.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
"..\..\src\hw\board\setup.h"
|
||||
|
||||
1699298688 source:f:\microrally\udccd_controller\tests\ut_hw\ut_analog.c
|
||||
"ut_analog.h"
|
||||
"..\mock_board\mock_board_ain.h"
|
||||
"..\..\src\hw\analog.h"
|
||||
|
||||
1699298688 source:f:\microrally\udccd_controller\tests\ut_hw\ut_buttons.c
|
||||
"ut_buttons.h"
|
||||
"..\mock_board\mock_board_din.h"
|
||||
"..\mock_board\mock_board_dout.h"
|
||||
"..\..\src\hw\buttons.h"
|
||||
|
||||
1699298688 source:f:\microrally\udccd_controller\tests\ut_hw\ut_led_display.c
|
||||
"ut_led_display.h"
|
||||
"..\mock_board\mock_board_odout.h"
|
||||
"..\..\src\hw\led_display.h"
|
||||
|
||||
1699298688 f:\microrally\udccd_controller\tests\ut_hw\ut_led_display.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
||||
1699298688 source:f:\microrally\udccd_controller\tests\ut_hw\ut_startup.c
|
||||
"ut_startup.h"
|
||||
"..\mock_board\mock_board_setup.h"
|
||||
"..\..\src\hw\startup.h"
|
||||
|
||||
1699391649 source:f:\microrally\udccd_controller\src\hw\hb_control.c
|
||||
"board/utils/utils.h"
|
||||
"board/halfbridge.h"
|
||||
"hb_control.h"
|
||||
|
||||
1699382733 f:\microrally\udccd_controller\src\hw\hb_control.h
|
||||
<stdint.h>
|
||||
"board/utils/faults.h"
|
||||
"board/utils/fuses.h"
|
||||
"board/halfbridge.h"
|
||||
|
||||
1699393539 source:f:\microrally\udccd_controller\tests\ut_hw\ut_hb_control.c
|
||||
"ut_hb_control.h"
|
||||
"..\mock_board\mock_board_halfbridge.h"
|
||||
"..\..\src\hw\hb_control.h"
|
||||
|
||||
1699382733 f:\microrally\udccd_controller\tests\ut_hw\ut_hb_control.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
||||
1699535389 d:\microrally\udccd_controller\src\hw\board\config.h
|
||||
<stdint.h>
|
||||
|
||||
1699535687 d:\microrally\udccd_controller\src\hw\config.h
|
||||
<stdint.h>
|
||||
|
||||
145
firmware/tests/uDCCD_Unit_Tests_HW.layout
Normal file
145
firmware/tests/uDCCD_Unit_Tests_HW.layout
Normal file
@@ -0,0 +1,145 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_layout_file>
|
||||
<FileVersion major="1" minor="0" />
|
||||
<ActiveTarget name="Debug" />
|
||||
<File name="mock_board\mock_board_setup.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="228" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\src\hw\hb_control.c" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="5" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="5123" topLine="145" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="mock_board\mock_board_odout.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="56" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="mock_board\mock_board_odout.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="366" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="ut_hw\ut_hb_control.c" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="3" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="88492" topLine="2027" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="mock_board\mock_board_ain.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="357" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\src\hw\buttons.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1649" topLine="24" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="ut_hw\ut_led_display.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="176" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="ut_hw\ut_analog.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="496" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="ut_hw\ut_led_display.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="2" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="856" topLine="60" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\src\hw\hb_control.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="391" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="ut_hw\ut_startup.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="161" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="mock_board\mock_board_dout.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="326" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="ut_hw\ut_analog.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="129" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="mock_board\mock_board_halfbridge.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="281" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="mock_board\mock_board_din.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="164" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="ut_hw\ut_buttons.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="221" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="mock_board\mock_board_din.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="52" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="mock_board\mock_board_halfbridge.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="529" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="mock_board\mock_board_ain.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="550" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="ut_hw\ut_buttons.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="10084" topLine="798" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="hw_main.c" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="3" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="2087" topLine="55" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\src\hw\board\utils\utils.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="181" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="ut_hw\ut_hb_control.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="302" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="ut_hw\ut_startup.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="606" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="mock_board\mock_board_setup.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="117" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\src\hw\analog.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="588" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="mock_board\mock_board_dout.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="54" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
</CodeBlocks_layout_file>
|
||||
71
firmware/tests/uDCCD_Unit_Tests_Logic.cbp
Normal file
71
firmware/tests/uDCCD_Unit_Tests_Logic.cbp
Normal file
@@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="6" />
|
||||
<Project>
|
||||
<Option title="uDCCD_Unit_Tests_Logic" />
|
||||
<Option pch_mode="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Build>
|
||||
<Target title="Debug">
|
||||
<Option output="bin/Debug/uDCCD_Unit_Tests_Logic" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj/Debug/" />
|
||||
<Option type="1" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-g" />
|
||||
<Add option="-DTESTING" />
|
||||
</Compiler>
|
||||
</Target>
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add option="-Wall" />
|
||||
<Add option="-DTESTING" />
|
||||
</Compiler>
|
||||
<Unit filename="../src/logic/coil.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../src/logic/coil.h" />
|
||||
<Unit filename="../src/logic/display.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../src/logic/display.h" />
|
||||
<Unit filename="../src/logic/force.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../src/logic/force.h" />
|
||||
<Unit filename="../src/logic/pot.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../src/logic/pot.h" />
|
||||
<Unit filename="../src/logic/user_force.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../src/logic/user_force.h" />
|
||||
<Unit filename="logic_main.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="ut_logic/ut_coil.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="ut_logic/ut_coil.h" />
|
||||
<Unit filename="ut_logic/ut_display.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="ut_logic/ut_display.h" />
|
||||
<Unit filename="ut_logic/ut_force.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="ut_logic/ut_force.h" />
|
||||
<Unit filename="ut_logic/ut_pot.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="ut_logic/ut_pot.h" />
|
||||
<Unit filename="ut_logic/ut_user_force.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="ut_logic/ut_user_force.h" />
|
||||
<Extensions>
|
||||
<lib_finder disable_auto="1" />
|
||||
</Extensions>
|
||||
</Project>
|
||||
</CodeBlocks_project_file>
|
||||
80
firmware/tests/uDCCD_Unit_Tests_Logic.depend
Normal file
80
firmware/tests/uDCCD_Unit_Tests_Logic.depend
Normal file
@@ -0,0 +1,80 @@
|
||||
# depslib dependency file v1.0
|
||||
1699474847 source:f:\microrally\udccd_controller\src\logic\coil.c
|
||||
"coil.h"
|
||||
|
||||
1699474848 f:\microrally\udccd_controller\src\logic\coil.h
|
||||
<stdint.h>
|
||||
|
||||
1699472530 source:f:\microrally\udccd_controller\src\logic\display.c
|
||||
"display.h"
|
||||
|
||||
1699472535 f:\microrally\udccd_controller\src\logic\display.h
|
||||
<stdint.h>
|
||||
|
||||
1699474995 source:f:\microrally\udccd_controller\src\logic\force.c
|
||||
"force.h"
|
||||
|
||||
1699474996 f:\microrally\udccd_controller\src\logic\force.h
|
||||
<stdint.h>
|
||||
|
||||
1699031869 source:f:\microrally\udccd_controller\src\logic\pot.c
|
||||
"pot.h"
|
||||
|
||||
1699475345 f:\microrally\udccd_controller\src\logic\pot.h
|
||||
<stdint.h>
|
||||
|
||||
1699475089 source:f:\microrally\udccd_controller\src\logic\user_force.c
|
||||
"user_force.h"
|
||||
|
||||
1699475337 f:\microrally\udccd_controller\src\logic\user_force.h
|
||||
<stdint.h>
|
||||
|
||||
1699474661 source:f:\microrally\udccd_controller\tests\logic_main.c
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
"ut_logic/ut_coil.h"
|
||||
"ut_logic/ut_display.h"
|
||||
"ut_logic/ut_force.h"
|
||||
"ut_logic/ut_pot.h"
|
||||
"ut_logic/ut_user_force.h"
|
||||
|
||||
1698869680 f:\microrally\udccd_controller\tests\ut_logic\ut_coil.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
||||
1699473947 f:\microrally\udccd_controller\tests\ut_logic\ut_display.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
||||
1698869680 f:\microrally\udccd_controller\tests\ut_logic\ut_force.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
||||
1698869680 f:\microrally\udccd_controller\tests\ut_logic\ut_pot.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
||||
1698869680 f:\microrally\udccd_controller\tests\ut_logic\ut_user_force.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
|
||||
1699474942 source:f:\microrally\udccd_controller\tests\ut_logic\ut_coil.c
|
||||
"ut_coil.h"
|
||||
"..\..\src\logic\coil.h"
|
||||
|
||||
1699474733 source:f:\microrally\udccd_controller\tests\ut_logic\ut_display.c
|
||||
"ut_display.h"
|
||||
"..\..\src\logic\display.h"
|
||||
|
||||
1699475023 source:f:\microrally\udccd_controller\tests\ut_logic\ut_force.c
|
||||
"ut_force.h"
|
||||
"..\..\src\logic\force.h"
|
||||
|
||||
1699195810 source:f:\microrally\udccd_controller\tests\ut_logic\ut_pot.c
|
||||
"ut_pot.h"
|
||||
"..\..\src\logic\pot.h"
|
||||
|
||||
1699195775 source:f:\microrally\udccd_controller\tests\ut_logic\ut_user_force.c
|
||||
"ut_user_force.h"
|
||||
"..\..\src\logic\user_force.h"
|
||||
|
||||
70
firmware/tests/uDCCD_Unit_Tests_Logic.layout
Normal file
70
firmware/tests/uDCCD_Unit_Tests_Logic.layout
Normal file
@@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_layout_file>
|
||||
<FileVersion major="1" minor="0" />
|
||||
<ActiveTarget name="Debug" />
|
||||
<File name="ut_logic\ut_user_force.c" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="-2" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="974" topLine="15" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="ut_logic\ut_pot.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="-2" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="498" topLine="37" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="ut_logic\ut_force.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="147" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="logic_main.c" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="1" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1473" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="ut_logic\ut_user_force.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="200" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="ut_logic\ut_coil.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="108" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\src\logic\display.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="671" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="ut_logic\ut_pot.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="112" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="ut_logic\ut_display.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="114" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="ut_logic\ut_coil.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="409" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="ut_logic\ut_display.c" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="2" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="14278" topLine="370" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="ut_logic\ut_force.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="485" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\src\logic\user_force.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="459" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
</CodeBlocks_layout_file>
|
||||
96
firmware/tests/ut_board/ut_ain.c
Normal file
96
firmware/tests/ut_board/ut_ain.c
Normal file
@@ -0,0 +1,96 @@
|
||||
#include "ut_ain.h"
|
||||
|
||||
#include "..\mock_mcu\mock_mcu_hal_r8.h"
|
||||
#include "..\..\src\hw\board\ain.h"
|
||||
|
||||
static const uint8_t NOT_ACCESED_ADC_CH = 255;
|
||||
|
||||
static int ut_bsp_ain_read(uint8_t ain_ch, uint16_t adc_raw, uint16_t exp_out, uint8_t exp_adc_ch)
|
||||
{
|
||||
printf(" Input: Ain-Ch:%d Adc-Raw:%d \n", ain_ch, adc_raw);
|
||||
|
||||
mock_mcu_adc_set_ch(NOT_ACCESED_ADC_CH);
|
||||
mock_mcu_adc_set_raw(adc_raw, exp_adc_ch);
|
||||
|
||||
uint16_t out = bsp_ain_read(ain_ch);
|
||||
|
||||
uint8_t adc_ch = mock_mcu_adc_read_ch();
|
||||
|
||||
printf(" Output: AIN:%d Adc-Ch:%d \n", out, adc_ch);
|
||||
printf("Expected: AIN:%d Adc-Ch:%d \n", exp_out, exp_adc_ch);
|
||||
|
||||
if((out==exp_out)&&(adc_ch==exp_adc_ch))
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_bsp_ain_read_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("uint16_t bsp_ain_read(uint8_t ch)\n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
uint8_t ain_ch;
|
||||
uint16_t adc_raw;
|
||||
uint16_t exp_out;
|
||||
uint8_t exp_adc_ch;
|
||||
|
||||
// Normal 1
|
||||
ain_ch = BSP_AIN1;
|
||||
adc_raw = 88;
|
||||
exp_out = 430;
|
||||
exp_adc_ch = MCU_ADC5;
|
||||
test_res = ut_bsp_ain_read(ain_ch, adc_raw, exp_out, exp_adc_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Normal 2
|
||||
ain_ch = BSP_AIN2;
|
||||
adc_raw = 88;
|
||||
exp_out = 430;
|
||||
exp_adc_ch = MCU_ADC4;
|
||||
test_res = ut_bsp_ain_read(ain_ch, adc_raw, exp_out, exp_adc_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Normal 3
|
||||
ain_ch = BSP_AIN3;
|
||||
adc_raw = 500;
|
||||
exp_out = 2443;
|
||||
exp_adc_ch = MCU_ADC8;
|
||||
test_res = ut_bsp_ain_read(ain_ch, adc_raw, exp_out, exp_adc_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Norma 4
|
||||
ain_ch = BSP_AIN4;
|
||||
adc_raw = 1023;
|
||||
exp_out = 4998;
|
||||
exp_adc_ch = MCU_ADC14;
|
||||
test_res = ut_bsp_ain_read(ain_ch, adc_raw, exp_out, exp_adc_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Normal 5
|
||||
ain_ch = BSP_AIN5;
|
||||
adc_raw = 1;
|
||||
exp_out = 4;
|
||||
exp_adc_ch = MCU_ADC15;
|
||||
test_res = ut_bsp_ain_read(ain_ch, adc_raw, exp_out, exp_adc_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Not existing ADC channel
|
||||
ain_ch = 0;
|
||||
adc_raw = 500;
|
||||
exp_out = 0;
|
||||
exp_adc_ch = NOT_ACCESED_ADC_CH;
|
||||
test_res = ut_bsp_ain_read(ain_ch, adc_raw, exp_out, exp_adc_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
9
firmware/tests/ut_board/ut_ain.h
Normal file
9
firmware/tests/ut_board/ut_ain.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef UT_BOARD_AIN_H_
|
||||
#define UT_BOARD_AIN_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int ut_bsp_ain_read_test(void);
|
||||
|
||||
#endif /* UT_BOARD_AIN_H_ */
|
||||
191
firmware/tests/ut_board/ut_din.c
Normal file
191
firmware/tests/ut_board/ut_din.c
Normal file
@@ -0,0 +1,191 @@
|
||||
#include "ut_din.h"
|
||||
|
||||
#include "..\mock_mcu\mock_mcu_hal_r8.h"
|
||||
#include "..\..\src\hw\board\din.h"
|
||||
|
||||
static const uint8_t NOT_ACCESED_GPIO_CH = 255;
|
||||
|
||||
static int ut_bsp_din_read(uint8_t din_ch, uint8_t gpio_lvl, uint8_t exp_out, uint8_t exp_gpio_ch)
|
||||
{
|
||||
printf(" Input: Din-Ch:%d GPIO-lvl:%d \n", din_ch, gpio_lvl);
|
||||
|
||||
mock_mcu_gpio_set_ch(NOT_ACCESED_GPIO_CH);
|
||||
mock_mcu_gpio_set_input_lvl(gpio_lvl, exp_gpio_ch);
|
||||
|
||||
uint8_t out = bsp_din_read(din_ch);
|
||||
|
||||
uint8_t gpio_ch = mock_mcu_gpio_read_ch();
|
||||
|
||||
printf(" Output: DIN:%d GPIO-Ch:%d \n", out, gpio_ch);
|
||||
printf("Expected: DIN:%d GPIO-Ch:%d \n", exp_out, exp_gpio_ch);
|
||||
|
||||
if((out==exp_out)&&(gpio_ch==exp_gpio_ch))
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_bsp_din_read_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("uint8_t bsp_din_read(uint8_t ch)\n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
uint8_t din_ch;
|
||||
uint8_t gpio_lvl;
|
||||
uint8_t exp_out;
|
||||
uint8_t exp_gpio_ch;
|
||||
|
||||
// DIN 1
|
||||
din_ch = BSP_DIN1;
|
||||
gpio_lvl = MCU_GPIO_LOW;
|
||||
exp_out = 0;
|
||||
exp_gpio_ch = MCU_GPIO0;
|
||||
test_res = ut_bsp_din_read(din_ch, gpio_lvl, exp_out, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
din_ch = BSP_DIN1;
|
||||
gpio_lvl = MCU_GPIO_HIGH;
|
||||
exp_out = 1;
|
||||
exp_gpio_ch = MCU_GPIO0;
|
||||
test_res = ut_bsp_din_read(din_ch, gpio_lvl, exp_out, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// DIN 2
|
||||
din_ch = BSP_DIN2;
|
||||
gpio_lvl = MCU_GPIO_LOW;
|
||||
exp_out = 0;
|
||||
exp_gpio_ch = MCU_GPIO1;
|
||||
test_res = ut_bsp_din_read(din_ch, gpio_lvl, exp_out, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
din_ch = BSP_DIN2;
|
||||
gpio_lvl = MCU_GPIO_HIGH;
|
||||
exp_out = 1;
|
||||
exp_gpio_ch = MCU_GPIO1;
|
||||
test_res = ut_bsp_din_read(din_ch, gpio_lvl, exp_out, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// DIN 3
|
||||
din_ch = BSP_DIN3;
|
||||
gpio_lvl = MCU_GPIO_LOW;
|
||||
exp_out = 0;
|
||||
exp_gpio_ch = MCU_GPIO2;
|
||||
test_res = ut_bsp_din_read(din_ch, gpio_lvl, exp_out, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
din_ch = BSP_DIN3;
|
||||
gpio_lvl = MCU_GPIO_HIGH;
|
||||
exp_out = 1;
|
||||
exp_gpio_ch = MCU_GPIO2;
|
||||
test_res = ut_bsp_din_read(din_ch, gpio_lvl, exp_out, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// DIN 4
|
||||
din_ch = BSP_DIN4;
|
||||
gpio_lvl = MCU_GPIO_LOW;
|
||||
exp_out = 0;
|
||||
exp_gpio_ch = MCU_GPIO3;
|
||||
test_res = ut_bsp_din_read(din_ch, gpio_lvl, exp_out, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
din_ch = BSP_DIN4;
|
||||
gpio_lvl = MCU_GPIO_HIGH;
|
||||
exp_out = 1;
|
||||
exp_gpio_ch = MCU_GPIO3;
|
||||
test_res = ut_bsp_din_read(din_ch, gpio_lvl, exp_out, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// DIN 5
|
||||
din_ch = BSP_DIN5;
|
||||
gpio_lvl = MCU_GPIO_LOW;
|
||||
exp_out = 1;
|
||||
exp_gpio_ch = MCU_GPIO4;
|
||||
test_res = ut_bsp_din_read(din_ch, gpio_lvl, exp_out, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
din_ch = BSP_DIN5;
|
||||
gpio_lvl = MCU_GPIO_HIGH;
|
||||
exp_out = 0;
|
||||
exp_gpio_ch = MCU_GPIO4;
|
||||
test_res = ut_bsp_din_read(din_ch, gpio_lvl, exp_out, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// DIN 6
|
||||
din_ch = BSP_DIN6;
|
||||
gpio_lvl = MCU_GPIO_LOW;
|
||||
exp_out = 1;
|
||||
exp_gpio_ch = MCU_GPIO5;
|
||||
test_res = ut_bsp_din_read(din_ch, gpio_lvl, exp_out, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
din_ch = BSP_DIN6;
|
||||
gpio_lvl = MCU_GPIO_HIGH;
|
||||
exp_out = 0;
|
||||
exp_gpio_ch = MCU_GPIO5;
|
||||
test_res = ut_bsp_din_read(din_ch, gpio_lvl, exp_out, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// DIN 7
|
||||
din_ch = BSP_DIN7;
|
||||
gpio_lvl = MCU_GPIO_LOW;
|
||||
exp_out = 1;
|
||||
exp_gpio_ch = MCU_GPIO6;
|
||||
test_res = ut_bsp_din_read(din_ch, gpio_lvl, exp_out, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
din_ch = BSP_DIN7;
|
||||
gpio_lvl = MCU_GPIO_HIGH;
|
||||
exp_out = 0;
|
||||
exp_gpio_ch = MCU_GPIO6;
|
||||
test_res = ut_bsp_din_read(din_ch, gpio_lvl, exp_out, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// DIN 7N
|
||||
din_ch = BSP_DIN7N;
|
||||
gpio_lvl = MCU_GPIO_LOW;
|
||||
exp_out = 0;
|
||||
exp_gpio_ch = MCU_GPIO7;
|
||||
test_res = ut_bsp_din_read(din_ch, gpio_lvl, exp_out, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
din_ch = BSP_DIN7N;
|
||||
gpio_lvl = MCU_GPIO_HIGH;
|
||||
exp_out = 1;
|
||||
exp_gpio_ch = MCU_GPIO7;
|
||||
test_res = ut_bsp_din_read(din_ch, gpio_lvl, exp_out, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Wrong channel
|
||||
din_ch = 0;
|
||||
gpio_lvl = MCU_GPIO_LOW;
|
||||
exp_out = 0;
|
||||
exp_gpio_ch = NOT_ACCESED_GPIO_CH;
|
||||
test_res = ut_bsp_din_read(din_ch, gpio_lvl, exp_out, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// DSP OUTPUT DEFINITIONS
|
||||
din_ch = BSP_DIN1;
|
||||
gpio_lvl = MCU_GPIO_LOW;
|
||||
exp_out = BSP_DIN_LOW;
|
||||
exp_gpio_ch = MCU_GPIO0;
|
||||
test_res = ut_bsp_din_read(din_ch, gpio_lvl, exp_out, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
din_ch = BSP_DIN1;
|
||||
gpio_lvl = MCU_GPIO_HIGH;
|
||||
exp_out = BSP_DIN_HIGH;
|
||||
exp_gpio_ch = MCU_GPIO0;
|
||||
test_res = ut_bsp_din_read(din_ch, gpio_lvl, exp_out, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
9
firmware/tests/ut_board/ut_din.h
Normal file
9
firmware/tests/ut_board/ut_din.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef UT_BOARD_DIN_H_
|
||||
#define UT_BOARD_DIN_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int ut_bsp_din_read_test(void);
|
||||
|
||||
#endif /* UT_BOARD_DIN_H_ */
|
||||
142
firmware/tests/ut_board/ut_dout.c
Normal file
142
firmware/tests/ut_board/ut_dout.c
Normal file
@@ -0,0 +1,142 @@
|
||||
#include "ut_dout.h"
|
||||
|
||||
#include "..\mock_mcu\mock_mcu_hal_r8.h"
|
||||
#include "..\..\src\hw\board\dout.h"
|
||||
|
||||
static const uint8_t NOT_ACCESED_GPIO_CH = 255;
|
||||
static const uint8_t NOT_ACCESED_GPIO_LVL = MCU_GPIO_HIZ;
|
||||
|
||||
static int ut_bsp_dout_write(uint8_t dout_ch, int8_t dout_lvl, int8_t exp_gpio_lvl, uint8_t exp_gpio_ch)
|
||||
{
|
||||
printf(" Input: Dout-Ch:%d Dout-lvl:%d \n", dout_ch, dout_lvl);
|
||||
|
||||
mock_mcu_gpio_set_ch(NOT_ACCESED_GPIO_CH);
|
||||
mock_mcu_gpio_set_output_lvl(NOT_ACCESED_GPIO_LVL, exp_gpio_ch);
|
||||
|
||||
bsp_dout_write(dout_ch, dout_lvl);
|
||||
|
||||
uint8_t gpio_ch = mock_mcu_gpio_read_ch();
|
||||
int8_t gpio_lvl = mock_mcu_gpio_read_output_lvl(gpio_ch);
|
||||
|
||||
printf(" Output: GPIO-lvl:%d GPIO-Ch:%d \n", gpio_lvl, gpio_ch);
|
||||
printf("Expected: GPIO-lvl:%d GPIO-Ch:%d \n", exp_gpio_lvl, exp_gpio_ch);
|
||||
|
||||
if((gpio_lvl==exp_gpio_lvl)&&(gpio_ch==exp_gpio_ch))
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_bsp_dout_write_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("void bsp_dout_write(uint8_t ch, int8_t lvl)\n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
uint8_t dout_ch;
|
||||
uint8_t dout_lvl;
|
||||
int8_t exp_gpio_lvl;
|
||||
uint8_t exp_gpio_ch;
|
||||
|
||||
// DOUT 1
|
||||
dout_ch = BSP_DOUT1;
|
||||
dout_lvl = 0;
|
||||
exp_gpio_lvl = MCU_GPIO_LOW;
|
||||
exp_gpio_ch = MCU_GPIO0;
|
||||
test_res = ut_bsp_dout_write(dout_ch, dout_lvl, exp_gpio_lvl, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
dout_ch = BSP_DOUT1;
|
||||
dout_lvl = 1;
|
||||
exp_gpio_lvl = MCU_GPIO_HIGH;
|
||||
exp_gpio_ch = MCU_GPIO0;
|
||||
test_res = ut_bsp_dout_write(dout_ch, dout_lvl, exp_gpio_lvl, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
dout_ch = BSP_DOUT1;
|
||||
dout_lvl = -1;
|
||||
exp_gpio_lvl = MCU_GPIO_HIZ;
|
||||
exp_gpio_ch = MCU_GPIO0;
|
||||
test_res = ut_bsp_dout_write(dout_ch, dout_lvl, exp_gpio_lvl, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Defines test
|
||||
dout_ch = BSP_DOUT1;
|
||||
dout_lvl = BSP_DOUT_LOW;
|
||||
exp_gpio_lvl = MCU_GPIO_LOW;
|
||||
exp_gpio_ch = MCU_GPIO0;
|
||||
test_res = ut_bsp_dout_write(dout_ch, dout_lvl, exp_gpio_lvl, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
dout_ch = BSP_DOUT1;
|
||||
dout_lvl = BSP_DOUT_HIGH;
|
||||
exp_gpio_lvl = MCU_GPIO_HIGH;
|
||||
exp_gpio_ch = MCU_GPIO0;
|
||||
test_res = ut_bsp_dout_write(dout_ch, dout_lvl, exp_gpio_lvl, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
dout_ch = BSP_DOUT1;
|
||||
dout_lvl = BSP_DOUT_HIZ;
|
||||
exp_gpio_lvl = MCU_GPIO_HIZ;
|
||||
exp_gpio_ch = MCU_GPIO0;
|
||||
test_res = ut_bsp_dout_write(dout_ch, dout_lvl, exp_gpio_lvl, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// DOUT 2
|
||||
dout_ch = BSP_DOUT2;
|
||||
dout_lvl = BSP_DOUT_LOW;
|
||||
exp_gpio_lvl = MCU_GPIO_LOW;
|
||||
exp_gpio_ch = MCU_GPIO1;
|
||||
test_res = ut_bsp_dout_write(dout_ch, dout_lvl, exp_gpio_lvl, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// DOUT 3
|
||||
dout_ch = BSP_DOUT3;
|
||||
dout_lvl = BSP_DOUT_HIGH;
|
||||
exp_gpio_lvl = MCU_GPIO_HIGH;
|
||||
exp_gpio_ch = MCU_GPIO2;
|
||||
test_res = ut_bsp_dout_write(dout_ch, dout_lvl, exp_gpio_lvl, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// DOUT 4
|
||||
dout_ch = BSP_DOUT4;
|
||||
dout_lvl = BSP_DOUT_LOW;
|
||||
exp_gpio_lvl = MCU_GPIO_LOW;
|
||||
exp_gpio_ch = MCU_GPIO3;
|
||||
test_res = ut_bsp_dout_write(dout_ch, dout_lvl, exp_gpio_lvl, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// DOUT 5
|
||||
dout_ch = BSP_DOUT5;
|
||||
dout_lvl = BSP_DOUT_HIGH;
|
||||
exp_gpio_lvl = MCU_GPIO_HIGH;
|
||||
exp_gpio_ch = MCU_GPIO7;
|
||||
test_res = ut_bsp_dout_write(dout_ch, dout_lvl, exp_gpio_lvl, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// DOUT 6
|
||||
dout_ch = BSP_DOUT6;
|
||||
dout_lvl = BSP_DOUT_LOW;
|
||||
exp_gpio_lvl = MCU_GPIO_LOW;
|
||||
exp_gpio_ch = MCU_GPIO8;
|
||||
test_res = ut_bsp_dout_write(dout_ch, dout_lvl, exp_gpio_lvl, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Wrong channel
|
||||
dout_ch = 0;
|
||||
dout_lvl = BSP_DOUT_HIGH;
|
||||
exp_gpio_lvl = NOT_ACCESED_GPIO_LVL;
|
||||
exp_gpio_ch = NOT_ACCESED_GPIO_CH;
|
||||
test_res = ut_bsp_dout_write(dout_ch, dout_lvl, exp_gpio_lvl, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
9
firmware/tests/ut_board/ut_dout.h
Normal file
9
firmware/tests/ut_board/ut_dout.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef UT_BOARD_DOUT_H_
|
||||
#define UT_BOARD_DOUT_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int ut_bsp_dout_write_test(void);
|
||||
|
||||
#endif /* UT_BOARD_DOUT_H_ */
|
||||
273
firmware/tests/ut_board/ut_halfbridge.c
Normal file
273
firmware/tests/ut_board/ut_halfbridge.c
Normal file
@@ -0,0 +1,273 @@
|
||||
#include "ut_dout.h"
|
||||
|
||||
#include "..\mock_mcu\mock_mcu_hal_r8.h"
|
||||
#include "..\..\src\hw\board\halfbridge.h"
|
||||
|
||||
static const uint8_t NOT_ACCESED_GPIO_CH = 255;
|
||||
static const uint8_t NOT_ACCESED_GPIO_LVL = MCU_GPIO_HIZ;
|
||||
|
||||
static int ut_bsp_hb_write_low(uint8_t state, int8_t exp_gpio_lvl, uint8_t exp_gpio_ch)
|
||||
{
|
||||
printf(" Input: State:%d \n", state);
|
||||
|
||||
mock_mcu_gpio_set_ch(NOT_ACCESED_GPIO_CH);
|
||||
mock_mcu_gpio_set_output_lvl(NOT_ACCESED_GPIO_LVL, exp_gpio_ch);
|
||||
|
||||
bsp_hb_write_low(state);
|
||||
|
||||
uint8_t gpio_ch = mock_mcu_gpio_read_ch();
|
||||
int8_t gpio_lvl = mock_mcu_gpio_read_output_lvl(gpio_ch);
|
||||
|
||||
printf(" Output: GPIO-lvl:%d GPIO-Ch:%d \n", gpio_lvl, gpio_ch);
|
||||
printf("Expected: GPIO-lvl:%d GPIO-Ch:%d \n", exp_gpio_lvl, exp_gpio_ch);
|
||||
|
||||
if((gpio_lvl==exp_gpio_lvl)&&(gpio_ch==exp_gpio_ch))
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_bsp_hb_write_low_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("void bsp_hb_write_low(uint8_t state) \n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
uint8_t state;
|
||||
int8_t exp_gpio_lvl;
|
||||
uint8_t exp_gpio_ch;
|
||||
|
||||
// Low
|
||||
state = 0;
|
||||
exp_gpio_lvl = MCU_GPIO_LOW;
|
||||
exp_gpio_ch = MCU_GPIO15;
|
||||
test_res = ut_bsp_hb_write_low(state, exp_gpio_lvl, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// High
|
||||
state = 1;
|
||||
exp_gpio_lvl = MCU_GPIO_HIGH;
|
||||
exp_gpio_ch = MCU_GPIO15;
|
||||
test_res = ut_bsp_hb_write_low(state, exp_gpio_lvl, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// High
|
||||
state = 255;
|
||||
exp_gpio_lvl = MCU_GPIO_HIGH;
|
||||
exp_gpio_ch = MCU_GPIO15;
|
||||
test_res = ut_bsp_hb_write_low(state, exp_gpio_lvl, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
|
||||
static const uint8_t NOT_ACCESED_PWM_CH = 255;
|
||||
static const uint8_t NOT_ACCESED_PWM_VAL = 0xFFFF;
|
||||
|
||||
static int ut_bsp_hb_write_pwm(uint16_t pwm, uint16_t exp_pwm, uint8_t exp_pwm_ch)
|
||||
{
|
||||
printf(" Input: PWM:%d \n", pwm);
|
||||
|
||||
mock_mcu_pwm_set_ch(NOT_ACCESED_PWM_CH);
|
||||
mock_mcu_pwm_set_raw(NOT_ACCESED_PWM_VAL, exp_pwm_ch);
|
||||
|
||||
bsp_hb_write_pwm(pwm);
|
||||
|
||||
uint8_t pwm_ch = mock_mcu_pwm_read_ch();
|
||||
uint16_t pwm_value = mock_mcu_pwm_read_raw(pwm_ch);
|
||||
|
||||
printf(" Output: PWM:%d PWM-Ch:%d \n", pwm_value, pwm_ch);
|
||||
printf("Expected: PWM:%d PWM-Ch:%d \n", exp_pwm, exp_pwm_ch);
|
||||
|
||||
if((pwm_value==exp_pwm)&&(pwm_ch==exp_pwm_ch))
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_bsp_hb_write_pwm_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("void bsp_hb_write_pwm(uint16_t pwm) \n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
uint16_t pwm;
|
||||
uint16_t exp_pwm;
|
||||
uint8_t exp_pwm_ch;
|
||||
|
||||
// 0
|
||||
pwm = 0;
|
||||
exp_pwm = 0;
|
||||
exp_pwm_ch = MCU_PWM0;
|
||||
test_res = ut_bsp_hb_write_pwm(pwm, exp_pwm, exp_pwm_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// 100
|
||||
pwm = 100;
|
||||
exp_pwm = 100;
|
||||
exp_pwm_ch = MCU_PWM0;
|
||||
test_res = ut_bsp_hb_write_pwm(pwm, exp_pwm, exp_pwm_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// 95%
|
||||
pwm = 0xFC00;
|
||||
exp_pwm = 0xFC00;
|
||||
exp_pwm_ch = MCU_PWM0;
|
||||
test_res = ut_bsp_hb_write_pwm(pwm, exp_pwm, exp_pwm_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// MAX
|
||||
pwm = 0xFFFF;
|
||||
exp_pwm = 0xFC00;
|
||||
exp_pwm_ch = MCU_PWM0;
|
||||
test_res = ut_bsp_hb_write_pwm(pwm, exp_pwm, exp_pwm_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
|
||||
static const uint8_t NOT_ACCESED_ADC_CH = 255;
|
||||
static const uint8_t NOT_ACCESED_ADC_VAL = 0xFFFF;
|
||||
|
||||
static int ut_bsp_hb_read_meas(uint16_t adc_sup_u, uint16_t adc_sup_i, uint16_t adc_out_u, uint16_t adc_out_i, uint8_t low_side_lvl, uint16_t act_pwm, hb_meas_t* exp_meas)
|
||||
{
|
||||
printf(" Input: Out-U:%d Out-I:%d Sup-U:%d Sup-I:%d Low-Lvl:%d PWM:%d \n", adc_out_u, adc_out_i, adc_sup_u, adc_sup_i, low_side_lvl, act_pwm);
|
||||
|
||||
mock_mcu_adc_set_ch(NOT_ACCESED_ADC_CH);
|
||||
mock_mcu_adc_set_raw(adc_sup_u, MCU_ADC2);
|
||||
mock_mcu_adc_set_raw(adc_sup_i, MCU_ADC3);
|
||||
mock_mcu_adc_set_raw(adc_out_u, MCU_ADC1);
|
||||
mock_mcu_adc_set_raw(adc_out_i, MCU_ADC0);
|
||||
|
||||
mock_mcu_gpio_set_ch(NOT_ACCESED_GPIO_CH);
|
||||
mock_mcu_gpio_set_input_lvl(low_side_lvl, MCU_GPIO15);
|
||||
|
||||
mock_mcu_pwm_set_ch(NOT_ACCESED_PWM_CH);
|
||||
mock_mcu_pwm_set_raw(act_pwm, MCU_PWM0);
|
||||
|
||||
hb_meas_t out;
|
||||
|
||||
bsp_hb_read_meas(&out);
|
||||
|
||||
uint8_t adc_ch = mock_mcu_adc_read_ch();
|
||||
uint8_t gpio_ch = mock_mcu_gpio_read_ch();
|
||||
uint8_t pwm_ch = mock_mcu_pwm_read_ch();
|
||||
|
||||
int equal = 1;
|
||||
|
||||
if(out.out_voltage != exp_meas->out_voltage) equal = 0;
|
||||
if(out.out_current != exp_meas->out_current) equal = 0;
|
||||
if(out.sup_voltage != exp_meas->sup_voltage) equal = 0;
|
||||
if(out.sup_current != exp_meas->sup_current) equal = 0;
|
||||
if(out.out_power != exp_meas->out_power) equal = 0;
|
||||
if(out.sup_power != exp_meas->sup_power) equal = 0;
|
||||
if(out.out_impedance != exp_meas->out_impedance) equal = 0;
|
||||
if(out.low_side_ctrl != exp_meas->low_side_ctrl) equal = 0;
|
||||
if(out.pwm != exp_meas->pwm) equal = 0;
|
||||
|
||||
printf(" Output: Out-U:%d Out-I:%d Bat-U:%d Bat-I:%d Out-P:%d Bat-P:%d Out-Z:%d Low:%d PWM:%d \n", out.out_voltage, out.out_current, out.sup_voltage, out.sup_current, out.out_power, out.sup_power, out.out_impedance, out.low_side_ctrl, out.pwm);
|
||||
printf("Expected: Out-U:%d Out-I:%d Bat-U:%d Bat-I:%d Out-P:%d Bat-P:%d Out-Z:%d Low:%d PWM:%d \n", exp_meas->out_voltage, exp_meas->out_current, exp_meas->sup_voltage, exp_meas->sup_current, exp_meas->out_power, exp_meas->sup_power, exp_meas->out_impedance, exp_meas->low_side_ctrl, exp_meas->pwm);
|
||||
|
||||
if((equal)&&(gpio_ch==MCU_GPIO15)&&(pwm_ch==MCU_PWM0)&&(adc_ch!=NOT_ACCESED_ADC_CH))
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_bsp_hb_read_meas_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("void bsp_hb_read_meas(hb_meas_t* measurements) \n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
uint16_t adc_sup_u;
|
||||
uint16_t adc_sup_i;
|
||||
uint16_t adc_out_u;
|
||||
uint16_t adc_out_i;
|
||||
uint8_t low_side_lvl;
|
||||
uint16_t act_pwm;
|
||||
hb_meas_t exp_meas;
|
||||
|
||||
// 0
|
||||
adc_sup_u = 0;
|
||||
adc_sup_i = 0;
|
||||
adc_out_u = 0;
|
||||
adc_out_i = 0;
|
||||
low_side_lvl = MCU_GPIO_LOW;
|
||||
act_pwm = 0x0000;
|
||||
exp_meas.out_voltage = 0;
|
||||
exp_meas.out_current = 0;
|
||||
exp_meas.sup_voltage = 0;
|
||||
exp_meas.sup_current = 0;
|
||||
exp_meas.out_power = 0;
|
||||
exp_meas.sup_power = 0;
|
||||
exp_meas.out_impedance = 0xFFFF;
|
||||
exp_meas.low_side_ctrl = 0;
|
||||
exp_meas.pwm = 0;
|
||||
test_res = ut_bsp_hb_read_meas(adc_sup_u, adc_sup_i, adc_out_u, adc_out_i, low_side_lvl, act_pwm, &exp_meas);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Limits
|
||||
adc_sup_u = 1023;
|
||||
adc_sup_i = 1023;
|
||||
adc_out_u = 1023;
|
||||
adc_out_i = 1023;
|
||||
low_side_lvl = MCU_GPIO_HIGH;
|
||||
act_pwm = 457;
|
||||
exp_meas.out_voltage = 20460;
|
||||
exp_meas.out_current = 9997;
|
||||
exp_meas.sup_voltage = 20460;
|
||||
exp_meas.sup_current = 40067;
|
||||
exp_meas.out_power = 0xFFFF;
|
||||
exp_meas.sup_power = 0xFFFF;
|
||||
exp_meas.out_impedance = 2046;
|
||||
exp_meas.low_side_ctrl = 1;
|
||||
exp_meas.pwm = 457;
|
||||
test_res = ut_bsp_hb_read_meas(adc_sup_u, adc_sup_i, adc_out_u, adc_out_i, low_side_lvl, act_pwm, &exp_meas);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Normal
|
||||
adc_sup_u = 600;
|
||||
adc_sup_i = 51;
|
||||
adc_out_u = 300;
|
||||
adc_out_i = 409;
|
||||
low_side_lvl = MCU_GPIO_HIGH;
|
||||
act_pwm = 0xAAAA;
|
||||
exp_meas.out_voltage = 6000;
|
||||
exp_meas.out_current = 3997;
|
||||
exp_meas.sup_voltage = 12000;
|
||||
exp_meas.sup_current = 1997;
|
||||
exp_meas.out_power = 23982;
|
||||
exp_meas.sup_power = 23964;
|
||||
exp_meas.out_impedance = 1501;
|
||||
exp_meas.low_side_ctrl = 1;
|
||||
exp_meas.pwm = 0xAAAA;
|
||||
test_res = ut_bsp_hb_read_meas(adc_sup_u, adc_sup_i, adc_out_u, adc_out_i, low_side_lvl, act_pwm, &exp_meas);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
11
firmware/tests/ut_board/ut_halfbridge.h
Normal file
11
firmware/tests/ut_board/ut_halfbridge.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifndef UT_BOARD_HALFBRIDGE_H_
|
||||
#define UT_BOARD_HALFBRIDGE_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int ut_bsp_hb_write_low_test(void);
|
||||
int ut_bsp_hb_write_pwm_test(void);
|
||||
int ut_bsp_hb_read_meas_test(void);
|
||||
|
||||
#endif /* UT_BOARD_HALFBRIDGE_H_ */
|
||||
212
firmware/tests/ut_board/ut_odout.c
Normal file
212
firmware/tests/ut_board/ut_odout.c
Normal file
@@ -0,0 +1,212 @@
|
||||
#include "ut_odout.h"
|
||||
|
||||
#include "..\mock_mcu\mock_mcu_hal_r8.h"
|
||||
#include "..\..\src\hw\board\odout.h"
|
||||
|
||||
static const uint8_t NOT_ACCESED_GPIO_CH = 255;
|
||||
static const uint8_t NOT_ACCESED_GPIO_LVL = MCU_GPIO_HIZ;
|
||||
|
||||
static int ut_bsp_odout_write(uint8_t odout_ch, int8_t odout_lvl, int8_t exp_gpio_lvl, uint8_t exp_gpio_ch)
|
||||
{
|
||||
printf(" Input: ODout-Ch:%d ODout-lvl:%d \n", odout_ch, odout_lvl);
|
||||
|
||||
mock_mcu_gpio_set_ch(NOT_ACCESED_GPIO_CH);
|
||||
mock_mcu_gpio_set_output_lvl(NOT_ACCESED_GPIO_LVL, exp_gpio_ch);
|
||||
|
||||
bsp_odout_write(odout_ch, odout_lvl);
|
||||
|
||||
uint8_t gpio_ch = mock_mcu_gpio_read_ch();
|
||||
int8_t gpio_lvl = mock_mcu_gpio_read_output_lvl(gpio_ch);
|
||||
|
||||
printf(" Output: GPIO-lvl:%d GPIO-Ch:%d \n", gpio_lvl, gpio_ch);
|
||||
printf("Expected: GPIO-lvl:%d GPIO-Ch:%d \n", exp_gpio_lvl, exp_gpio_ch);
|
||||
|
||||
if((gpio_lvl==exp_gpio_lvl)&&(gpio_ch==exp_gpio_ch))
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_bsp_odout_write_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("void bsp_odout_write(uint8_t ch, int8_t lvl) \n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
uint8_t odout_ch;
|
||||
uint8_t odout_lvl;
|
||||
int8_t exp_gpio_lvl;
|
||||
uint8_t exp_gpio_ch;
|
||||
|
||||
// Control level - LOW
|
||||
odout_ch = BSP_OD1;
|
||||
odout_lvl = 0;
|
||||
exp_gpio_lvl = MCU_GPIO_HIGH;
|
||||
exp_gpio_ch = MCU_GPIO9;
|
||||
test_res = ut_bsp_odout_write(odout_ch, odout_lvl, exp_gpio_lvl, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Control level - HIGH
|
||||
odout_ch = BSP_OD1;
|
||||
odout_lvl = 1;
|
||||
exp_gpio_lvl = MCU_GPIO_LOW;
|
||||
exp_gpio_ch = MCU_GPIO9;
|
||||
test_res = ut_bsp_odout_write(odout_ch, odout_lvl, exp_gpio_lvl, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Control level - HIZ
|
||||
odout_ch = BSP_OD1;
|
||||
odout_lvl = -1;
|
||||
exp_gpio_lvl = MCU_GPIO_LOW;
|
||||
exp_gpio_ch = MCU_GPIO9;
|
||||
test_res = ut_bsp_odout_write(odout_ch, odout_lvl, exp_gpio_lvl, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Control level DEFINE - LOW
|
||||
odout_ch = BSP_OD1;
|
||||
odout_lvl = BSP_ODOUT_LOW;
|
||||
exp_gpio_lvl = MCU_GPIO_HIGH;
|
||||
exp_gpio_ch = MCU_GPIO9;
|
||||
test_res = ut_bsp_odout_write(odout_ch, odout_lvl, exp_gpio_lvl, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Control level DEFINE - HIGH
|
||||
odout_ch = BSP_OD1;
|
||||
odout_lvl = BSP_ODOUT_HIGH;
|
||||
exp_gpio_lvl = MCU_GPIO_LOW;
|
||||
exp_gpio_ch = MCU_GPIO9;
|
||||
test_res = ut_bsp_odout_write(odout_ch, odout_lvl, exp_gpio_lvl, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Control level DEFINE - HIZ
|
||||
odout_ch = BSP_OD1;
|
||||
odout_lvl = BSP_ODOUT_HIZ;
|
||||
exp_gpio_lvl = MCU_GPIO_LOW;
|
||||
exp_gpio_ch = MCU_GPIO9;
|
||||
test_res = ut_bsp_odout_write(odout_ch, odout_lvl, exp_gpio_lvl, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// ODOUT 2
|
||||
odout_ch = BSP_OD2;
|
||||
odout_lvl = 0;
|
||||
exp_gpio_lvl = MCU_GPIO_HIGH;
|
||||
exp_gpio_ch = MCU_GPIO10;
|
||||
test_res = ut_bsp_odout_write(odout_ch, odout_lvl, exp_gpio_lvl, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// ODOUT 3
|
||||
odout_ch = BSP_OD3;
|
||||
odout_lvl = 0;
|
||||
exp_gpio_lvl = MCU_GPIO_HIGH;
|
||||
exp_gpio_ch = MCU_GPIO11;
|
||||
test_res = ut_bsp_odout_write(odout_ch, odout_lvl, exp_gpio_lvl, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// ODOUT 4
|
||||
odout_ch = BSP_OD4;
|
||||
odout_lvl = 0;
|
||||
exp_gpio_lvl = MCU_GPIO_HIGH;
|
||||
exp_gpio_ch = MCU_GPIO12;
|
||||
test_res = ut_bsp_odout_write(odout_ch, odout_lvl, exp_gpio_lvl, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// ODOUT 5
|
||||
odout_ch = BSP_OD5;
|
||||
odout_lvl = 0;
|
||||
exp_gpio_lvl = MCU_GPIO_HIGH;
|
||||
exp_gpio_ch = MCU_GPIO13;
|
||||
test_res = ut_bsp_odout_write(odout_ch, odout_lvl, exp_gpio_lvl, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// ODOUT 6
|
||||
odout_ch = BSP_OD6;
|
||||
odout_lvl = 0;
|
||||
exp_gpio_lvl = MCU_GPIO_HIGH;
|
||||
exp_gpio_ch = MCU_GPIO14;
|
||||
test_res = ut_bsp_odout_write(odout_ch, odout_lvl, exp_gpio_lvl, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Wrong chanell
|
||||
odout_ch = 0;
|
||||
odout_lvl = 0;
|
||||
exp_gpio_lvl = NOT_ACCESED_GPIO_LVL;
|
||||
exp_gpio_ch = NOT_ACCESED_GPIO_CH;
|
||||
test_res = ut_bsp_odout_write(odout_ch, odout_lvl, exp_gpio_lvl, exp_gpio_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
|
||||
static const uint8_t NOT_ACCESED_PWM_CH = 255;
|
||||
static const uint8_t NOT_ACCESED_PWM_VAL = 0xFFFF;
|
||||
|
||||
static int ut_bsp_odout_write_common(uint8_t percent, uint16_t exp_pwm, uint8_t exp_pwm_ch)
|
||||
{
|
||||
printf(" Input: Percent:%d \n", percent);
|
||||
|
||||
mock_mcu_pwm_set_ch(NOT_ACCESED_PWM_CH);
|
||||
mock_mcu_pwm_set_raw(NOT_ACCESED_PWM_VAL, exp_pwm_ch);
|
||||
|
||||
bsp_odout_write_common(percent);
|
||||
|
||||
uint8_t pwm_ch = mock_mcu_pwm_read_ch();
|
||||
uint16_t pwm_value = mock_mcu_pwm_read_raw(pwm_ch);
|
||||
|
||||
printf(" Output: PWM:%d PWM-Ch:%d \n", pwm_value, pwm_ch);
|
||||
printf("Expected: PWM:%d PWM-Ch:%d \n", exp_pwm, exp_pwm_ch);
|
||||
|
||||
if((pwm_value==exp_pwm)&&(pwm_ch==exp_pwm_ch))
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_bsp_odout_write_common_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("void bsp_odout_write_common(uint8_t percent) \n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
uint8_t percent;
|
||||
uint16_t exp_pwm;
|
||||
uint8_t exp_pwm_ch;
|
||||
|
||||
// Zero
|
||||
percent = 0;
|
||||
exp_pwm = 0x0000;
|
||||
exp_pwm_ch = MCU_PWM1;
|
||||
test_res = ut_bsp_odout_write_common(percent, exp_pwm, exp_pwm_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// 100
|
||||
percent = 100;
|
||||
exp_pwm = 0xFFFF;
|
||||
exp_pwm_ch = MCU_PWM1;
|
||||
test_res = ut_bsp_odout_write_common(percent, exp_pwm, exp_pwm_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// 50
|
||||
percent = 50;
|
||||
exp_pwm = 0x7FFF;
|
||||
exp_pwm_ch = MCU_PWM1;
|
||||
test_res = ut_bsp_odout_write_common(percent, exp_pwm, exp_pwm_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
10
firmware/tests/ut_board/ut_odout.h
Normal file
10
firmware/tests/ut_board/ut_odout.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef UT_BOARD_ODOUT_H_
|
||||
#define UT_BOARD_ODOUT_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int ut_bsp_odout_write_test(void);
|
||||
int ut_bsp_odout_write_common_test(void);
|
||||
|
||||
#endif /* UT_BOARD_ODOUT_H_ */
|
||||
62
firmware/tests/ut_board/ut_setup.c
Normal file
62
firmware/tests/ut_board/ut_setup.c
Normal file
@@ -0,0 +1,62 @@
|
||||
#include "ut_odout.h"
|
||||
|
||||
#include "..\mock_mcu\mock_mcu_hal_r8.h"
|
||||
#include "..\..\src\hw\board\setup.h"
|
||||
|
||||
static adcClkDiv_t not_accesed_adc_clk = MCU_ADC_DIV128;
|
||||
static timerClkDiv_t not_accesed_pwm_clk = MCU_TIM_DIV1024;
|
||||
static uint16_t not_accesed_pwm_top = 0;
|
||||
static uint8_t not_accesed_pwm_chb_en = 255;
|
||||
|
||||
static int ut_bsp_startup(startupCfg_t* exp_cfg)
|
||||
{
|
||||
printf(" Input: \n");
|
||||
|
||||
startupCfg_t not_accesd_cfg;
|
||||
not_accesd_cfg.adc_clk = not_accesed_adc_clk;
|
||||
not_accesd_cfg.pwm_clk = not_accesed_pwm_clk;
|
||||
not_accesd_cfg.pwm_top = not_accesed_pwm_top;
|
||||
not_accesd_cfg.pwm_chb_en = not_accesed_pwm_chb_en;
|
||||
mock_mcu_startup_write_cfg(¬_accesd_cfg);
|
||||
|
||||
bsp_startup();
|
||||
|
||||
startupCfg_t cfg;
|
||||
mock_mcu_startup_read_cfg(&cfg);
|
||||
|
||||
printf(" Output: ADC-CLK:%d PWN-CLK:%d PWM-TOP:%d PWM-CHB-EN:%d \n", cfg.adc_clk, cfg.pwm_clk, cfg.pwm_top, cfg.pwm_chb_en);
|
||||
printf("Expected: ADC-CLK:%d PWN-CLK:%d PWM-TOP:%d PWM-CHB-EN:%d \n", exp_cfg->adc_clk, exp_cfg->pwm_clk, exp_cfg->pwm_top, exp_cfg->pwm_chb_en);
|
||||
|
||||
if((cfg.adc_clk==exp_cfg->adc_clk)&&(cfg.pwm_clk==exp_cfg->pwm_clk)&&(cfg.pwm_top==exp_cfg->pwm_top)&&(cfg.pwm_chb_en==exp_cfg->pwm_chb_en))
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_bsp_startup_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("void bsp_startup(void) \n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
startupCfg_t exp_cfg;
|
||||
|
||||
// Control level - LOW
|
||||
exp_cfg.adc_clk = MCU_ADC_DIV2;
|
||||
exp_cfg.pwm_clk = MCU_TIM_DIV1;
|
||||
exp_cfg.pwm_top = 511;
|
||||
exp_cfg.pwm_chb_en = 1;
|
||||
test_res = ut_bsp_startup(&exp_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
|
||||
9
firmware/tests/ut_board/ut_setup.h
Normal file
9
firmware/tests/ut_board/ut_setup.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef UT_BOARD_SETUP_H_
|
||||
#define UT_BOARD_SETUP_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int ut_bsp_startup_test(void);
|
||||
|
||||
#endif /* UT_BOARD_SETUP_H_ */
|
||||
73
firmware/tests/ut_hw/ut_analog.c
Normal file
73
firmware/tests/ut_hw/ut_analog.c
Normal file
@@ -0,0 +1,73 @@
|
||||
#include "ut_analog.h"
|
||||
|
||||
#include "..\mock_board\mock_board_ain.h"
|
||||
|
||||
#include "..\..\src\hw\analog.h"
|
||||
|
||||
static const uint8_t NOT_ACCESED_AIN_CH = 255;
|
||||
|
||||
static int ut_analog_ch_get(uint8_t analog_ch, uint16_t ain_value, uint16_t exp_out, uint8_t exp_ain_ch)
|
||||
{
|
||||
printf(" Input: Analog-Ch:%d AIN-Value:%d \n", analog_ch, ain_value);
|
||||
|
||||
mock_board_ain_write_ch(NOT_ACCESED_AIN_CH);
|
||||
mock_board_ain_write_data(exp_ain_ch, ain_value);
|
||||
|
||||
uint16_t out = analog_ch_get(analog_ch);
|
||||
|
||||
uint8_t ain_ch = mock_board_ain_read_ch();
|
||||
|
||||
printf(" Output: ANALOG:%d AIN-Ch:%d \n", out, ain_ch);
|
||||
printf("Expected: ANALOG:%d AIN-Ch:%d \n", exp_out, exp_ain_ch);
|
||||
|
||||
if((out==exp_out)&&(ain_ch==exp_ain_ch))
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_analog_ch_get_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("uint16_t analog_ch_get(uint8_t analog_ch) \n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
uint8_t analog_ch;
|
||||
uint16_t ain_value;
|
||||
uint16_t exp_out;
|
||||
uint8_t exp_ain_ch;
|
||||
|
||||
// Normal 1
|
||||
analog_ch = ANALOG_1;
|
||||
ain_value = 2500;
|
||||
exp_out = 2500;
|
||||
exp_ain_ch = BSP_AIN2;
|
||||
test_res = ut_analog_ch_get(analog_ch, ain_value, exp_out, exp_ain_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Normal 2
|
||||
analog_ch = ANALOG_2;
|
||||
ain_value = 3000;
|
||||
exp_out = 3000;
|
||||
exp_ain_ch = BSP_AIN1;
|
||||
test_res = ut_analog_ch_get(analog_ch, ain_value, exp_out, exp_ain_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Wrong channel
|
||||
analog_ch = 0;
|
||||
ain_value = 1200;
|
||||
exp_out = 0;
|
||||
exp_ain_ch = NOT_ACCESED_AIN_CH;
|
||||
test_res = ut_analog_ch_get(analog_ch, ain_value, exp_out, exp_ain_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
9
firmware/tests/ut_hw/ut_analog.h
Normal file
9
firmware/tests/ut_hw/ut_analog.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef UT_HW_ANALOG_H_
|
||||
#define UT_HW_ANALOG_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int ut_analog_ch_get_test(void);
|
||||
|
||||
#endif /* UT_HW_ANALOG_H_ */
|
||||
854
firmware/tests/ut_hw/ut_buttons.c
Normal file
854
firmware/tests/ut_hw/ut_buttons.c
Normal file
@@ -0,0 +1,854 @@
|
||||
#include "ut_buttons.h"
|
||||
|
||||
#include "..\mock_board\mock_board_din.h"
|
||||
#include "..\mock_board\mock_board_dout.h"
|
||||
|
||||
#include "..\..\src\hw\buttons.h"
|
||||
|
||||
static const uint8_t NOT_ACCESED_DIN_CH = 255;
|
||||
static const uint8_t NOT_ACCESED_DIN_LVL = BSP_DIN_LOW;
|
||||
|
||||
static const uint8_t NOT_ACCESED_DOUT_CH = 255;
|
||||
static const int8_t NOT_ACCESED_DOUT_LVL = BSP_DOUT_HIZ;
|
||||
|
||||
static int ut_btn_reset(btn_t* btn, btn_t* exp_btn)
|
||||
{
|
||||
printf(" Input: State:%d New-State:%d State-time:%d Transition-cntr:%d Debounce-act:%d \n", btn->state, btn->new_state, btn->state_time, btn->transition_cntr, btn->dbnc_active);
|
||||
|
||||
btn_reset(btn);
|
||||
|
||||
printf(" Output: State:%d New-State:%d State-time:%d Transition-cntr:%d Debounce-act:%d \n", btn->state, btn->new_state, btn->state_time, btn->transition_cntr, btn->dbnc_active);
|
||||
printf("Expected: State:%d New-State:%d State-time:%d Transition-cntr:%d Debounce-act:%d \n", exp_btn->state, exp_btn->new_state, exp_btn->state_time, exp_btn->transition_cntr, exp_btn->dbnc_active);
|
||||
|
||||
int equal = 1;
|
||||
if(btn->state != exp_btn->state) equal = 0;
|
||||
if(btn->new_state != exp_btn->new_state) equal = 0;
|
||||
if(btn->state_time != exp_btn->state_time) equal = 0;
|
||||
if(btn->transition_cntr != exp_btn->transition_cntr) equal = 0;
|
||||
if(btn->dbnc_active != exp_btn->dbnc_active) equal = 0;
|
||||
|
||||
if(equal)
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_btn_reset_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("void btn_reset(btn_t* btn) \n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
btn_t btn;
|
||||
btn_t exp_btn;
|
||||
|
||||
// Normal 1
|
||||
btn.state = 0;
|
||||
btn.new_state = 0;
|
||||
btn.state_time = 0;
|
||||
btn.transition_cntr = 0;
|
||||
btn.dbnc_active = 0;
|
||||
exp_btn.state = 0;
|
||||
exp_btn.new_state = 0;
|
||||
exp_btn.state_time = 0;
|
||||
exp_btn.transition_cntr = 0;
|
||||
exp_btn.dbnc_active = 1;
|
||||
test_res = ut_btn_reset(&btn, &exp_btn);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Normal 1
|
||||
btn.state = 1;
|
||||
btn.new_state = 1;
|
||||
btn.state_time = 1000;
|
||||
btn.transition_cntr = 20;
|
||||
btn.dbnc_active = 0;
|
||||
exp_btn.state = BTN_INACTIVE;
|
||||
exp_btn.new_state = 0;
|
||||
exp_btn.state_time = 0;
|
||||
exp_btn.transition_cntr = 0;
|
||||
exp_btn.dbnc_active = 1;
|
||||
test_res = ut_btn_reset(&btn, &exp_btn);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
|
||||
static int ut_btn_process(uint8_t lvl, btn_t* btn, btn_cfg_t* cfg, uint8_t exp_out, btn_t* exp_btn, btn_cfg_t* exp_cfg)
|
||||
{
|
||||
printf(" Input: Level:%d \n", lvl);
|
||||
printf(" Input: State:%d New-State:%d State-time:%d Transition-cntr:%d Debounce-act:%d \n", btn->state, btn->new_state, btn->state_time, btn->transition_cntr, btn->dbnc_active);
|
||||
printf(" Input: Act-Lvl:%d Debounce-lim:%d Repeat-Time:%d \n", cfg->act_lvl, cfg->dbnc_lim, cfg->repeat_time);
|
||||
|
||||
uint8_t out = btn_process(lvl, btn, cfg);
|
||||
|
||||
printf(" Output: %d \n", out);
|
||||
printf(" Output: State:%d New-State:%d State-time:%d Transition-cntr:%d Debounce-act:%d \n", btn->state, btn->new_state, btn->state_time, btn->transition_cntr, btn->dbnc_active);
|
||||
printf(" Output: Act-Lvl:%d Debounce-lim:%d Repeat-Time:%d \n", cfg->act_lvl, cfg->dbnc_lim, cfg->repeat_time);
|
||||
|
||||
printf("Expected: %d \n", exp_out);
|
||||
printf("Expected: State:%d New-State:%d State-time:%d Transition-cntr:%d Debounce-act:%d \n", exp_btn->state, exp_btn->new_state, exp_btn->state_time, exp_btn->transition_cntr, exp_btn->dbnc_active);
|
||||
printf("Expected: Act-Lvl:%d Debounce-lim:%d Repeat-Time:%d \n", exp_cfg->act_lvl, exp_cfg->dbnc_lim, exp_cfg->repeat_time);
|
||||
|
||||
int equal = 1;
|
||||
if(btn->state != exp_btn->state) equal = 0;
|
||||
if(btn->new_state != exp_btn->new_state) equal = 0;
|
||||
if(btn->state_time != exp_btn->state_time) equal = 0;
|
||||
if(btn->transition_cntr != exp_btn->transition_cntr) equal = 0;
|
||||
if(btn->dbnc_active != exp_btn->dbnc_active) equal = 0;
|
||||
if(cfg->act_lvl != exp_cfg->act_lvl) equal = 0;
|
||||
if(cfg->dbnc_lim != exp_cfg->dbnc_lim) equal = 0;
|
||||
if(cfg->repeat_time != exp_cfg->repeat_time) equal = 0;
|
||||
|
||||
if((out==exp_out)&&(equal))
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_btn_process_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("uint8_t btn_process(uint8_t lvl, btn_t* btn, btn_cfg_t* cfg) \n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
uint8_t lvl;
|
||||
btn_t btn;
|
||||
btn_cfg_t cfg;
|
||||
uint8_t exp_out;
|
||||
btn_t exp_btn;
|
||||
btn_cfg_t exp_cfg;
|
||||
|
||||
// No changes
|
||||
lvl = 0;
|
||||
btn.state = 0;
|
||||
btn.new_state = 0;
|
||||
btn.state_time = 0;
|
||||
btn.transition_cntr = 0;
|
||||
btn.dbnc_active = 0;
|
||||
cfg.act_lvl = 1;
|
||||
cfg.dbnc_lim = 0;
|
||||
cfg.repeat_time = 0;
|
||||
|
||||
exp_out = 0;
|
||||
exp_btn.state = 0;
|
||||
exp_btn.new_state = 0;
|
||||
exp_btn.state_time = 1;
|
||||
exp_btn.transition_cntr = 0;
|
||||
exp_btn.dbnc_active = 0;
|
||||
exp_cfg.act_lvl = cfg.act_lvl;
|
||||
exp_cfg.dbnc_lim = cfg.dbnc_lim;
|
||||
exp_cfg.repeat_time = cfg.repeat_time;
|
||||
|
||||
test_res = ut_btn_process(lvl, &btn, &cfg, exp_out, &exp_btn, &exp_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// State time increase
|
||||
lvl = 1;
|
||||
btn.state = 0;
|
||||
btn.new_state = 0;
|
||||
btn.state_time = 12345;
|
||||
btn.transition_cntr = 0;
|
||||
btn.dbnc_active = 0;
|
||||
cfg.act_lvl = 0;
|
||||
cfg.dbnc_lim = 0;
|
||||
cfg.repeat_time = 0;
|
||||
|
||||
exp_out = 0;
|
||||
exp_btn.state = 0;
|
||||
exp_btn.new_state = 0;
|
||||
exp_btn.state_time = 12346;
|
||||
exp_btn.transition_cntr = 0;
|
||||
exp_btn.dbnc_active = 0;
|
||||
exp_cfg.act_lvl = cfg.act_lvl;
|
||||
exp_cfg.dbnc_lim = cfg.dbnc_lim;
|
||||
exp_cfg.repeat_time = cfg.repeat_time;
|
||||
|
||||
test_res = ut_btn_process(lvl, &btn, &cfg, exp_out, &exp_btn, &exp_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Activation, first time, act high
|
||||
lvl = 1;
|
||||
btn.state = 0;
|
||||
btn.new_state = 0;
|
||||
btn.state_time = 38455;
|
||||
btn.transition_cntr = 0;
|
||||
btn.dbnc_active = 0;
|
||||
cfg.act_lvl = 1;
|
||||
cfg.dbnc_lim = 0;
|
||||
cfg.repeat_time = 0;
|
||||
|
||||
exp_out = 1;
|
||||
exp_btn.state = 1;
|
||||
exp_btn.new_state = 1;
|
||||
exp_btn.state_time = 0;
|
||||
exp_btn.transition_cntr = 0;
|
||||
exp_btn.dbnc_active = 0;
|
||||
exp_cfg.act_lvl = cfg.act_lvl;
|
||||
exp_cfg.dbnc_lim = cfg.dbnc_lim;
|
||||
exp_cfg.repeat_time = cfg.repeat_time;
|
||||
|
||||
test_res = ut_btn_process(lvl, &btn, &cfg, exp_out, &exp_btn, &exp_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Activation, first time, act low
|
||||
lvl = 0;
|
||||
btn.state = 0;
|
||||
btn.new_state = 0;
|
||||
btn.state_time = 38455;
|
||||
btn.transition_cntr = 0;
|
||||
btn.dbnc_active = 0;
|
||||
cfg.act_lvl = 0;
|
||||
cfg.dbnc_lim = 0;
|
||||
cfg.repeat_time = 0;
|
||||
|
||||
exp_out = 1;
|
||||
exp_btn.state = 1;
|
||||
exp_btn.new_state = 1;
|
||||
exp_btn.state_time = 0;
|
||||
exp_btn.transition_cntr = 0;
|
||||
exp_btn.dbnc_active = 0;
|
||||
exp_cfg.act_lvl = cfg.act_lvl;
|
||||
exp_cfg.dbnc_lim = cfg.dbnc_lim;
|
||||
exp_cfg.repeat_time = cfg.repeat_time;
|
||||
|
||||
test_res = ut_btn_process(lvl, &btn, &cfg, exp_out, &exp_btn, &exp_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Active second time, not cleared new flag
|
||||
lvl = 1;
|
||||
btn.state = 1;
|
||||
btn.new_state = 1;
|
||||
btn.state_time = 0;
|
||||
btn.transition_cntr = 0;
|
||||
btn.dbnc_active = 0;
|
||||
cfg.act_lvl = 1;
|
||||
cfg.dbnc_lim = 0;
|
||||
cfg.repeat_time = 0;
|
||||
|
||||
exp_out = 1;
|
||||
exp_btn.state = 1;
|
||||
exp_btn.new_state = 1;
|
||||
exp_btn.state_time = 1;
|
||||
exp_btn.transition_cntr = 0;
|
||||
exp_btn.dbnc_active = 0;
|
||||
exp_cfg.act_lvl = cfg.act_lvl;
|
||||
exp_cfg.dbnc_lim = cfg.dbnc_lim;
|
||||
exp_cfg.repeat_time = cfg.repeat_time;
|
||||
|
||||
test_res = ut_btn_process(lvl, &btn, &cfg, exp_out, &exp_btn, &exp_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Active second time, cleared new flag
|
||||
lvl = 1;
|
||||
btn.state = 1;
|
||||
btn.new_state = 0;
|
||||
btn.state_time = 0;
|
||||
btn.transition_cntr = 0;
|
||||
btn.dbnc_active = 0;
|
||||
cfg.act_lvl = 1;
|
||||
cfg.dbnc_lim = 0;
|
||||
cfg.repeat_time = 0;
|
||||
|
||||
exp_out = 1;
|
||||
exp_btn.state = 1;
|
||||
exp_btn.new_state = 0;
|
||||
exp_btn.state_time = 1;
|
||||
exp_btn.transition_cntr = 0;
|
||||
exp_btn.dbnc_active = 0;
|
||||
exp_cfg.act_lvl = cfg.act_lvl;
|
||||
exp_cfg.dbnc_lim = cfg.dbnc_lim;
|
||||
exp_cfg.repeat_time = cfg.repeat_time;
|
||||
|
||||
test_res = ut_btn_process(lvl, &btn, &cfg, exp_out, &exp_btn, &exp_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Deactive, act high
|
||||
lvl = 0;
|
||||
btn.state = 1;
|
||||
btn.new_state = 0;
|
||||
btn.state_time = 60584;
|
||||
btn.transition_cntr = 0;
|
||||
btn.dbnc_active = 0;
|
||||
cfg.act_lvl = 1;
|
||||
cfg.dbnc_lim = 0;
|
||||
cfg.repeat_time = 0;
|
||||
|
||||
exp_out = 0;
|
||||
exp_btn.state = 0;
|
||||
exp_btn.new_state = 1;
|
||||
exp_btn.state_time = 0;
|
||||
exp_btn.transition_cntr = 0;
|
||||
exp_btn.dbnc_active = 0;
|
||||
exp_cfg.act_lvl = cfg.act_lvl;
|
||||
exp_cfg.dbnc_lim = cfg.dbnc_lim;
|
||||
exp_cfg.repeat_time = cfg.repeat_time;
|
||||
|
||||
test_res = ut_btn_process(lvl, &btn, &cfg, exp_out, &exp_btn, &exp_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Deactive, act low
|
||||
lvl = 1;
|
||||
btn.state = 1;
|
||||
btn.new_state = 0;
|
||||
btn.state_time = 558;
|
||||
btn.transition_cntr = 0;
|
||||
btn.dbnc_active = 0;
|
||||
cfg.act_lvl = 0;
|
||||
cfg.dbnc_lim = 0;
|
||||
cfg.repeat_time = 0;
|
||||
|
||||
exp_out = 0;
|
||||
exp_btn.state = 0;
|
||||
exp_btn.new_state = 1;
|
||||
exp_btn.state_time = 0;
|
||||
exp_btn.transition_cntr = 0;
|
||||
exp_btn.dbnc_active = 0;
|
||||
exp_cfg.act_lvl = cfg.act_lvl;
|
||||
exp_cfg.dbnc_lim = cfg.dbnc_lim;
|
||||
exp_cfg.repeat_time = cfg.repeat_time;
|
||||
|
||||
test_res = ut_btn_process(lvl, &btn, &cfg, exp_out, &exp_btn, &exp_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Debounce, first
|
||||
lvl = 1;
|
||||
btn.state = 0;
|
||||
btn.new_state = 0;
|
||||
btn.state_time = 24789;
|
||||
btn.transition_cntr = 0;
|
||||
btn.dbnc_active = 0;
|
||||
cfg.act_lvl = 1;
|
||||
cfg.dbnc_lim = 10;
|
||||
cfg.repeat_time = 0;
|
||||
|
||||
exp_out = 0;
|
||||
exp_btn.state = 0;
|
||||
exp_btn.new_state = 0;
|
||||
exp_btn.state_time = 24790;
|
||||
exp_btn.transition_cntr = 0;
|
||||
exp_btn.dbnc_active = 1;
|
||||
exp_cfg.act_lvl = cfg.act_lvl;
|
||||
exp_cfg.dbnc_lim = cfg.dbnc_lim;
|
||||
exp_cfg.repeat_time = cfg.repeat_time;
|
||||
|
||||
test_res = ut_btn_process(lvl, &btn, &cfg, exp_out, &exp_btn, &exp_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Debounce at end
|
||||
lvl = 1;
|
||||
btn.state = 0;
|
||||
btn.new_state = 0;
|
||||
btn.state_time = 142;
|
||||
btn.transition_cntr = 9;
|
||||
btn.dbnc_active = 1;
|
||||
cfg.act_lvl = 1;
|
||||
cfg.dbnc_lim = 10;
|
||||
cfg.repeat_time = 0;
|
||||
|
||||
exp_out = 1;
|
||||
exp_btn.state = 1;
|
||||
exp_btn.new_state = 1;
|
||||
exp_btn.state_time = 0;
|
||||
exp_btn.transition_cntr = 0;
|
||||
exp_btn.dbnc_active = 0;
|
||||
exp_cfg.act_lvl = cfg.act_lvl;
|
||||
exp_cfg.dbnc_lim = cfg.dbnc_lim;
|
||||
exp_cfg.repeat_time = cfg.repeat_time;
|
||||
|
||||
test_res = ut_btn_process(lvl, &btn, &cfg, exp_out, &exp_btn, &exp_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Debounce fail, act high, fail to active state
|
||||
lvl = 0;
|
||||
btn.state = 0;
|
||||
btn.new_state = 0;
|
||||
btn.state_time = 142;
|
||||
btn.transition_cntr = 5;
|
||||
btn.dbnc_active = 1;
|
||||
cfg.act_lvl = 1;
|
||||
cfg.dbnc_lim = 10;
|
||||
cfg.repeat_time = 0;
|
||||
|
||||
exp_out = 0;
|
||||
exp_btn.state = 0;
|
||||
exp_btn.new_state = 0;
|
||||
exp_btn.state_time = 143;
|
||||
exp_btn.transition_cntr = 0;
|
||||
exp_btn.dbnc_active = 0;
|
||||
exp_cfg.act_lvl = cfg.act_lvl;
|
||||
exp_cfg.dbnc_lim = cfg.dbnc_lim;
|
||||
exp_cfg.repeat_time = cfg.repeat_time;
|
||||
|
||||
test_res = ut_btn_process(lvl, &btn, &cfg, exp_out, &exp_btn, &exp_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Debounce fail, act low, fail to active state
|
||||
lvl = 1;
|
||||
btn.state = 0;
|
||||
btn.new_state = 0;
|
||||
btn.state_time = 257;
|
||||
btn.transition_cntr = 4;
|
||||
btn.dbnc_active = 1;
|
||||
cfg.act_lvl = 0;
|
||||
cfg.dbnc_lim = 10;
|
||||
cfg.repeat_time = 0;
|
||||
|
||||
exp_out = 0;
|
||||
exp_btn.state = 0;
|
||||
exp_btn.new_state = 0;
|
||||
exp_btn.state_time = 258;
|
||||
exp_btn.transition_cntr = 0;
|
||||
exp_btn.dbnc_active = 0;
|
||||
exp_cfg.act_lvl = cfg.act_lvl;
|
||||
exp_cfg.dbnc_lim = cfg.dbnc_lim;
|
||||
exp_cfg.repeat_time = cfg.repeat_time;
|
||||
|
||||
test_res = ut_btn_process(lvl, &btn, &cfg, exp_out, &exp_btn, &exp_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Before New state repeat
|
||||
lvl = 1;
|
||||
btn.state = 1;
|
||||
btn.new_state = 0;
|
||||
btn.state_time = 4998;
|
||||
btn.transition_cntr = 0;
|
||||
btn.dbnc_active = 0;
|
||||
cfg.act_lvl = 1;
|
||||
cfg.dbnc_lim = 10;
|
||||
cfg.repeat_time = 5000;
|
||||
|
||||
exp_out = 1;
|
||||
exp_btn.state = 1;
|
||||
exp_btn.new_state = 0;
|
||||
exp_btn.state_time = 4999;
|
||||
exp_btn.transition_cntr = 0;
|
||||
exp_btn.dbnc_active = 0;
|
||||
exp_cfg.act_lvl = cfg.act_lvl;
|
||||
exp_cfg.dbnc_lim = cfg.dbnc_lim;
|
||||
exp_cfg.repeat_time = cfg.repeat_time;
|
||||
|
||||
test_res = ut_btn_process(lvl, &btn, &cfg, exp_out, &exp_btn, &exp_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Before New state repeat
|
||||
lvl = 1;
|
||||
btn.state = 1;
|
||||
btn.new_state = 0;
|
||||
btn.state_time = 4999;
|
||||
btn.transition_cntr = 0;
|
||||
btn.dbnc_active = 0;
|
||||
cfg.act_lvl = 1;
|
||||
cfg.dbnc_lim = 10;
|
||||
cfg.repeat_time = 5000;
|
||||
|
||||
exp_out = 1;
|
||||
exp_btn.state = 1;
|
||||
exp_btn.new_state = 1;
|
||||
exp_btn.state_time = 5000;
|
||||
exp_btn.transition_cntr = 0;
|
||||
exp_btn.dbnc_active = 0;
|
||||
exp_cfg.act_lvl = cfg.act_lvl;
|
||||
exp_cfg.dbnc_lim = cfg.dbnc_lim;
|
||||
exp_cfg.repeat_time = cfg.repeat_time;
|
||||
|
||||
test_res = ut_btn_process(lvl, &btn, &cfg, exp_out, &exp_btn, &exp_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Before New state repeat
|
||||
lvl = 1;
|
||||
btn.state = 1;
|
||||
btn.new_state = 0;
|
||||
btn.state_time = 5000;
|
||||
btn.transition_cntr = 0;
|
||||
btn.dbnc_active = 0;
|
||||
cfg.act_lvl = 1;
|
||||
cfg.dbnc_lim = 10;
|
||||
cfg.repeat_time = 5000;
|
||||
|
||||
exp_out = 1;
|
||||
exp_btn.state = 1;
|
||||
exp_btn.new_state = 0;
|
||||
exp_btn.state_time = 5001;
|
||||
exp_btn.transition_cntr = 0;
|
||||
exp_btn.dbnc_active = 0;
|
||||
exp_cfg.act_lvl = cfg.act_lvl;
|
||||
exp_cfg.dbnc_lim = cfg.dbnc_lim;
|
||||
exp_cfg.repeat_time = cfg.repeat_time;
|
||||
|
||||
test_res = ut_btn_process(lvl, &btn, &cfg, exp_out, &exp_btn, &exp_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Before New state repeat
|
||||
lvl = 1;
|
||||
btn.state = 1;
|
||||
btn.new_state = 0;
|
||||
btn.state_time = 19999;
|
||||
btn.transition_cntr = 0;
|
||||
btn.dbnc_active = 0;
|
||||
cfg.act_lvl = 1;
|
||||
cfg.dbnc_lim = 10;
|
||||
cfg.repeat_time = 5000;
|
||||
|
||||
exp_out = 1;
|
||||
exp_btn.state = 1;
|
||||
exp_btn.new_state = 1;
|
||||
exp_btn.state_time = 20000;
|
||||
exp_btn.transition_cntr = 0;
|
||||
exp_btn.dbnc_active = 0;
|
||||
exp_cfg.act_lvl = cfg.act_lvl;
|
||||
exp_cfg.dbnc_lim = cfg.dbnc_lim;
|
||||
exp_cfg.repeat_time = cfg.repeat_time;
|
||||
|
||||
test_res = ut_btn_process(lvl, &btn, &cfg, exp_out, &exp_btn, &exp_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Before New state repeat
|
||||
lvl = 1;
|
||||
btn.state = 1;
|
||||
btn.new_state = 0;
|
||||
btn.state_time = 0xFFFE;
|
||||
btn.transition_cntr = 0;
|
||||
btn.dbnc_active = 0;
|
||||
cfg.act_lvl = 1;
|
||||
cfg.dbnc_lim = 10;
|
||||
cfg.repeat_time = 255;
|
||||
|
||||
exp_out = 1;
|
||||
exp_btn.state = 1;
|
||||
exp_btn.new_state = 0;
|
||||
exp_btn.state_time = 0xFFFF;
|
||||
exp_btn.transition_cntr = 0;
|
||||
exp_btn.dbnc_active = 0;
|
||||
exp_cfg.act_lvl = cfg.act_lvl;
|
||||
exp_cfg.dbnc_lim = cfg.dbnc_lim;
|
||||
exp_cfg.repeat_time = cfg.repeat_time;
|
||||
|
||||
test_res = ut_btn_process(lvl, &btn, &cfg, exp_out, &exp_btn, &exp_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
|
||||
static int ut_btn_ch_process(uint8_t btn_ch, btn_t* btn, uint8_t din_lvl, uint8_t exp_out, btn_t* exp_btn, uint8_t exp_din_ch)
|
||||
{
|
||||
printf(" Input: Btn-Ch:%d Din-Lvl:%d\n", btn_ch, din_lvl);
|
||||
printf(" Input: State:%d New-State:%d State-time:%d Transition-cntr:%d Debounce-act:%d \n", btn->state, btn->new_state, btn->state_time, btn->transition_cntr, btn->dbnc_active);
|
||||
|
||||
mock_board_din_write_ch(NOT_ACCESED_DIN_CH);
|
||||
mock_board_din_write_data(exp_din_ch, din_lvl);
|
||||
|
||||
uint8_t out = btn_ch_process(btn_ch, btn);
|
||||
|
||||
uint8_t din_ch = mock_board_din_read_ch();
|
||||
|
||||
printf(" Output: %d \n", out);
|
||||
printf(" Output: State:%d New-State:%d State-time:%d Transition-cntr:%d Debounce-act:%d \n", btn->state, btn->new_state, btn->state_time, btn->transition_cntr, btn->dbnc_active);
|
||||
printf(" Output: Din-Ch:%d \n", din_ch);
|
||||
|
||||
printf("Expected: %d \n", exp_out);
|
||||
printf("Expected: State:%d New-State:%d State-time:%d Transition-cntr:%d Debounce-act:%d \n", exp_btn->state, exp_btn->new_state, exp_btn->state_time, exp_btn->transition_cntr, exp_btn->dbnc_active);
|
||||
printf("Expected: Din-Ch:%d \n", exp_din_ch);
|
||||
|
||||
int equal = 1;
|
||||
if(btn->state != exp_btn->state) equal = 0;
|
||||
if(btn->new_state != exp_btn->new_state) equal = 0;
|
||||
if(btn->state_time != exp_btn->state_time) equal = 0;
|
||||
if(btn->transition_cntr != exp_btn->transition_cntr) equal = 0;
|
||||
if(btn->dbnc_active != exp_btn->dbnc_active) equal = 0;
|
||||
|
||||
if((out==exp_out)&&(equal)&&(din_ch==exp_din_ch))
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_btn_ch_process_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("uint8_t btn_ch_process(uint8_t btn_ch, btn_t* btn) \n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
uint8_t btn_ch;
|
||||
btn_t btn;
|
||||
uint8_t din_lvl;
|
||||
uint8_t exp_out;
|
||||
btn_t exp_btn;
|
||||
uint8_t exp_din_ch;
|
||||
|
||||
// Mapping check 1
|
||||
btn_ch = BTN_1;
|
||||
btn.state = 0;
|
||||
btn.new_state = 0;
|
||||
btn.state_time = 150;
|
||||
btn.transition_cntr = 9;
|
||||
btn.dbnc_active = 1;
|
||||
din_lvl = BSP_DIN_LOW;
|
||||
|
||||
exp_out = 1;
|
||||
exp_btn.state = 1;
|
||||
exp_btn.new_state = 1;
|
||||
exp_btn.state_time = 0;
|
||||
exp_btn.transition_cntr = 0;
|
||||
exp_btn.dbnc_active = 0;
|
||||
exp_din_ch = BSP_DIN1;
|
||||
|
||||
test_res = ut_btn_ch_process(btn_ch, &btn, din_lvl, exp_out, &exp_btn, exp_din_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Mapping check 2
|
||||
btn_ch = BTN_2;
|
||||
btn.state = 0;
|
||||
btn.new_state = 0;
|
||||
btn.state_time = 150;
|
||||
btn.transition_cntr = 9;
|
||||
btn.dbnc_active = 1;
|
||||
din_lvl = BSP_DIN_LOW;
|
||||
|
||||
exp_out = 1;
|
||||
exp_btn.state = 1;
|
||||
exp_btn.new_state = 1;
|
||||
exp_btn.state_time = 0;
|
||||
exp_btn.transition_cntr = 0;
|
||||
exp_btn.dbnc_active = 0;
|
||||
exp_din_ch = BSP_DIN3;
|
||||
|
||||
test_res = ut_btn_ch_process(btn_ch, &btn, din_lvl, exp_out, &exp_btn, exp_din_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Mapping check 3
|
||||
btn_ch = BTN_3;
|
||||
btn.state = 0;
|
||||
btn.new_state = 0;
|
||||
btn.state_time = 150;
|
||||
btn.transition_cntr = 9;
|
||||
btn.dbnc_active = 1;
|
||||
din_lvl = BSP_DIN_LOW;
|
||||
|
||||
exp_out = 1;
|
||||
exp_btn.state = 1;
|
||||
exp_btn.new_state = 1;
|
||||
exp_btn.state_time = 0;
|
||||
exp_btn.transition_cntr = 0;
|
||||
exp_btn.dbnc_active = 0;
|
||||
exp_din_ch = BSP_DIN4;
|
||||
|
||||
test_res = ut_btn_ch_process(btn_ch, &btn, din_lvl, exp_out, &exp_btn, exp_din_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Mapping check 4
|
||||
btn_ch = BTN_4;
|
||||
btn.state = 0;
|
||||
btn.new_state = 0;
|
||||
btn.state_time = 150;
|
||||
btn.transition_cntr = 9;
|
||||
btn.dbnc_active = 1;
|
||||
din_lvl = BSP_DIN_HIGH;
|
||||
|
||||
exp_out = 1;
|
||||
exp_btn.state = 1;
|
||||
exp_btn.new_state = 1;
|
||||
exp_btn.state_time = 0;
|
||||
exp_btn.transition_cntr = 0;
|
||||
exp_btn.dbnc_active = 0;
|
||||
exp_din_ch = BSP_DIN5;
|
||||
|
||||
test_res = ut_btn_ch_process(btn_ch, &btn, din_lvl, exp_out, &exp_btn, exp_din_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Mapping check 5
|
||||
btn_ch = BTN_5;
|
||||
btn.state = 0;
|
||||
btn.new_state = 0;
|
||||
btn.state_time = 150;
|
||||
btn.transition_cntr = 9;
|
||||
btn.dbnc_active = 1;
|
||||
din_lvl = BSP_DIN_HIGH;
|
||||
|
||||
exp_out = 1;
|
||||
exp_btn.state = 1;
|
||||
exp_btn.new_state = 1;
|
||||
exp_btn.state_time = 0;
|
||||
exp_btn.transition_cntr = 0;
|
||||
exp_btn.dbnc_active = 0;
|
||||
exp_din_ch = BSP_DIN6;
|
||||
|
||||
test_res = ut_btn_ch_process(btn_ch, &btn, din_lvl, exp_out, &exp_btn, exp_din_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Mapping check 6
|
||||
btn_ch = BTN_6;
|
||||
btn.state = 0;
|
||||
btn.new_state = 0;
|
||||
btn.state_time = 150;
|
||||
btn.transition_cntr = 9;
|
||||
btn.dbnc_active = 1;
|
||||
din_lvl = BSP_DIN_LOW;
|
||||
|
||||
exp_out = 1;
|
||||
exp_btn.state = 1;
|
||||
exp_btn.new_state = 1;
|
||||
exp_btn.state_time = 0;
|
||||
exp_btn.transition_cntr = 0;
|
||||
exp_btn.dbnc_active = 0;
|
||||
exp_din_ch = BSP_DIN7;
|
||||
|
||||
test_res = ut_btn_ch_process(btn_ch, &btn, din_lvl, exp_out, &exp_btn, exp_din_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Mapping check 6N
|
||||
btn_ch = BTN_6N;
|
||||
btn.state = 0;
|
||||
btn.new_state = 0;
|
||||
btn.state_time = 150;
|
||||
btn.transition_cntr = 9;
|
||||
btn.dbnc_active = 1;
|
||||
din_lvl = BSP_DIN_LOW;
|
||||
|
||||
exp_out = 1;
|
||||
exp_btn.state = 1;
|
||||
exp_btn.new_state = 1;
|
||||
exp_btn.state_time = 0;
|
||||
exp_btn.transition_cntr = 0;
|
||||
exp_btn.dbnc_active = 0;
|
||||
exp_din_ch = BSP_DIN7N;
|
||||
|
||||
test_res = ut_btn_ch_process(btn_ch, &btn, din_lvl, exp_out, &exp_btn, exp_din_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Wrong channel
|
||||
btn_ch = 0;
|
||||
btn.state = 1;
|
||||
btn.new_state = 0;
|
||||
btn.state_time = 150;
|
||||
btn.transition_cntr = 9;
|
||||
btn.dbnc_active = 1;
|
||||
din_lvl = BSP_DIN_LOW;
|
||||
|
||||
exp_out = 0;
|
||||
exp_btn.state = 1;
|
||||
exp_btn.new_state = 0;
|
||||
exp_btn.state_time = 150;
|
||||
exp_btn.transition_cntr = 9;
|
||||
exp_btn.dbnc_active = 1;
|
||||
exp_din_ch = NOT_ACCESED_DIN_CH;
|
||||
|
||||
test_res = ut_btn_ch_process(btn_ch, &btn, din_lvl, exp_out, &exp_btn, exp_din_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
|
||||
static int ut_btn_ch_set_pull(uint8_t btn_ch, int8_t lvl, int8_t exp_dout_lvl, uint8_t exp_dout_ch)
|
||||
{
|
||||
printf(" Input: Btn-Ch:%d Din-Lvl:%d\n", btn_ch, lvl);
|
||||
|
||||
mock_board_dout_write_ch(NOT_ACCESED_DOUT_CH);
|
||||
mock_board_dout_write_data(exp_dout_ch, NOT_ACCESED_DOUT_LVL);
|
||||
|
||||
btn_ch_set_pull(btn_ch, lvl);
|
||||
|
||||
uint8_t dout_ch = mock_board_dout_read_ch();
|
||||
int8_t dout = mock_board_dout_read_data(exp_dout_ch);
|
||||
|
||||
printf(" Output: Dout-Ch:%d Dout-Lvl:%d \n", dout_ch, dout);
|
||||
printf("Expected: Dout-Ch:%d Dout-Lvl:%d \n", exp_dout_ch, exp_dout_lvl);
|
||||
|
||||
if((dout==exp_dout_lvl)&&(dout_ch==exp_dout_ch))
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_btn_ch_set_pull_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("void btn_ch_set_pull(uint8_t btn_ch, int8_t lvl) \n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
uint8_t btn_ch;
|
||||
int8_t lvl;
|
||||
int8_t exp_dout_lvl;
|
||||
uint8_t exp_dout_ch;
|
||||
|
||||
// Mapping check 1
|
||||
btn_ch = BTN_6;
|
||||
lvl = 0;
|
||||
exp_dout_lvl = BSP_DOUT_LOW;
|
||||
exp_dout_ch = BSP_DOUT5;
|
||||
test_res = ut_btn_ch_set_pull(btn_ch, lvl, exp_dout_lvl, exp_dout_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Mapping check 2
|
||||
btn_ch = BTN_6N;
|
||||
lvl = 1;
|
||||
exp_dout_lvl = BSP_DOUT_HIGH;
|
||||
exp_dout_ch = BSP_DOUT5;
|
||||
test_res = ut_btn_ch_set_pull(btn_ch, lvl, exp_dout_lvl, exp_dout_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Define check 1
|
||||
btn_ch = BTN_6N;
|
||||
lvl = BTN_PULL_LOW;
|
||||
exp_dout_lvl = BSP_DOUT_LOW;
|
||||
exp_dout_ch = BSP_DOUT5;
|
||||
test_res = ut_btn_ch_set_pull(btn_ch, lvl, exp_dout_lvl, exp_dout_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Define check 2
|
||||
btn_ch = BTN_6N;
|
||||
lvl = BTN_PULL_HIGH;
|
||||
exp_dout_lvl = BSP_DOUT_HIGH;
|
||||
exp_dout_ch = BSP_DOUT5;
|
||||
test_res = ut_btn_ch_set_pull(btn_ch, lvl, exp_dout_lvl, exp_dout_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Define check 3
|
||||
btn_ch = BTN_6N;
|
||||
lvl = BTN_PULL_NONE;
|
||||
exp_dout_lvl = BSP_DOUT_HIZ;
|
||||
exp_dout_ch = BSP_DOUT5;
|
||||
test_res = ut_btn_ch_set_pull(btn_ch, lvl, exp_dout_lvl, exp_dout_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Wrong channel
|
||||
btn_ch = 0;
|
||||
lvl = 0;
|
||||
exp_dout_lvl = NOT_ACCESED_DOUT_LVL;
|
||||
exp_dout_ch = NOT_ACCESED_DOUT_CH;
|
||||
test_res = ut_btn_ch_set_pull(btn_ch, lvl, exp_dout_lvl, exp_dout_ch);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
12
firmware/tests/ut_hw/ut_buttons.h
Normal file
12
firmware/tests/ut_hw/ut_buttons.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef UT_HW_BUTTONS_H_
|
||||
#define UT_HW_BUTTONS_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int ut_btn_reset_test(void);
|
||||
int ut_btn_process_test(void);
|
||||
int ut_btn_ch_process_test(void);
|
||||
int ut_btn_ch_set_pull_test(void);
|
||||
|
||||
#endif /* UT_HW_BUTTONS_H_ */
|
||||
2638
firmware/tests/ut_hw/ut_hb_control.c
Normal file
2638
firmware/tests/ut_hw/ut_hb_control.c
Normal file
File diff suppressed because it is too large
Load Diff
15
firmware/tests/ut_hw/ut_hb_control.h
Normal file
15
firmware/tests/ut_hw/ut_hb_control.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef UT_HW_HB_CONTROL_H_
|
||||
#define UT_HW_HB_CONTROL_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int ut_hb_is_equal_fb_struct_test(void);
|
||||
int ut_hb_is_equal_ctrl_struct_test(void);
|
||||
|
||||
int ut_hb_init_test(void);
|
||||
int ut_hb_enable_test(void);
|
||||
int ut_hb_disable_test(void);
|
||||
int ut_hb_process_test(void);
|
||||
|
||||
#endif /* UT_HW_HB_CONTROL_H_ */
|
||||
170
firmware/tests/ut_hw/ut_led_display.c
Normal file
170
firmware/tests/ut_hw/ut_led_display.c
Normal file
@@ -0,0 +1,170 @@
|
||||
#include "ut_led_display.h"
|
||||
|
||||
#include "..\mock_board\mock_board_odout.h"
|
||||
|
||||
#include "..\..\src\hw\led_display.h"
|
||||
|
||||
static uint8_t NOT_ACCESD_OD_CHANNEL = 255;
|
||||
static uint8_t NOT_ACCESD_OD_LEVEL = BSP_ODOUT_HIGH;
|
||||
static uint8_t NOT_ACCESD_PERCENT = 255;
|
||||
|
||||
static int ut_led_dsp_set_image(uint8_t image, uint8_t exp_image)
|
||||
{
|
||||
printf(" Input:%x \n", image);
|
||||
|
||||
// Reset image
|
||||
mock_board_odout_write_ch(NOT_ACCESD_OD_CHANNEL);
|
||||
mock_board_odout_write_data(BSP_OD1,NOT_ACCESD_OD_LEVEL);
|
||||
mock_board_odout_write_data(BSP_OD2,NOT_ACCESD_OD_LEVEL);
|
||||
mock_board_odout_write_data(BSP_OD3,NOT_ACCESD_OD_LEVEL);
|
||||
mock_board_odout_write_data(BSP_OD4,NOT_ACCESD_OD_LEVEL);
|
||||
mock_board_odout_write_data(BSP_OD5,NOT_ACCESD_OD_LEVEL);
|
||||
mock_board_odout_write_data(BSP_OD6,NOT_ACCESD_OD_LEVEL);
|
||||
|
||||
led_dsp_set_image(image);
|
||||
|
||||
// Read set OD output image
|
||||
uint8_t i1 = mock_board_odout_read_data(BSP_OD1);
|
||||
uint8_t i2 = mock_board_odout_read_data(BSP_OD2);
|
||||
uint8_t i3 = mock_board_odout_read_data(BSP_OD3);
|
||||
uint8_t i4 = mock_board_odout_read_data(BSP_OD4);
|
||||
uint8_t i5 = mock_board_odout_read_data(BSP_OD5);
|
||||
uint8_t i6 = mock_board_odout_read_data(BSP_OD6);
|
||||
|
||||
uint8_t out_image = 0x00;
|
||||
if(i1==BSP_ODOUT_LOW) out_image |= 0x01;
|
||||
if(i2==BSP_ODOUT_LOW) out_image |= 0x02;
|
||||
if(i3==BSP_ODOUT_LOW) out_image |= 0x04;
|
||||
if(i4==BSP_ODOUT_LOW) out_image |= 0x08;
|
||||
if(i5==BSP_ODOUT_LOW) out_image |= 0x10;
|
||||
if(i6==BSP_ODOUT_LOW) out_image |= 0x20;
|
||||
|
||||
printf(" Output:%x \n", out_image);
|
||||
printf("Expected:%x \n", exp_image);
|
||||
|
||||
if(out_image==exp_image)
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_led_dsp_set_image_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("void led_dsp_set_image(uint8_t image) \n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
uint8_t image;
|
||||
uint8_t exp_image;
|
||||
|
||||
// Normal 1
|
||||
image = 0x00;
|
||||
exp_image = 0x00;
|
||||
test_res = ut_led_dsp_set_image(image, exp_image);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Normal 1
|
||||
image = 0x3F;
|
||||
exp_image = 0x3F;
|
||||
test_res = ut_led_dsp_set_image(image, exp_image);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Normal 1
|
||||
image = 0xAA;
|
||||
exp_image = 0x2A;
|
||||
test_res = ut_led_dsp_set_image(image, exp_image);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Normal 1
|
||||
image = 0x55;
|
||||
exp_image = 0x15;
|
||||
test_res = ut_led_dsp_set_image(image, exp_image);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
|
||||
static int ut_led_dsp_backligth_set(uint8_t percent, uint8_t exp_percent)
|
||||
{
|
||||
printf(" Input:%d \n", percent);
|
||||
|
||||
// Reset image
|
||||
mock_board_odout_write_pwm(NOT_ACCESD_PERCENT);
|
||||
|
||||
led_dsp_backligth_set(percent);
|
||||
|
||||
// Read set OD output image
|
||||
uint8_t pwm = mock_board_odout_read_pwm();
|
||||
|
||||
printf(" Output:%d \n", pwm);
|
||||
printf("Expected:%d \n", exp_percent);
|
||||
|
||||
if(pwm==exp_percent)
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_led_dsp_backligth_set_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("void led_dsp_backligth_set(uint8_t percent) \n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
uint8_t percent;
|
||||
uint8_t exp_percent;
|
||||
|
||||
// Normal 1
|
||||
percent = 0;
|
||||
exp_percent = 0;
|
||||
test_res = ut_led_dsp_backligth_set(percent, exp_percent);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Normal 1
|
||||
percent = 25;
|
||||
exp_percent = 25;
|
||||
test_res = ut_led_dsp_backligth_set(percent, exp_percent);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Normal 1
|
||||
percent = 50;
|
||||
exp_percent = 50;
|
||||
test_res = ut_led_dsp_backligth_set(percent, exp_percent);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Normal 1
|
||||
percent = 75;
|
||||
exp_percent = 75;
|
||||
test_res = ut_led_dsp_backligth_set(percent, exp_percent);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Normal 1
|
||||
percent = 100;
|
||||
exp_percent = 100;
|
||||
test_res = ut_led_dsp_backligth_set(percent, exp_percent);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Normal 1
|
||||
percent = 200;
|
||||
exp_percent = 200;
|
||||
test_res = ut_led_dsp_backligth_set(percent, exp_percent);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
10
firmware/tests/ut_hw/ut_led_display.h
Normal file
10
firmware/tests/ut_hw/ut_led_display.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef UT_HW_LED_DISPLAY_H_
|
||||
#define UT_HW_LED_DISPLAY_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int ut_led_dsp_set_image_test(void);
|
||||
int ut_led_dsp_backligth_set_test(void);
|
||||
|
||||
#endif /* UT_HW_LED_DISPLAY_H_ */
|
||||
48
firmware/tests/ut_hw/ut_startup.c
Normal file
48
firmware/tests/ut_hw/ut_startup.c
Normal file
@@ -0,0 +1,48 @@
|
||||
#include "ut_startup.h"
|
||||
|
||||
#include "..\mock_board\mock_board_setup.h"
|
||||
|
||||
#include "..\..\src\hw\startup.h"
|
||||
|
||||
static int ut_hw_startup(uint8_t exp_called)
|
||||
{
|
||||
printf(" Input: \n");
|
||||
|
||||
mock_board_setup_reset_called();
|
||||
|
||||
hw_startup();
|
||||
|
||||
uint8_t called = mock_board_setup_read_called();
|
||||
|
||||
printf(" Output: Called:%d \n", called);
|
||||
printf("Expected: Called:%d \n", exp_called);
|
||||
|
||||
if(called==exp_called)
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_hw_startup_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("void hw_startup(void) \n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
uint8_t exp_called;
|
||||
|
||||
// Normal 1
|
||||
exp_called = 1;
|
||||
test_res = ut_hw_startup(exp_called);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
9
firmware/tests/ut_hw/ut_startup.h
Normal file
9
firmware/tests/ut_hw/ut_startup.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef UT_HW_STARTUP_H_
|
||||
#define UT_HW_STARTUP_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int ut_hw_startup_test(void);
|
||||
|
||||
#endif /* UT_HW_STARTUP_H_ */
|
||||
86
firmware/tests/ut_logic/ut_coil.c
Normal file
86
firmware/tests/ut_logic/ut_coil.c
Normal file
@@ -0,0 +1,86 @@
|
||||
#include "ut_coil.h"
|
||||
#include "..\..\src\logic\coil.h"
|
||||
|
||||
static int ut_coil_target(uint8_t force, uint8_t hbrake_act, int16_t exp_out)
|
||||
{
|
||||
int16_t out = coil_target(force, hbrake_act);
|
||||
|
||||
printf("Force:%d Handbrake:%d \n", force, hbrake_act);
|
||||
printf("Output:%d Expected:%d\n", out, exp_out);
|
||||
|
||||
if(out==exp_out)
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_coil_target_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("int16_t coil_target(uint8_t force, uint8_t hbrake_act)\n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
uint8_t force;
|
||||
uint8_t hbrake;
|
||||
|
||||
int16_t exp_out;
|
||||
|
||||
force = 0;
|
||||
hbrake = 0;
|
||||
exp_out = 0;
|
||||
test_res = ut_coil_target(force, hbrake, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
force = 50;
|
||||
hbrake = 0;
|
||||
exp_out = COIL_LOCK_VOLTAGE/2;
|
||||
test_res = ut_coil_target(force, hbrake, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
force = 100;
|
||||
hbrake = 0;
|
||||
exp_out = COIL_LOCK_VOLTAGE;
|
||||
test_res = ut_coil_target(force, hbrake, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
force = 255;
|
||||
hbrake = 0;
|
||||
exp_out = COIL_LOCK_VOLTAGE;
|
||||
test_res = ut_coil_target(force, hbrake, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
force = 0;
|
||||
hbrake = 1;
|
||||
exp_out = COIL_TARGET_HANDBRAKE;
|
||||
test_res = ut_coil_target(force, hbrake, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
force = 50;
|
||||
hbrake = 1;
|
||||
exp_out = COIL_TARGET_HANDBRAKE;
|
||||
test_res = ut_coil_target(force, hbrake, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
force = 100;
|
||||
hbrake = 1;
|
||||
exp_out = COIL_TARGET_HANDBRAKE;
|
||||
test_res = ut_coil_target(force, hbrake, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
force = 255;
|
||||
hbrake = 1;
|
||||
exp_out = COIL_TARGET_HANDBRAKE;
|
||||
test_res = ut_coil_target(force, hbrake, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
|
||||
9
firmware/tests/ut_logic/ut_coil.h
Normal file
9
firmware/tests/ut_logic/ut_coil.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef UT_COIL_H_
|
||||
#define UT_COIL_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int ut_coil_target_test(void);
|
||||
|
||||
#endif /* UT_COIL_H_ */
|
||||
552
firmware/tests/ut_logic/ut_display.c
Normal file
552
firmware/tests/ut_logic/ut_display.c
Normal file
@@ -0,0 +1,552 @@
|
||||
#include "ut_display.h"
|
||||
#include "..\..\src\logic\display.h"
|
||||
|
||||
static const uint8_t BACKLIGHT_DIMM = DSP_BACKLIGHT_DIMM_PERCENT;
|
||||
static const uint8_t BACKLIGHT_BRIGTH = DSP_BACKLIGHT_BRIGTH_PERCENT;
|
||||
|
||||
static int ut_dsp_init_ctrl(dsp_ctrl_t* ctrl, dsp_ctrl_t* exp_ctrl)
|
||||
{
|
||||
printf(" Input: lock:%d act-image:%x \n", ctrl->img_lock, ctrl->act_img);
|
||||
|
||||
dsp_init_ctrl(ctrl);
|
||||
|
||||
printf(" Output: lock:%d act-image:%x \n", ctrl->img_lock, ctrl->act_img);
|
||||
printf("Expected: lock:%d act-image:%x \n", exp_ctrl->img_lock, exp_ctrl->act_img);
|
||||
|
||||
if((ctrl->img_lock==exp_ctrl->img_lock)&&(ctrl->act_img==exp_ctrl->act_img))
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_dsp_init_ctrl_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("void dsp_init_ctrl(dsp_ctrl_t* ctrl) \n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
dsp_ctrl_t ctrl;
|
||||
dsp_ctrl_t exp_ctrl;
|
||||
|
||||
ctrl.img_lock = 0;
|
||||
ctrl.act_img = 0;
|
||||
exp_ctrl.img_lock = 0;
|
||||
exp_ctrl.act_img = 0x00;
|
||||
test_res = ut_dsp_init_ctrl(&ctrl, &exp_ctrl);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
ctrl.img_lock = 1;
|
||||
ctrl.act_img = 0xAA;
|
||||
exp_ctrl.img_lock = 0;
|
||||
exp_ctrl.act_img = 0x00;
|
||||
test_res = ut_dsp_init_ctrl(&ctrl, &exp_ctrl);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
|
||||
static int ut_dsp_set_lock(dsp_ctrl_t* ctrl, dsp_ctrl_t* exp_ctrl)
|
||||
{
|
||||
printf(" Input: lock:%d act-image:%x \n", ctrl->img_lock, ctrl->act_img);
|
||||
|
||||
dsp_set_lock(ctrl);
|
||||
|
||||
printf(" Output: lock:%d act-image:%x \n", ctrl->img_lock, ctrl->act_img);
|
||||
printf("Expected: lock:%d act-image:%x \n", exp_ctrl->img_lock, exp_ctrl->act_img);
|
||||
|
||||
if((ctrl->img_lock==exp_ctrl->img_lock)&&(ctrl->act_img==exp_ctrl->act_img))
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_dsp_set_lock_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("void dsp_set_lock(dsp_ctrl_t* ctrl)\n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
dsp_ctrl_t ctrl;
|
||||
dsp_ctrl_t exp_ctrl;
|
||||
|
||||
ctrl.img_lock = 0;
|
||||
ctrl.act_img = 0x18;
|
||||
exp_ctrl.img_lock = 1;
|
||||
exp_ctrl.act_img = 0x18;
|
||||
test_res = ut_dsp_set_lock(&ctrl, &exp_ctrl);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
ctrl.img_lock = 1;
|
||||
ctrl.act_img = 0x3F;
|
||||
exp_ctrl.img_lock = 1;
|
||||
exp_ctrl.act_img = 0x3F;
|
||||
test_res = ut_dsp_set_lock(&ctrl, &exp_ctrl);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
|
||||
static int ut_dsp_reset_lock(dsp_ctrl_t* ctrl, dsp_ctrl_t* exp_ctrl)
|
||||
{
|
||||
printf(" Input: lock:%d act-image:%x \n", ctrl->img_lock, ctrl->act_img);
|
||||
|
||||
dsp_reset_lock(ctrl);
|
||||
|
||||
printf(" Output: lock:%d act-image:%x \n", ctrl->img_lock, ctrl->act_img);
|
||||
printf("Expected: lock:%d act-image:%x \n", exp_ctrl->img_lock, exp_ctrl->act_img);
|
||||
|
||||
if((ctrl->img_lock==exp_ctrl->img_lock)&&(ctrl->act_img==exp_ctrl->act_img))
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_dsp_reset_lock_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("void dsp_reset_lock(dsp_ctrl_t* ctrl)\n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
dsp_ctrl_t ctrl;
|
||||
dsp_ctrl_t exp_ctrl;
|
||||
|
||||
ctrl.img_lock = 0;
|
||||
ctrl.act_img = 0x18;
|
||||
exp_ctrl.img_lock = 0;
|
||||
exp_ctrl.act_img = 0x18;
|
||||
test_res = ut_dsp_reset_lock(&ctrl, &exp_ctrl);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
ctrl.img_lock = 1;
|
||||
ctrl.act_img = 0x18;
|
||||
exp_ctrl.img_lock = 0;
|
||||
exp_ctrl.act_img = 0x18;
|
||||
test_res = ut_dsp_reset_lock(&ctrl, &exp_ctrl);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
|
||||
static int ut_dsp_img_percent(uint8_t value, dsp_style_t style, dsp_ctrl_t* ctrl, uint8_t exp_out, dsp_ctrl_t* exp_ctrl)
|
||||
{
|
||||
printf(" Input: Percent:%d Style:%d lock:%d act-image:%x \n", value, style, ctrl->img_lock, ctrl->act_img);
|
||||
|
||||
uint8_t out = dsp_img_percent(value, style, ctrl);
|
||||
|
||||
printf(" Output: image:%x lock:%d act-image:%x \n", out, ctrl->img_lock, ctrl->act_img);
|
||||
printf("Expected: image:%x lock:%d act-image:%x \n", exp_out, exp_ctrl->img_lock, exp_ctrl->act_img);
|
||||
|
||||
if((out==exp_out)&&(ctrl->img_lock==exp_ctrl->img_lock)&&(ctrl->act_img==exp_ctrl->act_img))
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_dsp_img_percent_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("uint8_t dsp_img_percent(uint8_t value, dsp_style_t style, dsp_ctrl_t* ctrl)\n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
uint8_t value;
|
||||
dsp_style_t style;
|
||||
dsp_ctrl_t ctrl;
|
||||
uint8_t exp_out;
|
||||
dsp_ctrl_t exp_ctrl;
|
||||
|
||||
// Test lock
|
||||
value = 50;
|
||||
style = LED_DSP_BAR;
|
||||
ctrl.img_lock = 1;
|
||||
ctrl.act_img = 0x2A;
|
||||
exp_out = 0x2A;
|
||||
exp_ctrl.img_lock = ctrl.img_lock;
|
||||
exp_ctrl.act_img = exp_out;
|
||||
test_res = ut_dsp_img_percent(value, style, &ctrl, exp_out, &exp_ctrl);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Test styles
|
||||
value = 50;
|
||||
style = LED_DSP_BAR;
|
||||
ctrl.img_lock = 0;
|
||||
ctrl.act_img = 0x00;
|
||||
exp_out = 0x07;
|
||||
exp_ctrl.img_lock = ctrl.img_lock;
|
||||
exp_ctrl.act_img = exp_out;
|
||||
test_res = ut_dsp_img_percent(value, style, &ctrl, exp_out, &exp_ctrl);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Test styles
|
||||
value = 50;
|
||||
style = LED_DSP_DOT20;
|
||||
ctrl.img_lock = 0;
|
||||
ctrl.act_img = 0x00;
|
||||
exp_out = 0x04;
|
||||
exp_ctrl.img_lock = ctrl.img_lock;
|
||||
exp_ctrl.act_img = exp_out;
|
||||
test_res = ut_dsp_img_percent(value, style, &ctrl, exp_out, &exp_ctrl);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Test styles
|
||||
value = 50;
|
||||
style = LED_DSP_DOT10;
|
||||
ctrl.img_lock = 0;
|
||||
ctrl.act_img = 0x00;
|
||||
exp_out = 0x0C;
|
||||
exp_ctrl.img_lock = ctrl.img_lock;
|
||||
exp_ctrl.act_img = exp_out;
|
||||
test_res = ut_dsp_img_percent(value, style, &ctrl, exp_out, &exp_ctrl);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Test values
|
||||
value = 0;
|
||||
style = LED_DSP_DOT10;
|
||||
ctrl.img_lock = 0;
|
||||
ctrl.act_img = 0x00;
|
||||
exp_out = 0x01;
|
||||
exp_ctrl.img_lock = ctrl.img_lock;
|
||||
exp_ctrl.act_img = exp_out;
|
||||
test_res = ut_dsp_img_percent(value, style, &ctrl, exp_out, &exp_ctrl);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Test values
|
||||
value = 10;
|
||||
style = LED_DSP_DOT10;
|
||||
ctrl.img_lock = 0;
|
||||
ctrl.act_img = 0x00;
|
||||
exp_out = 0x03;
|
||||
exp_ctrl.img_lock = ctrl.img_lock;
|
||||
exp_ctrl.act_img = exp_out;
|
||||
test_res = ut_dsp_img_percent(value, style, &ctrl, exp_out, &exp_ctrl);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Test values
|
||||
value = 20;
|
||||
style = LED_DSP_DOT10;
|
||||
ctrl.img_lock = 0;
|
||||
ctrl.act_img = 0x00;
|
||||
exp_out = 0x02;
|
||||
exp_ctrl.img_lock = ctrl.img_lock;
|
||||
exp_ctrl.act_img = exp_out;
|
||||
test_res = ut_dsp_img_percent(value, style, &ctrl, exp_out, &exp_ctrl);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Test values
|
||||
value = 30;
|
||||
style = LED_DSP_DOT10;
|
||||
ctrl.img_lock = 0;
|
||||
ctrl.act_img = 0x00;
|
||||
exp_out = 0x06;
|
||||
exp_ctrl.img_lock = ctrl.img_lock;
|
||||
exp_ctrl.act_img = exp_out;
|
||||
test_res = ut_dsp_img_percent(value, style, &ctrl, exp_out, &exp_ctrl);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Test values
|
||||
value = 40;
|
||||
style = LED_DSP_DOT10;
|
||||
ctrl.img_lock = 0;
|
||||
ctrl.act_img = 0x00;
|
||||
exp_out = 0x04;
|
||||
exp_ctrl.img_lock = ctrl.img_lock;
|
||||
exp_ctrl.act_img = exp_out;
|
||||
test_res = ut_dsp_img_percent(value, style, &ctrl, exp_out, &exp_ctrl);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Test values
|
||||
value = 50;
|
||||
style = LED_DSP_DOT10;
|
||||
ctrl.img_lock = 0;
|
||||
ctrl.act_img = 0x00;
|
||||
exp_out = 0x0C;
|
||||
exp_ctrl.img_lock = ctrl.img_lock;
|
||||
exp_ctrl.act_img = exp_out;
|
||||
test_res = ut_dsp_img_percent(value, style, &ctrl, exp_out, &exp_ctrl);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Test values
|
||||
value = 60;
|
||||
style = LED_DSP_DOT10;
|
||||
ctrl.img_lock = 0;
|
||||
ctrl.act_img = 0x00;
|
||||
exp_out = 0x08;
|
||||
exp_ctrl.img_lock = ctrl.img_lock;
|
||||
exp_ctrl.act_img = exp_out;
|
||||
test_res = ut_dsp_img_percent(value, style, &ctrl, exp_out, &exp_ctrl);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Test values
|
||||
value = 80;
|
||||
style = LED_DSP_DOT10;
|
||||
ctrl.img_lock = 0;
|
||||
ctrl.act_img = 0x00;
|
||||
exp_out = 0x10;
|
||||
exp_ctrl.img_lock = ctrl.img_lock;
|
||||
exp_ctrl.act_img = exp_out;
|
||||
test_res = ut_dsp_img_percent(value, style, &ctrl, exp_out, &exp_ctrl);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Test values
|
||||
value = 90;
|
||||
style = LED_DSP_DOT10;
|
||||
ctrl.img_lock = 0;
|
||||
ctrl.act_img = 0x00;
|
||||
exp_out = 0x30;
|
||||
exp_ctrl.img_lock = ctrl.img_lock;
|
||||
exp_ctrl.act_img = exp_out;
|
||||
test_res = ut_dsp_img_percent(value, style, &ctrl, exp_out, &exp_ctrl);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Test values
|
||||
value = 110;
|
||||
style = LED_DSP_DOT10;
|
||||
ctrl.img_lock = 0;
|
||||
ctrl.act_img = 0x00;
|
||||
exp_out = 0x20;
|
||||
exp_ctrl.img_lock = ctrl.img_lock;
|
||||
exp_ctrl.act_img = exp_out;
|
||||
test_res = ut_dsp_img_percent(value, style, &ctrl, exp_out, &exp_ctrl);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
|
||||
static int ut_dsp_img_raw(uint8_t image, dsp_ctrl_t* ctrl, uint8_t exp_out, dsp_ctrl_t* exp_ctrl)
|
||||
{
|
||||
printf(" Input: Image:%x lock:%d act-image:%x \n", image, ctrl->img_lock, ctrl->act_img);
|
||||
|
||||
uint8_t out = dsp_img_raw(image, ctrl);
|
||||
|
||||
printf(" Output: image:%x lock:%d act-image:%x \n", out, ctrl->img_lock, ctrl->act_img);
|
||||
printf("Expected: image:%x lock:%d act-image:%x \n", exp_out, exp_ctrl->img_lock, exp_ctrl->act_img);
|
||||
|
||||
if((out==exp_out)&&(ctrl->img_lock==exp_ctrl->img_lock)&&(ctrl->act_img==exp_ctrl->act_img))
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_dsp_img_raw_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("uint8_t dsp_img_raw(int8_t image, dsp_ctrl_t* ctrl)\n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
uint8_t image;
|
||||
dsp_ctrl_t ctrl;
|
||||
uint8_t exp_out;
|
||||
dsp_ctrl_t exp_ctrl;
|
||||
|
||||
// Test lock
|
||||
image = 0x17;
|
||||
ctrl.img_lock = 1;
|
||||
ctrl.act_img = 0x2A;
|
||||
exp_out = 0x2A;
|
||||
exp_ctrl.img_lock = ctrl.img_lock;
|
||||
exp_ctrl.act_img = exp_out;
|
||||
test_res = ut_dsp_img_raw(image, &ctrl, exp_out, &exp_ctrl);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Test normal
|
||||
image = 0x17;
|
||||
ctrl.img_lock = 0;
|
||||
ctrl.act_img = 0x00;
|
||||
exp_out = 0x17;
|
||||
exp_ctrl.img_lock = ctrl.img_lock;
|
||||
exp_ctrl.act_img = exp_out;
|
||||
test_res = ut_dsp_img_raw(image, &ctrl, exp_out, &exp_ctrl);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Test limit
|
||||
image = 0xAA;
|
||||
ctrl.img_lock = 0;
|
||||
ctrl.act_img = 0x00;
|
||||
exp_out = 0x2A;
|
||||
exp_ctrl.img_lock = ctrl.img_lock;
|
||||
exp_ctrl.act_img = exp_out;
|
||||
test_res = ut_dsp_img_raw(image, &ctrl, exp_out, &exp_ctrl);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Test limit
|
||||
image = 0xCC;
|
||||
ctrl.img_lock = 0;
|
||||
ctrl.act_img = 0x00;
|
||||
exp_out = 0x0C;
|
||||
exp_ctrl.img_lock = ctrl.img_lock;
|
||||
exp_ctrl.act_img = exp_out;
|
||||
test_res = ut_dsp_img_raw(image, &ctrl, exp_out, &exp_ctrl);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
|
||||
static int ut_dsp_get_act_img(dsp_ctrl_t* ctrl, uint8_t exp_out, dsp_ctrl_t* exp_ctrl)
|
||||
{
|
||||
printf(" Input: lock:%d act-image:%x \n", ctrl->img_lock, ctrl->act_img);
|
||||
|
||||
uint8_t out = dsp_get_act_img(ctrl);
|
||||
|
||||
printf(" Output: image:%x lock:%d act-image:%x \n", out, ctrl->img_lock, ctrl->act_img);
|
||||
printf("Expected: image:%x lock:%d act-image:%x \n", exp_out, exp_ctrl->img_lock, exp_ctrl->act_img);
|
||||
|
||||
if((out==exp_out)&&(ctrl->img_lock==exp_ctrl->img_lock)&&(ctrl->act_img==exp_ctrl->act_img))
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_dsp_get_act_img_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("uint8_t dsp_get_act_img(void)\n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
dsp_ctrl_t ctrl;
|
||||
uint8_t exp_out;
|
||||
dsp_ctrl_t exp_ctrl;
|
||||
|
||||
// Test
|
||||
ctrl.img_lock = 0;
|
||||
ctrl.act_img = 0x2A;
|
||||
exp_out = 0x2A;
|
||||
exp_ctrl.img_lock = ctrl.img_lock;
|
||||
exp_ctrl.act_img = exp_out;
|
||||
test_res = ut_dsp_get_act_img(&ctrl, exp_out, &exp_ctrl);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Test
|
||||
ctrl.img_lock = 1;
|
||||
ctrl.act_img = 0x3F;
|
||||
exp_out = 0x3F;
|
||||
exp_ctrl.img_lock = ctrl.img_lock;
|
||||
exp_ctrl.act_img = exp_out;
|
||||
test_res = ut_dsp_get_act_img(&ctrl, exp_out, &exp_ctrl);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
|
||||
static int ut_dsp_backlight(uint8_t dimm_act, dsp_ctrl_t* ctrl, uint8_t exp_out, dsp_ctrl_t* exp_ctrl)
|
||||
{
|
||||
printf(" Input: dimm-act:%d lock:%d act-image:%x \n", dimm_act, ctrl->img_lock, ctrl->act_img);
|
||||
|
||||
uint8_t out = dsp_backlight(dimm_act);
|
||||
|
||||
printf(" Output: percent:%x lock:%d act-image:%x \n", out, ctrl->img_lock, ctrl->act_img);
|
||||
printf("Expected: percent:%x lock:%d act-image:%x \n", exp_out, exp_ctrl->img_lock, exp_ctrl->act_img);
|
||||
|
||||
if((out==exp_out)&&(ctrl->img_lock==exp_ctrl->img_lock)&&(ctrl->act_img==exp_ctrl->act_img))
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_dsp_backlight_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("uint8_t dsp_backlight(uint8_t dimm_act)\n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
uint8_t dimm_act;
|
||||
dsp_ctrl_t ctrl;
|
||||
uint8_t exp_out;
|
||||
dsp_ctrl_t exp_ctrl;
|
||||
|
||||
// Test
|
||||
dimm_act = 0;
|
||||
ctrl.img_lock = 0;
|
||||
ctrl.act_img = 0x2A;
|
||||
exp_out = DSP_BACKLIGHT_BRIGTH_PERCENT;
|
||||
exp_ctrl.img_lock = ctrl.img_lock;
|
||||
exp_ctrl.act_img = ctrl.act_img;
|
||||
test_res = ut_dsp_backlight(dimm_act, &ctrl, exp_out, &exp_ctrl);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Test
|
||||
dimm_act = 1;
|
||||
ctrl.img_lock = 0;
|
||||
ctrl.act_img = 0x2A;
|
||||
exp_out = DSP_BACKLIGHT_DIMM_PERCENT;
|
||||
exp_ctrl.img_lock = ctrl.img_lock;
|
||||
exp_ctrl.act_img = ctrl.act_img;
|
||||
test_res = ut_dsp_backlight(dimm_act, &ctrl, exp_out, &exp_ctrl);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Test lock ignore
|
||||
dimm_act = 0;
|
||||
ctrl.img_lock = 1;
|
||||
ctrl.act_img = 0x2A;
|
||||
exp_out = DSP_BACKLIGHT_BRIGTH_PERCENT;
|
||||
exp_ctrl.img_lock = ctrl.img_lock;
|
||||
exp_ctrl.act_img = ctrl.act_img;
|
||||
test_res = ut_dsp_backlight(dimm_act, &ctrl, exp_out, &exp_ctrl);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Test lock ignore
|
||||
dimm_act = 1;
|
||||
ctrl.img_lock = 1;
|
||||
ctrl.act_img = 0x2A;
|
||||
exp_out = DSP_BACKLIGHT_DIMM_PERCENT;
|
||||
exp_ctrl.img_lock = ctrl.img_lock;
|
||||
exp_ctrl.act_img = ctrl.act_img;
|
||||
test_res = ut_dsp_backlight(dimm_act, &ctrl, exp_out, &exp_ctrl);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
19
firmware/tests/ut_logic/ut_display.h
Normal file
19
firmware/tests/ut_logic/ut_display.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef UT_DISPLAY_H_
|
||||
#define UT_DISPLAY_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
int ut_dsp_init_ctrl_test(void);
|
||||
|
||||
int ut_dsp_set_lock_test(void);
|
||||
int ut_dsp_reset_lock_test(void);
|
||||
|
||||
int ut_dsp_img_percent_test(void);
|
||||
|
||||
int ut_dsp_img_raw_test(void);
|
||||
|
||||
int ut_dsp_get_act_img_test(void);
|
||||
|
||||
int ut_dsp_backlight_test(void);
|
||||
|
||||
#endif /* UT_DISPLAY_H_ */
|
||||
170
firmware/tests/ut_logic/ut_force.c
Normal file
170
firmware/tests/ut_logic/ut_force.c
Normal file
@@ -0,0 +1,170 @@
|
||||
#include "ut_force.h"
|
||||
#include "..\..\src\logic\force.h"
|
||||
|
||||
static int ut_force_cycle_bmode(fbrake_mode_t bmode, fbrake_mode_t exp_out)
|
||||
{
|
||||
fbrake_mode_t out = force_cycle_bmode(bmode);
|
||||
|
||||
printf("Brake mode:%d\n", bmode);
|
||||
printf("Output:%d Expected:%d\n", out, exp_out);
|
||||
|
||||
if(out==exp_out)
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_force_cycle_bmode_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("fbrake_mode_t force_cycle_bmode(fbrake_mode_t bmode)\n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
fbrake_mode_t bmode;
|
||||
|
||||
fbrake_mode_t exp_out;
|
||||
|
||||
bmode = FORCE_BMODE_OPEN;
|
||||
exp_out = FORCE_BMODE_KEEP;
|
||||
test_res = ut_force_cycle_bmode(bmode,exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
bmode = FORCE_BMODE_KEEP;
|
||||
exp_out = FORCE_BMODE_LOCK;
|
||||
test_res = ut_force_cycle_bmode(bmode,exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
bmode = FORCE_BMODE_LOCK;
|
||||
exp_out = FORCE_BMODE_OPEN;
|
||||
test_res = ut_force_cycle_bmode(bmode,exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
|
||||
static int ut_force_next(uint8_t handbrake, uint8_t brakes, fbrake_mode_t bmode, uint8_t user_force, uint16_t hbarke_act_time, uint8_t exp_out)
|
||||
{
|
||||
uint8_t out = force_next(handbrake, brakes, bmode, user_force, hbarke_act_time);
|
||||
|
||||
printf("Handbrake:%d Brakes:%d Brake-Mode:%d User-Force:%d Handbrake-time:%d\n", handbrake, brakes, bmode, user_force, hbarke_act_time);
|
||||
printf("Output:%d Expected:%d\n", out, exp_out);
|
||||
|
||||
if(out==exp_out)
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_force_next_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("uint8_t force_next(uint8_t handbrake, uint8_t brakes, fbrake_mode_t bmode, uint8_t user_force, uint16_t hbarke_act_time)\n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
uint8_t handbrake;
|
||||
uint8_t brakes;
|
||||
fbrake_mode_t bmode;
|
||||
uint8_t user_force;
|
||||
uint16_t hbarke_act_time;
|
||||
|
||||
uint8_t exp_out;
|
||||
|
||||
handbrake = 0;
|
||||
brakes = 0;
|
||||
bmode = FORCE_BMODE_OPEN;
|
||||
user_force = 0;
|
||||
hbarke_act_time = 0;
|
||||
exp_out = 0;
|
||||
test_res = ut_force_next(handbrake, brakes, bmode, user_force, hbarke_act_time, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
handbrake = 0;
|
||||
brakes = 0;
|
||||
bmode = FORCE_BMODE_OPEN;
|
||||
user_force = 99;
|
||||
hbarke_act_time = 0;
|
||||
exp_out = 99;
|
||||
test_res = ut_force_next(handbrake, brakes, bmode, user_force, hbarke_act_time, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
handbrake = 0;
|
||||
brakes = 1;
|
||||
bmode = FORCE_BMODE_OPEN;
|
||||
user_force = 99;
|
||||
hbarke_act_time = 0;
|
||||
exp_out = 0;
|
||||
test_res = ut_force_next(handbrake, brakes, bmode, user_force, hbarke_act_time, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
handbrake = 0;
|
||||
brakes = 1;
|
||||
bmode = FORCE_BMODE_KEEP;
|
||||
user_force = 99;
|
||||
hbarke_act_time = 0;
|
||||
exp_out = 99;
|
||||
test_res = ut_force_next(handbrake, brakes, bmode, user_force, hbarke_act_time, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
handbrake = 0;
|
||||
brakes = 1;
|
||||
bmode = FORCE_BMODE_LOCK;
|
||||
user_force = 99;
|
||||
hbarke_act_time = 0;
|
||||
exp_out = 100;
|
||||
test_res = ut_force_next(handbrake, brakes, bmode, user_force, hbarke_act_time, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
handbrake = 1;
|
||||
brakes = 1;
|
||||
bmode = FORCE_BMODE_LOCK;
|
||||
user_force = 99;
|
||||
hbarke_act_time = 0;
|
||||
exp_out = 0;
|
||||
test_res = ut_force_next(handbrake, brakes, bmode, user_force, hbarke_act_time, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
handbrake = 1;
|
||||
brakes = 1;
|
||||
bmode = FORCE_BMODE_LOCK;
|
||||
user_force = 99;
|
||||
hbarke_act_time = FORCE_MAX_HBRAKE_HOLD_TIME-1;
|
||||
exp_out = 0;
|
||||
test_res = ut_force_next(handbrake, brakes, bmode, user_force, hbarke_act_time, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
handbrake = 1;
|
||||
brakes = 1;
|
||||
bmode = FORCE_BMODE_LOCK;
|
||||
user_force = 99;
|
||||
hbarke_act_time = FORCE_MAX_HBRAKE_HOLD_TIME;
|
||||
exp_out = 100;
|
||||
test_res = ut_force_next(handbrake, brakes, bmode, user_force, hbarke_act_time, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
handbrake = 1;
|
||||
brakes = 1;
|
||||
bmode = FORCE_BMODE_LOCK;
|
||||
user_force = 99;
|
||||
hbarke_act_time = FORCE_MAX_HBRAKE_HOLD_TIME+1;
|
||||
exp_out = 100;
|
||||
test_res = ut_force_next(handbrake, brakes, bmode, user_force, hbarke_act_time, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
10
firmware/tests/ut_logic/ut_force.h
Normal file
10
firmware/tests/ut_logic/ut_force.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef UT_FORCE_H_
|
||||
#define UT_FORCE_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int ut_force_cycle_bmode_test(void);
|
||||
int ut_force_next_test(void);
|
||||
|
||||
#endif /* UT_FORCE_H_ */
|
||||
100
firmware/tests/ut_logic/ut_pot.c
Normal file
100
firmware/tests/ut_logic/ut_pot.c
Normal file
@@ -0,0 +1,100 @@
|
||||
#include "ut_pot.h"
|
||||
#include "..\..\src\logic\pot.h"
|
||||
|
||||
static int ut_pot_mv_to_percent(uint16_t value, pot_cfg_t* cfg, uint8_t exp_out)
|
||||
{
|
||||
uint8_t out = pot_mv_to_percent(value, cfg);
|
||||
|
||||
printf("Value:%d Reference:%d Deadband:%d \n", value, cfg->reference, cfg->deadband);
|
||||
printf("Output:%d Expected:%d\n", out, exp_out);
|
||||
|
||||
if(out==exp_out)
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_pot_mv_to_percent_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("uint8_t pot_mv_to_percent(uint16_t value, pot_cfg_t* cfg)\n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
uint16_t value;
|
||||
pot_cfg_t cfg;
|
||||
|
||||
uint8_t exp_out;
|
||||
|
||||
value = 0;
|
||||
cfg.deadband = 500;
|
||||
cfg.reference = 5000;
|
||||
exp_out = 0;
|
||||
test_res = ut_pot_mv_to_percent(value, &cfg, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
value = 499;
|
||||
cfg.deadband = 500;
|
||||
cfg.reference = 5000;
|
||||
exp_out = 0;
|
||||
test_res = ut_pot_mv_to_percent(value, &cfg, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
value = 500;
|
||||
cfg.deadband = 500;
|
||||
cfg.reference = 5000;
|
||||
exp_out = 0;
|
||||
test_res = ut_pot_mv_to_percent(value, &cfg, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
value = 1500;
|
||||
cfg.deadband = 500;
|
||||
cfg.reference = 5000;
|
||||
exp_out = 25;
|
||||
test_res = ut_pot_mv_to_percent(value, &cfg, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
value = 2500;
|
||||
cfg.deadband = 500;
|
||||
cfg.reference = 5000;
|
||||
exp_out = 50;
|
||||
test_res = ut_pot_mv_to_percent(value, &cfg, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
value = 3500;
|
||||
cfg.deadband = 500;
|
||||
cfg.reference = 5000;
|
||||
exp_out = 75;
|
||||
test_res = ut_pot_mv_to_percent(value, &cfg, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
value = 4500;
|
||||
cfg.deadband = 500;
|
||||
cfg.reference = 5000;
|
||||
exp_out = 100;
|
||||
test_res = ut_pot_mv_to_percent(value, &cfg, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
value = 4501;
|
||||
cfg.deadband = 500;
|
||||
cfg.reference = 5000;
|
||||
exp_out = 100;
|
||||
test_res = ut_pot_mv_to_percent(value, &cfg, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
value = 5000;
|
||||
cfg.deadband = 500;
|
||||
cfg.reference = 5000;
|
||||
exp_out = 100;
|
||||
test_res = ut_pot_mv_to_percent(value, &cfg, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
9
firmware/tests/ut_logic/ut_pot.h
Normal file
9
firmware/tests/ut_logic/ut_pot.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef UT_POT_H_
|
||||
#define UT_POT_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int ut_pot_mv_to_percent_test(void);
|
||||
|
||||
#endif /* UT_POT_H_ */
|
||||
419
firmware/tests/ut_logic/ut_user_force.c
Normal file
419
firmware/tests/ut_logic/ut_user_force.c
Normal file
@@ -0,0 +1,419 @@
|
||||
#include "ut_user_force.h"
|
||||
#include "..\..\src\logic\user_force.h"
|
||||
|
||||
static int ut_user_force_btn(uint8_t prev_force, uint8_t up_act, uint8_t down_act, uint8_t delta, uint8_t exp_out)
|
||||
{
|
||||
uint8_t out = user_force_btn(prev_force, up_act, down_act, delta);
|
||||
|
||||
printf("Prev-Force:%d Up-act:%d Down-act:%d Delta:%d\n", prev_force, up_act, down_act, delta);
|
||||
printf("Output:%d Expected:%d\n", out, exp_out);
|
||||
|
||||
if(out==exp_out)
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_user_force_btn_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("uint8_t user_force_btn(uint8_t prev_force, uint8_t up_act, uint8_t down_act, uint8_t delta)\n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
uint8_t prev_force;
|
||||
uint8_t up_act;
|
||||
uint8_t down_act;
|
||||
uint8_t delta;
|
||||
|
||||
uint8_t exp_out;
|
||||
|
||||
// No change
|
||||
prev_force = 0;
|
||||
up_act = 0;
|
||||
down_act = 0;
|
||||
delta = 5;
|
||||
exp_out = 0;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = USER_FORCE_MIN_PERCENT-1;
|
||||
up_act = 0;
|
||||
down_act = 0;
|
||||
delta = 5;
|
||||
exp_out = 0;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = 50;
|
||||
up_act = 0;
|
||||
down_act = 0;
|
||||
delta = 5;
|
||||
exp_out = 50;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = USER_FORCE_MAX_PERCENT+1;
|
||||
up_act = 0;
|
||||
down_act = 0;
|
||||
delta = 5;
|
||||
exp_out = 100;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = 100;
|
||||
up_act = 0;
|
||||
down_act = 0;
|
||||
delta = 5;
|
||||
exp_out = 100;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Start 0
|
||||
prev_force = 0;
|
||||
up_act = 1;
|
||||
down_act = 0;
|
||||
delta = 5;
|
||||
exp_out = USER_FORCE_MIN_PERCENT;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = 0;
|
||||
up_act = 0;
|
||||
down_act = 1;
|
||||
delta = 5;
|
||||
exp_out = 0;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = 0;
|
||||
up_act = 1;
|
||||
down_act = 1;
|
||||
delta = 5;
|
||||
exp_out = 0;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = 0;
|
||||
up_act = 1;
|
||||
down_act = 0;
|
||||
delta = USER_FORCE_MIN_PERCENT+1;
|
||||
exp_out = USER_FORCE_MIN_PERCENT+1;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Start 100
|
||||
prev_force = 100;
|
||||
up_act = 1;
|
||||
down_act = 0;
|
||||
delta = 5;
|
||||
exp_out = 100;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = 100;
|
||||
up_act = 0;
|
||||
down_act = 1;
|
||||
delta = 5;
|
||||
exp_out = USER_FORCE_MAX_PERCENT;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = 100;
|
||||
up_act = 1;
|
||||
down_act = 1;
|
||||
delta = 5;
|
||||
exp_out = USER_FORCE_MAX_PERCENT;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = 100;
|
||||
up_act = 0;
|
||||
down_act = 1;
|
||||
delta = 100-USER_FORCE_MAX_PERCENT+1;
|
||||
exp_out = USER_FORCE_MAX_PERCENT-1;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Start 50
|
||||
prev_force = 50;
|
||||
up_act = 1;
|
||||
down_act = 0;
|
||||
delta = 5;
|
||||
exp_out = 55;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = 50;
|
||||
up_act = 0;
|
||||
down_act = 1;
|
||||
delta = 5;
|
||||
exp_out = 45;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = 50;
|
||||
up_act = 1;
|
||||
down_act = 1;
|
||||
delta = 5;
|
||||
exp_out = 45;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = 50;
|
||||
up_act = 1;
|
||||
down_act = 0;
|
||||
delta = 10;
|
||||
exp_out = 60;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = 50;
|
||||
up_act = 0;
|
||||
down_act = 1;
|
||||
delta = 10;
|
||||
exp_out = 40;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Start MIN_PERCENT+1
|
||||
prev_force = USER_FORCE_MIN_PERCENT+1;
|
||||
up_act = 1;
|
||||
down_act = 0;
|
||||
delta = 5;
|
||||
exp_out = prev_force+delta;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = USER_FORCE_MIN_PERCENT+1;
|
||||
up_act = 0;
|
||||
down_act = 1;
|
||||
delta = 5;
|
||||
exp_out = 0;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = USER_FORCE_MIN_PERCENT+1;
|
||||
up_act = 1;
|
||||
down_act = 1;
|
||||
delta = 5;
|
||||
exp_out = 0;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Start MAX_PERCENT-1
|
||||
prev_force = USER_FORCE_MAX_PERCENT-1;
|
||||
up_act = 1;
|
||||
down_act = 0;
|
||||
delta = 5;
|
||||
exp_out = 100;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = USER_FORCE_MAX_PERCENT-1;
|
||||
up_act = 0;
|
||||
down_act = 1;
|
||||
delta = 5;
|
||||
exp_out = prev_force-delta;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = USER_FORCE_MAX_PERCENT-1;
|
||||
up_act = 1;
|
||||
down_act = 1;
|
||||
delta = 5;
|
||||
exp_out = prev_force-delta;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Up down seq
|
||||
prev_force = 0;
|
||||
up_act = 1;
|
||||
down_act = 0;
|
||||
delta = 20;
|
||||
exp_out = 20;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = 20;
|
||||
up_act = 1;
|
||||
down_act = 0;
|
||||
delta = 20;
|
||||
exp_out = 40;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = 40;
|
||||
up_act = 1;
|
||||
down_act = 0;
|
||||
delta = 20;
|
||||
exp_out = 60;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = 60;
|
||||
up_act = 1;
|
||||
down_act = 0;
|
||||
delta = 20;
|
||||
exp_out = 80;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = 80;
|
||||
up_act = 1;
|
||||
down_act = 0;
|
||||
delta = 20;
|
||||
exp_out = 100;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = 100;
|
||||
up_act = 1;
|
||||
down_act = 0;
|
||||
delta = 20;
|
||||
exp_out = 100;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = 100;
|
||||
up_act = 0;
|
||||
down_act = 1;
|
||||
delta = 20;
|
||||
exp_out = 80;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = 80;
|
||||
up_act = 0;
|
||||
down_act = 1;
|
||||
delta = 20;
|
||||
exp_out = 60;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = 60;
|
||||
up_act = 0;
|
||||
down_act = 1;
|
||||
delta = 20;
|
||||
exp_out = 40;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = 40;
|
||||
up_act = 0;
|
||||
down_act = 1;
|
||||
delta = 20;
|
||||
exp_out = 20;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = 20;
|
||||
up_act = 0;
|
||||
down_act = 1;
|
||||
delta = 20;
|
||||
exp_out = 0;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = 0;
|
||||
up_act = 0;
|
||||
down_act = 1;
|
||||
delta = 20;
|
||||
exp_out = 0;
|
||||
test_res = ut_user_force_btn(prev_force, up_act, down_act, delta, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
|
||||
static int ut_user_force_pot(uint8_t prev_force, uint8_t pot, uint8_t hyst, uint8_t exp_out)
|
||||
{
|
||||
uint8_t out = user_force_pot(prev_force, pot, hyst);
|
||||
|
||||
printf("Prev-Force:%d Pot-percent:%d Hysteresis:%d \n", prev_force, pot, hyst);
|
||||
printf("Output:%d Expected:%d\n", out, exp_out);
|
||||
|
||||
if(out==exp_out)
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_user_force_pot_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("uint8_t user_force_pot(uint8_t prev_force, uint8_t pot, uint8_t hyst)\n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
uint8_t prev_force;
|
||||
uint8_t pot;
|
||||
uint8_t hyst;
|
||||
|
||||
uint8_t exp_out;
|
||||
|
||||
prev_force = 50;
|
||||
pot = 0;
|
||||
hyst = 10;
|
||||
exp_out = 0;
|
||||
test_res = ut_user_force_pot(prev_force, pot, hyst, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = 50;
|
||||
pot = USER_FORCE_MIN_PERCENT-1;
|
||||
hyst = 10;
|
||||
exp_out = 0;
|
||||
test_res = ut_user_force_pot(prev_force, pot, hyst, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = 50;
|
||||
pot = USER_FORCE_MIN_PERCENT;
|
||||
hyst = 10;
|
||||
exp_out = USER_FORCE_MIN_PERCENT;
|
||||
test_res = ut_user_force_pot(prev_force, pot, hyst, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = 50;
|
||||
pot = 50;
|
||||
hyst = 10;
|
||||
exp_out = 50;
|
||||
test_res = ut_user_force_pot(prev_force, pot, hyst, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = 50;
|
||||
pot = USER_FORCE_MAX_PERCENT;
|
||||
hyst = 10;
|
||||
exp_out = USER_FORCE_MAX_PERCENT;
|
||||
test_res = ut_user_force_pot(prev_force, pot, hyst, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = 50;
|
||||
pot = USER_FORCE_MAX_PERCENT+1;
|
||||
hyst = 10;
|
||||
exp_out = 100;
|
||||
test_res = ut_user_force_pot(prev_force, pot, hyst, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
prev_force = 50;
|
||||
pot = 100;
|
||||
hyst = 10;
|
||||
exp_out = 100;
|
||||
test_res = ut_user_force_pot(prev_force, pot, hyst, exp_out);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
10
firmware/tests/ut_logic/ut_user_force.h
Normal file
10
firmware/tests/ut_logic/ut_user_force.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef UT_USER_FORCE_H_
|
||||
#define UT_USER_FORCE_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int ut_user_force_btn_test(void);
|
||||
int ut_user_force_pot_test(void);
|
||||
|
||||
#endif /* UT_USER_FORCE_H_ */
|
||||
951
firmware/tests/ut_utils/ut_fault.c
Normal file
951
firmware/tests/ut_utils/ut_fault.c
Normal file
@@ -0,0 +1,951 @@
|
||||
#include "ut_fault.h"
|
||||
|
||||
#include "..\..\src\hw\board\utils\faults.h"
|
||||
|
||||
static int ut_fault_process(fault_t* fault, uint8_t w_trig, uint8_t f_trig, fault_cfg_t* cfg, uint8_t exp_out, fault_t* exp_out_fault, fault_cfg_t* exp_out_cfg)
|
||||
{
|
||||
printf("W-Trig:%d F-trig:%d \n", w_trig, f_trig);
|
||||
printf("Severity:%d W-time:%d F-time:%d \n", fault->severity, fault->w_time, fault->f_time);
|
||||
printf("Delay:%d WtoF:%d \n", cfg->delay, cfg->wtof);
|
||||
|
||||
uint8_t out = fault_process(fault, w_trig, f_trig, cfg);
|
||||
|
||||
printf("Output:%d Expected:%d\n", out, exp_out);
|
||||
printf(" Output: Severity:%d W-time:%d F-time:%d \n", fault->severity, fault->w_time, fault->f_time);
|
||||
printf("Expected: Severity:%d W-time:%d F-time:%d \n", exp_out_fault->severity, exp_out_fault->w_time, exp_out_fault->f_time);
|
||||
printf("Delay:%d WtoF:%d \n", cfg->delay, cfg->wtof);
|
||||
|
||||
if((out==exp_out)&&(fault->severity==exp_out_fault->severity)&&(fault->w_time==exp_out_fault->w_time)&&(fault->f_time==exp_out_fault->f_time)&&(cfg->delay==exp_out_cfg->delay)&&(cfg->wtof==exp_out_cfg->wtof))
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_fault_process_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("uint8_t fault_process(fault_t* fault, uint8_t w_trig, uint8_t f_trig, fault_cfg_t* cfg)\n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
fault_t fault;
|
||||
uint8_t w_trig;
|
||||
uint8_t f_trig;
|
||||
fault_cfg_t cfg;
|
||||
|
||||
uint8_t exp_out;
|
||||
fault_t exp_out_fault;
|
||||
fault_cfg_t exp_out_cfg;
|
||||
|
||||
// NORMAL NO FAULT CONDITION *************************************************************************
|
||||
// No change test, start form OK
|
||||
fault.severity = FAULT_LVL_OK;
|
||||
fault.w_time = 0;
|
||||
fault.f_time = 0;
|
||||
w_trig = 0;
|
||||
f_trig = 0;
|
||||
cfg.delay = 0;
|
||||
cfg.wtof = 0;
|
||||
exp_out = 0;
|
||||
exp_out_fault.severity = FAULT_LVL_OK;
|
||||
exp_out_fault.w_time = 0;
|
||||
exp_out_fault.f_time = 0;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// STARTING CONDITIONS *************************************************************************
|
||||
// Warning trigger test, start form OK
|
||||
fault.severity = FAULT_LVL_OK;
|
||||
fault.w_time = 0;
|
||||
fault.f_time = 0;
|
||||
w_trig = 1;
|
||||
f_trig = 0;
|
||||
cfg.delay = 0;
|
||||
cfg.wtof = 0;
|
||||
exp_out = 0;
|
||||
exp_out_fault.severity = FAULT_LVL_WARNING;
|
||||
exp_out_fault.w_time = 0;
|
||||
exp_out_fault.f_time = 0;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Fault trigger test, start form OK
|
||||
fault.severity = FAULT_LVL_OK;
|
||||
fault.w_time = 0;
|
||||
fault.f_time = 0;
|
||||
w_trig = 0;
|
||||
f_trig = 1;
|
||||
cfg.delay = 0;
|
||||
cfg.wtof = 0;
|
||||
exp_out = 1;
|
||||
exp_out_fault.severity = FAULT_LVL_FAULT;
|
||||
exp_out_fault.w_time = 0;
|
||||
exp_out_fault.f_time = 0;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Warning and Fault trigger test, start form OK
|
||||
fault.severity = FAULT_LVL_OK;
|
||||
fault.w_time = 0;
|
||||
fault.f_time = 0;
|
||||
w_trig = 1;
|
||||
f_trig = 1;
|
||||
cfg.delay = 0;
|
||||
cfg.wtof = 0;
|
||||
exp_out = 1;
|
||||
exp_out_fault.severity = FAULT_LVL_FAULT;
|
||||
exp_out_fault.w_time = 0;
|
||||
exp_out_fault.f_time = 0;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Wrong start severity WARNING, with no triggers
|
||||
fault.severity = FAULT_LVL_WARNING;
|
||||
fault.w_time = 0;
|
||||
fault.f_time = 0;
|
||||
w_trig = 0;
|
||||
f_trig = 0;
|
||||
cfg.delay = 0;
|
||||
cfg.wtof = 0;
|
||||
exp_out = 0;
|
||||
exp_out_fault.severity = FAULT_LVL_OK;
|
||||
exp_out_fault.w_time = 0;
|
||||
exp_out_fault.f_time = 0;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Wrong start severity FAULT, with no triggers
|
||||
fault.severity = FAULT_LVL_FAULT;
|
||||
fault.w_time = 0;
|
||||
fault.f_time = 0;
|
||||
w_trig = 0;
|
||||
f_trig = 0;
|
||||
cfg.delay = 0;
|
||||
cfg.wtof = 0;
|
||||
exp_out = 0;
|
||||
exp_out_fault.severity = FAULT_LVL_OK;
|
||||
exp_out_fault.w_time = 0;
|
||||
exp_out_fault.f_time = 0;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Wrong start times, with no triggers
|
||||
fault.severity = FAULT_LVL_OK;
|
||||
fault.w_time = 78;
|
||||
fault.f_time = 56;
|
||||
w_trig = 0;
|
||||
f_trig = 0;
|
||||
cfg.delay = 0;
|
||||
cfg.wtof = 0;
|
||||
exp_out = 0;
|
||||
exp_out_fault.severity = FAULT_LVL_OK;
|
||||
exp_out_fault.w_time = 0;
|
||||
exp_out_fault.f_time = 0;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
|
||||
// TIME INCREASE TESTS - SECOND ITERATION WITH TRIGGER ACTIVE *************************************************************************
|
||||
// Warning time increase with continuing warning condition
|
||||
fault.severity = FAULT_LVL_WARNING;
|
||||
fault.w_time = 45;
|
||||
fault.f_time = 0;
|
||||
w_trig = 1;
|
||||
f_trig = 0;
|
||||
cfg.delay = 0;
|
||||
cfg.wtof = 0;
|
||||
exp_out = 0;
|
||||
exp_out_fault.severity = FAULT_LVL_WARNING;
|
||||
exp_out_fault.w_time = 46;
|
||||
exp_out_fault.f_time = 0;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Fault and warning time increase with continuing fault only condition
|
||||
fault.severity = FAULT_LVL_FAULT;
|
||||
fault.w_time = 78;
|
||||
fault.f_time = 23;
|
||||
w_trig = 0;
|
||||
f_trig = 1;
|
||||
cfg.delay = 0;
|
||||
cfg.wtof = 0;
|
||||
exp_out = 1;
|
||||
exp_out_fault.severity = FAULT_LVL_FAULT;
|
||||
exp_out_fault.w_time = 79;
|
||||
exp_out_fault.f_time = 24;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Fault and warning time increase with continuing both triggers condition
|
||||
fault.severity = FAULT_LVL_FAULT;
|
||||
fault.w_time = 57;
|
||||
fault.f_time = 12;
|
||||
w_trig = 1;
|
||||
f_trig = 1;
|
||||
cfg.delay = 0;
|
||||
cfg.wtof = 0;
|
||||
exp_out = 1;
|
||||
exp_out_fault.severity = FAULT_LVL_FAULT;
|
||||
exp_out_fault.w_time = 58;
|
||||
exp_out_fault.f_time = 13;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Time increase and transition to fault with both triggers
|
||||
fault.severity = FAULT_LVL_WARNING;
|
||||
fault.w_time = 0;
|
||||
fault.f_time = 0;
|
||||
w_trig = 1;
|
||||
f_trig = 1;
|
||||
cfg.delay = 0;
|
||||
cfg.wtof = 0;
|
||||
exp_out = 1;
|
||||
exp_out_fault.severity = FAULT_LVL_FAULT;
|
||||
exp_out_fault.w_time = 1;
|
||||
exp_out_fault.f_time = 1;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Warning time increase and transition to fault with only fault trigger
|
||||
fault.severity = FAULT_LVL_WARNING;
|
||||
fault.w_time = 0;
|
||||
fault.f_time = 0;
|
||||
w_trig = 0;
|
||||
f_trig = 1;
|
||||
cfg.delay = 0;
|
||||
cfg.wtof = 0;
|
||||
exp_out = 1;
|
||||
exp_out_fault.severity = FAULT_LVL_FAULT;
|
||||
exp_out_fault.w_time = 1;
|
||||
exp_out_fault.f_time = 1;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Time saturation
|
||||
fault.severity = FAULT_LVL_FAULT;
|
||||
fault.w_time = 65535;
|
||||
fault.f_time = 65535;
|
||||
w_trig = 1;
|
||||
f_trig = 1;
|
||||
cfg.delay = 0;
|
||||
cfg.wtof = 0;
|
||||
exp_out = 1;
|
||||
exp_out_fault.severity = FAULT_LVL_FAULT;
|
||||
exp_out_fault.w_time = 65535;
|
||||
exp_out_fault.f_time = 65535;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Fallback to warning and time increase
|
||||
fault.severity = FAULT_LVL_FAULT;
|
||||
fault.w_time = 784;
|
||||
fault.f_time = 457;
|
||||
w_trig = 1;
|
||||
f_trig = 0;
|
||||
cfg.delay = 0;
|
||||
cfg.wtof = 0;
|
||||
exp_out = 0;
|
||||
exp_out_fault.severity = FAULT_LVL_WARNING;
|
||||
exp_out_fault.w_time = 785;
|
||||
exp_out_fault.f_time = 0;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Fallback to OK and time reset from fault
|
||||
fault.severity = FAULT_LVL_FAULT;
|
||||
fault.w_time = 784;
|
||||
fault.f_time = 457;
|
||||
w_trig = 0;
|
||||
f_trig = 0;
|
||||
cfg.delay = 0;
|
||||
cfg.wtof = 0;
|
||||
exp_out = 0;
|
||||
exp_out_fault.severity = FAULT_LVL_OK;
|
||||
exp_out_fault.w_time = 0;
|
||||
exp_out_fault.f_time = 0;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Fallback to OK and time reset from warning
|
||||
fault.severity = FAULT_LVL_WARNING;
|
||||
fault.w_time = 479;
|
||||
fault.f_time = 0;
|
||||
w_trig = 0;
|
||||
f_trig = 0;
|
||||
cfg.delay = 0;
|
||||
cfg.wtof = 0;
|
||||
exp_out = 0;
|
||||
exp_out_fault.severity = FAULT_LVL_OK;
|
||||
exp_out_fault.w_time = 0;
|
||||
exp_out_fault.f_time = 0;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// FAULT DELAY TESTS *************************************************************************
|
||||
// Not transition to fault
|
||||
fault.severity = FAULT_LVL_OK;
|
||||
fault.w_time = 0;
|
||||
fault.f_time = 0;
|
||||
w_trig = 1;
|
||||
f_trig = 1;
|
||||
cfg.delay = 100;
|
||||
cfg.wtof = 0;
|
||||
exp_out = 0;
|
||||
exp_out_fault.severity = FAULT_LVL_WARNING;
|
||||
exp_out_fault.w_time = 0;
|
||||
exp_out_fault.f_time = 0;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Not transition to fault second time
|
||||
fault.severity = FAULT_LVL_WARNING;
|
||||
fault.w_time = 0;
|
||||
fault.f_time = 0;
|
||||
w_trig = 1;
|
||||
f_trig = 1;
|
||||
cfg.delay = 100;
|
||||
cfg.wtof = 0;
|
||||
exp_out = 0;
|
||||
exp_out_fault.severity = FAULT_LVL_WARNING;
|
||||
exp_out_fault.w_time = 1;
|
||||
exp_out_fault.f_time = 1;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Not transition to fault before limit
|
||||
fault.severity = FAULT_LVL_WARNING;
|
||||
fault.w_time = 128;
|
||||
fault.f_time = 98;
|
||||
w_trig = 1;
|
||||
f_trig = 1;
|
||||
cfg.delay = 100;
|
||||
cfg.wtof = 0;
|
||||
exp_out = 0;
|
||||
exp_out_fault.severity = FAULT_LVL_WARNING;
|
||||
exp_out_fault.w_time = 129;
|
||||
exp_out_fault.f_time = 99;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Transition to fault at limit
|
||||
fault.severity = FAULT_LVL_WARNING;
|
||||
fault.w_time = 358;
|
||||
fault.f_time = 99;
|
||||
w_trig = 1;
|
||||
f_trig = 1;
|
||||
cfg.delay = 100;
|
||||
cfg.wtof = 0;
|
||||
exp_out = 1;
|
||||
exp_out_fault.severity = FAULT_LVL_FAULT;
|
||||
exp_out_fault.w_time = 359;
|
||||
exp_out_fault.f_time = 100;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Transition to fault after limit
|
||||
fault.severity = FAULT_LVL_WARNING;
|
||||
fault.w_time = 786;
|
||||
fault.f_time = 100;
|
||||
w_trig = 1;
|
||||
f_trig = 1;
|
||||
cfg.delay = 100;
|
||||
cfg.wtof = 0;
|
||||
exp_out = 1;
|
||||
exp_out_fault.severity = FAULT_LVL_FAULT;
|
||||
exp_out_fault.w_time = 787;
|
||||
exp_out_fault.f_time = 101;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Continued fault condition
|
||||
fault.severity = FAULT_LVL_FAULT;
|
||||
fault.w_time = 101;
|
||||
fault.f_time = 101;
|
||||
w_trig = 1;
|
||||
f_trig = 1;
|
||||
cfg.delay = 100;
|
||||
cfg.wtof = 0;
|
||||
exp_out = 1;
|
||||
exp_out_fault.severity = FAULT_LVL_FAULT;
|
||||
exp_out_fault.w_time = 102;
|
||||
exp_out_fault.f_time = 102;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Fallback to warning
|
||||
fault.severity = FAULT_LVL_FAULT;
|
||||
fault.w_time = 101;
|
||||
fault.f_time = 101;
|
||||
w_trig = 1;
|
||||
f_trig = 0;
|
||||
cfg.delay = 100;
|
||||
cfg.wtof = 0;
|
||||
exp_out = 0;
|
||||
exp_out_fault.severity = FAULT_LVL_WARNING;
|
||||
exp_out_fault.w_time = 102;
|
||||
exp_out_fault.f_time = 0;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Fallback to OK
|
||||
fault.severity = FAULT_LVL_FAULT;
|
||||
fault.w_time = 101;
|
||||
fault.f_time = 101;
|
||||
w_trig = 0;
|
||||
f_trig = 0;
|
||||
cfg.delay = 100;
|
||||
cfg.wtof = 0;
|
||||
exp_out = 0;
|
||||
exp_out_fault.severity = FAULT_LVL_OK;
|
||||
exp_out_fault.w_time = 0;
|
||||
exp_out_fault.f_time = 0;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Allready was fault condition, with lower time - fixes to correct state
|
||||
fault.severity = FAULT_LVL_FAULT;
|
||||
fault.w_time = 45;
|
||||
fault.f_time = 45;
|
||||
w_trig = 1;
|
||||
f_trig = 1;
|
||||
cfg.delay = 100;
|
||||
cfg.wtof = 0;
|
||||
exp_out = 0;
|
||||
exp_out_fault.severity = FAULT_LVL_WARNING;
|
||||
exp_out_fault.w_time = 46;
|
||||
exp_out_fault.f_time = 46;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// WARNING TO FAULT TRANSITION TESTS *************************************************************************
|
||||
// Not transition to fault
|
||||
fault.severity = FAULT_LVL_OK;
|
||||
fault.w_time = 0;
|
||||
fault.f_time = 0;
|
||||
w_trig = 1;
|
||||
f_trig = 0;
|
||||
cfg.delay = 0;
|
||||
cfg.wtof = 200;
|
||||
exp_out = 0;
|
||||
exp_out_fault.severity = FAULT_LVL_WARNING;
|
||||
exp_out_fault.w_time = 0;
|
||||
exp_out_fault.f_time = 0;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Not transition to fault
|
||||
fault.severity = FAULT_LVL_WARNING;
|
||||
fault.w_time = 0;
|
||||
fault.f_time = 0;
|
||||
w_trig = 1;
|
||||
f_trig = 0;
|
||||
cfg.delay = 0;
|
||||
cfg.wtof = 200;
|
||||
exp_out = 0;
|
||||
exp_out_fault.severity = FAULT_LVL_WARNING;
|
||||
exp_out_fault.w_time = 1;
|
||||
exp_out_fault.f_time = 0;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Not transition to fault before limit
|
||||
fault.severity = FAULT_LVL_WARNING;
|
||||
fault.w_time = 198;
|
||||
fault.f_time = 0;
|
||||
w_trig = 1;
|
||||
f_trig = 0;
|
||||
cfg.delay = 0;
|
||||
cfg.wtof = 200;
|
||||
exp_out = 0;
|
||||
exp_out_fault.severity = FAULT_LVL_WARNING;
|
||||
exp_out_fault.w_time = 199;
|
||||
exp_out_fault.f_time = 0;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Not Transition to fault at limit
|
||||
fault.severity = FAULT_LVL_WARNING;
|
||||
fault.w_time = 199;
|
||||
fault.f_time = 0;
|
||||
w_trig = 1;
|
||||
f_trig = 0;
|
||||
cfg.delay = 0;
|
||||
cfg.wtof = 200;
|
||||
exp_out = 0;
|
||||
exp_out_fault.severity = FAULT_LVL_WARNING;
|
||||
exp_out_fault.w_time = 200;
|
||||
exp_out_fault.f_time = 0;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Transition to fault after limit
|
||||
fault.severity = FAULT_LVL_WARNING;
|
||||
fault.w_time = 200;
|
||||
fault.f_time = 0;
|
||||
w_trig = 1;
|
||||
f_trig = 0;
|
||||
cfg.delay = 0;
|
||||
cfg.wtof = 200;
|
||||
exp_out = 1;
|
||||
exp_out_fault.severity = FAULT_LVL_FAULT;
|
||||
exp_out_fault.w_time = 201;
|
||||
exp_out_fault.f_time = 1;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Continued fault
|
||||
fault.severity = FAULT_LVL_FAULT;
|
||||
fault.w_time = 201;
|
||||
fault.f_time = 1;
|
||||
w_trig = 1;
|
||||
f_trig = 0;
|
||||
cfg.delay = 0;
|
||||
cfg.wtof = 200;
|
||||
exp_out = 1;
|
||||
exp_out_fault.severity = FAULT_LVL_FAULT;
|
||||
exp_out_fault.w_time = 202;
|
||||
exp_out_fault.f_time = 2;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Fallback to ok
|
||||
fault.severity = FAULT_LVL_FAULT;
|
||||
fault.w_time = 247;
|
||||
fault.f_time = 0;
|
||||
w_trig = 0;
|
||||
f_trig = 0;
|
||||
cfg.delay = 0;
|
||||
cfg.wtof = 200;
|
||||
exp_out = 0;
|
||||
exp_out_fault.severity = FAULT_LVL_OK;
|
||||
exp_out_fault.w_time = 0;
|
||||
exp_out_fault.f_time = 0;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// WARNING TO FAULT TRANSITION WITH FAULT DELAY TESTS *************************************************************************
|
||||
// Not transition to fault
|
||||
fault.severity = FAULT_LVL_OK;
|
||||
fault.w_time = 0;
|
||||
fault.f_time = 0;
|
||||
w_trig = 1;
|
||||
f_trig = 0;
|
||||
cfg.delay = 50;
|
||||
cfg.wtof = 200;
|
||||
exp_out = 0;
|
||||
exp_out_fault.severity = FAULT_LVL_WARNING;
|
||||
exp_out_fault.w_time = 0;
|
||||
exp_out_fault.f_time = 0;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Not transition to fault
|
||||
fault.severity = FAULT_LVL_OK;
|
||||
fault.w_time = 0;
|
||||
fault.f_time = 0;
|
||||
w_trig = 1;
|
||||
f_trig = 1;
|
||||
cfg.delay = 50;
|
||||
cfg.wtof = 200;
|
||||
exp_out = 0;
|
||||
exp_out_fault.severity = FAULT_LVL_WARNING;
|
||||
exp_out_fault.w_time = 0;
|
||||
exp_out_fault.f_time = 0;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
fault.severity = FAULT_LVL_OK;
|
||||
fault.w_time = 0;
|
||||
fault.f_time = 0;
|
||||
w_trig = 0;
|
||||
f_trig = 1;
|
||||
cfg.delay = 50;
|
||||
cfg.wtof = 200;
|
||||
exp_out = 0;
|
||||
exp_out_fault.severity = FAULT_LVL_WARNING;
|
||||
exp_out_fault.w_time = 0;
|
||||
exp_out_fault.f_time = 0;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Transition to fault at delay
|
||||
fault.severity = FAULT_LVL_WARNING;
|
||||
fault.w_time = 49;
|
||||
fault.f_time = 49;
|
||||
w_trig = 1;
|
||||
f_trig = 1;
|
||||
cfg.delay = 50;
|
||||
cfg.wtof = 200;
|
||||
exp_out = 1;
|
||||
exp_out_fault.severity = FAULT_LVL_FAULT;
|
||||
exp_out_fault.w_time = 50;
|
||||
exp_out_fault.f_time = 50;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// No Transition to fault at wtof
|
||||
fault.severity = FAULT_LVL_WARNING;
|
||||
fault.w_time = 200;
|
||||
fault.f_time = 0;
|
||||
w_trig = 1;
|
||||
f_trig = 0;
|
||||
cfg.delay = 50;
|
||||
cfg.wtof = 200;
|
||||
exp_out = 0;
|
||||
exp_out_fault.severity = FAULT_LVL_WARNING;
|
||||
exp_out_fault.w_time = 201;
|
||||
exp_out_fault.f_time = 1;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// No Transition to fault before wtof + delay
|
||||
fault.severity = FAULT_LVL_WARNING;
|
||||
fault.w_time = 248;
|
||||
fault.f_time = 48;
|
||||
w_trig = 1;
|
||||
f_trig = 0;
|
||||
cfg.delay = 50;
|
||||
cfg.wtof = 200;
|
||||
exp_out = 0;
|
||||
exp_out_fault.severity = FAULT_LVL_WARNING;
|
||||
exp_out_fault.w_time = 249;
|
||||
exp_out_fault.f_time = 49;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Transition to fault before wtof + delay
|
||||
fault.severity = FAULT_LVL_WARNING;
|
||||
fault.w_time = 249;
|
||||
fault.f_time = 49;
|
||||
w_trig = 1;
|
||||
f_trig = 0;
|
||||
cfg.delay = 50;
|
||||
cfg.wtof = 200;
|
||||
exp_out = 1;
|
||||
exp_out_fault.severity = FAULT_LVL_FAULT;
|
||||
exp_out_fault.w_time = 250;
|
||||
exp_out_fault.f_time = 50;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Continued wtof fault condition
|
||||
fault.severity = FAULT_LVL_FAULT;
|
||||
fault.w_time = 250;
|
||||
fault.f_time = 50;
|
||||
w_trig = 1;
|
||||
f_trig = 0;
|
||||
cfg.delay = 50;
|
||||
cfg.wtof = 200;
|
||||
exp_out = 1;
|
||||
exp_out_fault.severity = FAULT_LVL_FAULT;
|
||||
exp_out_fault.w_time = 251;
|
||||
exp_out_fault.f_time = 51;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// Continued wtof fault condition, without warning trigger
|
||||
fault.severity = FAULT_LVL_FAULT;
|
||||
fault.w_time = 350;
|
||||
fault.f_time = 150;
|
||||
w_trig = 0;
|
||||
f_trig = 1;
|
||||
cfg.delay = 50;
|
||||
cfg.wtof = 200;
|
||||
exp_out = 1;
|
||||
exp_out_fault.severity = FAULT_LVL_FAULT;
|
||||
exp_out_fault.w_time = 351;
|
||||
exp_out_fault.f_time = 151;
|
||||
exp_out_cfg.delay = cfg.delay;
|
||||
exp_out_cfg.wtof = cfg.wtof;
|
||||
test_res = ut_fault_process(&fault, w_trig, f_trig, &cfg, exp_out, &exp_out_fault, &exp_out_cfg);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
|
||||
static int ut_fault_is_active(fault_t* fault, uint8_t exp_out, fault_t* exp_out_fault)
|
||||
{
|
||||
printf("Severity:%d W-time:%d F-time:%d \n", fault->severity, fault->w_time, fault->f_time);
|
||||
|
||||
uint8_t out = fault_is_active(fault);
|
||||
|
||||
printf("Output:%d Expected:%d\n", out, exp_out);
|
||||
printf(" Output: Severity:%d W-time:%d F-time:%d \n", fault->severity, fault->w_time, fault->f_time);
|
||||
printf("Expected: Severity:%d W-time:%d F-time:%d \n", exp_out_fault->severity, exp_out_fault->w_time, exp_out_fault->f_time);
|
||||
|
||||
if((out==exp_out)&&(fault->severity==exp_out_fault->severity)&&(fault->w_time==exp_out_fault->w_time)&&(fault->f_time==exp_out_fault->f_time))
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_fault_is_active_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("uint8_t fault_is_active(fault_t* fault)\n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
fault_t fault;
|
||||
|
||||
uint8_t exp_out;
|
||||
fault_t exp_out_fault;
|
||||
|
||||
fault.severity = FAULT_LVL_OK;
|
||||
fault.w_time = 500;
|
||||
fault.f_time = 300;
|
||||
exp_out = 0;
|
||||
exp_out_fault.severity = fault.severity;
|
||||
exp_out_fault.w_time = fault.w_time;
|
||||
exp_out_fault.f_time = fault.f_time;
|
||||
test_res = ut_fault_is_active(&fault, exp_out, &exp_out_fault);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
fault.severity = FAULT_LVL_WARNING;
|
||||
fault.w_time = 500;
|
||||
fault.f_time = 300;
|
||||
exp_out = 0;
|
||||
exp_out_fault.severity = fault.severity;
|
||||
exp_out_fault.w_time = fault.w_time;
|
||||
exp_out_fault.f_time = fault.f_time;
|
||||
test_res = ut_fault_is_active(&fault, exp_out, &exp_out_fault);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
fault.severity = FAULT_LVL_FAULT;
|
||||
fault.w_time = 500;
|
||||
fault.f_time = 300;
|
||||
exp_out = 1;
|
||||
exp_out_fault.severity = fault.severity;
|
||||
exp_out_fault.w_time = fault.w_time;
|
||||
exp_out_fault.f_time = fault.f_time;
|
||||
test_res = ut_fault_is_active(&fault, exp_out, &exp_out_fault);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
|
||||
static int ut_fault_is_warning(fault_t* fault, uint8_t exp_out, fault_t* exp_out_fault)
|
||||
{
|
||||
printf("Severity:%d W-time:%d F-time:%d \n", fault->severity, fault->w_time, fault->f_time);
|
||||
|
||||
uint8_t out = fault_is_warning(fault);
|
||||
|
||||
printf("Output:%d Expected:%d\n", out, exp_out);
|
||||
printf(" Output: Severity:%d W-time:%d F-time:%d \n", fault->severity, fault->w_time, fault->f_time);
|
||||
printf("Expected: Severity:%d W-time:%d F-time:%d \n", exp_out_fault->severity, exp_out_fault->w_time, exp_out_fault->f_time);
|
||||
|
||||
if((out==exp_out)&&(fault->severity==exp_out_fault->severity)&&(fault->w_time==exp_out_fault->w_time)&&(fault->f_time==exp_out_fault->f_time))
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_fault_is_warning_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("uint8_t fault_is_warning(fault_t* fault)\n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
fault_t fault;
|
||||
|
||||
uint8_t exp_out;
|
||||
fault_t exp_out_fault;
|
||||
|
||||
fault.severity = FAULT_LVL_OK;
|
||||
fault.w_time = 500;
|
||||
fault.f_time = 300;
|
||||
exp_out = 0;
|
||||
exp_out_fault.severity = fault.severity;
|
||||
exp_out_fault.w_time = fault.w_time;
|
||||
exp_out_fault.f_time = fault.f_time;
|
||||
test_res = ut_fault_is_warning(&fault, exp_out, &exp_out_fault);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
fault.severity = FAULT_LVL_WARNING;
|
||||
fault.w_time = 500;
|
||||
fault.f_time = 300;
|
||||
exp_out = 1;
|
||||
exp_out_fault.severity = fault.severity;
|
||||
exp_out_fault.w_time = fault.w_time;
|
||||
exp_out_fault.f_time = fault.f_time;
|
||||
test_res = ut_fault_is_warning(&fault, exp_out, &exp_out_fault);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
fault.severity = FAULT_LVL_FAULT;
|
||||
fault.w_time = 500;
|
||||
fault.f_time = 300;
|
||||
exp_out = 1;
|
||||
exp_out_fault.severity = fault.severity;
|
||||
exp_out_fault.w_time = fault.w_time;
|
||||
exp_out_fault.f_time = fault.f_time;
|
||||
test_res = ut_fault_is_warning(&fault, exp_out, &exp_out_fault);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
|
||||
static int ut_fault_reset(fault_t* fault, fault_t* exp_out_fault)
|
||||
{
|
||||
printf("Severity:%d W-time:%d F-time:%d \n", fault->severity, fault->w_time, fault->f_time);
|
||||
|
||||
fault_reset(fault);
|
||||
|
||||
printf(" Output: Severity:%d W-time:%d F-time:%d \n", fault->severity, fault->w_time, fault->f_time);
|
||||
printf("Expected: Severity:%d W-time:%d F-time:%d \n", exp_out_fault->severity, exp_out_fault->w_time, exp_out_fault->f_time);
|
||||
|
||||
if((fault->severity==exp_out_fault->severity)&&(fault->w_time==exp_out_fault->w_time)&&(fault->f_time==exp_out_fault->f_time))
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_fault_reset_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("void fault_reset(fault_t* fault)\n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
fault_t fault;
|
||||
|
||||
fault_t exp_out_fault;
|
||||
|
||||
fault.severity = FAULT_LVL_OK;
|
||||
fault.w_time = 0;
|
||||
fault.f_time = 0;
|
||||
exp_out_fault.severity = FAULT_LVL_OK;
|
||||
exp_out_fault.w_time = 0;
|
||||
exp_out_fault.f_time = 0;
|
||||
test_res = ut_fault_reset(&fault, &exp_out_fault);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
fault.severity = FAULT_LVL_WARNING;
|
||||
fault.w_time = 500;
|
||||
fault.f_time = 0;
|
||||
exp_out_fault.severity = FAULT_LVL_OK;
|
||||
exp_out_fault.w_time = 0;
|
||||
exp_out_fault.f_time = 0;
|
||||
test_res = ut_fault_reset(&fault, &exp_out_fault);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
fault.severity = FAULT_LVL_FAULT;
|
||||
fault.w_time = 1000;
|
||||
fault.f_time = 500;
|
||||
exp_out_fault.severity = FAULT_LVL_OK;
|
||||
exp_out_fault.w_time = 0;
|
||||
exp_out_fault.f_time = 0;
|
||||
test_res = ut_fault_reset(&fault, &exp_out_fault);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
|
||||
12
firmware/tests/ut_utils/ut_fault.h
Normal file
12
firmware/tests/ut_utils/ut_fault.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef UT_FAULTS_H_
|
||||
#define UT_FAULTS_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int ut_fault_process_test(void);
|
||||
int ut_fault_is_active_test(void);
|
||||
int ut_fault_is_warning_test(void);
|
||||
int ut_fault_reset_test(void);
|
||||
|
||||
#endif /* UT_FAULTS_H_ */
|
||||
79
firmware/tests/ut_utils/ut_fuses.c
Normal file
79
firmware/tests/ut_utils/ut_fuses.c
Normal file
@@ -0,0 +1,79 @@
|
||||
#include "ut_fuses.h"
|
||||
|
||||
#include "..\..\src\hw\board\utils\fuses.h"
|
||||
|
||||
static int ut_fuse_reset(fuse_t* fuse, fuse_t* exp_out_fuse)
|
||||
{
|
||||
printf("State:%d Timer:%d Count:%d \n", fuse->state, fuse->timer, fuse->count);
|
||||
|
||||
fuse_reset(fuse);
|
||||
|
||||
printf(" Output: State:%d Timer:%d Count:%d \n", fuse->state, fuse->timer, fuse->count);
|
||||
printf("Expected: State:%d Timer:%d Count:%d \n", exp_out_fuse->state, exp_out_fuse->timer, exp_out_fuse->count);
|
||||
|
||||
if((fuse->state==exp_out_fuse->state)&&(fuse->timer==exp_out_fuse->timer)&&(fuse->count==exp_out_fuse->count))
|
||||
{
|
||||
printf("PASS\n\n");
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAIL\n\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ut_fuse_reset_test(void)
|
||||
{
|
||||
printf("******************************************************\n");
|
||||
printf("void fuse_reset(fuse_t* fuse)\n");
|
||||
|
||||
int test_res;
|
||||
int pass = 1;
|
||||
|
||||
fuse_t fuse;
|
||||
|
||||
fuse_t exp_out_fuse;
|
||||
|
||||
// No change test
|
||||
fuse.state = FUSE_OFF;
|
||||
fuse.timer = 0;
|
||||
fuse.count = 0;
|
||||
exp_out_fuse.state = FUSE_OFF;
|
||||
exp_out_fuse.timer = 0;
|
||||
exp_out_fuse.count = 0;
|
||||
test_res = ut_fuse_reset(&fuse, &exp_out_fuse);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// No change test
|
||||
fuse.state = FUSE_ACTIVE;
|
||||
fuse.timer = 1254;
|
||||
fuse.count = 124;
|
||||
exp_out_fuse.state = FUSE_OFF;
|
||||
exp_out_fuse.timer = 0;
|
||||
exp_out_fuse.count = 0;
|
||||
test_res = ut_fuse_reset(&fuse, &exp_out_fuse);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// No change test
|
||||
fuse.state = FUSE_COOLDOWN;
|
||||
fuse.timer = 4578;
|
||||
fuse.count = 14;
|
||||
exp_out_fuse.state = FUSE_OFF;
|
||||
exp_out_fuse.timer = 0;
|
||||
exp_out_fuse.count = 0;
|
||||
test_res = ut_fuse_reset(&fuse, &exp_out_fuse);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
// No change test
|
||||
fuse.state = FUSE_RETRY;
|
||||
fuse.timer = 0;
|
||||
fuse.count = 0;
|
||||
exp_out_fuse.state = FUSE_OFF;
|
||||
exp_out_fuse.timer = 0;
|
||||
exp_out_fuse.count = 0;
|
||||
test_res = ut_fuse_reset(&fuse, &exp_out_fuse);
|
||||
if(!test_res) pass = 0;
|
||||
|
||||
return pass;
|
||||
}
|
||||
9
firmware/tests/ut_utils/ut_fuses.h
Normal file
9
firmware/tests/ut_utils/ut_fuses.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef UT_FUSES_H_
|
||||
#define UT_FUSES_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int ut_fuse_reset_test(void);
|
||||
|
||||
#endif /* UT_FUSES_H_ */
|
||||
1334
firmware/tests/ut_utils/ut_utils.c
Normal file
1334
firmware/tests/ut_utils/ut_utils.c
Normal file
File diff suppressed because it is too large
Load Diff
27
firmware/tests/ut_utils/ut_utils.h
Normal file
27
firmware/tests/ut_utils/ut_utils.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef UT_UTILS_H_
|
||||
#define UT_UTILS_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int ut_util_invert_8b_test(void);
|
||||
int ut_util_sat_add_8b_test(void);
|
||||
int ut_util_sat_subtract_8b_test(void);
|
||||
int ut_util_sat_util_sat_add_16b_test(void);
|
||||
int ut_util_sat_subtract_16b_test(void);
|
||||
|
||||
int ut_util_limit_u32b_to_u16b_test(void);
|
||||
int ut_util_limit_s32b_to_u16b_test(void);
|
||||
|
||||
int ut_util_convert_muldivoff_test(void);
|
||||
|
||||
int ut_util_sat_mul_kilo_test(void);
|
||||
int ut_util_sat_div_kilo_test(void);
|
||||
|
||||
int ut_util_sat_ratio_16b_test(void);
|
||||
int ut_util_percent_to_16b_test(void);
|
||||
|
||||
int ut_util_interpolate_1d_u16b_test(void);
|
||||
int ut_util_interpolate_2d_u16b_test(void);
|
||||
|
||||
#endif /* UT_UTILS_H_ */
|
||||
Reference in New Issue
Block a user