Exemplo n.º 1
0
void rtc_init(void)
{
    /* initialize driver */
    adi_rtc_Open(RTC_DEVICE_NUM,aRtcDevMem0,ADI_RTC_MEMORY_SIZE,&hDevice0);

    adi_rtc_Enable(hDevice0, true);
}
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);
}