Functions
RTC Functions
RTC

Functions

void RTC_reset (void)
void RTC_start (void)
void RTC_stop (void)
CSL_Status RTC_config (CSL_RtcConfig *pConfig)
CSL_Status RTC_getConfig (CSL_RtcConfig *pGetConfig)
CSL_Status RTC_setTime (CSL_RtcTime *pRtcTime)
CSL_Status RTC_getTime (CSL_RtcTime *pGetRtcTime)
CSL_Status RTC_setDate (CSL_RtcDate *pRtcDate)
CSL_Status RTC_getDate (CSL_RtcDate *pGetRtcDate)
CSL_Status RTC_setAlarm (CSL_RtcAlarm *pRtcAlarm)
CSL_Status RTC_setPeriodicInterval (CSL_RTCPeriodicInterruptType periodicInterruptType)
CSL_Status RTC_eventEnable (CSL_RTCEventType rtcEvent)
CSL_Status RTC_eventDisable (CSL_RTCEventType rtcEvent)
CSL_RTCEventType RTC_getEventId (void)
Uint16 RTC_decToBcd (Uint16 decVal)
Uint16 RTC_bcdToDec (Uint16 hexVal)
CSL_Status RTC_setCallback (CSL_RtcIsrDispatchTable *rtcDispatchTable, CSL_RtcIsrAddr *isrAddr)
CSL_Status RTC_setCompensation (CSL_RTCCompType compType, Uint16 compVal)

Function Documentation

Uint16 RTC_bcdToDec ( Uint16  hexVal)

===========================================================================
RTC_bcdToDec

Description
This function will convert hex value to corresponding value for BCD compatible.

Arguments

            hexVal          rtc(time and Date Fields) register value.

     

Return Value Uint16

Pre Condition
NOne.

Post Condition
None

Modifies
None

Example


            Uint16   hexVal;
            Uint16   decVal;

    hexVal = 16;
            decVal = RTC_bcdToDec(rtcEvent);
    decVal = 10;
            ...
     

===========================================================================

References rtc_pow(), rtcDivFun(), and rtcModuloDivFun().

Referenced by RTC_getDate(), and RTC_getTime().

CSL_Status RTC_config ( CSL_RtcConfig pConfig)

===========================================================================
RTC_config

Description
It configures the RTC registers as per the RTC config structure.

Arguments

            pConfig          Pointer to RTC Config structure.

     

Return Value CSL_Status

  • CSL_SOK
  • CSL_ESYS_INVPARAMS - Congig Parameter is invalid.

Pre Condition
NOne.

Post Condition
None

Modifies
1. RTC registers will be updated as per config parameter

Example


            CSL_RtcConfig       pConfig;
            CSL_status           status;

	pConfig.rtcyear  = 8;
	pConfig.rtcmonth = 8;
	pConfig.rtcday   = 8;
	pConfig.rtchour  = 8;
	pConfig.rtcmin   = 8;
	pConfig.rtcsec   = 8;
	pConfig.rtcmSec  = 8;

	pConfig.rtcyeara  = 8;
	pConfig.rtcmontha = 8;
	pConfig.rtcdaya   = 8;
	pConfig.rtchoura  = 8;
	pConfig.rtcmina   = 8;
	pConfig.rtcseca   = 8;
	pConfig.rtcmSeca  = 10;

	pConfig.rtcintcr  = 0x803F;

            status = RTC_config(&pConfig);
            ...
     

===========================================================================

References CSL_RTC_BIT_RESET, CSL_RTC_WAIT_CYCLE, CSL_RtcConfig::rtcday, CSL_RtcConfig::rtcdaya, CSL_RtcConfig::rtchour, CSL_RtcConfig::rtchoura, CSL_RtcConfig::rtcintcr, CSL_RtcConfig::rtcmin, CSL_RtcConfig::rtcmina, CSL_RtcConfig::rtcmonth, CSL_RtcConfig::rtcmontha, CSL_RtcConfig::rtcmSec, CSL_RtcConfig::rtcmSeca, CSL_RtcConfig::rtcsec, CSL_RtcConfig::rtcseca, CSL_RtcConfig::rtcyear, and CSL_RtcConfig::rtcyeara.

Uint16 RTC_decToBcd ( Uint16  decVal)

===========================================================================
RTC_decToBcd

Description
This function will convert decimal value to corresponding value for BCD compatible.

Arguments

            decVal         value(RTC time and Date Fields) passed by user.

     

Return Value Uint16

Pre Condition
NOne.

Post Condition
None

Modifies
None

Example


            Uint16   decVal;
            Uint16   bcdVal;
    decVal = 10;
            bcdVal = RTC_decToBcd(rtcEvent);
    bcdVal = 16;
            ...
     

===========================================================================

References rtc_pow(), rtcDivFun(), and rtcModuloDivFun().

Referenced by RTC_setAlarm(), RTC_setCompensation(), RTC_setDate(), and RTC_setTime().

CSL_Status RTC_eventDisable ( CSL_RTCEventType  rtcEvent)

===========================================================================
RTC_eventDisable

Description
It disable the RTC Interrupt as per passed event paraeter.

Arguments

            rtcEvent          rtc event type.

     

Return Value CSL_Status

  • CSL_SOK
  • CSL_ESYS_INVPARAMS - Parameter is invalid.

Pre Condition
NOne.

Post Condition
None

Modifies
None

Example


            CSL_RTCEventType   rtcEvent;
            CSL_status         status;

	 rtcEvent = CSL_RTC_EXTEVENT_INTERRUPT;

            status = RTC_eventDisable(rtcEvent);
            ...
     

===========================================================================

References CSL_RTC_WAIT_CYCLE.

CSL_Status RTC_eventEnable ( CSL_RTCEventType  rtcEvent)

===========================================================================
RTC_eventEnable

Description
It enable the RTC Interrupt as per passed event paraeter.

Arguments

            rtcEvent          rtc event type.

     

Return Value CSL_Status

  • CSL_SOK
  • CSL_ESYS_INVPARAMS - Parameter is invalid.

Pre Condition
None.

Post Condition
None

Modifies
None

Example


            CSL_RTCEventType   rtcEvent;
            CSL_status         status;

 	rtcEvent = CSL_RTC_EXTEVENT_INTERRUPT;

            status = RTC_eventEnable(rtcEvent);
            ...
     

===========================================================================

References CSL_RTC_WAIT_CYCLE.

CSL_Status RTC_getConfig ( CSL_RtcConfig pGetConfig)

===========================================================================
RTC_getConfig

Description
It get the RTC registers value.

Arguments

            pGetConfig      Pointer to RTC Config structure.

     

Return Value CSL_Status

  • CSL_SOK
  • CSL_ESYS_INVPARAMS - Congig Parameter is invalid.

Pre Condition
None.

Post Condition
None

Modifies
1. RTC Config structure will be updated with RTC Registers field.

Example


            CSL_RtcConfig       pGetConfig;
            CSL_status           status;

            status = RTC_getConfig(&pGetConfig);
            ...
     

===========================================================================

References CSL_RtcConfig::rtcday, CSL_RtcConfig::rtcdaya, CSL_RtcConfig::rtchour, CSL_RtcConfig::rtchoura, CSL_RtcConfig::rtcintcr, CSL_RtcConfig::rtcmin, CSL_RtcConfig::rtcmina, CSL_RtcConfig::rtcmonth, CSL_RtcConfig::rtcmontha, CSL_RtcConfig::rtcmSec, CSL_RtcConfig::rtcmSeca, CSL_RtcConfig::rtcsec, CSL_RtcConfig::rtcseca, CSL_RtcConfig::rtcyear, and CSL_RtcConfig::rtcyeara.

CSL_Status RTC_getDate ( CSL_RtcDate pGetRtcDate)

===========================================================================
RTC_getDate

Description
It get the RTC registers value related to Date Field.

Arguments

            pGetRtcDate      Pointer to RTC Date structure.

     

Return Value CSL_Status

  • CSL_SOK
  • CSL_ESYS_INVPARAMS - Parameter is invalid.

Pre Condition
NOne.

Post Condition
None

Modifies
1.Passed Parameter will be updated with RTC Date related Registers value.

Example


            CSL_RtcDate       pGetRtcDate;
            CSL_status         status;

            status = RTC_getDate(&pGetRtcDate);
            ...
     

===========================================================================

References CSL_RtcDate::day, CSL_RtcDate::month, RTC_bcdToDec(), and CSL_RtcDate::year.

CSL_RTCEventType RTC_getEventId ( void  )

===========================================================================
RTC_getEventId

Description
Function return the events of RTC(Status of RTC Event).

Arguments

     

Return Value CSL_RTCEventType

Pre Condition
None

Post Condition
None

Modifies
None

Example


            CSL_RTCEventType   eventId;

            eventId = RTC_getEventId();

     

===========================================================================

CSL_Status RTC_getTime ( CSL_RtcTime pGetRtcTime)

===========================================================================
RTC_getTime

Description
It get the RTC registers value related to Time Field.

Arguments

            pGetRtcTime      Pointer to RTC Time structure.

     

Return Value CSL_Status

  • CSL_SOK
  • CSL_ESYS_INVPARAMS - Congig Parameter is invalid.

Pre Condition
NOne.

Post Condition
None

Modifies
1.Passed Parameter will be updated with RTC Time related Registers value.

Example


            CSL_RtcTime       pGetRtcTime;
            CSL_status         status;

            status = RTC_getTime(&pGetRtcTime);
            ...
     

===========================================================================

References CSL_RtcTime::hours, CSL_RtcTime::mins, CSL_RtcTime::mSecs, RTC_bcdToDec(), and CSL_RtcTime::secs.

void RTC_reset ( void  )

===========================================================================
RTC_reset

Description
Function reset all the register of RTC.

Arguments

     

Return Value
None

Pre Condition
None

Post Condition
None

Modifies
RTC Register will be populated with the reset values.

Example


             RTC_reset();
     

===========================================================================

CSL_Status RTC_setAlarm ( CSL_RtcAlarm pRtcAlarm)

===========================================================================
RTC_setAlarm

Description
It configures the RTC Alarm registers as per passed Alarm Parameter.

Arguments

            pRtcAlarm          Pointer to RTC Alarm Time structure.

     

Return Value CSL_Status

  • CSL_SOK
  • CSL_ESYS_INVPARAMS - Parameter is invalid.

Pre Condition
NOne.

Post Condition
None

Modifies
1. RTC Alarm Related registers will be updated as per passed parameter.

Example


            CSL_RtcAlarm  pRtcAlarm;
            CSL_status         status;

    pRtcAlarm.year = 8;
    pRtcAlarm.month = 10;
    pRtcAlarm.day = 16;
    pRtcAlarm.hours = 12;
    pRtcAlarm.mins = 1;
    pRtcAlarm.secs = 5;
    pRtcAlarm.mSecs =0;

            status = RTC_setAlarm(&pRtcAlarm);
            ...
     

===========================================================================

References CSL_RTC_BIT_RESET, CSL_RTC_WAIT_CYCLE, and RTC_decToBcd().

CSL_Status RTC_setCallback ( CSL_RtcIsrDispatchTable rtcDispatchTable,
CSL_RtcIsrAddr isrAddr 
)

============================================================================
RTC_setCallback

Description
RTC_setCallback will set call back functions in isrDispatchTable.

Arguments

 		rtcDispatchTable - pointer to the 	CSL_RtcIsrDispatchTable.
 		isrAddr          - pointer to the 	RTC_IsrAddr.
      

Return Value CSL_Status

  • CSL_SOK - RTC_setCallback call is successful.
  • CSL_ESYS_INVPARAMS - bad parameter. Pre Condition
    Post Condition
    Setup call back functions in the RTC_setCallback

Modifies
rtcDispatchTable

Example

 	     CSL_Status     	    status;
         RTC_IsrAddr 			isrAddr;
	     CSL_RtcIsrDispatchTable rtcDispatchTable

        status =   RTC_setCallback(&rtcDispatchTable, &isrAddr);

     

============================================================================

References CSL_RtcIsrAddr::AlarmEvtAddr, CSL_RtcIsrAddr::DayEvtAddr, CSL_RtcIsrAddr::ExtEvtAddr, CSL_RtcIsrAddr::HourEvtAddr, CSL_RtcIsrDispatchTable::isr, CSL_RtcIsrAddr::MilEvtAddr, CSL_RtcIsrAddr::MinEvtAddr, and CSL_RtcIsrAddr::SecEvtAddr.

CSL_Status RTC_setCompensation ( CSL_RTCCompType  compType,
Uint16  compVal 
)

============================================================================
RTC_setCompensation

Description
RTC_setCompensation will set RTC oscillator drift compensation register The RTC can compensate for oscillator drift due to temperature by adding or subtracting the value of the compensation registers (in milliseconds) to the 32KHz counter every hour. Compensation values range from 0 to 1024. Compenastion values passed to the RTC_setCompensation function are converted into BCD form before writing to the register. Zero compensation value is also allowed so that same API is used to remove the compensation

NOTE: RTC clock positive compensation doesn't work for compensation values that are multiples of 10 on the chip C5505 and C5504. This API returns error for such values. This issue is not present on chip C5515 and C5514.

Arguments

 		compType     - Type of the RTC compenstation
 		compVal      - Value of the compensation
      

Return Value CSL_Status

  • CSL_SOK - RTC compensation set is succesful
  • CSL_ESYS_INVPARAMS - bad parameter.

Pre Condition
RTC should be configured and started Post Condition
Sets the RTC compensation value

Modifies
RTC Oscillator Drift Compensation Register

Example

 	     CSL_Status    status;
		 Uint16        compVal;

		 compVal = 35;

        status = RTC_setCompensation(CSL_RTC_COMPENSATION_POSITIVE, compVal);

     

============================================================================

References CSL_RTC_COMPENSATION_MAX, and RTC_decToBcd().

CSL_Status RTC_setDate ( CSL_RtcDate pRtcDate)

===========================================================================
RTC_setDate

Description
It configures the RTC registers related to date field as per passed Time structure.

Arguments

            pRtcDate          Pointer to RTC Time structure.

     

Return Value CSL_Status

  • CSL_SOK
  • CSL_ESYS_INVPARAMS - Parameter is invalid.

Pre Condition
NOne.

Post Condition
None

Modifies
1. RTC Date Related registers will be updated as per passed parameter.

Example


            CSL_RtcDate       pRtcDate;
            CSL_status         status;

    pRtcDate.year = 8;
    pRtcDate.month = 10;
    pRtcDate.day = 16;

            status = RTC_setDate(&pRtcDate);
            ...
     

===========================================================================

References CSL_RTC_BIT_RESET, CSL_RTC_WAIT_CYCLE, and RTC_decToBcd().

CSL_Status RTC_setPeriodicInterval ( CSL_RTCPeriodicInterruptType  periodicInterruptType)

===========================================================================
RTC_setPeriodicInterval

Description
It configures the periodic interrrupt for RTC.

Arguments

            periodicInterruptType     Type of periodic interrupt.

     

Return Value CSL_Status

  • CSL_SOK
  • CSL_ESYS_INVPARAMS - Parameter is invalid.

Pre Condition
NOne.

Post Condition
None

Modifies
None

Example


            periodicInterruptType   periodicInterruptType;
            CSL_status              status;

 	periodicInterruptType = CSL_RTC_SEC_PERIODIC_INTERRUPT;

            status = RTC_setPeriodicInterval(periodicInterruptType);
            ...
     

===========================================================================

References CSL_RTC_WAIT_CYCLE.

CSL_Status RTC_setTime ( CSL_RtcTime pRtcTime)

===========================================================================
RTC_setTime

Description
It configures the RTC registers related to time field as per passed Time structure.

Arguments

            pRtcTime          Pointer to RTC Time structure.

     

Return Value CSL_Status

  • CSL_SOK
  • CSL_ESYS_INVPARAMS - Parameter is invalid.

Pre Condition
NOne.

Post Condition
None

Modifies
1. RTC Time Related registers will be updated as per passed parameter.

Example


            CSL_RtcTime       pRtcTime;
            CSL_status         status;

    pRtcTime.hours = 12;
    pRtcTime.mins = 0;
    pRtcTime.secs = 0;
    pRtcTime.mSecs =0;

            status = RTC_setTime(&pRtcTime);
            ...
     

===========================================================================

References CSL_RTC_BIT_RESET, CSL_RTC_WAIT_CYCLE, and RTC_decToBcd().

void RTC_start ( void  )

===========================================================================
RTC_start

Description
Function enable the RTC interrupts.

Arguments

     

Return Value
None

Pre Condition
None

Post Condition
None

Modifies
NOne

Example


             RTC_start();
     

===========================================================================

References CSL_RTC_STATUS_MASK.

void RTC_stop ( void  )

===========================================================================
RTC_stop

Description
Function disable the RTC interrupts.

Arguments

     

Return Value
None

Pre Condition
None

Post Condition
None

Modifies
None

Example


             RTC_stop();
     

===========================================================================