1

I have two function definitions

void USART_puts(USART_TypeDef* USARTx, volatile char *s)
{
 .....
}


void send_packet(char op, unsigned char *data, unsigned char len) 
{
....
}

now I have created a function pointer for send_packet(char,unsigned char*,unsigned char) as

void (*send_packet)(char,unsigned char*,unsigned char);

I want to pass this function pointer like this

 USART_Puts(USART1,send_packet)    

But I am getting an error " argument of type send_packet * is incompatible with type volatile char * " I can understand from the error that two arguments are not matching. But can anyone please tell me how can I pass this function pointer?

user2819759
  • 85
  • 1
  • 9

1 Answers1

1

USART_Puts needs to have a parameter of function pointer type.

void USART_puts(USART_TypeDef* USARTx, void (*s)(char,unsigned char*,unsigned char))

The definition of send_packet as a pointer after its definition as a function is unnecessary. Two such declarations of the same name should not even coexist.

Potatoswatter
  • 134,909
  • 25
  • 265
  • 421
  • Apparently `USART_Puts` is part of a vendor API, so if he makes this change to the vendor-supplied header files then he is in for a world of hurt – M.M Dec 01 '14 at 04:25
  • @MattMcNabb Well, it'll have approximately the same effect as passing the function pointer as a data buffer by casting it. So, the question is actually, "how do I get asynchronous I/O from a driver without support?" – Potatoswatter Dec 01 '14 at 12:21