PlatformIO 开发STM32 (Arduino框架)


PlatformIO 开发STM32 (Arduino框架)

创建项目

BoardSTM32F103C8(20k RAM.64k Flash)(Generic)

硬件接线及跳线

跳线

使用Jlink无需配置boot引脚

建议都默认为0,boot启动模式参考文档

硬件接线

JLINK STM32 Board
(Reset) (R)
(3.3v) (3.3v)
(SWCLK) (DCLK)
(SWDIO) (DIO)
(GND) (GND)

JLink驱动安装包及其手册

测试代码

platformio.ini
; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:genericSTM32F103C8]
platform = ststm32
board = genericSTM32F103C8
framework = arduino

; board_build.f_cpu = 72000000L

upload_protocol = jlink
main.cpp
/*
 * @Author: Dapenson
 * @Date: 2022-03-28 15:20:38
 * @LastEditors: Dapenson
 * @LastEditTime: 2022-03-28 16:36:05
 * @FilePath: \F103EnvTest\src\main.cpp
 * @Description:
 *
 * Copyright (c) 2022 by Dapenson, All Rights Reserved.
 */
#include 

const int ledPin = PC13;

void setup()
{
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}

void loop()
{
  digitalWrite(ledPin, HIGH); // turn the LED on (HIGH is the voltage level)
  delay(1000);                // wait for a second
  digitalWrite(ledPin, LOW);  // turn the LED off by making the voltage LOW
  delay(1000);                // wait for a second
  Serial.println("Done!");
}

参考教程

stm32开发新方式-platformio的IDE (smslit.cn)

PlatformIO IDE(VSCode) - stm32cube 框架的工程 - 知乎 (zhihu.com)

stm32开发新方式-platformio (smslit.cn)