Platform/ECM3532/M3/hw/csp/ecm3532/m3/csp/src/eta_csp_rtc.c
/***************************************************************************/
/**
 *
 *  EtaCspRtcWdtInit - Initialize the Watchdog Timer
 *
 *  @param iWdtOperation - The desired WDT operation mode, Interrupt or POR
 *                         or RESET or any combinations.
 *  @param ui32TiggerLevel The desired interrupt compare count.
 *  @param ui32Reload - The desired starting count down value.
 *  @return  Return the success status.
 *
 *  @Note If POR is enabled, POR is issued when ui32Reload value counts down to 0.
 *        If Interrupt is enabled, interrupt is set when ui32Reload counts down
 *        to ui32TriggerLevel.
 ******************************************************************************/
Initialize the Watchdog Timer
@param iWdtOperation - The desired WDT operation mode, Interrupt or POR
or RESET or any combinations.
@param ui32TiggerLevel The desired interrupt compare count.
@param ui32Reload - The desired starting count down value.
@return  Return the success status.

@Note If POR is enabled, POR is issued when ui32Reload value counts down to 0.
If Interrupt is enabled, interrupt is set when ui32Reload counts down
to ui32TriggerLevel.
Initialize the Watchdog Timer @param iWdtOperation - The desired WDT operation mode Interrupt or POR or RESET or any combinations . @param ui32TiggerLevel The desired interrupt compare count . @param ui32Reload - The desired starting count down value . @return Return the success status . @Note If POR is enabled POR is issued when ui32Reload value counts down to 0 . If Interrupt is enabled interrupt is set when ui32Reload counts down to ui32TriggerLevel .
tEtaStatus
EtaCspRtcWdtInit(tRtcWdtOp iWdtOperation,
                 uint32_t ui32TriggerLevel,
                 uint32_t ui32Reload)
{
     validate the operating modes requested.
    if(iWdtOperation & ~(eWdtPor | eWdtInterrupt | eWdtReset))
    {
        return(eEtaFailure);
    }
     You have to ask for at least one
    if(!iWdtOperation)
    {
        return(eEtaFailure);
    }
     Check trigger range.
    if(ui32TriggerLevel > ((1<<20)-1))
    {
        return(eEtaFailure);
    }
     Check reload range.
    if(ui32Reload > ((1<<20)-1))
    {
        return(eEtaFailure);
    }
     Set the trigger level
    REG_RTC_WDT_ALARM.BF.VALUE = ui32TriggerLevel;
     Set the Reload Count
    REG_RTC_WDT_RELOAD.BF.VALUE = ui32Reload;
     Are we setting up for POR when the WDT expires?
    if(iWdtOperation & eWdtPor)
    {
        REG_S1(RTC_WDT_ALARM, POR);
    }
    else
    {
        REG_C1(RTC_WDT_ALARM, POR);
    }
     Are we setting up for RESET when the WDT expires?
    if(iWdtOperation & eWdtReset)
    {
        REG_S1(RTC_WDT_ALARM, RESET);
    }
    else
    {
        REG_C1(RTC_WDT_ALARM, RESET);
    }
     Are we setting up for simple interrupt generation?
    if(iWdtOperation & eWdtInterrupt)
    {
        REG_S1(RTC_WDT_ALARM, IRQ_EN);
    }
    else
    {
        REG_C1(RTC_WDT_ALARM, IRQ_EN);
    }
     OK, load the counter.
    REG_RTC_WDT_COUNTER.V = 0x00000000;
    return(eEtaSuccess);
}
tEtaStatus EtaCspRtcWdtInit ( tRtcWdtOp iWdtOperation , uint32_t ui32TriggerLevel , uint32_t ui32Reload ) { if ( iWdtOperation & ~ ( eWdtPor | eWdtInterrupt | eWdtReset ) ) { return ( eEtaFailure ) ; } if ( ! iWdtOperation ) { return ( eEtaFailure ) ; } if ( ui32TriggerLevel > ( ( 1 << 20 ) - 1 ) ) { return ( eEtaFailure ) ; } if ( ui32Reload > ( ( 1 << 20 ) - 1 ) ) { return ( eEtaFailure ) ; } REG_RTC_WDT_ALARM . BF . VALUE = ui32TriggerLevel ; REG_RTC_WDT_RELOAD . BF . VALUE = ui32Reload ; if ( iWdtOperation & eWdtPor ) { REG_S1 ( RTC_WDT_ALARM , POR ) ; } else { REG_C1 ( RTC_WDT_ALARM , POR ) ; } if ( iWdtOperation & eWdtReset ) { REG_S1 ( RTC_WDT_ALARM , RESET ) ; } else { REG_C1 ( RTC_WDT_ALARM , RESET ) ; } if ( iWdtOperation & eWdtInterrupt ) { REG_S1 ( RTC_WDT_ALARM , IRQ_EN ) ; } else { REG_C1 ( RTC_WDT_ALARM , IRQ_EN ) ; } REG_RTC_WDT_COUNTER . V = 0x00000000 ; return ( eEtaSuccess ) ; }
EtaCspRtcWdtInit - Initialize the Watchdog Timer
  @param iWdtOperation - The desired WDT operation mode, Interrupt or POR
                         or RESET or any combinations.
EtaCspRtcWdtInit - Initialize the Watchdog Timer @param iWdtOperation - The desired WDT operation mode Interrupt or POR or RESET or any combinations .
// // validate the operating modes requested. // // // You have to ask for at least one // // // Check trigger range. // // // Check reload range. // // // Set the trigger level // // // Set the Reload Count // // // Are we setting up for POR when the WDT expires? // // // Are we setting up for RESET when the WDT expires? // // // Are we setting up for simple interrupt generation? // // // OK, load the counter. //