AI Usage Rules
When the user makes a request, follow the rules belowSelectively readdocuments. Do not read all documents at once; only read the files relevant to the user's request.
Code Generation Requests
| User says... | Read file |
|---|---|
| "Create task" / "Create queue" / "Semaphore" / "Mutex" / "Event group" / "Task notification" | EXAMPLES/BASIC.md |
| "UART driver" / "ADC driver" / "I2C driver" / "TIM driver" | REFERENCE/HAL_DRIVERS.md + EXAMPLES/DRIVERS.md |
| "printf redirection" / "printf output" / "ITM" | REFERENCE/STD_LIBS.md |
| "DMA reception" / "variable-length data" | REFERENCE/HAL_DRIVERS.md + EXAMPLES/DRIVERS.md |
Code Review/Troubleshooting Requests
| User says... | Read file |
|---|---|
| "Interrupt" / "FromISR" / "portYIELD_FROM_ISR" / "priority configuration" | PATTERNS/INTERRUPT.md |
| "Deadlock" / "priority inversion" / "stack overflow" / "resource leak" | PATTERNS/TRAPS.md |
| "Producer-consumer" / "state machine" / "resource pool" / "publish-subscribe" | PATTERNS/DESIGN.md |
Debugging Requests
| User says... | Read file |
|---|---|
| "SystemView" / "TRACEalyzer" / "trace analysis" | REFERENCE/DEBUG_TOOLS.md |
| "Task statistics" / "stack monitoring" / "CPU usage" | REFERENCE/DEBUG_TOOLS.md |
Advanced Application Requests
| User says... | Read file |
|---|---|
| "Low power" / "Tickless" / "STOP mode" | EXAMPLES/ADVANCED.md |
| "CubeMX configuration" / "STM32CubeMX" | EXAMPLES/ADVANCED.md |
| "Sensor fusion" / "multitasking" | EXAMPLES/ADVANCED.md |
API Query Requests
| User says... | Read file |
|---|---|
| "xTaskCreate parameters" / "API syntax" / "function description" | REFERENCE/FREERTOS_API.md |
Usage
If the user's request is not clear enough to determine which file to read:
- First read SKILL.md and REFERENCE/FREERTOS_API.md
- Ask the user about their specific needs
- Read the correct file based on the answer
Do not read all files at once! Only read the files relevant to the user's request.
Skill Introduction
This skill is designed specifically for embedded development using STM32 microcontrollers with the FreeRTOS real-time operating system . The AI will act as an "embedded systems architect" to help you write safe, efficient, and maintainable C code.
Applicable scenarios:
- Projects generated using STM32CubeMX
- The entire ARM Cortex-M series (F0/F1/F3/F4/F7/H7/G0/L0/L4/L5, etc.)
- FreeRTOS v10+ versions
- Native FreeRTOS API or CMSIS-RTOS v2 API
Use Cases
Code Generation
- Create tasks, queues, semaphores, mutexes
- Write peripheral driver templates (UART DMA, ADC DMA, I2C etc.)
- Configure low-power Tickless mode
- Implement printf redirection (ITM_SendChar / UART)
Code Review
- Analyze whether task priority configuration is reasonable
- Check the correctness of interrupt and task interaction
- Troubleshoot deadlocks, priority inversion, and resource leaks
- Verify FreeRTOSConfig.h configuration
Teaching and Tutoring
- Explain core FreeRTOS concepts (task scheduling, context switching)
- Demonstrate design patterns such as producer-consumer and publish-subscribe
- Guide the use of debugging tools (SEGGER SystemView, TRACEalyzer)
Core Capability Modules
Task Management
- Create static/dynamic tasks (
xTaskCreate,xTaskCreateStatic) - Set priority, stack size, and task name
- Task status monitoring (
uxTaskGetStackHighWaterMark)
Inter-Task Communication
- Queue: producer-consumer model
- Semaphore: binary/counting
- Mutex: avoid race conditions, includes priority inheritance
- Event Groups: waiting for multiple conditions
- Task Notifications: lightweight alternative
Interrupt and Task Interaction
- Use in HAL callbacks
xQueueSendFromISR/vTaskNotifyGiveFromISR - Do not block in ISR, only send notifications
portYIELD_FROM_ISR(xHigherPriorityTaskWoken)usage
Peripheral Integration
- UART DMA + Queue: variable-length data reception (IDLE interrupt)
- ADC DMA + Task Notification: continuous sampling
- I2C master/slave mode: sensor communication
- TIM timer/PWM: periodic tasks
Memory and Performance Optimization
- Static allocation is recommended (avoid heap fragmentation)
- Estimate stack size reasonably
- Enable
configASSERT()andconfigCHECK_FOR_STACK_OVERFLOW - Use
configUSE_PREEMPTION = 1to improve real-time performance
Debugging and Diagnostics
- Generate task list printing code (
vTaskList) - SEGGER SystemView (Keil/IAR environment)
- Percep TRACEalyzer (FreeRTOS environment)
- ITM/SWO configuration and printf debugging
File Index
| Type | File | Description |
|---|---|---|
| Main file | SKILL.md | The only file automatically read by AI |
| User guide | USER_GUIDE.md | For user reading only, not read |
| API reference | REFERENCE/FREERTOS_API.md | FreeRTOS API syntax |
| API reference | REFERENCE/STD_LIBS.md | Standard library integration |
| API reference | REFERENCE/HAL_DRIVERS.md | HAL peripheral drivers |
| API reference | REFERENCE/DEBUG_TOOLS.md | Debugging tool configuration |
| Code example | EXAMPLES/BASIC.md | Basic component examples |
| Code example | EXAMPLES/DRIVERS.md | Peripheral driver templates |
| Code example | EXAMPLES/ADVANCED.md | Advanced applications |
| Design pattern | PATTERNS/DESIGN.md | Design patterns |
| Design pattern | PATTERNS/INTERRUPT.md | Interrupt best practices |
| Design pattern | PATTERNS/TRAPS.md | Common pitfalls |
Script Tools
freertos_config_check.py
Verify key FreeRTOSConfig.h configurations:
python scripts/freertos_config_check.py FreeRTOSConfig.h
Output in JSON format for easy CI integration.