📄 rtc_test_misc.c
字号:
/********************************************************************************/
/* */
/* File Name: rtc_test_misc.c */
/* */
/* Purpose: This file gathers miscellaneous tests fot RTC. */
/* */
/* Notes: None. */
/* */
/* Revision History: */
/* 03/20/01 Laurent Sollier Create. */
/* Revision History: */
/* 06/30/03 Thierry VEDEL Modifie. */
/* 09/12/03 Sylvain MURATON cleanup */
/* 09/18/03 Sylvain MURATON cleanup */
/* */
/* (C) Copyright 2000 by Texas Instruments Incorporated, All Rights Reserved */
/* */
/********************************************************************************/
/********************************************************************************/
/* */
/* Include files used for RTC testing. */
/* */
/********************************************************************************/
#include "tests/rv/rv_test_filter.h"
#if (RTC_MISC == SW_COMPILED)
#include "kpd/kpd_api.h"
#include "tests/rv/rv_test_misc.h"
#include "r2d/lcd_messages_ti.h"
#include "r2d/lcd_messages.h"
#include "rtc/rtc_api.h"
#include "tests/grd/grd_api.h"
#include "tests/rtest/rtest_api.h"
#include "rtc/tests/rtc_test_msg.h"
#include <stdio.h>
#ifndef _WINDOWS
#include "chipset.cfg"
#if (CHIPSET == 12)
#include "inth/sys_inth.h"
#endif
#include "ulpd/ulpd.h"
#include "memif/mem.h"
#include "inth/inth.h"
#include "inth/iq.h"
#endif
extern void key_event(void* msg_p);
T_RV_TEST_RET rtc_test_verdict;
T_result_info s_resultInfo;
UINT8 uc_Alarm = FALSE;
UINT8 uc_Exit = FALSE;
UINT8 uc_id_obtained[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
UINT8 uc_id_waited[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
T_RVF_RET ResultFunction;
T_RTC_DATE_TIME Memo_date_time;
/********************************************************************************/
/* */
/* Internal name: RTC MISC TEST 1 */
/* */
/* Description: */
/* */
/* Notes: */
/* */
/********************************************************************************/
/* list "Define" */
#define RESULT_ROUNDING30_S 0
#define MODE_24H 0
#define MODE_12H 1
#define MODE_ERROR 2
#define RTC_NB_ADD_HOUR_TEST 3
/********************************************************************************/
/* */
/* Notes: This function display "Alarm" */
/* */
/* Revision History: */
/* 03/20/01 Laurent Sollier Create. */
/* */
/********************************************************************************/
void alarm(void* param)
{
uc_Alarm = TRUE;
LCD_WriteString( 3, 0, "Alarm", NORMAL);
}
/********************************************************************************/
/* */
/* Notes: This function display "Alarm" */
/* */
/* Revision History: */
/* 03/20/01 Laurent Sollier Create. */
/* 06/26/03 Thierry VEDEL Modifie. */
/* */
/********************************************************************************/
void execute_test(void)
{
static UINT8 num_test = 0;
static BOOL test_to_execute = FALSE;
T_RTC_DATE_TIME date_time;
T_RV_RETURN return_path;
UINT8 time[15];
UINT8 date[15];
UINT8 ui_LcdMessage[15];
BOOL b_resultMsg=FALSE;
static UINT8 ui_CounterAdd = 1;
return_path.callback_func = alarm;
s_resultInfo.display_format=DIS_BYTE;
s_resultInfo.display_base=DIS_DEC;
switch (num_test)
{
case 0:
if (!test_to_execute)
{
/* Memory Date & Time */
RTC_GetDateTime(&Memo_date_time);
LCD_WriteString( 2, 0, "Round minute ", NORMAL);
}
else
{
uc_id_waited[0] = RESULT_ROUNDING30_S;
RTC_Rounding30s();
LCD_WriteString( 2, 0, " ", NORMAL);
rvf_delay(RVF_SECS_TO_TICKS(1));
sprintf((char*)s_resultInfo.test_ref,"%s",RTC_009_REF);
sprintf((char*)s_resultInfo.test_name,"%s",RTC_009_NAME);
sprintf((char*)s_resultInfo.test_comment,"%s",RTC_009_COMMENT);
gen_display_header (&s_resultInfo);
RTC_GetDateTime(&date_time);
uc_id_obtained[0] = date_time.second;
b_resultMsg = gen_display_table_result(&uc_id_waited[0], &uc_id_obtained[0], sizeof(uc_id_waited[0]),&s_resultInfo);
gen_display_report (b_resultMsg);
}
break;
case 1:
if (!test_to_execute)
LCD_WriteString( 2, 0, "Set 12 hour mode", NORMAL);
else
{
RTC_GetDateTime(&date_time);
if (RTC_Is12HourMode() == FALSE)
uc_id_waited[0] = MODE_12H;
else
uc_id_waited[0] = MODE_24H;
RTC_Set12HourMode(TRUE);
LCD_WriteString( 2, 0, " ", NORMAL);
sprintf((char*)s_resultInfo.test_ref,"%s",RTC_010_REF);
sprintf((char*)s_resultInfo.test_name,"%s",RTC_010_NAME);
sprintf((char*)s_resultInfo.test_comment,"%s",RTC_010_COMMENT);
gen_display_header (&s_resultInfo);
RTC_GetDateTime(&date_time);
if(RTC_Is12HourMode() == FALSE)
uc_id_obtained[0] = MODE_24H;
else
uc_id_obtained[0] = MODE_12H;
b_resultMsg = gen_display_table_result(&uc_id_waited[0], &uc_id_obtained[0], sizeof(uc_id_waited[0]),&s_resultInfo);
gen_display_report (b_resultMsg);
}
break;
case 2:
if (!test_to_execute)
LCD_WriteString( 2, 0, "Set 24 hour mode", NORMAL);
else
{
RTC_Set12HourMode(FALSE);
LCD_WriteString( 2, 0, " ", NORMAL);
}
break;
case 3:
if (!test_to_execute)
LCD_WriteString( 2, 0, "Add one hour", NORMAL);
else
{
uc_id_waited[0]=RVF_OK;
if (ResultFunction=RTC_GetDateTime(&date_time) == RVF_NOT_READY)
{
rvf_delay(RVF_MS_TO_TICKS(1));
ResultFunction=RTC_GetDateTime(&date_time);
}
sprintf((char*)s_resultInfo.test_ref,"%s",RTC_002_REF);
sprintf((char*)s_resultInfo.test_name,"%s",RTC_002_NAME);
sprintf((char*)s_resultInfo.test_comment,"%s",RTC_002_COMMENT);
gen_display_header (&s_resultInfo);
uc_id_obtained[0]=ResultFunction;
sprintf((char*)s_resultInfo.var_name,"%s",RTC_002_RESULT_FONCTION);
b_resultMsg = gen_display_table_result(&uc_id_waited[0], &uc_id_obtained[0], sizeof(uc_id_waited[0]),&s_resultInfo);
gen_display_report (b_resultMsg);
date_time.hour++;
uc_id_waited[0]=RVF_OK;
uc_id_waited[1]=date_time.hour;
if (RTC_SetDateTime(date_time) == RVF_NOT_READY)
{
rvf_delay(RVF_MS_TO_TICKS(1));
ResultFunction=RTC_SetDateTime(date_time);
if(ResultFunction==RVF_INTERNAL_ERR)
{
LCD_WriteString( 2, 0, "SetDateTime FAILED INT", NORMAL);
rtc_test_verdict=TEST_FAILED;
return;
}
else
if(ResultFunction==RVF_INVALID_PARAMETER)
{
LCD_WriteString( 2, 0, "SetDateTime FAILED PAR", NORMAL);
rtc_test_verdict=TEST_FAILED;
return;
}
else
LCD_WriteString( 3, 0, "SetDateTime PASSED", NORMAL);
}
uc_id_obtained[0] = ResultFunction;
RTC_GetDateTime(&date_time);
uc_id_obtained[1]=date_time.hour;
LCD_WriteString( 2, 0, " ", NORMAL);
}
break;
case 4:
if (!test_to_execute)
{
LCD_WriteString( 3, 0, " ", NORMAL);
LCD_WriteString( 2, 0, "Remove one hour", NORMAL);
}
else
{
if (RTC_GetDateTime(&date_time) == RVF_NOT_READY)
{
rvf_delay(RVF_MS_TO_TICKS(1));
RTC_GetDateTime(&date_time);
}
date_time.hour--;
uc_id_waited[2]=date_time.hour;
if (RTC_SetDateTime(date_time) == RVF_NOT_READY)
{
rvf_delay(RVF_MS_TO_TICKS(1));
RTC_SetDateTime(date_time);
}
LCD_WriteString( 2, 0, " ", NORMAL);
sprintf((char*)s_resultInfo.test_ref,"%s",RTC_003_REF);
sprintf((char*)s_resultInfo.test_name,"%s",RTC_003_NAME);
sprintf((char*)s_resultInfo.test_comment,"%s",RTC_003_COMMENT);
gen_display_header (&s_resultInfo);
RTC_GetDateTime(&date_time);
uc_id_obtained[2]=date_time.hour;
sprintf((char*)s_resultInfo.var_name,"%s",RTC_003_RESULT_FONCTION);
b_resultMsg = gen_display_table_result(&uc_id_waited[0], &uc_id_obtained[0], sizeof(uc_id_waited[0]),&s_resultInfo);
sprintf((char*)s_resultInfo.var_name,"%s",RTC_003_ADD_HOUR);
b_resultMsg = gen_display_table_result(&uc_id_waited[1], &uc_id_obtained[1], sizeof(uc_id_waited[1]),&s_resultInfo);
sprintf((char*)s_resultInfo.var_name,"%s",RTC_003_REMOVE_HOUR);
b_resultMsg = gen_display_table_result(&uc_id_waited[2], &uc_id_obtained[2], sizeof(uc_id_waited[2]),&s_resultInfo);
gen_display_report (b_resultMsg);
}
break;
case 5: // Test RTC_SetAlarm
if (!test_to_execute)
{
LCD_WriteString( 3, 0, " ", NORMAL);
LCD_WriteString( 2, 0, "Set alarm 3 s ", NORMAL);
if (RTC_GetDateTime(&date_time) == RVF_NOT_READY)
{
rvf_delay(RVF_MS_TO_TICKS(1));
RTC_GetDateTime(&date_time);
}
date_time.second += 3;
if (date_time.second > 59 )
{
date_time.second -= 60;
date_time.minute++;
}
uc_id_waited[0]=RVF_OK;
uc_id_waited[1]=TRUE;
if (RTC_SetAlarm(date_time, return_path) == RVF_NOT_READY)
{
rvf_delay(RVF_MS_TO_TICKS(1));
ResultFunction=RTC_SetAlarm(date_time,return_path);
if (ResultFunction == RVF_NOT_READY)
{
LCD_WriteString( 2, 0, "SetAlarm WAIT", NORMAL);
rvf_delay(RVF_MS_TO_TICKS(1));
ResultFunction=RTC_SetAlarm(date_time,return_path);
if(ResultFunction==RVF_OK)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -