This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

UART Callback CC1310F128, TI v15.12.3.LTS Query...

Hi,

Can someone cast their eyes over my code please and tell me what I'm doing wrong.

I'm wanting to setup a Callback function for the UART such that I'm not blocking any processing whilst waiting for a response to an earlier UART command.  I've read the various Forum posts and Google, etc and this is my code...

Top of file...

#include <ti/drivers/UART.h>

...

void uart_callback_read (UART_Handle handle, void *buffer, int size);

Within Task...

UART_Handle uart;
UART_Params uartParams;

UART_Params_init(&uartParams);

uartParams.writeDataMode = UART_DATA_BINARY;
uartParams.readDataMode = UART_DATA_BINARY;
uartParams.readEcho = UART_ECHO_OFF;
uartParams.readMode = UART_MODE_CALLBACK;
uartParams.readCallback = &uart_callback_read;


#ifdef DEBUG_INFO
uartParams.baudRate = 115200;

#else
uartParams.baudRate = 19200;
#endif
uart = UART_open(Board_UART0, &uartParams);

Bottom of file...

void uart_callback_read (UART_Handle handle, void *buffer, int size) {
/*Leave Blank for now until successul compile... */

}

I then have a UART_Write(uart, &command, CMD_LEN) followed by a UART_Read(uart, &response, RESP_LEN), where I expect the Callback to be called when RESP_LEN has been received.

Now, I get the following Warning when I compile:

#515-D a value of type "void (*)(UART_Handle, void *, int)" cannot be assigned to an entity of type "UART_Callback"

I don't like Warnings like this, what would cause this Warning and how do I resolve it?

Any Pointers (no pun intended) welcome.

Thankyou,

Mike.

  • There are only 2 possibilities: your function signature or the pointer your are passing

    Have you tried removing the & in front of the callback assignment (the function is a pointer)?

    // Use this
    uartParams.readCallback = uart_callback_read;
    
    // instead of this
    uartParams.readCallback = &uart_callback_read;

    Or, the UART_Callback doesn't like the int but prefers a size_t. Here is the typedef of UART_Callback

    typedef void(* UART_Callback) (UART_Handle, void *buf, size_t count)

    Hope this helps

    Michel

  • Ahhhhhh. I'm being a Clampit. It's the Parameter Type of the callback like you suggested.
    Thankyou for your help.