AnsweredAssumed Answered

IAR UART_Setcallback function problem

Question asked by Dave Telling on Jan 8, 2015
Latest reply on Jan 8, 2015 by Dave Telling

I have a UART function that should receive an ASCII character, put it into a small buffer, increment a buffer counter, and set a flag if a CR or LF is received. This function should occur when the KE02Z UART1 generates an RDRF as a complete character comes into the UART.

Here is the interrupt function:

 

void UART_Rx_Task(void)

{

  uint8_t tempData;

  /* reset RDB flag */

  tempData = UART_CheckFlag(UART1, UART_FlagRDRF);

  /* read the character and put into buffer */

  inChar[rxBufCount] = UART_ReadDataReg(UART1);

  if ((inChar[rxBufCount] == CR) || (inChar[rxBufCount] == LF))

  {

    rxFull = true;

    rxBufCount = 0;

  }

  else

  {

    rxBufCount++;

    if (rxBufCount >= rxMax)

    {

      rxBufCount = 0;

      rxFull = true;

    }

  }

}

Without going into a discussion about the best way to do this, my real problem is that I cannot seem to tell the program to uses this interrupt.

The IAR tools have a predefined function (in 'uart.h'):

void UART_SetCallback(UART_CallbackType pfnCallback);

The "CallbackType" is defined like this:

typedef void (*UART_CallbackType)(UART_Type *pUART);

I am not exactly sure what this means - C syntax is not my field of expertise, and when I try to compile this, I get this error message:

Error[Pe167]: argument of type "void (*)(void)" is incompatible with parameter of type "UART_CallbackType"

Can someone explain what exactly this means, in non-professional programmer language?

Outcomes