[rtduino]重新整理pinout (#6445)
* [rtduino][stm32l475-pandora] 重新整理pinout * [rtduino][bluepill] 整理pinout * [rtduino][stm32-f401nucleo]整理pinout * [rtduino][stm32-pandora] 整理pinout * [rtduino][stm32f072]整理pinout
This commit is contained in:
parent
d1c66d0e30
commit
8d3c1f7008
|
@ -22,8 +22,8 @@ Hardware Drivers Config --->
|
|||
|
||||
| Arduino引脚编号 | STM32引脚编号 | 5V容忍 | 备注 |
|
||||
| ----------- | --------- | ---- | -------------------------------------- |
|
||||
| 0 (D0) | PA3 | 否 | 默认为串口RX引脚,不建议当做普通IO |
|
||||
| 1 (D1) | PA2 | 否 | 默认为串口TX引脚,不建议当做普通IO |
|
||||
| 0 (D0) | PA3 | 否 | Serial-Rx,默认被RT-Thread的UART设备框架uart2接管 |
|
||||
| 1 (D1) | PA2 | 否 | Serial-tx,默认被RT-Thread的UART设备框架uart2接管 |
|
||||
| 2 (D2) | PA10 | 是 | |
|
||||
| 3 (D3) | PB3 | 是 | PWM(定时器2发生) |
|
||||
| 4 (D4) | PB5 | 是 | |
|
||||
|
@ -59,6 +59,16 @@ Hardware Drivers Config --->
|
|||
>
|
||||
> 【1】[STM32 Nucleo板官方手册](https://www.st.com/resource/en/user_manual/um1724-stm32-nucleo64-boards-mb1136-stmicroelectronics.pdf)
|
||||
|
||||
## 3 I2C总线
|
||||
## 3 通信
|
||||
|
||||
### 3.1 I2C总线
|
||||
|
||||
STM32F072 Nucleo板的I2C总线是板上丝印的 `SCL/D15` 和 `SDA/D14` 引脚,这两个引脚默认是被RT-Thread I2C设备框架接管的,直接引用`#include <Wire.h>`(Arduino官方I2C头文件)即可使用。
|
||||
|
||||
### 3.2 SPI总线
|
||||
|
||||
目前本BSP不支持使用Arduino的SPI功能。
|
||||
|
||||
### 3.3 串口
|
||||
|
||||
本BSP通过 `Serial.` 方法调用 `uart2` 串口设备。详见[例程](https://github.com/RTduino/RTduino/blob/master/examples/Basic/helloworld.cpp)。
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
* Copyright (c) 2006-2022, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
|
@ -7,42 +7,43 @@
|
|||
* Date Author Notes
|
||||
* 2021-12-10 Meco Man first version
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <board.h>
|
||||
#include "pins_arduino.h"
|
||||
|
||||
/*
|
||||
{Arduino Pin, RT-Thread Pin [, Device Name(PWM or ADC), Channel]}
|
||||
[] means optional
|
||||
Digital pins must NOT give the device name and channel.
|
||||
Analog pins MUST give the device name and channel(ADC, PWM or DAC).
|
||||
Arduino Pin must keep in sequence.
|
||||
*/
|
||||
* {Arduino Pin, RT-Thread Pin [, Device Name, Channel]}
|
||||
* [] means optional
|
||||
* Digital pins must NOT give the device name and channel.
|
||||
* Analog pins MUST give the device name and channel(ADC, PWM or DAC).
|
||||
* Arduino Pin must keep in sequence.
|
||||
*/
|
||||
const pin_map_t pin_map_table[]=
|
||||
{
|
||||
{D0, GET_PIN(A,3), "uart2"}, /* UART2-RX */
|
||||
{D1, GET_PIN(A,2), "uart2"}, /* UART2-TX */
|
||||
{D0, GET_PIN(A,3), "uart2"}, /* Serial-Rx */
|
||||
{D1, GET_PIN(A,2), "uart2"}, /* Serial-Tx */
|
||||
{D2, GET_PIN(A,10)},
|
||||
{D3, GET_PIN(B,3), "pwm2", 2}, /* PWM */
|
||||
{D3, GET_PIN(B,3), "pwm2", 2}, /* PWM */
|
||||
{D4, GET_PIN(B,5)},
|
||||
{D5, GET_PIN(B,4), "pwm3", 1}, /* PWM */
|
||||
{D6, GET_PIN(B,10), "pwm2", 3}, /* PWM */
|
||||
{D5, GET_PIN(B,4), "pwm3", 1}, /* PWM */
|
||||
{D6, GET_PIN(B,10), "pwm2", 3}, /* PWM */
|
||||
{D7, GET_PIN(A,8)},
|
||||
{D8, GET_PIN(A,9)},
|
||||
{D9, GET_PIN(C,7), "pwm3", 2}, /* PWM */
|
||||
{D10, GET_PIN(B,6), "pwm16", -1}, /* PWM16 CH1N */
|
||||
{D11, GET_PIN(A,7), "pwm17", 1}, /* PWM */
|
||||
{D9, GET_PIN(C,7), "pwm3", 2}, /* PWM */
|
||||
{D10, GET_PIN(B,6), "pwm16", -1}, /* PWM */
|
||||
{D11, GET_PIN(A,7), "pwm17", 1}, /* PWM */
|
||||
{D12, GET_PIN(A,6)},
|
||||
{D13, GET_PIN(A,5)},
|
||||
{D14, GET_PIN(B,9), "i2c1"}, /* I2C1-SDA */
|
||||
{D15, GET_PIN(B,8), "i2c1"}, /* I2C1-SCL */
|
||||
{D16, GET_PIN(C,13)}, /* user button */
|
||||
{A0, GET_PIN(A,0), "adc1", 0}, /* ADC */
|
||||
{A1, GET_PIN(A,1), "adc1", 1}, /* ADC */
|
||||
{A2, GET_PIN(A,4), "adc1", 4}, /* ADC */
|
||||
{A3, GET_PIN(B,0), "adc1", 8}, /* ADC */
|
||||
{A4, GET_PIN(C,1), "adc1", 11}, /* ADC */
|
||||
{A5, GET_PIN(C,0), "adc1", 10}, /* ADC */
|
||||
{A6, RT_NULL, "adc1", 17}, /* ADC, On-Chip: internal reference voltage, ADC_CHANNEL_VREFINT */
|
||||
{A7, RT_NULL, "adc1", 16} /* ADC, On-Chip: internal temperature sensor, ADC_CHANNEL_TEMPSENSOR */
|
||||
{D13, GET_PIN(A,5)}, /* LED_BUILTIN */
|
||||
{D14, GET_PIN(B,9), "i2c1"}, /* I2C-SDA (Wire) */
|
||||
{D15, GET_PIN(B,8), "i2c1"}, /* I2C-SCL (Wire) */
|
||||
{D16, GET_PIN(C,13)},
|
||||
{A0, GET_PIN(A,0), "adc1", 0}, /* ADC */
|
||||
{A1, GET_PIN(A,1), "adc1", 1}, /* ADC */
|
||||
{A2, GET_PIN(A,4), "adc1", 4}, /* ADC */
|
||||
{A3, GET_PIN(B,0), "adc1", 8}, /* ADC */
|
||||
{A4, GET_PIN(C,1), "adc1", 11}, /* ADC */
|
||||
{A5, GET_PIN(C,0), "adc1", 10}, /* ADC */
|
||||
{A6, RT_NULL, "adc1", 17}, /* ADC, On-Chip: internal reference voltage, ADC_CHANNEL_VREFINT */
|
||||
{A7, RT_NULL, "adc1", 16}, /* ADC, On-Chip: internal temperature sensor, ADC_CHANNEL_TEMPSENSOR */
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
* Copyright (c) 2006-2022, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
|
@ -12,35 +12,37 @@
|
|||
#define Pins_Arduino_h
|
||||
|
||||
/* pins alias. Must keep in sequence */
|
||||
#define D0 (0)
|
||||
#define D1 (1)
|
||||
#define D2 (2)
|
||||
#define D3 (3)
|
||||
#define D4 (4)
|
||||
#define D5 (5)
|
||||
#define D6 (6)
|
||||
#define D7 (7)
|
||||
#define D8 (8)
|
||||
#define D9 (9)
|
||||
#define D10 (10)
|
||||
#define D11 (11)
|
||||
#define D12 (12)
|
||||
#define D13 (13)
|
||||
#define D14 (14)
|
||||
#define D15 (15)
|
||||
#define D16 (16)
|
||||
#define A0 (17)
|
||||
#define A1 (18)
|
||||
#define A2 (19)
|
||||
#define A3 (20)
|
||||
#define A4 (21)
|
||||
#define A5 (22)
|
||||
#define A6 (23)
|
||||
#define A7 (24)
|
||||
#define D0 (0)
|
||||
#define D1 (1)
|
||||
#define D2 (2)
|
||||
#define D3 (3)
|
||||
#define D4 (4)
|
||||
#define D5 (5)
|
||||
#define D6 (6)
|
||||
#define D7 (7)
|
||||
#define D8 (8)
|
||||
#define D9 (9)
|
||||
#define D10 (10)
|
||||
#define D11 (11)
|
||||
#define D12 (12)
|
||||
#define D13 (13)
|
||||
#define D14 (14)
|
||||
#define D15 (15)
|
||||
#define D16 (16)
|
||||
#define A0 (17)
|
||||
#define A1 (18)
|
||||
#define A2 (19)
|
||||
#define A3 (20)
|
||||
#define A4 (21)
|
||||
#define A5 (22)
|
||||
#define A6 (23)
|
||||
#define A7 (24)
|
||||
|
||||
#define F_CPU 48000000L /* CPU: 48MHz */
|
||||
#define LED_BUILTIN D13 /* Default Built-in LED */
|
||||
#define F_CPU 48000000L /* CPU:48MHz */
|
||||
|
||||
#define RTDUINO_DEFAULT_IIC_BUS_NAME "i2c1"
|
||||
#define LED_BUITIN D13 /* Default Built-in LED */
|
||||
|
||||
/* i2c1 - PB9-SDA PB8-SCL */
|
||||
#define RTDUINO_DEFAULT_IIC_BUS_NAME "i2c1"
|
||||
|
||||
#endif /* Pins_Arduino_h */
|
||||
|
|
|
@ -20,42 +20,42 @@ Hardware Drivers Config --->
|
|||
|
||||
![blue-pill-f103-pinout](blue-pill-f103-pinout.jpg)
|
||||
|
||||
| Arduino Pin | STM32 Pin | 5V Tolerate | 备注 |
|
||||
| ----------- | --------- | ----------- | ----------------------------------------------------------------------------------------------------------- |
|
||||
| 0 (D0) | PB7 | Yes | |
|
||||
| 1 (D1) | PB6 | Yes | |
|
||||
| 2 (D2) | PB5 | No | PWM3-CH2. Token over by RT-Thread PWM device by default |
|
||||
| 3 (D3) | PB4 | Yes | PWM3-CH1. Token over by RT-Thread PWM device by default |
|
||||
| 4 (D4) | PB3 | Yes | PWM2-CH2. Token over by RT-Thread PWM device by default |
|
||||
| 5 (D5) | PA15 | Yes | PWM2-CH1. Token over by RT-Thread PWM device by default |
|
||||
| 6 (D6) | PA8 | Yes | |
|
||||
| 7 (D7) | PB12 | Yes | |
|
||||
| 8 (D8) | PC13 | No | |
|
||||
| 9 (D9) | PC14 | No | |
|
||||
| 10 (D10) | PC15 | No | |
|
||||
| 11 (D11) | PA0 | No | |
|
||||
| 12 (D12) | PB0 | No | PWM3-CH3. Token over by RT-Thread PWM device by default |
|
||||
| 13 (D13) | PB1 | No | PWM3-CH4. Token over by RT-Thread PWM device by default |
|
||||
| 14 (D14) | PB9 | Yes | I2C-SDA. Token over by RT-Thread I2C device by default |
|
||||
| 15 (D15) | PB8 | Yes | I2C-SCL. Token over by RT-Thread I2C device by default |
|
||||
| 16 (D16) | PA12 | Yes | USB-DP. Token over by [TinyUSB](https://github.com/RT-Thread-packages/tinyusb) software package by default. |
|
||||
| 17 (D17) | PA11 | Yes | USB-DM. Token over by [TinyUSB](https://github.com/RT-Thread-packages/tinyusb) software package by default. |
|
||||
| 18 (D18) | PA10 | Yes | UART1-RX. Token over by RT-Thread UART device by default |
|
||||
| 19 (D19) | PA9 | Yes | UART1-TX. Token over by RT-Thread UART device by default |
|
||||
| 20 (D20) | PA2 | No | UART2-TX. Token over by RT-Thread UART device by default |
|
||||
| 21 (D21) | PA3 | No | UART2-RX. Token over by RT-Thread UART device by default |
|
||||
| 22 (D22) | PB10 | Yes | UART3-TX. Token over by RT-Thread UART device by default |
|
||||
| 23 (D23) | PB11 | Yes | UART3-RX. Token over by RT-Thread UART device by default |
|
||||
| 24 (D24) | PB15 | Yes | SPI-MOSI. Token over by RT-Thread SPI device by default |
|
||||
| 25 (D25) | PB14 | Yes | SPI-MISO. Token over by RT-Thread SPI device by default |
|
||||
| 26 (D26) | PB13 | Yes | SPI-SCK. Token over by RT-Thread SPI device by default |
|
||||
| 27 (A0) | PA1 | No | ADC1-CH1. Token over by RT-Thread ADC device by default |
|
||||
| 28 (A1) | PA4 | No | ADC1-CH4. Token over by RT-Thread ADC device by default |
|
||||
| 29 (A2) | PA5 | No | ADC1-CH5. Token over by RT-Thread ADC device by default |
|
||||
| 30 (A3) | PA6 | No | ADC1-CH6. Token over by RT-Thread ADC device by default |
|
||||
| 31 (A4) | PA7 | No | ADC1-CH7. Token over by RT-Thread ADC device by default |
|
||||
| 32 (A5) | -- | | ADC of chip internal reference voltage. Token over by RT-Thread ADC device by default |
|
||||
| 33 (A6) | -- | | ADC of chip internal temperature. Token over by RT-Thread ADC device by default |
|
||||
| Arduino Pin | STM32 Pin | 5V Tolerate | 备注 |
|
||||
| ------------------- | --------- | ----------- | ----------------------------------------------------------------------------------------------------------- |
|
||||
| 0 (D0) | PB7 | Yes | |
|
||||
| 1 (D1) | PB6 | Yes | |
|
||||
| 2 (D2) | PB5 | No | PWM3-CH2. Token over by RT-Thread PWM device by default |
|
||||
| 3 (D3) | PB4 | Yes | PWM3-CH1. Token over by RT-Thread PWM device by default |
|
||||
| 4 (D4) | PB3 | Yes | PWM2-CH2. Token over by RT-Thread PWM device by default |
|
||||
| 5 (D5) | PA15 | Yes | PWM2-CH1. Token over by RT-Thread PWM device by default |
|
||||
| 6 (D6) | PA8 | Yes | |
|
||||
| 7 (D7, SS) | PB12 | Yes | SPI chip select by default |
|
||||
| 8 (D8, LED_BUILTIN) | PC13 | No | Build-in LED |
|
||||
| 9 (D9) | PC14 | No | |
|
||||
| 10 (D10) | PC15 | No | |
|
||||
| 11 (D11) | PA0 | No | |
|
||||
| 12 (D12) | PB0 | No | PWM3-CH3. Token over by RT-Thread PWM device by default |
|
||||
| 13 (D13) | PB1 | No | PWM3-CH4. Token over by RT-Thread PWM device by default |
|
||||
| 14 (D14) | PB9 | Yes | I2C-SDA. Token over by RT-Thread I2C device by default |
|
||||
| 15 (D15) | PB8 | Yes | I2C-SCL. Token over by RT-Thread I2C device by default |
|
||||
| 16 (D16) | PA12 | Yes | USB-DP. Token over by [TinyUSB](https://github.com/RT-Thread-packages/tinyusb) software package by default. |
|
||||
| 17 (D17) | PA11 | Yes | USB-DM. Token over by [TinyUSB](https://github.com/RT-Thread-packages/tinyusb) software package by default. |
|
||||
| 18 (D18) | PA10 | Yes | Serial-Rx. Token over by RT-Thread UART device by default |
|
||||
| 19 (D19) | PA9 | Yes | Serial-Tx. Token over by RT-Thread UART device by default |
|
||||
| 20 (D20) | PA2 | No | Serial2-Tx. Token over by RT-Thread UART device by default |
|
||||
| 21 (D21) | PA3 | No | Serial2-Rx. Token over by RT-Thread UART device by default |
|
||||
| 22 (D22) | PB10 | Yes | Serial3-Tx. Token over by RT-Thread UART device by default |
|
||||
| 23 (D23) | PB11 | Yes | Serial3-Rx. Token over by RT-Thread UART device by default |
|
||||
| 24 (D24) | PB15 | Yes | SPI-MOSI. Token over by RT-Thread SPI device by default |
|
||||
| 25 (D25) | PB14 | Yes | SPI-MISO. Token over by RT-Thread SPI device by default |
|
||||
| 26 (D26) | PB13 | Yes | SPI-SCK. Token over by RT-Thread SPI device by default |
|
||||
| 27 (A0) | PA1 | No | ADC1-CH1. Token over by RT-Thread ADC device by default |
|
||||
| 28 (A1) | PA4 | No | ADC1-CH4. Token over by RT-Thread ADC device by default |
|
||||
| 29 (A2) | PA5 | No | ADC1-CH5. Token over by RT-Thread ADC device by default |
|
||||
| 30 (A3) | PA6 | No | ADC1-CH6. Token over by RT-Thread ADC device by default |
|
||||
| 31 (A4) | PA7 | No | ADC1-CH7. Token over by RT-Thread ADC device by default |
|
||||
| 32 (A5) | -- | | ADC of chip internal reference voltage. Token over by RT-Thread ADC device by default |
|
||||
| 33 (A6) | -- | | ADC of chip internal temperature. Token over by RT-Thread ADC device by default |
|
||||
|
||||
> Note:
|
||||
>
|
||||
|
@ -75,3 +75,7 @@ SPI bus is `D24`, `D25` and `D26` pins. Users can directly include the `#include
|
|||
### 3.3 USB
|
||||
|
||||
This board supports USB virtual COM by default. See [example](https://github.com/RTduino/RTduino/tree/master/examples/USBSerial).
|
||||
|
||||
### 3.4 Serial
|
||||
|
||||
This board supports to use `Serail.` method to use `uart1` device; use `Serial2.` method to use `uart2` device; use `Serial3.` method to use `uart3` device. See [example](https://github.com/RTduino/RTduino/blob/master/examples/Basic/helloworld.cpp).
|
||||
|
|
|
@ -20,42 +20,42 @@ Hardware Drivers Config --->
|
|||
|
||||
![blue-pill-f103-pinout](blue-pill-f103-pinout.jpg)
|
||||
|
||||
| Arduino引脚编号 | STM32引脚编号 | 5V容忍 | 备注 |
|
||||
| ----------- | --------- | ---- | ------------------------------------------------------------------------- |
|
||||
| 0 (D0) | PB7 | 是 | |
|
||||
| 1 (D1) | PB6 | 是 | |
|
||||
| 2 (D2) | PB5 | 否 | PWM3-CH2,默认被RT-Thread的PWM设备框架pwm3接管 |
|
||||
| 3 (D3) | PB4 | 是 | PWM3-CH1,默认被RT-Thread的PWM设备框架pwm3接管 |
|
||||
| 4 (D4) | PB3 | 是 | PWM2-CH2,默认被RT-Thread的PWM设备框架pwm2接管 |
|
||||
| 5 (D5) | PA15 | 是 | PWM2-CH1,默认被RT-Thread的PWM设备框架pwm2接管 |
|
||||
| 6 (D6) | PA8 | 是 | |
|
||||
| 7 (D7) | PB12 | 是 | |
|
||||
| 8 (D8) | PC13 | 否 | |
|
||||
| 9 (D9) | PC14 | 否 | |
|
||||
| 10 (D10) | PC15 | 否 | |
|
||||
| 11 (D11) | PA0 | 否 | |
|
||||
| 12 (D12) | PB0 | 否 | PWM3-CH3,默认被RT-Thread的PWM设备框架pwm3接管 |
|
||||
| 13 (D13) | PB1 | 否 | PWM3-CH4,默认被RT-Thread的PWM设备框架pwm3接管 |
|
||||
| 14 (D14) | PB9 | 是 | I2C-SDA,默认被RT-Thread的I2C设备框架i2c1总线接管 |
|
||||
| 15 (D15) | PB8 | 是 | I2C-SCL,默认被RT-Thread的I2C设备框架i2c1总线接管 |
|
||||
| 16 (D16) | PA12 | 是 | USB-DP,默认被 [TinyUSB软件包](https://github.com/RT-Thread-packages/tinyusb) 接管 |
|
||||
| 17 (D17) | PA11 | 是 | USB-DM,默认被 [TinyUSB软件包](https://github.com/RT-Thread-packages/tinyusb) 接管 |
|
||||
| 18 (D18) | PA10 | 是 | UART1-RX,默认被RT-Thread的UART设备框架uart1接管 |
|
||||
| 19 (D19) | PA9 | 是 | UART1-TX,默认被RT-Thread的UART设备框架uart1接管 |
|
||||
| 20 (D20) | PA2 | 否 | UART2-TX,默认被RT-Thread的UART设备框架uart2接管 |
|
||||
| 21 (D21) | PA3 | 否 | UART2-RX,默认被RT-Thread的UART设备框架uart2接管 |
|
||||
| 22 (D22) | PB10 | 是 | UART3-TX,默认被RT-Thread的UART设备框架uart3接管 |
|
||||
| 23 (D23) | PB11 | 是 | UART3-RX,默认被RT-Thread的UART设备框架uart3接管 |
|
||||
| 24 (D24) | PB15 | 是 | SPI-MOSI,默认被RT-Thread的SPI设备框架spi2接管 |
|
||||
| 25 (D25) | PB14 | 是 | SPI-MISO,默认被RT-Thread的SPI设备框架spi2接管 |
|
||||
| 26 (D26) | PB13 | 是 | SPI-SCK ,默认被RT-Thread的SPI设备框架spi2接管 |
|
||||
| 27 (A0) | PA1 | 否 | ADC1-CH1,默认被RT-Thread的ADC设备框架adc1接管 |
|
||||
| 28 (A1) | PA4 | 否 | ADC1-CH4,默认被RT-Thread的ADC设备框架adc1接管 |
|
||||
| 29 (A2) | PA5 | 否 | ADC1-CH5,默认被RT-Thread的ADC设备框架adc1接管 |
|
||||
| 30 (A3) | PA6 | 否 | ADC1-CH6,默认被RT-Thread的ADC设备框架adc1接管 |
|
||||
| 31 (A4) | PA7 | 否 | ADC1-CH7,默认被RT-Thread的ADC设备框架adc1接管 |
|
||||
| 32 (A5) | -- | | 芯片内部参考电压 ADC,默认被RT-Thread的ADC设备框架adc1接管 |
|
||||
| 33 (A6) | -- | | 芯片内部温度 ADC,默认被RT-Thread的ADC设备框架adc1接管 |
|
||||
| Arduino引脚编号 | STM32引脚编号 | 5V容忍 | 备注 |
|
||||
| ------------------- | --------- | ---- | ------------------------------------------------------------------------- |
|
||||
| 0 (D0) | PB7 | 是 | |
|
||||
| 1 (D1) | PB6 | 是 | |
|
||||
| 2 (D2) | PB5 | 否 | PWM3-CH2,默认被RT-Thread的PWM设备框架pwm3接管 |
|
||||
| 3 (D3) | PB4 | 是 | PWM3-CH1,默认被RT-Thread的PWM设备框架pwm3接管 |
|
||||
| 4 (D4) | PB3 | 是 | PWM2-CH2,默认被RT-Thread的PWM设备框架pwm2接管 |
|
||||
| 5 (D5) | PA15 | 是 | PWM2-CH1,默认被RT-Thread的PWM设备框架pwm2接管 |
|
||||
| 6 (D6) | PA8 | 是 | |
|
||||
| 7 (D7, SS) | PB12 | 是 | SPI片选默认引脚 |
|
||||
| 8 (D8, LED_BUILTIN) | PC13 | 否 | 板载LED |
|
||||
| 9 (D9) | PC14 | 否 | |
|
||||
| 10 (D10) | PC15 | 否 | |
|
||||
| 11 (D11) | PA0 | 否 | |
|
||||
| 12 (D12) | PB0 | 否 | PWM3-CH3,默认被RT-Thread的PWM设备框架pwm3接管 |
|
||||
| 13 (D13) | PB1 | 否 | PWM3-CH4,默认被RT-Thread的PWM设备框架pwm3接管 |
|
||||
| 14 (D14) | PB9 | 是 | I2C-SDA,默认被RT-Thread的I2C设备框架i2c1总线接管 |
|
||||
| 15 (D15) | PB8 | 是 | I2C-SCL,默认被RT-Thread的I2C设备框架i2c1总线接管 |
|
||||
| 16 (D16) | PA12 | 是 | USB-DP,默认被 [TinyUSB软件包](https://github.com/RT-Thread-packages/tinyusb) 接管 |
|
||||
| 17 (D17) | PA11 | 是 | USB-DM,默认被 [TinyUSB软件包](https://github.com/RT-Thread-packages/tinyusb) 接管 |
|
||||
| 18 (D18) | PA10 | 是 | Serial-Rx,默认被RT-Thread的UART设备框架uart1接管 |
|
||||
| 19 (D19) | PA9 | 是 | Serial-Tx,默认被RT-Thread的UART设备框架uart1接管 |
|
||||
| 20 (D20) | PA2 | 否 | Serial2-Tx,默认被RT-Thread的UART设备框架uart2接管 |
|
||||
| 21 (D21) | PA3 | 否 | Serial2-Rx,默认被RT-Thread的UART设备框架uart2接管 |
|
||||
| 22 (D22) | PB10 | 是 | Serial3-Tx,默认被RT-Thread的UART设备框架uart3接管 |
|
||||
| 23 (D23) | PB11 | 是 | Serial3-Rx,默认被RT-Thread的UART设备框架uart3接管 |
|
||||
| 24 (D24) | PB15 | 是 | SPI-MOSI,默认被RT-Thread的SPI设备框架spi2接管 |
|
||||
| 25 (D25) | PB14 | 是 | SPI-MISO,默认被RT-Thread的SPI设备框架spi2接管 |
|
||||
| 26 (D26) | PB13 | 是 | SPI-SCK ,默认被RT-Thread的SPI设备框架spi2接管 |
|
||||
| 27 (A0) | PA1 | 否 | ADC1-CH1,默认被RT-Thread的ADC设备框架adc1接管 |
|
||||
| 28 (A1) | PA4 | 否 | ADC1-CH4,默认被RT-Thread的ADC设备框架adc1接管 |
|
||||
| 29 (A2) | PA5 | 否 | ADC1-CH5,默认被RT-Thread的ADC设备框架adc1接管 |
|
||||
| 30 (A3) | PA6 | 否 | ADC1-CH6,默认被RT-Thread的ADC设备框架adc1接管 |
|
||||
| 31 (A4) | PA7 | 否 | ADC1-CH7,默认被RT-Thread的ADC设备框架adc1接管 |
|
||||
| 32 (A5) | -- | | 芯片内部参考电压 ADC,默认被RT-Thread的ADC设备框架adc1接管 |
|
||||
| 33 (A6) | -- | | 芯片内部温度 ADC,默认被RT-Thread的ADC设备框架adc1接管 |
|
||||
|
||||
> 注意:
|
||||
>
|
||||
|
@ -75,3 +75,7 @@ SPI总线是 `D24` 、`D25` 和 `D26` 引脚,这三个引脚默认是被RT-Thr
|
|||
### 3.3 USB
|
||||
|
||||
默认支持USB虚拟串口,详见[例程](https://github.com/RTduino/RTduino/tree/master/examples/USBSerial)。
|
||||
|
||||
### 3.4 串口
|
||||
|
||||
默认支持通过 `Serial.` 方法调用 `uart1` 串口设备;通过 `Serial2.` 方法调用 `uart2` 串口设备;通过 `Serial3.` 方法调用 `uart3` 串口设备。详见[例程](https://github.com/RTduino/RTduino/blob/master/examples/Basic/helloworld.cpp)。
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.0 MiB After Width: | Height: | Size: 1.0 MiB |
|
@ -38,12 +38,12 @@ const pin_map_t pin_map_table[]=
|
|||
{D15, GET_PIN(B,8), "i2c1"}, /* I2C (Wire) */
|
||||
{D16, GET_PIN(A,12), "usb"}, /* SerialUSB */
|
||||
{D17, GET_PIN(A,11), "usb"}, /* SerialUSB */
|
||||
{D18, GET_PIN(A,10), "uart1"}, /* Serial */
|
||||
{D19, GET_PIN(A,9), "uart1"}, /* Serial */
|
||||
{D20, GET_PIN(A,2), "uart2"}, /* Serial2 */
|
||||
{D21, GET_PIN(A,3), "uart2"}, /* Serial2 */
|
||||
{D22, GET_PIN(B,10), "uart3"}, /* Serial3 */
|
||||
{D23, GET_PIN(B,11), "uart3"}, /* Serial3 */
|
||||
{D18, GET_PIN(A,10), "uart1"}, /* Serial-Rx */
|
||||
{D19, GET_PIN(A,9), "uart1"}, /* Serial-Tx */
|
||||
{D20, GET_PIN(A,2), "uart2"}, /* Serial2-Tx */
|
||||
{D21, GET_PIN(A,3), "uart2"}, /* Serial2-Rx */
|
||||
{D22, GET_PIN(B,10), "uart3"}, /* Serial3-Tx */
|
||||
{D23, GET_PIN(B,11), "uart3"}, /* Serial3-Rx */
|
||||
{D24, GET_PIN(B,15), "spi2"}, /* SPI */
|
||||
{D25, GET_PIN(B,14), "spi2"}, /* SPI */
|
||||
{D26, GET_PIN(B,13), "spi2"}, /* SPI */
|
||||
|
|
|
@ -53,10 +53,10 @@
|
|||
/* i2c1 - PB9-SDA PB8-SCL */
|
||||
#define RTDUINO_DEFAULT_IIC_BUS_NAME "i2c1"
|
||||
|
||||
/* uart2 - PA2-TX PA3-RX */
|
||||
/* Serial2 - PA2-TX PA3-RX */
|
||||
#define RTDUINO_SERIAL2_DEVICE_NAME "uart2"
|
||||
|
||||
/* uart3 - PB10-TX PB11-RX */
|
||||
/* Serial3 - PB10-TX PB11-RX */
|
||||
#define RTDUINO_SERIAL3_DEVICE_NAME "uart3"
|
||||
|
||||
/* spi2 - PB13-SCK PB14-MISO PB15-MOSI */
|
||||
|
|
|
@ -20,45 +20,55 @@ Hardware Drivers Config --->
|
|||
|
||||
该BSP遵照Arduino UNO板的引脚排列方式。详见 `pins_arduino.c`
|
||||
|
||||
| Arduino引脚编号 | STM32引脚编号 | 5V容忍 | 备注 |
|
||||
| --------------- | ------------- | ------ | -------------------------------------------------------- |
|
||||
| 0 (D0) | -- | | UART2-RX,默认被RT-Thread的UART设备框架uart2接管 |
|
||||
| 1 (D1) | -- | | UART2-TX,默认被RT-Thread的UART设备框架uart2接管 |
|
||||
| 2 (D2) | PA10 | 是 | |
|
||||
| 3 (D3) | PB3 | 是 | PWM2-CH2,默认被RT-Thread的PWM设备框架pwm2接管 |
|
||||
| 4 (D4) | PB5 | 是 | |
|
||||
| 5 (D5) | PB4 | 是 | PWM3-CH1,默认被RT-Thread的PWM设备框架pwm3接管 |
|
||||
| 6 (D6) | PB10 | 是 | PWM2-CH3,默认被RT-Thread的PWM设备框架pwm2接管 |
|
||||
| 7 (D7) | PA8 | 是 | |
|
||||
| 8 (D8) | PA9 | 是 | |
|
||||
| 9 (D9) | PC7 | 是 | PWM3-CH2,默认被RT-Thread的PWM设备框架pwm3接管 |
|
||||
| 10 (D10) | PB6 | 是 | PWM4-CH1,默认被RT-Thread的PWM设备框架pwm4接管 |
|
||||
| 11 (D11) | PA7 | 是 | PWM1-CH1N,默认被RT-Thread的PWM设备框架pwm1接管 |
|
||||
| 12 (D12) | PA6 | 是 | |
|
||||
| 13 (D13) | PA5 | 是 | |
|
||||
| 14 (D14) | PB9 | 是 | I2C-SDA,默认被RT-Thread的I2C设备框架i2c1总线接管 |
|
||||
| 15 (D15) | PB8 | 是 | I2C-SCL,默认被RT-Thread的I2C设备框架i2c1总线接管 |
|
||||
| 16 (D16) | PC13 | 是 | Nucleo板载用户按键(左侧蓝色) |
|
||||
| A0 | PA0 | 是 | ADC1-CH0,默认被RT-Thread的ADC设备框架adc1接管 |
|
||||
| A1 | PA1 | 是 | ADC1-CH1,默认被RT-Thread的ADC设备框架adc1接管 |
|
||||
| A2 | PA4 | 是 | ADC1-CH4,默认被RT-Thread的ADC设备框架adc1接管 |
|
||||
| A3 | PB0 | 是 | ADC1-CH8,默认被RT-Thread的ADC设备框架adc1接管 |
|
||||
| A4 | PC1 | 是 | ADC1-CH11,默认被RT-Thread的ADC设备框架adc1接管 |
|
||||
| A5 | PC0 | 是 | ADC1-CH10,默认被RT-Thread的ADC设备框架adc1接管 |
|
||||
| A6 | -- | | 芯片内部参考电压 ADC,默认被RT-Thread的ADC设备框架adc1接管 |
|
||||
| A7 | -- | | 芯片内部温度 ADC,默认被RT-Thread的ADC设备框架adc1接管 |
|
||||
| Arduino引脚编号 | STM32引脚编号 | 5V容忍 | 备注 |
|
||||
| ----------- | --------- | ---- | --------------------------------------- |
|
||||
| 0 (D0) | PA3 | | Serial2-Rx,默认被RT-Thread的UART设备框架uart2接管 |
|
||||
| 1 (D1) | PA2 | | Serial2-Tx,默认被RT-Thread的UART设备框架uart2接管 |
|
||||
| 2 (D2) | PA10 | 是 | |
|
||||
| 3 (D3) | PB3 | 是 | PWM2-CH2,默认被RT-Thread的PWM设备框架pwm2接管 |
|
||||
| 4 (D4) | PB5 | 是 | |
|
||||
| 5 (D5) | PB4 | 是 | PWM3-CH1,默认被RT-Thread的PWM设备框架pwm3接管 |
|
||||
| 6 (D6) | PB10 | 是 | PWM2-CH3,默认被RT-Thread的PWM设备框架pwm2接管 |
|
||||
| 7 (D7) | PA8 | 是 | |
|
||||
| 8 (D8) | PA9 | 是 | |
|
||||
| 9 (D9) | PC7 | 是 | PWM3-CH2,默认被RT-Thread的PWM设备框架pwm3接管 |
|
||||
| 10 (D10) | PB6 | 是 | PWM4-CH1,默认被RT-Thread的PWM设备框架pwm4接管 |
|
||||
| 11 (D11) | PA7 | 是 | PWM1-CH1N,默认被RT-Thread的PWM设备框架pwm1接管 |
|
||||
| 12 (D12) | PA6 | 是 | |
|
||||
| 13 (D13) | PA5 | 是 | 板载LED |
|
||||
| 14 (D14) | PB9 | 是 | I2C-SDA,默认被RT-Thread的I2C设备框架i2c1总线接管 |
|
||||
| 15 (D15) | PB8 | 是 | I2C-SCL,默认被RT-Thread的I2C设备框架i2c1总线接管 |
|
||||
| 16 (D16) | PC13 | 是 | 板载用户按键(左侧蓝色) |
|
||||
| A0 | PA0 | 是 | ADC1-CH0,默认被RT-Thread的ADC设备框架adc1接管 |
|
||||
| A1 | PA1 | 是 | ADC1-CH1,默认被RT-Thread的ADC设备框架adc1接管 |
|
||||
| A2 | PA4 | 是 | ADC1-CH4,默认被RT-Thread的ADC设备框架adc1接管 |
|
||||
| A3 | PB0 | 是 | ADC1-CH8,默认被RT-Thread的ADC设备框架adc1接管 |
|
||||
| A4 | PC1 | 是 | ADC1-CH11,默认被RT-Thread的ADC设备框架adc1接管 |
|
||||
| A5 | PC0 | 是 | ADC1-CH10,默认被RT-Thread的ADC设备框架adc1接管 |
|
||||
| A6 | -- | | 芯片内部参考电压 ADC,默认被RT-Thread的ADC设备框架adc1接管 |
|
||||
| A7 | -- | | 芯片内部温度 ADC,默认被RT-Thread的ADC设备框架adc1接管 |
|
||||
|
||||
> 注意:
|
||||
>
|
||||
>
|
||||
> 1. 驱动舵机和analogWrite函数要选择不同定时器发生的PWM信号引脚,由于STM32的定时器4个通道需要保持相同的频率,如果采用相同的定时器发生的PWM分别驱动舵机和analogWrite,可能会导致舵机失效。
|
||||
> 2. USART2是Nucleo板的默认串口,理论应对接到了Arduino引脚编号的D0和D1,但是其实际用于串口通信,因此不允许当做普通IO来使用和操作。如果需要将D0、D1与STM32 USART2的引脚相连,需要手动焊接锡桥SB62、SB63。
|
||||
> 3. Nucleo板的Arduino接口中AVDD(即AREF)默认是与VDD相连的,如果需要扩展板提供外部参考电压,需要将SB57锡桥挑开。
|
||||
> 4. D11引脚是PWM反相位引脚(也就是常说的互补输出引脚CHxN)。但是这里不用考虑到占空比互补问题(CHx-20%,CHxN-80%),直接正常使用即可。
|
||||
|
||||
> 参考资料
|
||||
>
|
||||
>
|
||||
> 【1】[STM32 Nucleo板官方手册](https://www.st.com/resource/en/user_manual/um1724-stm32-nucleo64-boards-mb1136-stmicroelectronics.pdf)
|
||||
|
||||
## 3 I2C总线
|
||||
## 3 通信
|
||||
|
||||
### 3.1 I2C总线
|
||||
|
||||
STM32F401 Nucleo板的I2C总线是板上丝印的 `SCL/D15` 和 `SDA/D14` 引脚,这两个引脚是被RT-Thread I2C设备框架接管的,不需要直接操控这两个引脚,直接引用`#include <Wire.h>`(Arduino官方I2C头文件)即可使用。
|
||||
|
||||
### 3.2 SPI总线
|
||||
|
||||
目前本BSP不支持使用Arduino的SPI功能。
|
||||
|
||||
### 3.3 串口
|
||||
|
||||
本BSP通过 `Serial.` 方法调用 `uart2` 串口设备。详见[例程](https://github.com/RTduino/RTduino/blob/master/examples/Basic/helloworld.cpp)。
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
*/
|
||||
const pin_map_t pin_map_table[]=
|
||||
{
|
||||
{D0, GET_PIN(A,3), "uart2"}, /* Serial */
|
||||
{D1, GET_PIN(A,2), "uart2"}, /* Serial */
|
||||
{D0, GET_PIN(A,3), "uart2"}, /* Serial-Rx */
|
||||
{D1, GET_PIN(A,2), "uart2"}, /* Serial-Tx */
|
||||
{D2, GET_PIN(A,10)},
|
||||
{D3, GET_PIN(B,3), "pwm2", 2}, /* PWM */
|
||||
{D4, GET_PIN(B,5)},
|
||||
|
@ -35,8 +35,8 @@ const pin_map_t pin_map_table[]=
|
|||
{D11, GET_PIN(A,7), "pwm1", -1}, /* PWM */
|
||||
{D12, GET_PIN(A,6)},
|
||||
{D13, GET_PIN(A,5)}, /* LED_BUILTIN */
|
||||
{D14, GET_PIN(B,9), "i2c1"}, /* I2C (Wire) */
|
||||
{D15, GET_PIN(B,8), "i2c1"}, /* I2C (Wire) */
|
||||
{D14, GET_PIN(B,9), "i2c1"}, /* I2C-SDA (Wire) */
|
||||
{D15, GET_PIN(B,8), "i2c1"}, /* I2C-SCL (Wire) */
|
||||
{D16, GET_PIN(C,13)},
|
||||
{A0, GET_PIN(A,0), "adc1", 0}, /* ADC */
|
||||
{A1, GET_PIN(A,1), "adc1", 1}, /* ADC */
|
||||
|
|
|
@ -20,53 +20,53 @@ Hardware Drivers Config --->
|
|||
|
||||
### 2.1 Arduino引脚排布统览
|
||||
|
||||
| Arduino引脚编号 | STM32引脚编号 | 5V容忍 | 备注 |
|
||||
| --------------------- | --------- | ------- | -------------------------------------------- |
|
||||
| 0 (D0) | -- | | 该引脚在UNO板中为串口RX引脚,不可当做普通IO |
|
||||
| 1 (D1) | -- | | 该引脚在UNO板中为串口TX引脚,不可当做普通IO |
|
||||
| 2 (D2) | PB9 | 是 | 普通IO |
|
||||
| 3 (D3) | PD15 | 是 | PWM(定时器4发生) |
|
||||
| 4 (D4) | PA8 | 是 | 普通IO |
|
||||
| 5 (D5) | PD14 | 是 | 普通IO |
|
||||
| 6 (D6) | PB11 | 是 | PWM(定时器2发生) |
|
||||
| 7 (D7) | PB14 | 是 | 普通IO |
|
||||
| 8 (D8) | PB12 | 是 | 普通IO |
|
||||
| 9 (D9) | PD12 | 是 | PWM(定时器4发生) |
|
||||
| 10 (D10) | PB10 | 是 | PWM(定时器2发生) |
|
||||
| 11 (D11) | PB8 | 是 | PWM(定时器4发生) |
|
||||
| 12 (D12) | PB15 | 是 | 普通IO |
|
||||
| 13 (D13) | PB13 | 是 | 普通IO |
|
||||
| 14 (D14) | PA1 | 是 | 振动电机-A |
|
||||
| 15 (D15) | PA0 | 是 | 振动电机-B |
|
||||
| 16 (D16) | PB2 | 是 | 蜂鸣器 |
|
||||
| 17 (D17) | PD10 | 是 | KEY0 |
|
||||
| 18 (D18) | PD9 | 是 | KEY1 |
|
||||
| 19 (D19) | PD8 | 是 | KEY2 |
|
||||
| 20 (D20) | PC13 | 是 | KEY-WKUP |
|
||||
| 21 (D21) | PE7 | 是 | 红色LED |
|
||||
| 22 (D22, LED_BUILTIN) | PE8 | 是 | 绿色LED,Arduino默认LED |
|
||||
| 23 (D23) | PE9 | 是 | 蓝色LED,具有PWM功能(定时器1发生) |
|
||||
| 24 (D24) | PB0 | 3.6V容忍 | 红外发送 |
|
||||
| 25 (D25) | PB1 | 是 | 红外接收 |
|
||||
| 26 (D26) | PD7 | 是 | LCD 片选 CS |
|
||||
| 27 (D27) | PB6 | 是 | LCD 复位 RESET |
|
||||
| 28 (D28) | PB4 | 是 | LCD D/C 数据命令选择 |
|
||||
| 29 (D29) | PB7 | 是 | LCD 背光电源 |
|
||||
| 30 (D30) | PD4 | 是 | 无线模块 CE |
|
||||
| 31 (D31) | PD3 | 是 | 无线模块 中断 |
|
||||
| 32 (D32) | PD5 | 是 | 无线模块 片选 CS |
|
||||
| A0 | PC2 | 是(但不建议) | ADC |
|
||||
| A1 | PC4 | 是(但不建议) | ADC |
|
||||
| A2 | -- | | 芯片内部参考电压 ADC |
|
||||
| A3 | -- | | 芯片内部温度 ADC |
|
||||
| DAC0 | PA4 | 3.6V容忍 | 真模拟输出 DAC |
|
||||
| -- | PC7 | 是 | I2C1-SDA,被RT-Thread的I2C设备框架i2c1总线接管,不可当做普通IO |
|
||||
| -- | PC6 | 是 | I2C1-SCL,被RT-Thread的I2C设备框架i2c1总线接管,不可当做普通IO |
|
||||
| Arduino引脚编号 | STM32引脚编号 | 5V容忍 | 备注 |
|
||||
| --------------------- | --------- | ------- | -------------------------------------- |
|
||||
| 0 (D0) | PA10 | 是 | Serial-Rx,被RT-Thread的UART设备框架uart1接管 |
|
||||
| 1 (D1) | PA9 | 是 | Serial-Tx,被RT-Thread的UART设备框架uart1接管 |
|
||||
| 2 (D2) | PB9 | 是 | 普通IO |
|
||||
| 3 (D3) | PD15 | 是 | PWM(定时器4发生) |
|
||||
| 4 (D4) | PA8 | 是 | 普通IO |
|
||||
| 5 (D5) | PD14 | 是 | 普通IO |
|
||||
| 6 (D6) | PB11 | 是 | PWM(定时器2发生) |
|
||||
| 7 (D7) | PB14 | 是 | 普通IO |
|
||||
| 8 (D8) | PB12 | 是 | 普通IO |
|
||||
| 9 (D9) | PD12 | 是 | PWM(定时器4发生) |
|
||||
| 10 (D10) | PB10 | 是 | PWM(定时器2发生) |
|
||||
| 11 (D11) | PB8 | 是 | PWM(定时器4发生) |
|
||||
| 12 (D12) | PB15 | 是 | 普通IO |
|
||||
| 13 (D13) | PB13 | 是 | 普通IO |
|
||||
| 14 (D14) | PA1 | 是 | 振动电机-A |
|
||||
| 15 (D15) | PA0 | 是 | 振动电机-B |
|
||||
| 16 (D16) | PB2 | 是 | 蜂鸣器 |
|
||||
| 17 (D17) | PD10 | 是 | KEY0 |
|
||||
| 18 (D18) | PD9 | 是 | KEY1 |
|
||||
| 19 (D19) | PD8 | 是 | KEY2 |
|
||||
| 20 (D20) | PC13 | 是 | KEY-WKUP |
|
||||
| 21 (D21) | PE7 | 是 | 红色LED |
|
||||
| 22 (D22, LED_BUILTIN) | PE8 | 是 | 绿色LED,Arduino默认LED |
|
||||
| 23 (D23) | PE9 | 是 | 蓝色LED,具有PWM功能(定时器1发生) |
|
||||
| 24 (D24) | PB0 | 3.6V容忍 | 红外发送 |
|
||||
| 25 (D25) | PB1 | 是 | 红外接收 |
|
||||
| 26 (D26) | PD4 | 是 | 无线模块 CE |
|
||||
| 27 (D27) | PD3 | 是 | 无线模块 中断 |
|
||||
| 28 (D28, SS) | PD5 | 是 | 无线模块 片选 CS |
|
||||
| 29 (D29) | PB13 | | SPI2-SCK,默认被RT-Thread的SPI设备框架spi2总线接管 |
|
||||
| 30 (D30) | PB14 | | SPI2-MISO,默认被RT-Thread的SPI设备框架spi2总线接管 |
|
||||
| 31 (D31) | PB15 | | SPI2-MOSI,默认被RT-Thread的SPI设备框架spi2总线接管 |
|
||||
| 32 (D32) | PC7 | 是 | I2C1-SDA,默认被RT-Thread的I2C设备框架i2c1总线接管 |
|
||||
| 33 (D33) | PC6 | 是 | I2C1-SCL,默认被RT-Thread的I2C设备框架i2c1总线接管 |
|
||||
| 34 (D34) | PA2 | | Serial2-Tx,默认被RT-Thread的UART设备框架uart2接管 |
|
||||
| 35 (D35) | PA3 | | Serial2-Rx,默认被RT-Thread的UART设备框架uart2接管 |
|
||||
| A0 | PC2 | 是(但不建议) | ADC |
|
||||
| A1 | PC4 | 是(但不建议) | ADC |
|
||||
| A2 | -- | | 芯片内部参考电压 ADC |
|
||||
| A3 | -- | | 芯片内部温度 ADC |
|
||||
| DAC0 | PA4 | 3.6V容忍 | 真模拟输出 DAC |
|
||||
|
||||
> 注意:
|
||||
>
|
||||
> 1. 驱动舵机和analogWrite函数要选择不同定时器发生的PWM信号引脚,由于STM32的定时器4个通道需要保持相同的频率,如果采用相同的定时器发生的PWM分别驱动舵机和analogWrite,可能会导致舵机失效。
|
||||
> 2. USART1是潘多拉板的默认串口,理论应对接到了Arduino引脚编号的D0和D1,但是其实际用于串口通信,因此不允许当做普通IO来使用和操作。
|
||||
|
||||
### 2.2 板载排针的Arduino引脚排布
|
||||
|
||||
|
@ -99,7 +99,9 @@ Hardware Drivers Config --->
|
|||
| 红外发射 | 24 (D24) | PB0 |
|
||||
| 红外接收 | 25 (D25) | PB1 |
|
||||
|
||||
## 3 I2C总线
|
||||
## 3 通信
|
||||
|
||||
### 3.1 I2C总线
|
||||
|
||||
潘多拉Arduino支持三条I2C总线,分别是:i2c1、i2c3 和 i2c4。你可以通过`pins_arduino.h`文件中的 `RTDUINO_DEFAULT_IIC_BUS_NAME` 宏来设定Arduino的I2C总线,**默认为 i2c4 总线**。其中:
|
||||
|
||||
|
@ -109,13 +111,21 @@ Hardware Drivers Config --->
|
|||
|
||||
I2C的引脚都是被RT-Thread I2C设备框架接管的,不需要直接操控这两个引脚,直接引用`#include <Wire.h>`(Arduino官方I2C头文件)即可使用。
|
||||
|
||||
## 4 SPI总线
|
||||
### 3.2 SPI总线
|
||||
|
||||
潘多拉板的Arduino SPI总线是spi2总线,位置为板上左上角的`WIRELESS`插槽。 `SCK`、`MISO`、`MOSI`引脚是被RT-Thread SPI设备框架接管的,不需要直接操控这3个引脚,直接引用`#include <SPI.h>`(Arduino官方SPI头文件)即可使用。按照Arduino的编程标准,用户需要自行控制片选信号。
|
||||
潘多拉板的Arduino SPI总线是spi2总线,位置为板上左上角的`WIRELESS`插槽。 `SCK`、`MISO`、`MOSI`引脚是被RT-Thread SPI设备框架接管的,不需要直接操控这3个引脚,直接引用`#include <SPI.h>`(Arduino官方SPI头文件)即可使用。按照Arduino的编程标准,用户需要自行控制片选信号,默认为 `SS`, 即 `D28`。
|
||||
|
||||
## 5 特殊功能说明
|
||||
### 3.3 串口
|
||||
|
||||
### 5.1 芯片内部ADC通道
|
||||
默认支持通过 `Serial.` 方法调用 `uart1` 串口设备;通过 `Serial2.` 方法调用 `uart2` 串口设备。详见[例程](https://github.com/RTduino/RTduino/blob/master/examples/Basic/helloworld.cpp)。
|
||||
|
||||
### 3.4 USB
|
||||
|
||||
默认支持USB虚拟串口,详见[例程](https://github.com/RTduino/RTduino/tree/master/examples/USBSerial)。
|
||||
|
||||
## 4 特殊功能说明
|
||||
|
||||
### 4.1 芯片内部ADC通道
|
||||
|
||||
本BSP适配了STM32的两个芯片内部ADC通道,可以通过 analogRead 函数来分别获取如下功能:
|
||||
|
||||
|
@ -124,7 +134,7 @@ I2C的引脚都是被RT-Thread I2C设备框架接管的,不需要直接操控
|
|||
| 芯片内部参考电压 ADC | A2 | -- |
|
||||
| 芯片内部温度 ADC | A3 | -- |
|
||||
|
||||
### 5.2 真模拟输出功能 (True Analog Output)
|
||||
### 4.2 真模拟输出功能 (True Analog Output)
|
||||
|
||||
Arduino的 analogWrite 函数虽为模拟写,但是实际输出的是PWM数字信号,并非真正的模拟信号。这是由于Arduino早期使用的AVR单片机并不支持DAC的功能,因此这个习惯就被保留了下来。但是随着Arduino支持芯片的丰富,部分高级芯片已经内建了DAC(例如Arduino官方板MKR、Zero等),因此Arduino的 analogWrite 函数后续也支持了真模拟输出功能。
|
||||
|
||||
|
|
|
@ -6,56 +6,61 @@
|
|||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-12-10 Meco Man first version
|
||||
* 2022-09-18 Meco Man sort pinout out
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <board.h>
|
||||
#include "pins_arduino.h"
|
||||
|
||||
/*
|
||||
{Arduino Pin, RT-Thread Pin [, Device Name(PWM or ADC), Channel]}
|
||||
[] means optional
|
||||
Digital pins must NOT give the device name and channel.
|
||||
Analog pins MUST give the device name and channel(ADC, PWM or DAC).
|
||||
Arduino Pin must keep in sequence.
|
||||
*/
|
||||
* {Arduino Pin, RT-Thread Pin [, Device Name, Channel]}
|
||||
* [] means optional
|
||||
* Digital pins must NOT give the device name and channel.
|
||||
* Analog pins MUST give the device name and channel(ADC, PWM or DAC).
|
||||
* Arduino Pin must keep in sequence.
|
||||
*/
|
||||
const pin_map_t pin_map_table[]=
|
||||
{
|
||||
{D0}, /* RX */
|
||||
{D1}, /* TX */
|
||||
{D0, GET_PIN(A,10), "uart1"}, /* Serial-Rx */
|
||||
{D1, GET_PIN(A,9), "uart1"}, /* Serial-Tx */
|
||||
{D2, GET_PIN(B,9)},
|
||||
{D3, GET_PIN(D,15), "pwm4", 4}, /* PWM */
|
||||
{D3, GET_PIN(D,15), "pwm4", 4}, /* PWM */
|
||||
{D4, GET_PIN(A,8)},
|
||||
{D5, GET_PIN(D,14)},
|
||||
{D6, GET_PIN(B,11), "pwm2", 4}, /* PWM */
|
||||
{D6, GET_PIN(B,11), "pwm2", 4}, /* PWM */
|
||||
{D7, GET_PIN(B,14)},
|
||||
{D8, GET_PIN(B,12)},
|
||||
{D9, GET_PIN(D,12), "pwm4", 1}, /* PWM */
|
||||
{D10, GET_PIN(B,10), "pwm2", 3}, /* PWM */
|
||||
{D11, GET_PIN(B,8), "pwm4", 3}, /* PWM */
|
||||
{D9, GET_PIN(D,12), "pwm4", 1}, /* PWM */
|
||||
{D10, GET_PIN(B,10), "pwm2", 3}, /* PWM */
|
||||
{D11, GET_PIN(B,8), "pwm4", 3}, /* PWM */
|
||||
{D12, GET_PIN(B,15)},
|
||||
{D13, GET_PIN(B,13)},
|
||||
{D14, GET_PIN(A,1)}, /* BSP: MOTOR-A */
|
||||
{D15, GET_PIN(A,0)}, /* BSP: MOTOR-B */
|
||||
{D16, GET_PIN(B,2)}, /* BSP: BEEP */
|
||||
{D17, GET_PIN(D,10)}, /* BSP: KEY0 */
|
||||
{D18, GET_PIN(D,9)}, /* BSP: KEY1 */
|
||||
{D19, GET_PIN(D,8)}, /* BSP: KEY2 */
|
||||
{D20, GET_PIN(C,13)}, /* BSP: KEY-WKUP */
|
||||
{D21, GET_PIN(E,7)}, /* BSP: RED-LED */
|
||||
{D22, GET_PIN(E,8)}, /* LED_BUILTIN, BSP: GREEN-LED */
|
||||
{D23, GET_PIN(E,9), "pwm1", 1}, /* PWM, BSP: BLUE-LED */
|
||||
{D24, GET_PIN(B,0)}, /* INFRARED EMISSION */
|
||||
{D25, GET_PIN(B,1)}, /* INFRARED RECEPTION */
|
||||
{D26, GET_PIN(D,7)}, /* LCD CS */
|
||||
{D27, GET_PIN(B,6)}, /* LCD RESET */
|
||||
{D28, GET_PIN(B,4)}, /* LCD DC (data or command) */
|
||||
{D29, GET_PIN(B,7)}, /* LCD POWER */
|
||||
{D30, GET_PIN(D,4)}, /* WIRELESS CE */
|
||||
{D31, GET_PIN(D,3)}, /* WIRELESS IRQ */
|
||||
{D32, GET_PIN(D,5)}, /* WIRELESS CS */
|
||||
{A0, GET_PIN(C,2), "adc1", 3}, /* ADC */
|
||||
{A1, GET_PIN(C,4), "adc1", 13}, /* ADC */
|
||||
{A2, RT_NULL, "adc1", 0}, /* ADC, On-Chip: internal reference voltage, ADC_CHANNEL_VREFINT */
|
||||
{A3, RT_NULL, "adc1", 17}, /* ADC, On-Chip: internal temperature sensor, ADC_CHANNEL_TEMPSENSOR */
|
||||
{DAC0, GET_PIN(A,4), "dac1", 1} /* DAC */
|
||||
{D14, GET_PIN(A,1)}, /* BSP: MOTOR-A */
|
||||
{D15, GET_PIN(A,0)}, /* BSP: MOTOR-B */
|
||||
{D16, GET_PIN(B,2)}, /* BSP: BEEP */
|
||||
{D17, GET_PIN(D,10)}, /* BSP: KEY0 */
|
||||
{D18, GET_PIN(D,9)}, /* BSP: KEY1 */
|
||||
{D19, GET_PIN(D,8)}, /* BSP: KEY2 */
|
||||
{D20, GET_PIN(C,13)}, /* BSP: KEY-WKUP */
|
||||
{D21, GET_PIN(E,7)}, /* BSP: RED-LED */
|
||||
{D22, GET_PIN(E,8)}, /* LED_BUILTIN, BSP: GREEN-LED */
|
||||
{D23, GET_PIN(E,9), "pwm1", 1}, /* PWM, BSP: BLUE-LED */
|
||||
{D24, GET_PIN(B,0)}, /* BSP: INFRARED EMISSION */
|
||||
{D25, GET_PIN(B,1)}, /* BSP: INFRARED RECEPTION */
|
||||
{D26, GET_PIN(D,4)}, /* BSP: WIRELESS CE */
|
||||
{D27, GET_PIN(D,3)}, /* BSP: WIRELESS IRQ */
|
||||
{D28, GET_PIN(D,5)}, /* SPI-SS, BSP: WIRELESS CS */
|
||||
{D29, GET_PIN(B,13), "spi2"}, /* SPI-SCK */
|
||||
{D30, GET_PIN(B,14), "spi2"}, /* SPI-MISO */
|
||||
{D31, GET_PIN(B,15), "spi2"}, /* SPI-MOSI */
|
||||
{D32, GET_PIN(C,7), "i2c1"}, /* I2C-SDA (Wire) */
|
||||
{D33, GET_PIN(C,6), "i2c1"}, /* I2C-SCL (Wire) */
|
||||
{D34, GET_PIN(A,2), "uart2"}, /* Serial2-Tx */
|
||||
{D35, GET_PIN(A,3), "uart2"}, /* Serial2-Rx */
|
||||
{A0, GET_PIN(C,2), "adc1", 3}, /* ADC */
|
||||
{A1, GET_PIN(C,4), "adc1", 13}, /* ADC */
|
||||
{A2, RT_NULL, "adc1", 0}, /* ADC, On-Chip: internal reference voltage, ADC_CHANNEL_VREFINT */
|
||||
{A3, RT_NULL, "adc1", 17}, /* ADC, On-Chip: internal temperature sensor, ADC_CHANNEL_TEMPSENSOR */
|
||||
{DAC0, GET_PIN(A,4), "dac1", 1}, /* DAC */
|
||||
};
|
||||
|
|
|
@ -6,68 +6,73 @@
|
|||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-12-10 Meco Man first version
|
||||
* 2022-09-18 Meco Man sort pinout out
|
||||
*/
|
||||
|
||||
#ifndef Pins_Arduino_h
|
||||
#define Pins_Arduino_h
|
||||
|
||||
/* pins alias. Must keep in sequence */
|
||||
#define D0 (0)
|
||||
#define D1 (1)
|
||||
#define D2 (2)
|
||||
#define D3 (3)
|
||||
#define D4 (4)
|
||||
#define D5 (5)
|
||||
#define D6 (6)
|
||||
#define D7 (7)
|
||||
#define D8 (8)
|
||||
#define D9 (9)
|
||||
#define D10 (10)
|
||||
#define D11 (11)
|
||||
#define D12 (12)
|
||||
#define D13 (13)
|
||||
#define D14 (14)
|
||||
#define D15 (15)
|
||||
#define D16 (16)
|
||||
#define D17 (17)
|
||||
#define D18 (18)
|
||||
#define D19 (19)
|
||||
#define D20 (20)
|
||||
#define D21 (21)
|
||||
#define D22 (22)
|
||||
#define D23 (23)
|
||||
#define D24 (24)
|
||||
#define D25 (25)
|
||||
#define D26 (26)
|
||||
#define D27 (27)
|
||||
#define D28 (28)
|
||||
#define D29 (29)
|
||||
#define D30 (30)
|
||||
#define D31 (31)
|
||||
#define D32 (32)
|
||||
#define A0 (33)
|
||||
#define A1 (34)
|
||||
#define A2 (35)
|
||||
#define A3 (36)
|
||||
#define DAC0 (37)
|
||||
#define D0 (0)
|
||||
#define D1 (1)
|
||||
#define D2 (2)
|
||||
#define D3 (3)
|
||||
#define D4 (4)
|
||||
#define D5 (5)
|
||||
#define D6 (6)
|
||||
#define D7 (7)
|
||||
#define D8 (8)
|
||||
#define D9 (9)
|
||||
#define D10 (10)
|
||||
#define D11 (11)
|
||||
#define D12 (12)
|
||||
#define D13 (13)
|
||||
#define D14 (14)
|
||||
#define D15 (15)
|
||||
#define D16 (16)
|
||||
#define D17 (17)
|
||||
#define D18 (18)
|
||||
#define D19 (19)
|
||||
#define D20 (20)
|
||||
#define D21 (21)
|
||||
#define D22 (22)
|
||||
#define D23 (23)
|
||||
#define D24 (24)
|
||||
#define D25 (25)
|
||||
#define D26 (26)
|
||||
#define D27 (27)
|
||||
#define D28 (28)
|
||||
#define D29 (29)
|
||||
#define D30 (30)
|
||||
#define D31 (31)
|
||||
#define D32 (32)
|
||||
#define D33 (33)
|
||||
#define D34 (34)
|
||||
#define D35 (35)
|
||||
#define A0 (36)
|
||||
#define A1 (37)
|
||||
#define A2 (38)
|
||||
#define A3 (39)
|
||||
#define DAC0 (40)
|
||||
|
||||
#define F_CPU 80000000L /* CPU: 80MHz */
|
||||
#define LED_BUILTIN D22 /* Default Built-in LED */
|
||||
#define F_CPU 80000000L /* CPU:80MHz */
|
||||
|
||||
#define LED_BUITIN D22 /* Default Built-in LED */
|
||||
|
||||
/*
|
||||
* i2c1 - PC7-SDA PC6-SCL (User I2C)
|
||||
* i2c3 - ICM20608, AP3216C (On Board)
|
||||
* i2c4 - AHT10 (On Board)
|
||||
*/
|
||||
#define RTDUINO_DEFAULT_IIC_BUS_NAME "i2c4"
|
||||
#define RTDUINO_DEFAULT_IIC_BUS_NAME "i2c4"
|
||||
|
||||
/*
|
||||
* spi2 - Wireless Interface (User SPI)
|
||||
* spi3 - LCD ST7789
|
||||
*/
|
||||
#define RTDUINO_DEFAULT_SPI_BUS_NAME "spi2"
|
||||
/* spi2 - PB13-SCK PB14-MISO PB15-MOSI */
|
||||
#define SS D28 /* Chip select pin of default spi */
|
||||
#define RTDUINO_DEFAULT_SPI_BUS_NAME "spi2"
|
||||
|
||||
#define RTDUINO_DEFAULT_HWTIMER_DEVICE_NAME "timer7"
|
||||
#define RTDUINO_SERIAL2_DEVICE_NAME "uart2"
|
||||
/* Serial2 - PA2-TX PA3-RX */
|
||||
#define RTDUINO_SERIAL2_DEVICE_NAME "uart2"
|
||||
|
||||
#define RTDUINO_DEFAULT_HWTIMER_DEVICE_NAME "timer7"
|
||||
|
||||
#endif /* Pins_Arduino_h */
|
||||
|
|
Loading…
Reference in New Issue