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