unsigned int mdrv_rtc_get_value(void) { u32 value = 0; s32 ret = 0; if (g_rtc_ctrl.mapped == 0) { struct device_node *np; np = of_find_compatible_node(NULL, NULL, CONFIG_RTC_COMPATIBLE); if (!np) { rtc_log("of_find_compatible_node"); return 0; } ret = get_rtc_addr(np, 0, "offset", &(g_rtc_ctrl.rtc_base_addr)); if (ret) { rtc_log("get_rtc_addr"); return 0; } g_rtc_ctrl.mapped = 1; } value = get_rtc_curr(g_rtc_ctrl.rtc_base_addr); return value; }
int mdrv_rtc_read_time(struct rtc_time *tm) { u32 value = mdrv_rtc_get_value(); if(NULL == tm) { rtc_log("the parameter error, tm == NULL!\n"); return MDRV_ERROR; } rtc_time_to_tm(value, tm); return MDRV_OK; }
/** * This function will return the value of time read from the on board CPU real time clock. Time value must be given in the format of * the structure wiced_rtc_time_t * * @return WICED_SUCCESS : on success. * @return WICED_ERROR : if an error occurred with any step */ OSStatus platform_rtc_get_time( platform_rtc_time_t* time) { #ifdef MICO_ENABLE_MCU_RTC bool valid = false; if( time == 0 ) { return kParamErr; } /* get current rtc time */ convert_units_passed_to_rtc_calendar_values( Chip_RTC_GetCount(LPC_RTC), time ); MICO_VERIFY_TIME(time, valid); if( valid == false ) { return kParamErr; } #if 0 rtc_log(" return convert_units_passed_to_rtc_calendar_values address = 0x%x ", temp_time); rtc_log(" sec = %d ", temp_time->sec); rtc_log(" min = %d ", temp_time->min); rtc_log(" hr = %d ", temp_time->hr); rtc_log(" weekday = %d ", temp_time->weekday); rtc_log(" date = %d ", temp_time->date); rtc_log(" month = %d ", temp_time->month); rtc_log(" year = %d ", temp_time->year); #endif return kNoErr; #else /* #ifdef WICED_ENABLE_MCU_RTC */ UNUSED_PARAMETER(time); return kUnsupportedErr; #endif /* #ifdef MICO_ENABLE_MCU_RTC */ }