1.6.21.56 RTC_CALLBACK Typedef

C

typedef void (*RTC_CALLBACK)( RTC_CLOCK_EVENT event, uintptr_t context );

OR

typedef void (*RTC_CALLBACK)(uint32_t int_cause, uintptr_t context);

Summary

Defines the data type and function signature of the Real Time Clock Calendar callback function.

Description

This data type defines the function signature of the RTC Real Time Clock Calendar Callback function. The RTC peripheral will call back the client's function with this signature when the configured RTCC Alarm has occurred.

The application should register a callback function whose signature (input arguments and return type) must match the signature of this function. The callback function should be registered by calling the RTC_RTCCCallbackRegister() function. The callback function should be registered before setting the alarm.

Precondition

The RTC_Initialize() function should have been called to initialize the RTC peripheral. The RTC_RTCCCallbackRegister() function should have been called to register the callback function. The RTC peripheral should have been configured for RTCC operation in MHC. The RTC peripheral should have been configured for interrupt mode of operation in MHC.

Parameters

For prototype

typedef void (*RTC_CALLBACK)( RTC_CLOCK_EVENT event, uintptr_t context );
Param Description
event RTCC event that caused the callback function to be called. Multiple events could be active. Application should process all events in the callback function.
context Allows the caller to provide a context value (usually a pointer to the callers context for multi-instance clients)

For prototype

typedef void (*RTC_CALLBACK)(uint32_t int_cause, uintptr_t context);
Param Description
int_cause RTC interrupt cause
context Allows the caller to provide a context value (usually a pointer to the callers context for multi-instance clients)

Returns

None.

Example

void MyRTCCCallback ( RTC_CLOCK_EVENT event, uintptr_t context )
{
    if((event & RTC_CLOCK_EVENT_YEAR_OVERFLOW) ==
    RTC_CLOCK_EVENT_YEAR_OVERFLOW)
    {
        // This means a year overflow has occurred.
    }
    else if ((event & RTC_CLOCK_EVENT_ALARM) == RTC_CLOCK_EVENT_ALARM)
    {
        // This means an alarm has occurred.
    }
}

// Initialize the RTC Peripheral and register the callback function.
// Note how the pointer to the alarmOccurred flag is specified
// as the context. This is passed back into the callback function.
// Refer to the description of the RTC_RTCCTimeSet() and
// RTC_RTCCAlarmSet() function for API usage details.

RTC_Initialize();
RTC_RTCCTimeSet(&time);
RTC_RTCCAlarmSet(&alarm);
RTC_RTCCCallbackRegister(MyRTCCCallback, &alarmOccurred);

Remarks

The Real Time Clock Calendar feature is available when the RTC peripheral is configured for Real Time Clock Calendar mode. The callback function will be execute in an interrupt context. Avoid calling blocking functions , performing computationally intensive operations or interrupt un-safe functions from the callback function.