让arduino 把你的无用的stm32板子玩起来 之一
[复制链接]
本帖最后由 damiaa 于 2020-12-31 13:01 编辑
让arduino 把你的无用的stm32板子玩起来 之一
1,环境很重要 下载安装1.8.13.
2,文件==》首选项=》附加开发板管理网址加入
https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json 记得莫覆盖前面加入过的。加入单独一行这样就可以不去掉以前加入的
3,工具==》开发板==》开发板管理器==》输入stm32 看到如下图的stm32的支持包。安装请耐心,有时候不成功 多试几次。
4,这个时候就OK了
5,拿块板子个点灯。记得stm32的所有板子基本都可以!!!不过最新的不一定 切记!!!
int led2 = 48;
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(led2, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(led2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led2, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
6,燃后设置芯片板子类型,芯片类型,烧写方式 比如我的是stm32F030R8的 discovery板子 就选 discovery stm32F030R8 swd烧写。编译上传就OK
7,记得去查找你的IO口在这个目录的这个文件: 这个可以找到你的板子的IO对应
C:\Users\zz\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\variants\DISCO_F030R8\
variant.h
// P1 connector Right side (bottom view)
#define PC13 0
#define PC14 1
#define PC15 2
#define PF0 3
#define PF1 4
#define PC0 A0
#define PC1 A1
#define PC2 A2
#define PC3 A3
#define PA0 A4 // USER_BTN
#define PA1 A5
#define PA2 A6
#define PA3 A7
#define PF4 13
#define PF5 14
#define PA4 A8
#define PA5 A9
#define PA6 A10
#define PA7 A11
#define PC4 A12
#define PC5 A13
#define PB0 A14
#define PB1 A15
#define PB2 23
#define PB10 24
#define PB11 25
#define PB12 26
// P2 connector Left side (bottom view)
#define PB9 27
#define PB8 28
#define PB7 29
#define PB6 30
#define PB5 31
#define PB4 32
#define PB3 33
#define PD2 34
#define PC12 35
#define PC11 36
#define PC10 37
#define PA15 38
#define PA14 39
#define PF7 40
#define PF6 41
#define PA13 42
#define PA12 43
#define PA11 44
#define PA10 45
#define PA9 46
#define PA8 47
#define PC9 48 // LED_GREEN (LD3)
#define PC8 49 // LED_BLUE (LD4)
#define PC7 50
#define PC6 51
#define PB15 52
#define PB14 53
#define PB13 54
// This must be a literal
#define NUM_DIGITAL_PINS 71
// This must be a literal with a value less than or equal to to MAX_ANALOG_INPUTS
#define NUM_ANALOG_INPUTS 16
//On-board LED pin number
#define LED_BUILTIN PC9 // LD3
#define LED_GREEN LED_BUILTIN
#define LED_BLUE PC8 // LD4
//On-board user button
#define USER_BTN PA0
// SPI definitions
// SPI1 is used
#define PIN_SPI_SS PA4
#define PIN_SPI_SS1 PC4
#define PIN_SPI_SS2 PB12
#define PIN_SPI_SS3 PC6
#define PIN_SPI_MOSI PA7
#define PIN_SPI_MISO PA6
#define PIN_SPI_SCK PA5
// I2C Definitions
// I2C1 is used
#define PIN_WIRE_SDA PB9
#define PIN_WIRE_SCL PB8
// Timer Definitions
// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin
#define TIMER_TONE TIM6
#define TIMER_SERVO TIM14
// UART Definitions
#define SERIAL_UART_INSTANCE 1 // USART 1
// Mandatory for Firmata
#define PIN_SERIAL_RX PA10
#define PIN_SERIAL_TX PA9
#ifdef __cplusplus
} // extern "C"
#endif
|