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.

CC3220SF-LAUNCHXL: cc3220 uart callback example

Part Number: CC3220SF-LAUNCHXL

where can I find a cc3220 uart read callback example?

  • Hi Gary,

    There is no specific UART read with callback mode example in the SDK. However, setting up a UART interface in callback mode is done in the same way as a UART interface in blocking mode, except for the readMode and readCallback members of the UART_Params struct. So, the setup and opening of the UART interface would be done like so:

        UART_Params uartParams;
        UART_Params_init(&uartParams);
        uartParams.writeDataMode = UART_DATA_BINARY;
        uartParams.readDataMode = UART_DATA_BINARY;
        uartParams.readReturnMode = UART_RETURN_FULL;
        uartParams.readEcho = UART_ECHO_OFF;
        uartParams.baudRate = UART_BAUDRATE;
        uartParams.readCallback = uart_isr_callback;
        uartParams.readMode = UART_MODE_CALLBACK;
        uartHandle1 = UART_open(Board_UART1, &uartParams);

    From there, you can call UART_read() as you would normally, except that instead of blocking until the timeout occurs or all data is read, you would immediately return from the UART_read() and continue on with program execution in that thread. Of course, you'll need to have a callback function do something to inform the rest of your program that the UART read is complete. A simple callback that just posts to a semaphore could look like this:

    void uart_isr_callback (UART_Handle handle, void *buf, size_t count){
    
        currentFrameNumber++;
        Semaphore_post(mainSemHandle);
    }

    Let me know if you need more help on running the UART peripheral in callback mode, or have additional questions.

    Regards,
    Michael