Part Number: LAUNCHXL-CC1310
Other Parts Discussed in Thread: CC1310
I'm trying to work out how to use the UART drivers for the CC1310. I'm starting as a nortos project just to figure it out. Ultimately, I may end up using RTOS once I have a good handle on how all the drivers work. I have the code below, and it never calls uartWriteCallbackFxn(). This is not production code. This is minimal test code to figure it out. If you send it a byte, it does process the read callback function, sets totalBytes to 1, then writes that byte repeatedly, as fast as it can. It never runs the write callback to set totalBytes back to 0.
/*
* This is based on the TI uartecho_CC1310_LAUNCHXL_nortos example.
* Trying to implement the UART driver in callback mode so that
* I can then use that mode in more complex applications.
*
* 12/21/2017 DJQ
*/
/*
* ======== uartecho.c ========
*/
#include <stdint.h>
#include <stddef.h>
/* Driver Header files */
#include <ti/drivers/GPIO.h>
#include <ti/drivers/UART.h>
#include <ti/drivers/uart/UARTCC26XX.h>
/* Example/Board Header files */
#include "Board.h"
int totalBytes = 0;
char input = '\0';
// ********************************************************************
//
// Callback Functions
//
// ********************************************************************
void uartReadCallbackFxn (UART_Handle handle, void *buf, size_t count)
{
totalBytes = 1;
}
void uartWriteCallbackFxn (UART_Handle handle, void *buf, size_t count)
{
totalBytes = 0;
}
/*
* ======== mainThread ========
*/
void *mainThread(void *arg0)
{
const char echoPrompt[] = "Echoing characters:\r\n";
UART_Handle uart;
UART_Params uartParams;
/* Call driver init functions */
GPIO_init();
UART_init();
/* Turn on user LED */
GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);
/* Create a UART with data processing off. */
UART_Params_init(&uartParams);
uartParams.writeDataMode = UART_DATA_TEXT;
uartParams.readDataMode = UART_DATA_TEXT;
uartParams.readReturnMode = UART_RETURN_FULL;
uartParams.readEcho = UART_ECHO_OFF;
uartParams.baudRate = 115200;
uartParams.readMode = UART_MODE_CALLBACK;
uartParams.writeMode = UART_MODE_CALLBACK;
uartParams.readCallback = &uartReadCallbackFxn;
uartParams.writeCallback = &uartWriteCallbackFxn;
uart = UART_open(Board_UART0, &uartParams);
if (uart == NULL) {
/* UART_open() failed */
while (1);
}
// UART_control(uart, UARTCC26XX_CMD_RETURN_PARTIAL_ENABLE, NULL);
UART_write(uart, echoPrompt, sizeof(echoPrompt));
while (1) {
UART_read(uart, &input, 1);
if(totalBytes == 1){
UART_write(uart, &input, 1);
}
}
}
What do I have to do in order to get it to call the callback for write mode as well? I'm my final code I will end up needing the callback to be called.
