Hi everybody
I konw that there are already some threads about this problem. Unfortunately none of these answers the question. I try to setup a UART communication from a CC2650/SmartRF06EB running a modified SimpleBLECentral Bluetooth low energy exampe project to my Windows PC. Writing data from the CC2650 to the PC (I use HyperTerminal) works fine. Unfortunately I am not able to transmit any data from the PC to the CC2650 because the read callback function never gets called. Here some of my code:
bool InitUART()
{
UART_Params_init(&uartParams);
uartParams.baudRate = UART_BAUD_RATE;
uartParams.readMode = UART_MODE_CALLBACK;
uartParams.writeMode = UART_MODE_BLOCKING;
uartParams.writeDataMode = UART_DATA_BINARY;
uartParams.readDataMode = UART_DATA_BINARY;
uartParams.readReturnMode = UART_RETURN_NEWLINE;
uartParams.readEcho = UART_ECHO_OFF;
uartParams.readTimeout = UART_WAIT_FOREVER;
uartParams.readCallback = UartReadCallback;
uartHandle = UART_open(CC2650_UART0, &uartParams);
if (!uartHandle)
{
return false;
}
int ret = UART_read(uartHandle, uartRxBuf, 2); //read 2 bytes
if (ret == UART_ERROR)
{
return false;
}
return true;
}
static void SimpleBLECentral_init(void)
{
uint8_t i;
// Setup discovery delay as a one-shot timer
Util_constructClock(&startDiscClock, SimpleBLECentral_startDiscHandler, DEFAULT_SVC_DISCOVERY_DELAY, 0, false, 0);
Board_initKeys(SimpleBLECentral_keyChangeHandler);
Board_openLCD();
ledPinHandle = PIN_open(&ledPinState, pLedPinTable);
// Initialize UART
bool initUARTSuccess = InitUART();
if (!initUARTSuccess)
{
LCD_WRITE_STRING_VALUE("UART open failed: ", (uint32_t)uartHandle, 10, LCD_PAGE3);
}
else
{
LCD_WRITE_STRING("UART open success", LCD_PAGE3);
}
...
void UartReadCallback(UART_Handle handle, void *rxBuf, size_t size) // Gets never called.
{
LCD_WRITE_STRING("UART read CB", LCD_PAGE5);
if (size <= 0)
{
return;
}
// Start another read
UART_read(uartHandle, uartRxBuf, 2);
}
The initialization is successful: "UART open success" get written to the display. But the callback never gets called. If I replace UART_WAIT_FOREVER by a fixed timeout (e.g. 100) the callback function also never gets called.
Is my procedure correct? I do not use a separate task for the UART communication. Is that ok?
I also do not want to implement any complicated memory-hungry network layer as described here: