前言:
我將FreeRTOS的Task用Thread方式實作,使用方式和Java或Qt的用法相似,好處是使用上比較方便習慣些。
用法:
1. 繼承使用Thread
#include "pico/stdlib.h"
#include "thread.h"
class LedWriter : public Thread
{
};
2. 實做run Method
public:
LedWriter();
.....
void run();
.....
3. 主程式中實做
TaskHandle_t ledwriter_thread = NULL;
LedWriter *led_writer = new LedWriter();
4. xTaskCreate啟動Task
BaseType_t ret = xTaskCreate(LedWriter::start, "led_writer", 512, led_writer, tskIDLE_PRIORITY, &ledwriter_thread);
程式碼下載:
https://gitlab.com/ycfunet/freertos_thread_template
沒有留言:
張貼留言