[RTduino][ch32v307] add English readme

This commit is contained in:
Meco Man 2023-01-12 14:26:14 -05:00 committed by guo
parent b2402029b2
commit ce3f60b22b
5 changed files with 139 additions and 79 deletions

View File

@ -1,12 +1,14 @@
# CH32V307V-R1的Arduino生态兼容说明 # The Arduino Compatible for CH32V307V-R1
## 1 RTduino - RT-Thread的Arduino生态兼容层 **English** | [中文](README_zh.md)
CH32V307V-R1 开发板已经完整适配了 [RTduino软件包](https://github.com/RTduino/RTduino),即 RT-Thread 的 Arduino生态兼容层。用户可以按照 Arduino 的编程习惯来操作该 BSP并且可以使用大量 Arduino 社区丰富的库是对RT-Thread生态的极大增强。更多信息请参见 [RTduino软件包说明文档](https://github.com/RTduino/RTduino)。 ## 1 RTduino - Arduino Ecosystem Compatibility Layer for RT-Thread
### 1.1 如何开启针对本BSP的Arduino生态兼容层 CH32V307V-R1 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.
Env 工具下敲入 menuconfig 命令,或者 RT-Thread Studio IDE 下选择 RT-Thread Settings ### 1.1 How to Enable RTduino
This board complies with Arduino UNO pins layout. For more details, Please go to the [RTduino repository](https://github.com/RTduino/RTduino).
```Kconfig ```Kconfig
Hardware Drivers Config ---> Hardware Drivers Config --->
@ -14,53 +16,49 @@ Hardware Drivers Config --->
[*] Compatible with Arduino Ecosystem (RTduino) [*] Compatible with Arduino Ecosystem (RTduino)
``` ```
## 2 Arduino引脚排布 ## 2 Arduino Pinout
该BSP遵照Arduino UNO板的引脚排列方式。详见 `pins_arduino.c` For more information, please see [pins_arduino.c](pins_arduino.c) and [pins_arduino.h](pins_arduino.h).
### 2.1 Arduino引脚排布统览 | Arduino Pin | CH32 Pin | 5V Tolerate | Note |
| ----------- | -------- | ----------- | --------------------------------------------------------- |
| 0 (D0) | PA10 | Yes | Serial-Rx. Token over by RT-Thread UART device by default |
| 1 (D1) | PA9 | Yes | Serial-Tx. Token over by RT-Thread UART device by default |
| 2 (D2) | PA8 | Yes | PWM1-CH1. Token over by RT-Thread PWM device by default |
| 3 (D3) | PA7 | No | PWM3-CH2. Token over by RT-Thread PWM device by default |
| 4 (D4) | PA6 | No | PWM3-CH1. Token over by RT-Thread PWM device by default |
| 5 (D5) | PB5 | Yes | |
| 6 (D6) | PB8 | Yes | PWM4-CH3. Token over by RT-Thread PWM device by default |
| 7 (D7) | PB9 | Yes | PWM4-CH4. Token over by RT-Thread PWM device by default |
| 8 (D8) | PB1 | No | PWM3-CH4. Token over by RT-Thread PWM device by default |
| 9 (D9) | PB0 | No | PWM3-CH3. Token over by RT-Thread PWM device by default |
| 10 (D10) | PB12 | Yes | |
| 11 (D11) | PB15 | Yes | |
| 12 (D12) | PB14 | Yes | |
| 13 (D13) | PB13 | Yes | |
| 14 (D14) | PB11 | Yes | I2C-SDA. Token over by RT-Thread I2C device by default |
| 15 (D15) | PB10 | No | I2C-SCL. Token over by RT-Thread I2C device by default |
| A0 | PA0 | No | ADC1-CH0. Token over by RT-Thread ADC device by default |
| A1 | PA1 | No | ADC1-CH1. Token over by RT-Thread ADC device by default |
| A2 | PA2 | No | ADC1-CH2. Token over by RT-Thread ADC device by default |
| A3 | PA3 | No | ADC1-CH3. Token over by RT-Thread ADC device by default |
| A4 | PA4 | No | ADC1-CH4. Token over by RT-Thread ADC device by default |
| A5 | PA5 | No | ADC1-CH5. Token over by RT-Thread ADC device by default |
更多引脚布局相关信息参见 [pins_arduino.c](./pins_arduino.c) 和 [pins_arduino.h](./pins_arduino.h)。 > Notice:
| Arduino引脚编号 | CH32引脚编号 | 5V容忍 | 备注 |
| ----------- | -------- | ---- | -------------------------------------- |
| 0 (D0) | PA10 | 是 | Serial-Rx默认被RT-Thread的UART设备框架uart1接管 |
| 1 (D1) | PA9 | 是 | Serial-Tx默认被RT-Thread的UART设备框架uart1接管 |
| 2 (D2) | PA8 | 是 | PWM1-CH1默认被RT-Thread的PWM设备框架pwm1接管 |
| 3 (D3) | PA7 | 否 | PWM3-CH2默认被RT-Thread的PWM设备框架pwm3接管 |
| 4 (D4) | PA6 | 否 | PWM3-CH1默认被RT-Thread的PWM设备框架pwm3接管 |
| 5 (D5) | PB5 | 是 | 默认led灯需使用杜邦线连接 |
| 6 (D6) | PB8 | 是 | PWM4-CH3默认被RT-Thread的PWM设备框架pwm4接管 |
| 7 (D7) | PB9 | 是 | PWM4-CH4默认被RT-Thread的PWM设备框架pwm4接管 |
| 8 (D8) | PB1 | 否 | PWM3-CH4默认被RT-Thread的PWM设备框架pwm3接管 |
| 9 (D9) | PB0 | 否 | PWM3-CH3默认被RT-Thread的PWM设备框架pwm3接管 |
| 10 (D10) | PB12 | 是 | 普通IO |
| 11 (D11) | PB15 | 是 | 普通IO |
| 12 (D12) | PB14 | 是 | 普通IO |
| 13 (D13) | PB13 | 是 | 普通IO |
| 14 (D14) | PB11 | 是 | I2C-SDA默认被RT-Thread的I2C设备框架i2c1总线接管 |
| 15 (D15) | PB10 | 否 | I2C-SCL默认被RT-Thread的I2C设备框架i2c1总线接管 |
| A0 | PA0 | 否 | ADC1-CH0默认被RT-Thread的ADC设备框架adc1接管 |
| A1 | PA1 | 否 | ADC1-CH1默认被RT-Thread的ADC设备框架adc1接管 |
| A2 | PA2 | 否 | ADC1-CH2默认被RT-Thread的ADC设备框架adc1接管 |
| A3 | PA3 | 否 | ADC1-CH3默认被RT-Thread的ADC设备框架adc1接管 |
| A4 | PA4 | 否 | ADC1-CH4默认被RT-Thread的ADC设备框架adc1接管 |
| A5 | PA5 | 否 | ADC1-CH5默认被RT-Thread的ADC设备框架adc1接管 |
> 注意:
> >
> 1. 驱动舵机和analogWrite函数要选择不同定时器发生的PWM信号引脚由于CH32的定时器4个通道需要保持相同的频率如果采用相同的定时器发生的PWM分别驱动舵机和analogWrite可能会导致舵机失效。 > 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.
## 3 通信 ## 3 Communication
### 3.1 I2C总线 ### 3.1 I2C Bus
CH32V307-R1 开发板的I2C总线是板上丝印的 `SCL/D15` 和 `SDA/D14` 引脚这两个引脚默认是被RT-Thread I2C设备框架接管的直接引用`#include <Wire.h>`Arduino官方I2C头文件即可使用。 I2C 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.
### 3.2 SPI总线 ### 3.2 SPI Bus
目前本BSP不支持使用Arduino的SPI功能。 This board doesn't support Arduino SPI header file and functions.
### 3.3 串口 ### 3.3 Serial
本BSP通过 `Serial.` 方法调用 `uart1` 串口设备。详见[例程](https://github.com/RTduino/RTduino/blob/master/examples/Basic/helloworld.cpp)。 This board supports to use `Serial.` method to operate `uart1` device. See [example](https://github.com/RTduino/RTduino/blob/master/examples/Basic/helloworld.cpp).

View File

@ -0,0 +1,64 @@
# CH32V307V-R1的Arduino生态兼容说明
[English](README.md) | **中文**
## 1 RTduino - RT-Thread的Arduino生态兼容层
CH32V307V-R1 开发板已经完整适配了 [RTduino软件包](https://github.com/RTduino/RTduino),即 RT-Thread 的 Arduino生态兼容层。用户可以按照 Arduino 的编程习惯来操作该 BSP并且可以使用大量 Arduino 社区丰富的库是对RT-Thread生态的极大增强。更多信息请参见 [RTduino软件包说明文档](https://github.com/RTduino/RTduino)。
### 1.1 如何开启针对本BSP的Arduino生态兼容层
Env 工具下敲入 menuconfig 命令,或者 RT-Thread Studio IDE 下选择 RT-Thread Settings
```Kconfig
Hardware Drivers Config --->
Onboard Peripheral Drivers --->
[*] Compatible with Arduino Ecosystem (RTduino)
```
## 2 Arduino引脚排布
该BSP遵照Arduino UNO板的引脚排列方式更多引脚布局相关信息参见 [pins_arduino.c](./pins_arduino.c) 和 [pins_arduino.h](./pins_arduino.h)。
| Arduino引脚编号 | CH32引脚编号 | 5V容忍 | 备注 |
| ----------- | -------- | ---- | -------------------------------------- |
| 0 (D0) | PA10 | 是 | Serial-Rx默认被RT-Thread的UART设备框架uart1接管 |
| 1 (D1) | PA9 | 是 | Serial-Tx默认被RT-Thread的UART设备框架uart1接管 |
| 2 (D2) | PA8 | 是 | PWM1-CH1默认被RT-Thread的PWM设备框架pwm1接管 |
| 3 (D3) | PA7 | 否 | PWM3-CH2默认被RT-Thread的PWM设备框架pwm3接管 |
| 4 (D4) | PA6 | 否 | PWM3-CH1默认被RT-Thread的PWM设备框架pwm3接管 |
| 5 (D5) | PB5 | 是 | |
| 6 (D6) | PB8 | 是 | PWM4-CH3默认被RT-Thread的PWM设备框架pwm4接管 |
| 7 (D7) | PB9 | 是 | PWM4-CH4默认被RT-Thread的PWM设备框架pwm4接管 |
| 8 (D8) | PB1 | 否 | PWM3-CH4默认被RT-Thread的PWM设备框架pwm3接管 |
| 9 (D9) | PB0 | 否 | PWM3-CH3默认被RT-Thread的PWM设备框架pwm3接管 |
| 10 (D10) | PB12 | 是 | |
| 11 (D11) | PB15 | 是 | |
| 12 (D12) | PB14 | 是 | |
| 13 (D13) | PB13 | 是 | |
| 14 (D14) | PB11 | 是 | I2C-SDA默认被RT-Thread的I2C设备框架i2c1总线接管 |
| 15 (D15) | PB10 | 否 | I2C-SCL默认被RT-Thread的I2C设备框架i2c1总线接管 |
| A0 | PA0 | 否 | ADC1-CH0默认被RT-Thread的ADC设备框架adc1接管 |
| A1 | PA1 | 否 | ADC1-CH1默认被RT-Thread的ADC设备框架adc1接管 |
| A2 | PA2 | 否 | ADC1-CH2默认被RT-Thread的ADC设备框架adc1接管 |
| A3 | PA3 | 否 | ADC1-CH3默认被RT-Thread的ADC设备框架adc1接管 |
| A4 | PA4 | 否 | ADC1-CH4默认被RT-Thread的ADC设备框架adc1接管 |
| A5 | PA5 | 否 | ADC1-CH5默认被RT-Thread的ADC设备框架adc1接管 |
> 注意:
>
> 1. 驱动舵机和analogWrite函数要选择不同定时器发生的PWM信号引脚由于硬件定时器4个通道需要保持相同的频率如果采用相同的定时器发生的PWM分别驱动舵机和analogWrite可能会导致舵机失效。
## 3 通信
### 3.1 I2C总线
CH32V307-R1 开发板的I2C总线是板上丝印的 `SCL/D15``SDA/D14` 引脚这两个引脚默认是被RT-Thread I2C设备框架接管的直接引用`#include <Wire.h>`Arduino官方I2C头文件即可使用。
### 3.2 SPI总线
目前本BSP不支持使用Arduino的SPI功能。
### 3.3 串口
本BSP通过 `Serial.` 方法调用 `uart1` 串口设备。详见[例程](https://github.com/RTduino/RTduino/blob/master/examples/Basic/helloworld.cpp)。

View File

@ -26,7 +26,7 @@ const pin_map_t pin_map_table[]=
{D2, GET_PIN(A,8), "pwm1", 1}, /* PWM */ {D2, GET_PIN(A,8), "pwm1", 1}, /* PWM */
{D3, GET_PIN(A,7), "pwm3", 2}, /* PWM */ {D3, GET_PIN(A,7), "pwm3", 2}, /* PWM */
{D4, GET_PIN(A,6), "pwm3", 1}, /* PWM */ {D4, GET_PIN(A,6), "pwm3", 1}, /* PWM */
{D5, GET_PIN(B,5)}, /* LED_BUILTIN */ {D5, GET_PIN(B,5)},
{D6, GET_PIN(B,8), "pwm4", 3}, /* PWM */ {D6, GET_PIN(B,8), "pwm4", 3}, /* PWM */
{D7, GET_PIN(B,9), "pwm4", 4}, /* PWM */ {D7, GET_PIN(B,9), "pwm4", 4}, /* PWM */
{D8, GET_PIN(B,1), "pwm3", 4}, /* PWM */ {D8, GET_PIN(B,1), "pwm3", 4}, /* PWM */

View File

@ -37,8 +37,6 @@
#define F_CPU 144000000L /* CPU:144MHz */ #define F_CPU 144000000L /* CPU:144MHz */
#define LED_BUILTIN D5 /* Default Built-in LED */
/* i2c1 : PB1-SDA PB10-SCL */ /* i2c1 : PB1-SDA PB10-SCL */
#define RTDUINO_DEFAULT_IIC_BUS_NAME "i2c1" #define RTDUINO_DEFAULT_IIC_BUS_NAME "i2c1"

View File

@ -7,6 +7,38 @@ config SOC_CH32V307VC
select RT_USING_USER_MAIN select RT_USING_USER_MAIN
default y default y
menu "Onboard Peripheral Drivers"
config BSP_USING_ARDUINO
bool "Compatible with Arduino Ecosystem (RTduino)"
select PKG_USING_RTDUINO
select BSP_USING_GPIO
select BSP_USING_ADC
select BSP_USING_ADC1
select BSP_USING_TIM
select BSP_USING_PWM
select BSP_USING_TIM1
select BSP_USING_TIM1_PWM
select BSP_USING_TIM1_PWM_CH1
select BSP_USING_TIM3
select BSP_USING_TIM3_PWM
select BSP_USING_TIM3_PWM_CH1
select BSP_USING_TIM3_PWM_CH2
select BSP_USING_TIM3_PWM_CH3
select BSP_USING_TIM3_PWM_CH4
select BSP_USING_TIM4
select BSP_USING_TIM4_PWM
select BSP_USING_TIM4_PWM_CH3
select BSP_USING_TIM4_PWM_CH4
select BSP_USING_TIM6
select BSP_USING_TIM6_HWTIMER
select BSP_USING_SOFT_I2C
select BSP_USING_I2C1
imply RTDUINO_USING_SERVO
imply RTDUINO_USING_WIRE
default n
endmenu
menu "On-chip Peripheral Drivers" menu "On-chip Peripheral Drivers"
config BSP_USING_GPIO config BSP_USING_GPIO
bool "Enable GPIO" bool "Enable GPIO"
@ -554,38 +586,6 @@ menu "On-chip Peripheral Drivers"
endmenu endmenu
menu "Onboard Peripheral Drivers"
config BSP_USING_ARDUINO
bool "Compatible with Arduino Ecosystem (RTduino)"
select PKG_USING_RTDUINO
select BSP_USING_GPIO
select BSP_USING_ADC
select BSP_USING_ADC1
select BSP_USING_TIM
select BSP_USING_PWM
select BSP_USING_TIM1
select BSP_USING_TIM1_PWM
select BSP_USING_TIM1_PWM_CH1
select BSP_USING_TIM3
select BSP_USING_TIM3_PWM
select BSP_USING_TIM3_PWM_CH1
select BSP_USING_TIM3_PWM_CH2
select BSP_USING_TIM3_PWM_CH3
select BSP_USING_TIM3_PWM_CH4
select BSP_USING_TIM4
select BSP_USING_TIM4_PWM
select BSP_USING_TIM4_PWM_CH3
select BSP_USING_TIM4_PWM_CH4
select BSP_USING_TIM6
select BSP_USING_TIM6_HWTIMER
select BSP_USING_SOFT_I2C
select BSP_USING_I2C1
imply RTDUINO_USING_SERVO
imply RTDUINO_USING_WIRE
default n
endmenu
menu "Board extended module Drivers" menu "Board extended module Drivers"
endmenu endmenu