Part Number: CC2340R5
Hello,
I'm using CC2340R5 SDK, version 7.40, basic_ble project.
I'm reading and writing data on UART_2. I'm sending commands on UART from MCU to BLE at initial but if BLE is disconnected/is in broadcasting mode, the UART callback function does not trigger.
While reading the callback function, it only triggers when I make a peripheral connection with android application.
In peripheral also, the callback does not always triggers. It sometimes misses the callback. Although, I get the data on UART.
Below is my code:
UART configuration:
void *mainThread(void *arg0)
{
char input;
const char echoPrompt[] = "Echoing characters:\r\n";
UART2_Params uartParams;
int32_t semStatus;
uint32_t status = UART2_STATUS_SUCCESS;
uint8_t tempbuf[64] = {0};
/* Create semaphore */
// semStatus = sem_init(&sem, 0, 0);
// if (semStatus != 0)
// {
// /* Error creating semaphore */
// // while (1) {}
// }
/* Create a UART in CALLBACK read mode */
UART2_Params_init(&uartParams);
uartParams.readMode = UART2_Mode_BLOCKING;
uartParams.writeMode = UART2_Mode_BLOCKING;
uartParams.readCallback = callbackFxn;
uartParams.baudRate = 115200;
// uartParams.readReturnMode = UART2_ReadReturnMode_PARTIAL;
uartParams.dataLength = UART2_DataLen_8;
uart_handle = UART2_open(CONFIG_DISPLAY_UART, &uartParams);
}
UART Callback:
void callbackFxn(UART2_Handle handle, void *buffer, size_t count, void *userArg, int_fast16_t status)
{
// uint8_t tempbuf[260] = {0};
if (status != UART2_STATUS_SUCCESS)
{
/* RX error occured in UART2_read() */
// while (1) {}
}
status = UART2_read(uart_handle, buffer, sizeof(count), NULL);
BLE_MCU_Cmd_parser(buffer);
}
Calling in main() function:
int main()
{
pthread_t thread;
pthread_attr_t attrs;
struct sched_param priParam;
int retc;
/* Register Application callback to trap asserts raised in the Stack */
halAssertCback = AssertHandler;
RegisterAssertCback(AssertHandler);
Board_init();
/* Initialize the attributes structure with default values */
pthread_attr_init(&attrs);
/* Set priority, detach state, and stack size attributes */
priParam.sched_priority = 1;
retc = pthread_attr_setschedparam(&attrs, &priParam);
retc |= pthread_attr_setdetachstate(&attrs, PTHREAD_CREATE_DETACHED);
retc |= pthread_attr_setstacksize(&attrs, THREADSTACKSIZE);
if (retc != 0)
{
/* failed to set attributes */
// while (1) {}
}
retc = pthread_create(&thread, &attrs, mainThread, NULL);
if (retc != 0)
{
/* pthread_create() failed */
// while (1) {}
}
/* Update User Configuration of the stack */
user0Cfg.appServiceInfo->timerTickPeriod = ICall_getTickPeriod();
user0Cfg.appServiceInfo->timerMaxMillisecond = ICall_getMaxMSecs();
/* Initialize all applications tasks */
appMain();
/* Start the FreeRTOS scheduler */
vTaskStartScheduler();
return 0;
}