From ce3f60b22bf7cce507f1a665c7a8e42c3ddc256b Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Thu, 12 Jan 2023 14:26:14 -0500 Subject: [PATCH] [RTduino][ch32v307] add English readme --- .../applications/arduino_pinout/README.md | 86 +++++++++---------- .../applications/arduino_pinout/README_zh.md | 64 ++++++++++++++ .../arduino_pinout/pins_arduino.c | 2 +- .../arduino_pinout/pins_arduino.h | 2 - bsp/wch/risc-v/ch32v307v-r1/board/Kconfig | 64 +++++++------- 5 files changed, 139 insertions(+), 79 deletions(-) create mode 100644 bsp/wch/risc-v/ch32v307v-r1/applications/arduino_pinout/README_zh.md diff --git a/bsp/wch/risc-v/ch32v307v-r1/applications/arduino_pinout/README.md b/bsp/wch/risc-v/ch32v307v-r1/applications/arduino_pinout/README.md index 43abf3c44f..edc6335253 100644 --- a/bsp/wch/risc-v/ch32v307v-r1/applications/arduino_pinout/README.md +++ b/bsp/wch/risc-v/ch32v307v-r1/applications/arduino_pinout/README.md @@ -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 Hardware Drivers Config ---> @@ -14,53 +16,49 @@ Hardware Drivers Config ---> [*] 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)。 - -| 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接管 | - -> 注意: +> Notice: > -> 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 `(Arduino官方I2C头文件)即可使用。 +I2C bus is `SCL/D15` and `SDA/D14` pins. Users can directly include the `#include `, 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). diff --git a/bsp/wch/risc-v/ch32v307v-r1/applications/arduino_pinout/README_zh.md b/bsp/wch/risc-v/ch32v307v-r1/applications/arduino_pinout/README_zh.md new file mode 100644 index 0000000000..b5fd75845b --- /dev/null +++ b/bsp/wch/risc-v/ch32v307v-r1/applications/arduino_pinout/README_zh.md @@ -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 `(Arduino官方I2C头文件)即可使用。 + +### 3.2 SPI总线 + +目前本BSP不支持使用Arduino的SPI功能。 + +### 3.3 串口 + +本BSP通过 `Serial.` 方法调用 `uart1` 串口设备。详见[例程](https://github.com/RTduino/RTduino/blob/master/examples/Basic/helloworld.cpp)。 diff --git a/bsp/wch/risc-v/ch32v307v-r1/applications/arduino_pinout/pins_arduino.c b/bsp/wch/risc-v/ch32v307v-r1/applications/arduino_pinout/pins_arduino.c index 04570c1ad9..718d47660b 100644 --- a/bsp/wch/risc-v/ch32v307v-r1/applications/arduino_pinout/pins_arduino.c +++ b/bsp/wch/risc-v/ch32v307v-r1/applications/arduino_pinout/pins_arduino.c @@ -26,7 +26,7 @@ const pin_map_t pin_map_table[]= {D2, GET_PIN(A,8), "pwm1", 1}, /* PWM */ {D3, GET_PIN(A,7), "pwm3", 2}, /* 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 */ {D7, GET_PIN(B,9), "pwm4", 4}, /* PWM */ {D8, GET_PIN(B,1), "pwm3", 4}, /* PWM */ diff --git a/bsp/wch/risc-v/ch32v307v-r1/applications/arduino_pinout/pins_arduino.h b/bsp/wch/risc-v/ch32v307v-r1/applications/arduino_pinout/pins_arduino.h index dad8b1b534..b321f21682 100644 --- a/bsp/wch/risc-v/ch32v307v-r1/applications/arduino_pinout/pins_arduino.h +++ b/bsp/wch/risc-v/ch32v307v-r1/applications/arduino_pinout/pins_arduino.h @@ -37,8 +37,6 @@ #define F_CPU 144000000L /* CPU:144MHz */ -#define LED_BUILTIN D5 /* Default Built-in LED */ - /* i2c1 : PB1-SDA PB10-SCL */ #define RTDUINO_DEFAULT_IIC_BUS_NAME "i2c1" diff --git a/bsp/wch/risc-v/ch32v307v-r1/board/Kconfig b/bsp/wch/risc-v/ch32v307v-r1/board/Kconfig index c188f44f48..c114dd57e4 100644 --- a/bsp/wch/risc-v/ch32v307v-r1/board/Kconfig +++ b/bsp/wch/risc-v/ch32v307v-r1/board/Kconfig @@ -7,6 +7,38 @@ config SOC_CH32V307VC select RT_USING_USER_MAIN 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" config BSP_USING_GPIO bool "Enable GPIO" @@ -554,38 +586,6 @@ menu "On-chip Peripheral Drivers" 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" endmenu