MIT License

技术解读

以下内容由 GitRead 中文社区 编辑团队基于项目 README 与官方资料整理, 结合中文开发者的常见使用场景补充技术选型建议。具体以项目官方文档为准。

深度技术分析:miniwinwm/BluePillDemo

项目背景与痛点

这个项目的背景在于对 STM32CubeIDE 工具链下的 Blue Pill 板进行软件程序实验。Blue Pill 作为 STM32F103C 系列的低成本开发板,其广泛应用于初级嵌入式开发项目中。然而,实际应用时,开发者面临的主要痛点是缺乏成熟的开发示例和组件库支持。miniwinwm/BluePillDemo 项目应运而生,提供了一系列精心设计的小型项目模板,以帮助开发者快速上手和搭建嵌入式应用。

核心技术揭秘

该项目的核心在于提供了一套经过优化的 STM32CubeIDE 开发环境下的项目模板,这些模板针对 Blue Pill 板尤其进行了调试和优化。STM32CubeIDE 提供了大量的底层驱动和 HAL 库支持,而项目则基于这些底层支持,搭建了几个具体的应用样例。

具体的开发流程大致如下:

  1. 环境搭建:在 STM33CubeIDE 中配置目标硬件、选择编译器、解决库依赖等。
  2. 项目模板初始化:将 Blue Pill 板的初始化配置、时钟配置、GPIO 设定等汇集成一系列可复用的代码模板。
  3. 功能实现:例如 LED 闪烁、按键检测等基础的实验项目,这些样例被进一步扩展,以支持更多实际应用。

下面是一个简化后的系统架构图,表明项目的主要工作流程:

graph TD A[环境搭建] --> B[配置硬件] B --> C[初始化模板] C --> D[功能实现] D --> E[生成镜像] E --> F[下载调试]

每个模板都预先设定好硬件相关的初始化步骤,从序列图中可以看出,从环境搭建到生成最终的固件镜像,每个步骤都经过了精心设计以降低开发者的学习成本。

功能亮点与差异

miniwinwm/BluePillDemo 项目区别于其他物理应用案例的主要亮点在于其对 GPIO、定时器等功能模块细致的集成优化,使得开发者可以直接复用这些模块,大幅节省项目开发时间。同时,每个样例代码段都附有详细的注释,这在应对资源紧张的开发场景时显得尤为重要。

应用场景与落地建议

由于 Blue Pill 板通常用于入门级嵌入式开发,因此它的主要应用场景是教育训练、创客项目和初级工程开发。在实际的生产环境中使用时,开发者需要特别注意硬件资源配置的合理性及稳定性。代码部分在某些情况下可能会出现与时钟、中断相关的 Minor Bug,建议在部署前充分验证各功能模块的稳定性。

综合评价

  • 优点:对于初学者友好,提供了多个成熟的项目模板;底码高度优化,可以大大节省开发时间。
  • 缺点:由于已经是最后一个版本,项目不再更新,新的硬件配置和库文件的支持需自行对应。

miniwinwm/BluePillDemo 为嵌入式开发者提供了一条快速搭建项目的捷径,它的出现大大降低了开发的门槛,对于想要进入嵌入式领域的开发者,这是一个完美的起点。

关于

GitHub 原始描述(英文)

A collection of small example projects tailored for the Blue Pill board created in STM32CubeIDE. No further updates.

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
272
价值分
110
活跃状态
活跃

语言占比

Assembly
C
HTML
JavaScript

README

BluePillDemo

The Blue Pill is a very cheap bare bones development board containing a STM32F103C8 ARM Coretex M3 processor with 64 kBytes of flash and 20 kBytes of RAM. This makes it an excellent piece of hardware to get into professional standard embedded programming on an ARM microcontroller on the cheap. There are many examples of how to get started with this board available but almost all of them use the Arduino environment. While this is fine, and an easy way to start embedded programming, it has its limitations. The Arduino way shelters you from getting close to the processor with an easy to use interface. This restricts what you can do in the code and makes it inefficient. Because of this the Arduino environment is almost never used professionally in industry. For anyone looking to make a career of embedded development it is necessary to move on.

The manufacturer of the processor on the Blue Pill board, ST, provide a compiler/IDE environment that is widely used in industry. The latest incarnation is called STM32CubeIDE and is a free unrestricted download from ST. However, it is a daunting bit of software supporting a huge range of processors and all their capabilities and is not easy at all to get going with. To help this process this repo contains a collection of small projects that can be directly imported into STM32CubeIDE.

Are you fed up with searching the internet for example code that is poorly written, full of messy commented out code, doesn’t build, doesn’t work or is cluttered with all sort of guff that hides what you are trying to find out to do? Me too. Therefore these projects start off at the lowest level being SIMPLE. The lowest level projects shows how to configure and then exercise one (usually!) peripheral on the processor. Then moving on there are some common simple driver examples that exercise the peripherals, like I2C, UART or SPI, by communicating with external devices. There are projects that integrate FreeRTOS, at the lowest level doing only that and nothing else, to keep that as simple as possible. Then there are projects that integrate FreeRTOS with peripheral drivers like the 16x2 HD44780 text display or third party middleware like the FatFS library. At the highest level are the SIM800L modem examples (these incorporate drivers (GPIO and UART), FreeRTOS, middleware (the modem driver), application code (MQTT library) and html and javascript running on a webserver) and the MAX30102 pulse oximeter with graphical display project.

Another bugbear of internet sourced example embedded code is that it’s often just the code and you are left clueless on how to wire up the hardware to run it. These projects all have a schematic where components external to the Blue Pill board are used.

In the project there is a readme file describing the project, a circuit diagram if required and the STM32CubeIDE hardware configuration file that is used to set up the processor’s hardware and any peripheral used (.ioc file). The example code then makes calls into ST’s HAL library to operate the peripheral.

Once the code is built, flashing and debugging needs a ST-LINK device connected to the Serial Wire 4 pin header at the end of the Blue Pill board. These are cheaply available on ebay for a few £€$, sometimes supplied together with a Blue Pill board. You need 4 female to female jumper cables to connect the two. Note: The ST-LINK v2 debugger will not connect to Blue Pill boards with fake processors on them. Some Blue Pill boards are supplied with non-genuine or cloned STM32F103C8T6 processors.

Any requests can be added as an issue to this repo. I’ll create a project if I have time and the extra hardware is not too expensive for me to buy.

The Seatalk projects are only of interest for interfacing with the Seatalk marine data network.

Creating a new Blue Pill project

A brief explanation of how to create a new project for the Blue Pill board in STM32CubeIDE using a ST-LINK device for flashing/debugging is shown below:

File|New|STM32 Project

In Target Selection type STM32F103C8 in Part Number Search

Select this processor when it is listed on the right, Next

Enter Project Name, select C++ if you need it, leave other selections default, Finish

In ‘Project Name’.ioc editor Select Pinout & Configuration tab

In Pinout & Configuration choose Categories then expand System Core then select SYS

Under Debug select Serial Wire

In System Core select RCC

In both High Speed Clock (HSE) and Low Speed Clock (LSE) select Crystal/Ceramic Resonator

Select Clock Configuration Tab

In System Clock Mux select PLLCLK

In PLL Source Mux select HSE

In PLLMul select X9

In APB1 Prescalar select /2

For projects using USB, ADC or RTC further clock configuration is required. See example projects.

评论

暂无评论