1.6.21.44 RTC_TIMER16_CALLBACK Typedef

C

typedef void (*RTC_TIMER16_CALLBACK)( RTC_TIMER16_INT_MASK interruptCause, uintptr_t context );

Summary

Defines the data type and function signature of the RTC 16-bit Timer Counter callback function.

Description

This data type defines the function signature of the RTC 16-bit Timer Counter Callback function. The RTC peripheral will call back the client's function with this signature everytime when the 16-bit Time Counter related event has occurred. Refer to the description of the RTC_TIMER16_INT_MASK enumeration for possible events. Hardware event flags are cleared when the callback function exits.

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_Timer16CallbackRegister() function. The callback function should be registered before starting the timer.

Precondition

The RTC_Initialize() function should have been called to initialize the RTC peripheral. The RTC_Timer16CallbackRegister() function should have been called to register the callback function. The RTC peripheral should have been configured for 16-bit Timer Counter mode in MHC. The RTC peripheral should have been configured for Interrupt mode operation in MHC.

Parameters

Param Description
event The 16-bit Timer Counter event that caused the callback function to be called. Multiple events can be active. The application should check for 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)

Returns

None.

Example

void MyTimer16Callback (RTC_TIMER16_INT_MASK_COMPARE0_MATCH interruptCause, uintptr_t context )
{
    if((interruptCause & RTC_TIMER16_EVENT_PERIOD_MATCH) ==
    RTC_TIMER16_EVENT_PERIOD_MATCH)
    {
        // The period has matched.
    }
    else if((interruptCause & RTC_TIMER16_EVENT_COMPARE1_MATCH) ==
    RTC_TIMER16_EVENT_COMPARE1_MATCH)
    {
        // Compare 1 value has matched.
    }
    else if((interruptCause & RTC_TIMER16_EVENT_COMPARE0_MATCH) ==
    RTC_TIMER16_EVENT_COMPARE0_MATCH)
    {
        // Compare 0 value has matched.
    }
}

// Initialize the RTC Peripheral and register the callback function.
// Note how the pointer to the peridoicIntervalHadExpired flag is specified
// as the context. This is passed back into the callback function.

RTC_Initialize();
RTC_Timer16CounterSet(0);
RTC_Timer16PeriodSet(0xFFF);
RTC_Timer16CallbackRegister(MyTimer16Callback, NULL);
RTC_Timer16Start();

Remarks

This callback if only available when the RTC peripheral is configured for 16-bit Timer Counter operation. The callback function will be execute in an interrupt context. Avoid calling blocking , computationally intensive or interrupt un-safe function from the callback function.