请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号:CC2340R5工具/软件:
您好论坛、
我想作为单独的 RTOS 任务实施 TPMS 扫描、UART 通信。 另外、将来我可能想进行特定的 GATT 配置文件数据交换。 那么、您是否有任何用于任务创建的代码库?
此外、如果您可以为其建议步骤或文档、将会更好。
此致
Vaibhav
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.
工具/软件:
您好论坛、
我想作为单独的 RTOS 任务实施 TPMS 扫描、UART 通信。 另外、将来我可能想进行特定的 GATT 配置文件数据交换。 那么、您是否有任何用于任务创建的代码库?
此外、如果您可以为其建议步骤或文档、将会更好。
此致
Vaibhav
您好!
您可以按照我们 用户指南中有关如何创建 FreeRTOS 任务的章节进行操作。
示例代码如下所示
#include <FreeRTOS.h>
#include <task.h>
#include <stdarg.h>
#define TASK_PRIORITY 1
#define TASK_STACK_SIZE 2048 /* bytes */
TaskHandle_t taskHandle = NULL;
/* Task function */
void taskFunction(void* a0)
{
/* Local variables. Variables here go onto task stack!! */
/* Run one-time code when task starts */
while (1) /* Run loop forever (unless terminated) */
{
/*
* Block on a signal or for a duration. Examples:
* ``xSemaphoreTake()``
* ``xQueueReceive``
* ``vTaskDelay()``
*
* "Process data"
*/
}
/* Tasks must not attempt to return from their implementing
function or otherwise exit. If it is necessary for a task to
exit then have the task call vTaskDelete( NULL ) to ensure
its exit is clean. */
vTaskDelete( NULL );
}
int main() {
BaseType_t xReturned;
/* Create the task, storing the handle. */
xReturned = xTaskCreate(
taskFxn, /* Function that implements the task. */
"MY_NEW_TASK", /* Text name for the task. */
TASK_STACK_SIZE / sizeof(uint32_t), /* Stack size in words, not bytes. */
( void * ) 1, /* Parameter passed into the task. */
TASK_PRIORITY, /* Priority at which the task is created. */
&taskHandle ); /* Used to pass out the created task's handle. */
if(xReturned == errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY)
{
/* Creation of FreeRTOS task failed */
while(1);
}
/* Start the FreeRTOS scheduler */
vTaskStartScheduler();
}
此致、
Lea