Repo unification
This commit is contained in:
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;
|
||||
}
|
||||
Reference in New Issue
Block a user