time_t rtc_read(void) { time_t currentCount; adi_rtc_GetCount(hDevice0, (uint32_t *)(¤tCount)); return(currentCount); }
ADI_RTC_RESULT rtc_UpdateAlarm (void) { ADI_RTC_RESULT eResult; uint32_t rtcCount; if(ADI_RTC_SUCCESS != (eResult = adi_rtc_GetCount(hDeviceRTC,&rtcCount))) { DEBUG_RESULT("\n Failed to open the device %04d",eResult,ADI_RTC_SUCCESS); return(eResult); } if(ADI_RTC_SUCCESS != (eResult = adi_rtc_SetAlarm(hDeviceRTC,rtcCount+RTC_ALARM_OFFSET))) { DEBUG_RESULT("\n Failed to open the device %04d",eResult,ADI_RTC_SUCCESS); return(eResult); } return(eResult); }
ADI_RTC_RESULT rtc_Init (void) { /* callbacks */ ADI_RTC_INT_TYPE nInterrupts = ADI_RTC_ALARM_INT; ADI_RTC_RESULT eResult; uint32_t nRtc1Count; do { eResult = adi_rtc_Open(RTC_DEVICE_NUM,aRtcDevMem0,ADI_RTC_MEMORY_SIZE,&hDeviceRTC); DEBUG_RESULT("\n Failed to open the device %04d",eResult,ADI_RTC_SUCCESS); eResult = adi_rtc_RegisterCallback(hDeviceRTC,rtc0Callback,hDeviceRTC); DEBUG_RESULT("\n Failed to open the device",eResult,ADI_RTC_SUCCESS); eResult = adi_rtc_SetTrim(hDeviceRTC,ADI_RTC_TRIM_INTERVAL,ADI_RTC_TRIM_VALUE,ADI_RTC_TRIM_DIRECTION); DEBUG_RESULT("Failed to set the trim value",eResult,ADI_RTC_SUCCESS); eResult = adi_rtc_EnableTrim(hDeviceRTC,true); DEBUG_RESULT("Failed to enable the trim",eResult,ADI_RTC_SUCCESS); eResult = adi_rtc_EnableAlarm(hDeviceRTC,true); DEBUG_RESULT("Failed to enable the alram ",eResult,ADI_RTC_SUCCESS); eResult = adi_rtc_EnableInterrupts(hDeviceRTC, nInterrupts,true); DEBUG_RESULT("Failed to enable the specified interrupts",eResult,ADI_RTC_SUCCESS); eResult = adi_rtc_GetCount(hDeviceRTC,&nRtc1Count); DEBUG_RESULT("\n Failed to open the device",eResult,ADI_RTC_SUCCESS); eResult = adi_rtc_SetAlarm(hDeviceRTC,RTC_ALARM_OFFSET + nRtc1Count); DEBUG_RESULT("\n Failed to open the device",eResult,ADI_RTC_SUCCESS); // eResult = adi_rtc_SetPreScale(hDeviceRTC,preScale); //change eResult = adi_rtc_Enable(hDeviceRTC,true); DEBUG_RESULT("Failed to enable the device",eResult,ADI_RTC_SUCCESS); }while(0); return(eResult); }
ADI_RTC_RESULT rtc_UpdateAlarm (void) { ADI_RTC_RESULT eResult; uint32_t rtcCount; /* Get current RTC count value*/ if(ADI_RTC_SUCCESS != (eResult = adi_rtc_GetCount(hDeviceRTC,&rtcCount))) { DEBUG_RESULT("\n Failed to open the device %04d",eResult,ADI_RTC_SUCCESS); return(eResult); } /*Set RTC alarm at RTC_ALARM_OFFSET counts from the present RTC count value */ if(ADI_RTC_SUCCESS != (eResult = adi_rtc_SetAlarm(hDeviceRTC,rtcCount+RTC_ALARM_OFFSET))) { DEBUG_RESULT("\n Failed to open the device %04d",eResult,ADI_RTC_SUCCESS); return(eResult); } return(eResult); }