[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:
Man, Jianting (Meco) 2022-09-18 22:14:35 -04:00 committed by GitHub
parent d1c66d0e30
commit 8d3c1f7008
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 358 additions and 307 deletions

View File

@ -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)。

View File

@ -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,21 +7,22 @@
* 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 */
{D4, GET_PIN(B,5)},
@ -30,13 +31,13 @@ const pin_map_t pin_map_table[]=
{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 */
{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 */
{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 */
@ -44,5 +45,5 @@ const pin_map_t pin_map_table[]=
{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 */
{A7, RT_NULL, "adc1", 16}, /* ADC, On-Chip: internal temperature sensor, ADC_CHANNEL_TEMPSENSOR */
};

View File

@ -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
*
@ -39,8 +39,10 @@
#define A7 (24)
#define F_CPU 48000000L /* CPU:48MHz */
#define LED_BUILTIN D13 /* Default Built-in LED */
#define LED_BUITIN D13 /* Default Built-in LED */
/* i2c1 - PB9-SDA PB8-SCL */
#define RTDUINO_DEFAULT_IIC_BUS_NAME "i2c1"
#endif /* Pins_Arduino_h */

View File

@ -21,7 +21,7 @@ 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 |
@ -29,8 +29,8 @@ Hardware Drivers Config --->
| 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 | |
| 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 | |
@ -40,12 +40,12 @@ Hardware Drivers Config --->
| 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 |
| 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 |
@ -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).

View File

@ -21,7 +21,7 @@ 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接管 |
@ -29,8 +29,8 @@ Hardware Drivers Config --->
| 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 | 否 | |
| 7 (D7, SS) | PB12 | 是 | SPI片选默认引脚 |
| 8 (D8, LED_BUILTIN) | PC13 | 否 | 板载LED |
| 9 (D9) | PC14 | 否 | |
| 10 (D10) | PC15 | 否 | |
| 11 (D11) | PA0 | 否 | |
@ -40,12 +40,12 @@ Hardware Drivers Config --->
| 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接管 |
| 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接管 |
@ -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

View File

@ -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 */

View File

@ -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 */

View File

@ -21,9 +21,9 @@ 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接管 |
| ----------- | --------- | ---- | --------------------------------------- |
| 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 | 是 | |
@ -35,10 +35,10 @@ Hardware Drivers Config --->
| 10 (D10) | PB6 | 是 | PWM4-CH1默认被RT-Thread的PWM设备框架pwm4接管 |
| 11 (D11) | PA7 | 是 | PWM1-CH1N默认被RT-Thread的PWM设备框架pwm1接管 |
| 12 (D12) | PA6 | 是 | |
| 13 (D13) | PA5 | 是 | |
| 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 | 是 | Nucleo板载用户按键(左侧蓝色) |
| 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接管 |
@ -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总线
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)。

View File

@ -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 */

View File

@ -21,9 +21,9 @@ Hardware Drivers Config --->
### 2.1 Arduino引脚排布统览
| Arduino引脚编号 | STM32引脚编号 | 5V容忍 | 备注 |
| --------------------- | --------- | ------- | -------------------------------------------- |
| 0 (D0) | -- | | 该引脚在UNO板中为串口RX引脚不可当做普通IO |
| 1 (D1) | -- | | 该引脚在UNO板中为串口TX引脚不可当做普通IO |
| --------------------- | --------- | ------- | -------------------------------------- |
| 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 |
@ -48,25 +48,25 @@ Hardware Drivers Config --->
| 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 |
| 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 |
| -- | PC7 | 是 | I2C1-SDA被RT-Thread的I2C设备框架i2c1总线接管不可当做普通IO |
| -- | PC6 | 是 | I2C1-SCL被RT-Thread的I2C设备框架i2c1总线接管不可当做普通IO |
> 注意:
>
> 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 函数后续也支持了真模拟输出功能。

View File

@ -6,22 +6,24 @@
* 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 */
{D4, GET_PIN(A,8)},
@ -44,18 +46,21 @@ const pin_map_t pin_map_table[]=
{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 */
{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 */
{DAC0, GET_PIN(A,4), "dac1", 1}, /* DAC */
};

View File

@ -6,6 +6,7 @@
* Change Logs:
* Date Author Notes
* 2021-12-10 Meco Man first version
* 2022-09-18 Meco Man sort pinout out
*/
#ifndef Pins_Arduino_h
@ -45,14 +46,18 @@
#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 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 LED_BUITIN D22 /* Default Built-in LED */
/*
* i2c1 - PC7-SDA PC6-SCL (User I2C)
@ -61,13 +66,13 @@
*/
#define RTDUINO_DEFAULT_IIC_BUS_NAME "i2c4"
/*
* spi2 - Wireless Interface (User SPI)
* spi3 - LCD ST7789
*/
/* 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"
/* Serial2 - PA2-TX PA3-RX */
#define RTDUINO_SERIAL2_DEVICE_NAME "uart2"
#define RTDUINO_DEFAULT_HWTIMER_DEVICE_NAME "timer7"
#endif /* Pins_Arduino_h */