When the ADC is configured in callback mode, a user-defined function is set to run when a desired ADC interrupt occurs. The predefined ADC conditions for excecuting an interrupt are: buffer received, window hit, and conversion error. In this example it is desirable to recieve an interrupt when the ADC conversion is complete, i.e. when the result buffer is recieved.
/* ADC Callback Function */
void adc_complete_callback(const struct adc_module *const module)
{
/* Set ADC conversion ended flag */
adc_read_done = true;
}
ADC_CALLBACK_READ_BUFFER
parameter indicates that the callback
function is to be associated with a complete
conversion./* Enable ADC Callback Function */
void configure_adc_callbacks(void)
{
adc_register_callback(&adc_instance,
adc_complete_callback, ADC_CALLBACK_READ_BUFFER);
adc_enable_callback(&adc_instance, ADC_CALLBACK_READ_BUFFER);
}