192 lines
5.0 KiB
C
192 lines
5.0 KiB
C
#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;
|
|
}
|