AnsweredAssumed Answered

Function pointer / callback function serial communication

Question asked by Peter Everix on Jul 14, 2009
Latest reply on Jul 14, 2009 by Peter Everix

Hello everyone

 

Since a few weeks i start to do programming  for freescale MCU's ( i use MC9S08AW ) . 

About 15 years ago i did some C/C++ programming under a MS-DOS enviroment and then switch to windows programming using Delphi. I still know C but pointers stuff is very far in my head.

 

I want to make a general communication library that I can use in all my projects. The freescale specific stuff is working. I can send and receive data from the SCI but I can't manage to get working the callback function. The function is called but the parameters contain rubish data.

 

This is what I have done, sorry for the long post.

 

- define my callback ( comm-lib.c )

typedef void (*com_callback)(const unsigned int iReceived);

 

- declare internal callback ( comm-lib.c )

volatile static com_callback ReceivedData; 

 

- create function to assign call back  ( comm-lib.c )

void uart_setcallback( void (*my_callback )(const unsigned int iReceived) ); 

 

- declare my call back ( main.c )

com_callback com_binnen ( const unsigned int iReceived );

 

- and it implementation ( main.c )

com_callback com_binnen ( const unsigned int iReceived )

{

  if ( iReceived == 2 )

  {

 

  }

}

 

- assign the callback ( main.c )

uart_setcallback ( *com_binnen ); 

 

When compiling i get a warning "Indirection to different types .................." but its compiling.

 

Can any one help me with what i'm doing wrong

Thanks

Peter 

Outcomes