
Stm32 Freertos Developer
Bootstrap STM32 firmware with FreeRTOS tasks using proven dynamic and static creation patterns from the skill examples.
Install
npx skills add https://github.com/2939387245/agent-skill_stm32-freertos --skill stm32-freertos-developerWhat is this skill?
- Complete dynamic task example with xTaskCreate, priorities, and vTaskDelay using HAL GPIO toggles
- Static task allocation pattern with StaticTask_t and preallocated stacks (document continuation in full skill)
- Shows HAL_Init, clock config, and vTaskStartScheduler failure handling
- Printf-style runtime logging hooks for debugging concurrent tasks
Adoption & trust: 1 installs on skills.sh; 12 GitHub stars; 3/3 security scanners passed (skills.sh audits).
Recommended Skills
Agent Browservercel-labs/agent-browser
Lark Imlarksuite/cli
Lark Calendarlarksuite/cli
Lark Sheetslarksuite/cli
Lark Vclarksuite/cli
Lark Contactlarksuite/cli
Journey fit
Primary fit
Firmware scheduling and HAL bring-up are pure product construction work on the device backend, not launch or growth tooling. FreeRTOS task creation, stacks, and scheduler startup are firmware/backend concerns on STM32 rather than frontend or distribution.
Common Questions / FAQ
Is Stm32 Freertos Developer safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - Stm32 Freertos Developer
# 基础示例 本文档包含 FreeRTOS 基础组件的完整示例代码。 --- ## 1.1 动态任务创建 ```c #include "main.h" #include "FreeRTOS.h" #include "task.h" /* 任务函数 */ void vTask1(void *pvParameters) { while (1) { /* 任务代码 */ HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin); printf("Task1 运行\r\n"); /* 延时 500ms */ vTaskDelay(pdMS_TO_TICKS(500)); } } void vTask2(void *pvParameters) { while (1) { /* 任务代码 */ HAL_GPIO_TogglePin(LED2_GPIO_Port, LED2_Pin); printf("Task2 运行\r\n"); /* 延时 1000ms */ vTaskDelay(pdMS_TO_TICKS(1000)); } } int main(void) { HAL_Init(); SystemClock_Config(); MX_GPIO_Init(); /* 创建任务 */ BaseType_t ret1 = xTaskCreate(vTask1, "Task1", 128, /* 堆栈深度(字) */ NULL, /* 参数 */ 2, /* 优先级 */ NULL);/* 句柄 */ BaseType_t ret2 = xTaskCreate(vTask2, "Task2", 128, NULL, 2, NULL); if (ret1 == pdPASS && ret2 == pdPASS) { printf("任务创建成功,启动调度器\r\n"); vTaskStartScheduler(); } else { printf("任务创建失败\r\n"); } while (1); } ``` --- ## 1.2 静态任务创建 ```c #include "main.h" #include "FreeRTOS.h" #include "task.h" /* 静态任务控制块和堆栈(全局变量) */ static StaticTask_t xTask1_TCB; static StackType_t xTask1_Stack[128]; static StaticTask_t xTask2_TCB; static StackType_t xTask2_Stack[256]; /* 任务函数 */ void vTask1(void *pvParameters) { while (1) { printf("静态任务1运行\r\n"); vTaskDelay(pdMS_TO_TICKS(1000)); } } void vTask2(void *pvParameters) { while (1) { printf("静态任务2运行\r\n"); vTaskDelay(pdMS_TO_TICKS(500)); } } int main(void) { HAL_Init(); SystemClock_Config(); MX_GPIO_Init(); /* 创建静态任务 */ TaskHandle_t handle1 = xTaskCreateStatic(vTask1, "Task1", 128, /* 堆栈深度(字) */ NULL, /* 参数 */ 2, /* 优先级 */ xTask1_Stack, &xTask1_TCB); TaskHandle_t handle2 = xTaskCreateStatic(vTask2, "Task2", 256, NULL, 2, xTask2_Stack, &xTask2_TCB); if (handle1 != NULL && handle2 != NULL) { printf("静态任务创建成功,启动调度器\r\n"); vTaskStartScheduler(); } else { printf("静态任务创建失败\r\n"); } while (1); } ``` --- ## 1.3 队列(生产者-消费者) ```c #include "main.h" #include "FreeRTOS.h" #include "queue.h" /* 数据帧定义 */ typedef struct { uint32_t id; float value; uint32_t timestamp; } DataFrame_t; /* 全局队列 */ QueueHandle_t g_data_queue; /* 生产者任务 */ void vProducerTask(void *pvParameters) { DataFrame_t frame; uint32_t count = 0; while (1) { /* 产生数据 */ frame.id = count; frame.value = (float)(count * 0.1f); frame.timestamp = HAL_GetTick(); /* 发送到队列 */ if (xQueueSend(g_data_queue, &frame, 0) == pdTRUE) { printf("生产者: 发送数据 #%lu\r\n", count); } else { printf("生产者: 队列满,丢弃数据\r\n"); } count++; vTaskDelay(pdMS_TO_TICKS(200)); } } /* 消费者任务 */ void vConsumerTask(void *pvParameters) { DataFrame_t frame; while (1) { /* 从队列接收数据(无限等待) */ if (xQueueReceive(g_data_queue, &frame, portMAX_DELAY) == pdTRUE) { printf("消费者: 收到数据 #%lu, 值=%.2f, 时间=%lu\r\n", frame.id, frame.value, frame.timestamp); } } } int mai