/**
 * 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);
}
Пример #2
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;
    }
}
Пример #3
0
s32 readtime_test(void)
{
	struct rtc_time	tm = {0};/*lint !e133 !e43*/
	balong_rtc_readtime( NULL, &tm);
    rtc_dbg("%4d-%02d-%02d %02d:%02d:%02d\n",
        tm.tm_year, tm.tm_mon, tm.tm_mday,
        tm.tm_hour, tm.tm_min, tm.tm_sec);
    return RTC_TEST_OK;
}
/**
 * balong_rtc_alarmhandler-the rtc irq handler function
 */
s32  balong_rtc_alarmhandler(int irq, void *data)
{
	u32 int_status = 0;
    u32 events = 0;
	struct rtc_device *rtc = (struct rtc_device *)data;


	int_status = readl(g_rtc_ctrl.rtc_base_addr + HI_RTC_STAT_OFFSET);
    /*清中断*/
    readl(g_rtc_ctrl.rtc_base_addr + HI_RTC_EOI_OFFSET);

	if (!int_status)
    {
		return IRQ_NONE;
	}
	events = RTC_IRQF | RTC_AF;
	rtc_update_irq(rtc, 1, events);
    rtc_dbg("=========alram is handled==========\r\n");
	return IRQ_HANDLED;
}