Warning "incompatible pointer type" while building sample callback ADC code for Atmel SAMD20

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am new to the whole Atmel Studio Ide and the Atmel SAM line of ARM microcontrollers. 
After build, Atmel 7 Studio returns with the warning "passing argument 2 of 'adc_register_callback' from incompatible pointer type".

Also this is the message in the error list: Severity Code Description Project File Line Message expected 'adc_callback_t' but argument is of type 'void (*)(const struct adc_module * const)' .

 

Callback Function: 

volatile bool adc_read_done = false;
void adc_complete_callback(const struct adc_module *const module)
{
   // ADC read has been completed
   adc_read_done = true;
}

 

Warning occurs while passing the 2nd argument:

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);
}

 

Am I passing the parameter wrong or the callback function defined is wrong? I'm using the sample code from Atmel-42319 -asf-manual application note. 

 

This topic has a solution.

Newbie to the world of Atmel SAM D microcontrollers.

Last Edited: Tue. Apr 26, 2016 - 04:35 AM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The callback has the wrong signature. I think the problem is that you have two "const" qualifiers in your code.

 

Try

void adc_complete_callback(struct adc_module *const module)
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Cheers for the quick reply. I don't know how I missed that part even after digging through the prototype of the callback function in the adc_feature, proper noob behaviour. Solution built without any issues. 

Newbie to the world of Atmel SAM D microcontrollers.

Last Edited: Tue. Apr 26, 2016 - 04:40 AM