README.md
1# The Arduino Compatible for STM32F410 Nucleo Board
2
3**English** | [中文](README_zh.md)
4
5## 1 RTduino - Arduino Ecosystem Compatibility Layer for RT-Thread
6
7STM32F410 Nucleo board has support [RTduino](https://github.com/RTduino/RTduino). Users can use Arduino APIs, third party libraries and programming method to program on the board.
8
9### 1.1 How to Enable RTduino
10
11Please go to the [RTduino repository](https://github.com/RTduino/RTduino) to see the details.
12
13```Kconfig
14Hardware Drivers Config --->
15 Onboard Peripheral Drivers --->
16 [*] Compatible with Arduino Ecosystem (RTduino)
17```
18
19# 2 Arduino Pinout
20
21
22
23This board complies with Arduino UNO pins layout. For more details, please take a look at: [pins_arduino.c](pins_arduino.c) and [pins_arduino.h](pins_arduino.h).
24
25| Arduino Pin | STM32 Pin | 5V Tolerate | Note |
26| --------------------- | --------- | ----------- | --------------------------------------------------------------------------------------------- |
27| 0 (D0) | PA3 | Yes | Serial-Rx. Token over by RT-Thread UART device by default |
28| 1 (D1) | PA2 | Yes | Serial-Tx. Token over by RT-Thread UART device by default |
29| 2 (D2) | PA10 | Yes | PWM1-CH3. Token over by RT-Thread PWM device by default |
30| 3 (D3) | PB3 | Yes | |
31| 4 (D4) | PB5 | Yes | |
32| 5 (D5) | PB4 | Yes | |
33| 6 (D6) | PB10 | Yes | |
34| 7 (D7) | PA8 | Yes | |
35| 8 (D8) | PA9 | Yes | PWM1-CH2. Token over by RT-Thread PWM device by default |
36| 9 (D9) | PC7 | Yes | |
37| 10 (D10) | PB6 | Yes | |
38| 11 (D11) | PA7 | Yes | PWM1-CH1N. Token over by RT-Thread PWM device by default |
39| 12 (D12) | PA6 | Yes | |
40| 13 (D13, LED_BUILTIN) | PA5 | Yes | USER LED |
41| 14 (D14) | PB9 | Yes | I2C-SDA. Token over by RT-Thread I2C device by default |
42| 15 (D15) | PB8 | Yes | I2C-SCL. Token over by RT-Thread I2C device by default |
43| 16 (D16) | PC13 | Yes | USER Button |
44| A0 | PA0 | Yes | ADC1-CH0. Token over by RT-Thread ADC device by default |
45| A1 | PA1 | Yes | ADC1-CH1. Token over by RT-Thread ADC device by default |
46| A2 | PA4 | Yes | ADC1-CH4. Token over by RT-Thread ADC device by default |
47| A3 | PB0 | Yes | ADC1-CH8. Token over by RT-Thread ADC device by default |
48| A4 | PC1 | Yes | ADC1-CH11. Token over by RT-Thread ADC device by default |
49| A5 | PC0 | Yes | ADC1-CH10. Token over by RT-Thread ADC device by default |
50| A6 | -- | | On-chip internal voltage sensor. ADC1-CH17. Token over by RT-Thread ADC device by default |
51| A7 | -- | | On-chip internal temperature sensor. ADC1-CH16. Token over by RT-Thread ADC device by default |
52
53> Notice:
54>
55> 1. Don't use a same hardware timer to drive PWM (analogRead) and servos at same time, because hardware timers can only generate a same frequency for 4 PWM channels. Otherwise, it could cause a failure when drive servos.
56
57> References
58>
59> 1. [STM32 Nucleo-64 user manual](https://www.st.com/resource/en/user_manual/um1724-stm32-nucleo64-boards-mb1136-stmicroelectronics.pdf)
60
61## 3 Communication
62
63### 3.1 I2C Bus
64
65I2C bus is `SCL/D15` and `SDA/D14` pins. Users can directly include the `#include <Wire.h>`, which is the Arduino official I2C header file, to use the I2C bus.
66
67### 3.2 SPI Bus
68
69This board doesn't support Arduino SPI header file and functions.
70
71### 3.3 Serial
72
73This board supports to use `Serial.` method to operate `uart2` device. See [example](https://github.com/RTduino/RTduino/blob/master/examples/Basic/helloworld.cpp).
74
README_zh.md
1# STM32F410 Nucleo开发板的Arduino生态兼容说明
2
3[English](README.md) | **中文**
4
5## 1 RTduino - RT-Thread的Arduino生态兼容层
6
7STM32F410 Nucleo开发板已经完整适配了[RTduino软件包](https://github.com/RTduino/RTduino),即RT-Thread的Arduino生态兼容层。用户可以按照Arduino的编程习惯来操作本BSP,并且可以使用大量Arduino社区丰富的库,是对RT-Thread生态的极大增强。更多信息,请参见[RTduino软件包说明文档](https://github.com/RTduino/RTduino)。
8
9### 1.1 如何开启针对本BSP的Arduino生态兼容层
10
11Env 工具下敲入 menuconfig 命令,或者 RT-Thread Studio IDE 下选择 RT-Thread Settings:
12
13```
14Hardware Drivers Config --->
15 Onboard Peripheral Drivers --->
16 [*] Compatible with Arduino Ecosystem (RTduino)
17```
18
19## 2 Arduino引脚排布
20
21
22
23该BSP遵照Arduino UNO板的引脚排列方式,详见 [pins_arduino.c](pins_arduino.c) 和 [pins_arduino.h](pins_arduino.h)。
24
25| Arduino引脚编号 | STM32引脚编号 | 5V容忍 | 备注 |
26| --------------------- | --------- | ---- | --------------------------------------------- |
27| 0 (D0) | PA3 | 是 | Serial-Rx,默认被RT-Thread的UART设备框架uart2接管 |
28| 1 (D1) | PA2 | 是 | Serial-Tx,默认被RT-Thread的UART设备框架uart2接管 |
29| 2 (D2) | PA10 | 是 | PWM1-CH3,默认被RT-Thread的PWM设备框架pwm1接管 |
30| 3 (D3) | PB3 | 是 | |
31| 4 (D4) | PB5 | 是 | |
32| 5 (D5) | PB4 | 是 | |
33| 6 (D6) | PB10 | 是 | |
34| 7 (D7) | PA8 | 是 | |
35| 8 (D8) | PA9 | 是 | PWM1-CH2,默认被RT-Thread的PWM设备框架pwm1接管 |
36| 9 (D9) | PC7 | 是 | |
37| 10 (D10) | PB6 | 是 | |
38| 11 (D11) | PA7 | 是 | PWM1-CH1N,默认被RT-Thread的PWM设备框架pwm1接管 |
39| 12 (D12) | PA6 | 是 | |
40| 13 (D13, LED_BUILTIN) | PA5 | 是 | 板载用户LED |
41| 14 (D14) | PB9 | 是 | I2C-SDA,默认被RT-Thread的I2C设备框架i2c1总线接管 |
42| 15 (D15) | PB8 | 是 | I2C-SCL,默认被RT-Thread的I2C设备框架i2c1总线接管 |
43| 16 (D16) | PC13 | 是 | 用户按键(左侧蓝色) |
44| A0 | PA0 | 是 | ADC1-CH0,默认被RT-Thread的ADC设备框架adc1接管 |
45| A1 | PA1 | 是 | ADC1-CH1,默认被RT-Thread的ADC设备框架adc1接管 |
46| A2 | PA4 | 是 | ADC1-CH4,默认被RT-Thread的ADC设备框架adc1接管 |
47| A3 | PB0 | 是 | ADC1-CH8,默认被RT-Thread的ADC设备框架adc1接管 |
48| A4 | PC1 | 是 | ADC1-CH11,默认被RT-Thread的ADC设备框架adc1接管 |
49| A5 | PC0 | 是 | ADC1-CH10,默认被RT-Thread的ADC设备框架adc1接管 |
50| A6 | -- | | 芯片内部参考电压 ADC1-CH17,默认被RT-Thread的ADC设备框架adc1接管 |
51| A7 | -- | | 芯片内部温度 ADC1-CH16,默认被RT-Thread的ADC设备框架adc1接管 |
52
53> 注意:
54>
55> 1. 驱动舵机和analogWrite函数要选择不同定时器发生的PWM信号引脚,由于STM32的定时器4个通道需要保持相同的频率,如果采用相同的定时器发生的PWM分别驱动舵机和analogWrite,可能会导致舵机失效。
56> 2. USART2是Nucleo板的默认串口,理论应对接到了Arduino引脚编号的D0和D1,但是其实际用于串口通信,因此不允许当做普通IO来使用和操作。如果需要将D0、D1与STM32 USART2的引脚相连,需要手动焊接锡桥SB62、SB63。
57> 3. Nucleo板的Arduino接口中AVDD(即AREF)默认是与VDD相连的,如果需要扩展板提供外部参考电压,需要将SB57锡桥挑开。
58> 4. D11引脚是PWM反相位引脚(互补输出引脚),但是这里不用考虑到占空比互补问题(CHx-20%,CHxN-80%),直接正常使用即可。
59
60> 参考资料
61>
62> 1. [STM32 Nucleo-64板用户手册](https://www.st.com/resource/en/user_manual/um1724-stm32-nucleo64-boards-mb1136-stmicroelectronics.pdf)
63
64## 3 通信
65
66### 3.1 I2C总线
67
68STM32F410 Nucleo板的I2C总线是板上丝印的 `SCL/D15` 和 `SDA/D14` 引脚,这两个引脚是被RT-Thread I2C设备框架接管的,不需要直接操控这两个引脚,直接引用`#include <Wire.h>`(Arduino官方I2C头文件)即可使用。
69
70### 3.2 SPI总线
71
72目前本BSP不支持使用Arduino的SPI功能。
73
74### 3.3 串口
75
76本BSP通过 `Serial.` 方法调用 `uart2` 串口设备。详见[例程](https://github.com/RTduino/RTduino/blob/master/examples/Basic/helloworld.cpp)。