主题中讨论的其他器件:SysConfig、 CC2340R5
工具与软件:
尊敬的 TI 团队:
我按照示例来创建一个任务、但是我已经注意到添加一个额外的任务会增加功耗。 是否有办法解决此问题?

int main()
{
/* Register Application callback to trap asserts raised in the Stack */
halAssertCback = AssertHandler;
RegisterAssertCback(AssertHandler);
Board_init();
/* Update User Configuration of the stack */
user0Cfg.appServiceInfo->timerTickPeriod = ICall_getTickPeriod();
user0Cfg.appServiceInfo->timerMaxMillisecond = ICall_getMaxMSecs();
/* Initialize all applications tasks */
appMain();
sub_proc();
/* Start the FreeRTOS scheduler */
vTaskStartScheduler();
return 0;
}
void *emsThread(void *arg0)
{
/* Configure the LED pin */
GPIO_setConfig(CONFIG_GPIO_LED_0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
GPIO_setConfig(CONFIG_GPIO_LED_1, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
/* Turn on user LED to indicate successful initialization */
GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_OFF);
GPIO_write(CONFIG_GPIO_LED_1, CONFIG_GPIO_LED_OFF);
while(1)
{
if(connection_LED == 0)
{
if (sem_trywait(&sem) == 0)
{
UART2_write(uart, (char*)"device disconnect OK!\r\n", strlen((char*)"device disconnect OK!\r\n"), NULL);
}
GPIO_toggle(CONFIG_GPIO_LED_0);
GPIO_write(CONFIG_GPIO_LED_1, CONFIG_GPIO_LED_OFF);
// UART2_write(uart, (char*)"Please connect device\r\n", strlen((char*)"Please connect device\r\n"), NULL);
usleep(250000);
}
else
{
if (sem_trywait(&sem) == 0) { //receive to sem
UART2_write(uart, (char*)"device connect OK!\r\n", strlen((char*)"device connect OK!\r\n"), NULL);
}
//GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_OFF);
GPIO_write(CONFIG_GPIO_LED_1, CONFIG_GPIO_LED_ON);
sleep(1);
}
}
}
void sub_proc(void)
{
/* collect data Task. */
pthread_t thread3;
pthread_attr_t attrs3;
struct sched_param priParam3;
int retc;
int32_t semStatus;
#if defined(Display_DISABLE_ALL)
uint32_t status = UART2_STATUS_SUCCESS;
const char echoPrompt[] = "Echoing characters:\r\n";
/* Create a UART in CALLBACK read mode */
UART2_Params_init(&uartParams);
uartParams.readMode = UART2_Mode_CALLBACK;
uartParams.readCallback = callbackFxn;
uartParams.baudRate = 115200;
// uart = UART2_open(CONFIG_UART2_0, &uartParams);
if (uart == NULL)
{
/* UART2_open() failed */
while (1) {}
}
UART2_read(uart, uartReadBuffer, UART_MAX_READ_SIZE, NULL);
/* Turn on user LED to indicate successful initialization */
//GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_ON);
/* Pass NULL for bytesWritten since it's not used in this example */
UART2_write(uart, echoPrompt, sizeof(echoPrompt), NULL);
#endif
/* Create semaphore */
semStatus = sem_init(&sem, 0, 0);
if (semStatus != 0)
{
/* Error creating semaphore */
while (1) {}
}
pthread_attr_init(&attrs3);
/* Set priority, detach state, and stack size attributes */
priParam3.sched_priority = 3;
retc = pthread_attr_setschedparam(&attrs3, &priParam3);
retc |= pthread_attr_setdetachstate(&attrs3, PTHREAD_CREATE_DETACHED);
retc |= pthread_attr_setstacksize(&attrs3, THREADSTACKSIZE);
if (retc != 0)
{
/* failed to set attributes */
while (1) {}
}
retc = pthread_create(&thread3, &attrs3, emsThread, NULL);
if (retc != 0)
{
/* pthread_create() failed */
while (1) {}
}
}


