Repo unification

This commit is contained in:
2024-03-12 21:22:26 +02:00
parent 7aa7edba33
commit 02cb3a9c70
152 changed files with 14575 additions and 2038 deletions

View 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;
}