Ejemplo n.º 1
0
s32 settime_test_case1(void)
{
	struct rtc_time tm = {0};
	struct rtc_time current_tm = {0};
    s32 ret = 0;
	tm.tm_year = 98;
	tm.tm_mon = 0;
	tm.tm_mday = 1;
	tm.tm_hour = 13;
	tm.tm_min = 1;
	tm.tm_sec = 25;

    balong_rtc_settime(NULL, &tm );
#ifdef CONFIG_BALONG_RTC
        taskDelay(200);
#else
        taskDelay(2);
#endif
	balong_rtc_readtime( NULL, &current_tm);
    ret = compare_rtctime(tm, current_tm);
    if(ret == 0)
    {
        return RTC_TEST_OK;
    }
    else
    {
        rtc_dbg("ccore settme : %4d-%02d-%02d %02d:%02d:%02d",
                RTC_BASE_YEAR + current_tm.tm_year, current_tm.tm_mon, current_tm.tm_mday,
                current_tm.tm_hour, current_tm.tm_min, current_tm.tm_sec);
        return RTC_TEST_ERROR;
    }
}
/**
 * balong_rtc_cb_settime-the icc callback function when ccore set the time through icc
 * @channel_id:	the icc channel id.
 * @len:		the type of the container struct this is embedded in.
 * @context:	the parameter pass from the register
 *
 */
static s32 balong_rtc_cb_settime(u32 channel_id , u32 len, void* context)
{
	s32 ret = 0;
	struct rtc_time tm = {0};
    rtc_dbg("balong_rtc_cb_settime is actived\r\n");
	ret = bsp_icc_read(channel_id, (u8*)&tm, len);
    rtc_dbg("%4d-%02d-%02d %02d:%02d:%02d\n",
            RTC_BASE_YEAR + tm.tm_year, tm.tm_mon, tm.tm_mday,
            tm.tm_hour, tm.tm_min, tm.tm_sec);
	if(len != (u32)ret)
	{
		rtc_print_error("balong_rtc_cb_settime error \r\n");
		return BSP_ERROR;
	}
	return balong_rtc_settime(NULL, &tm);
}