Articles
4
Home
文本处理工具
代码生成器
bes
Arduino
python
freertos
zklx
C#
xilinx
3D打印实用工具
Archives
找到我
Fun
Home
文本处理工具
代码生成器
bes
Arduino
python
freertos
zklx
C#
xilinx
3D打印实用工具
Archives
找到我
Fun
复制粘贴工程师专用工具
freertos
多任务
#include "FreeRTOSConfig.h" //freertos相关配置 #include "FreeRTOS.h" //相关api QueueHandle_t ui_queue;//ui task的消息队列 typedef struct { int a; int b; }ui_msg_t; void my_task(void *p) { while(1) { vTaskDelay(1000 / portTICK_PERIOD_MS); } } void ui_task_init(void) { ui_queue = xQueueCreate( 10, sizeof( ui_msg_t ) ); if( ui_queue == 0 ) { // Failed to create the queue. Serial.print("Failed to create the ui_queue. "); while(1); } } void sendmsg2_ui_task(ui_msg_t *msg)//给ui task发送消息 { if( ui_queue != 0 ) { // Send an uint32_t. Wait for 10 ticks for space to become // available if necessary. if( xQueueSend( ui_queue, msg,( TickType_t ) 10 ) != pdPASS ) { // Failed to post the message, even after 10 ticks. Serial.println("send fail"); } } } void ui_task(void * p) { ui_msg_t ui_msg; while(1) { if( xQueueReceive( ui_queue, &( ui_msg ),portMAX_DELAY) ) { //your code } } } xTaskCreate( my_task, /*任务函数*/ "my_task", /*带任务名称的字符串*/ 20000, /*堆栈大小,单位为字节*/ NULL, /*作为任务输入传递的参数*/ 6, /*任务的优先级*/ NULL); //TaskHandle_t * xTaskCreate( ui_task, /*任务函数*/ "ui_task", /*带任务名称的字符串*/ 10000, /*堆栈大小,单位为字节*/ NULL, /*作为任务输入传递的参数*/ 5, /*任务的优先级*/ NULL);
定时器
void get_vol_timerhandle(void *p) { //your code } get_vol_timer = xTimerCreate("get vol", 1000 / portTICK_PERIOD_MS, pdTRUE, NULL, get_vol_timerhandle); xTimerStart(get_vol_timer, 1000 / portTICK_PERIOD_MS);//启动定时器
zhoushenglin
Articles
4
Bookmark
Announcement
Hello!
Recent Post
WSL下安装petalinux
2022-08-19
video
2020-08-14
关于这个网站
2020-08-10
更新记录
2020-08-10
Archives
August 2022
1
August 2020
3
Info
Article :
4
UV :
PV :
2