这是一个基于 sloop 框架的 STM32G030K8T6 演示板 LED 控制示例。本项目展示了如何使用 sloop 框架和 flow 工作流机制来实现 LED 的控制和交互。
- 主控:STM32G030K8T6
- 内存:8KB RAM
- Flash:64KB Flash
- 用户输入:1个用户按键、1个振动开关
- 用户输出:3个用户LED
- 系统控制:1个复位按钮
- 状态指示:1个电源指示灯
- 调试接口:SWD调试接口
- 供电方式:Type-C接口供电
sloop 是一个轻量级的嵌入式任务调度框架,采用单线程协作式调度模型。它通过"互斥主任务 + 并行回调 + 软件定时器"构建执行模型,提供了丰富的任务管理功能,同时保持极低的资源消耗。
flow 是基于 sloop 框架的协作式工作流编程机制,通过宏定义构建可挂起的执行体,实现类似协程的断点续执行能力。它采用线性代码结构,使复杂业务逻辑更加清晰易读。
本示例展示了如何使用 sloop 框架和 flow 工作流机制来控制板载 LED,实现以下功能:
- LED 流星灯效果:主要演示功能
- 按键:作为用户拓展接口
- 振动开关:作为用户拓展接口
- 通过 RTT 输出运行日志
├── project/ # 项目文件
│ ├── Core/ # 核心系统文件
│ ├── Drivers/ # STM32 HAL和CMSIS库
│ ├── MDK-ARM/ # Keil项目文件
│ └── user/ # 用户应用代码
│ ├── app/ # 应用层
│ │ ├── config/ # 配置文件
│ │ └── tasks/ # 任务实现
│ └── sloop/ # 框架核心
│ ├── RTT/ # SEGGER RTT库
│ └── kernel/ # 内核实现
├── resource/ # 资源文件
│ ├── 3d view.png # 板子3D视图
│ ├── Schematic.png # 原理图
│ ├── led demo.mp4 # LED Demo运行视频
│ └── rtt log.png # RTT运行日志
├── LICENSE # 许可证文件
└── README.md # 项目文档
- 安装 Keil MDK-ARM 5.x+
- 安装 STM32G0 系列支持包
- 克隆或下载本项目
- 使用 Keil MDK 打开
project/MDK-ARM/project.uvprojx
- 选择目标设备(STM32G030K8Tx)
- 配置编译选项
- 点击编译按钮(F7)
- 生成的固件位于
project/MDK-ARM/bin/project.hex
- 使用 SWD 调试器连接开发板
- 烧录编译生成的固件
- 观察 LED 运行效果
- 使用 J-Link RTT Viewer 查看运行日志
LED 控制任务负责管理板载 LED 的状态,实现流星灯效果和状态变化。
展示如何使用 flow 工作流机制实现复杂的 LED 控制逻辑,包括状态管理和事件处理。
- 轻量级:sloop 框架资源消耗低,适合资源受限的微控制器
- 易用性:简洁直观的 API 设计,支持协作式工作流编程
- 可扩展性:模块化设计,便于功能扩展
- 实时性:高效的任务调度算法,保证实时响应
本项目采用 MIT 许可证,详见 LICENSE 文件。
如有问题或建议,欢迎提交 Issue 或 Pull Request。
This is an LED control example based on the sloop framework for the STM32G030K8T6 demo board. This project demonstrates how to use the sloop framework and flow workflow mechanism to implement LED control and interaction.
- Main Control: STM32G030K8T6
- RAM: 8KB RAM
- Flash: 64KB Flash
- User Input: 1 user button, 1 vibration switch
- User Output: 3 user LEDs
- System Control: 1 reset button
- Status Indication: 1 power indicator
- Debug Interface: SWD debug interface
- Power Supply: Type-C interface
sloop is a lightweight embedded task scheduling framework that adopts a single-threaded cooperative scheduling model. It builds an execution model through "mutex main task + parallel callback + software timer", providing rich task management functions while maintaining extremely low resource consumption.
flow is a cooperative workflow programming mechanism based on the sloop framework. It builds suspendable execution units through macro definitions, achieving coroutine-like breakpoint continuation capabilities. It adopts a linear code structure, making complex business logic clearer and easier to read.
This example demonstrates how to use the sloop framework and flow workflow mechanism to control on-board LEDs, implementing the following features:
- LED Meteor Light Effect: Main demonstration feature
- Button: As user expansion interface
- Vibration Switch: As user expansion interface
- RTT Log Output
├── project/ # Project files
│ ├── Core/ # Core system files
│ ├── Drivers/ # STM32 HAL and CMSIS libraries
│ ├── MDK-ARM/ # Keil project files
│ └── user/ # User application code
│ ├── app/ # Application layer
│ │ ├── config/ # Configuration files
│ │ └── tasks/ # Task implementations
│ └── sloop/ # Framework core
│ ├── RTT/ # SEGGER RTT library
│ └── kernel/ # Kernel implementation
├── resource/ # Resource files
│ ├── 3d view.png # Board 3D view
│ ├── Schematic.png # Schematic
│ ├── led demo.mp4 # LED Demo running video
│ └── rtt log.png # RTT running log
├── LICENSE # License file
└── README.md # Project documentation
- Install Keil MDK-ARM 5.x+
- Install STM32G0 series support package
- Clone or download this project
- Open
project/MDK-ARM/project.uvprojxusing Keil MDK
- Select the target device (STM32G030K8Tx)
- Configure compilation options
- Click the compile button (F7)
- The generated firmware is located at
project/MDK-ARM/bin/project.hex
- Connect the development board using SWD debugger
- Flash the compiled firmware
- Observe the LED running effects
- Use J-Link RTT Viewer to view running logs
The LED control task is responsible for managing the state of on-board LEDs, implementing meteor light effects and state changes.
Detect state changes of user buttons and vibration switches through interrupts, and trigger corresponding LED control logic.
Demonstrate how to use the flow workflow mechanism to implement complex LED control logic, including state management and event handling.
- Lightweight: sloop framework has low resource consumption, suitable for resource-constrained microcontrollers
- Ease of Use: Simple and intuitive API design, supporting cooperative workflow programming
- Extensibility: Modular design for easy function expansion
- Real-time Performance: Efficient task scheduling algorithm to ensure real-time response
This project adopts the MIT license, please refer to the LICENSE file for details.
If you have any questions or suggestions, please feel free to submit Issues or Pull Requests.


