171 lines
4.2 KiB
C
171 lines
4.2 KiB
C
#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;
|
|
}
|