1.41.1.17 ADCx_CallbackRegister Function

C

void ADCx_CallbackRegister( ADC_CALLBACK callback, uintptr_t context ); // x is instance of the peripheral and it is applicable only for devices having multiple instances of the peripheral.

Summary

Registers the function to be called from interrupt.

Description

This function registers the callback function to be called from interrupt.

Precondition

ADC_Initialize() must have been called first for the associated instance. Interrupt option in MHC should have been enabled.

Parameters

Param Description
callback callback function pointer
context Allows the caller to provide a context value (usually a pointer to the callers context for multi-instance clients)

Returns

None.

Example

void ADC0_ResultReadyCallback( ADC_STATUS status, uintptr_t context )
{
    uint16_t adcResult = 0;
    adcResult = ADC0_ConversionResultGet();
}

ADC0_Initialize();
ADC0_CallbackRegister(ADC0_ResultReadyCallback, (uintptr_t)NULL);
void ADC_Callback_Fn(uint32_t interruptStatus, uint32_t eocInterruptStatus, uintptr_t context)
{
    
}

ADC_Initialize();
ADC_CallbackRegister(ADC_Callback_Fn, NULL);

Remarks

Context value can be set to NULL if not required. To disable callback function, pass NULL for the callback parameter.