diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/README.md b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/README.md index 60f4f17ba..5d75b7205 100644 --- a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/README.md +++ b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/README.md @@ -1,58 +1,181 @@ -# CH32V307VCT6-board README +# 1. 简介 -## 1. 简介 +| 硬件 | 描述 | +| --------- | ------------------------------------------------------------ | +| 芯片型号 | CH32V208RBT6 | +| CPU | 单核RISC-V4C | +| 主频 | 144MHz | +| 片内SRAM | 可配:32KB、48KB、64KB | +| 片内FLASH | 可配:160KB、144KB、128KB | +| 外设 | 2Mbps低功耗蓝牙BLE通讯模块、10M以太网MAC+PHY模块、USB2.0全速设备+主机/设备接口、CAN控制器等 | -| 硬件 | 描述 | -| -- | -- | -|芯片型号| ch32v307 | -|CPU| 单核RV32GC | -|主频| 144MHz | -|片内SRAM| 可配最大128KB | -| 外设 | | -| | GPIO、UART| +# 2. 克隆代码 -## 2. 编译说明 +将XiUOS的源代码克隆下来: -编译环境:Ubuntu18.04 - -编译工具链:riscv-none-embed-gcc ( xPack GNU RISC-V Embedded GCC) -**xPack RISC-V Embedded GCC** 工具链可以使用[xpm](https://www.npmjs.com/package/xpm)工具进行安装: - -```console -$ xpm install --global @xpack-dev-tools/riscv-none-embed-gcc@8.2.0-3.1.1 +```bash +git clone https://gitlink.org.cn/xuos/xiuos.git ``` -编译步骤: +# 3. 下载编译工具链 ->1.将编译工具链的路径添加到board/ch32v307vct6/config.mk文件当中,例如将xpack-riscv-none-elf-gcc解压到/opt/下时添加: -``` -export CROSS_COMPILE ?=/opt/riscv-embedded-gcc/bin/riscv-none-embed- -``` ->2.在代码根目录下执行以下命令,生成配置文件 -``` -cd ./Ubiquitous/XiZi -make BOARD=ch32v307vct6 distclean -make BOARD=ch32v307vct6 menuconfig -``` ->3.在menuconfig界面配置需要关闭和开启的功能,按回车键进入下级菜单,按Y键选中需要开启的功能,按N键选中需要关闭的功能,配置结束后选择Exit保存并退出 ->4.继续执行以下命令,进行编译 -``` -make BOARD=ch32v307vct6 -``` ->5.如果编译正确无误,会产生XiZi-ch32v307vct6.elf、XiZi-ch32v307vct6.bin文件。其中XiZi-ch32v307vct6.bin需要烧写到设备中进行运行。 ->注:最后可以执行以下命令,清除配置文件和编译生成的文件 -``` -make BOARD=ch32v307vct6 distclean +编译环境:Ubuntu 20.04.6 LTS + +编译工具链:riscv-none-elf-gcc(xpack-riscv-none-elf-gcc-11.3.0-1) + +编译工具链可到Github进行下载:https://github.com/xpack-dev-tools/riscv-none-elf-gcc-xpack/releases + +![image-20240509155858504](imgs/image-20240509155858504.png) + +下载完成后将其移动到`/opt`目录下,并进行解压: + +```bash +sudo tar -xvzf xpack-riscv-none-elf-gcc-11.3.0-1-linux-x64.tar.gz ``` -## 3. 烧写及执行 +# 4. 编译 -开发板可使用数据线通过USB接口与电脑连接,将开发板的Boot0接口通电(连接VCC)后按动ReSet按钮,即可使用烧录工具[WCHISPTool](https://www.wch.cn/download/WCHISPTool_Setup_exe.html)进行烧录。![board_settng](img/board.jpg)烧录工具的配置如下图所示。![WCHISPTool配置](img/WCHIPSTool_setting.PNG) +1. 设置`CROSS_COMPILE`环境变量,以下为将编译工具链解压到`/opt`目录下时的命令: -烧录完成后可通过串口连接PC电脑与开发版,TX(PA9)接串口RX、RX(PA10)接串口TX。![](img/serial.jpg) + ```bash + export CROSS_COMPILE=/opt/xpack-riscv-none-elf-gcc-11.3.0-1/bin/riscv-none-elf- + ``` -### 3.1 运行结果 +2. 在`./Ubiquitous/XiZi_IIoT`目录下执行命令: -如果编译 & 烧写无误,将开发板BOOT引脚与VCC引脚断开后重新上电或将RESET引脚短接一下,将会在串口终端上看到信息打印输出。 + ```bash + make BOARD=ch32v208rbt6 distclean # 将之前的编译生成文件清空 + make BOARD=ch32v208rbt6 menuconfig # 进行编译设置 + ``` -![terminal](img/terminal.PNG) \ No newline at end of file + 如果`make BOARD=ch32v208rbt6 menuconfig`显示【无法找到`kconfig-mconf`】,需要先安装`ncurses-devel`和`kconfig-mconf`,如下: + + ```bash + sudo apt install libncurses5-dev kconfig-frontends + ``` + +3. 在`menuconfig`配置界面选择要增加的功能。按回车键进入下级菜单,按Y键选中需要开启的功能,按N键选中需要关闭的功能,配置结束后选择Exit保存并退出,完成后会生成`.config`文件。 + +4. 进行编译: + + ```bash + make BOARD=ch32v208rbt6 + ``` + +5. 编译完成后会生成`XiZi-ch32v208rbt6.bin`文件,将该文件拷贝至Windows侧待下一步进行烧录。 + +# 5. 端口连接 + +`ch32v208rbt6`需要使用`WCH-LINK`模块进行串口连接,各个端口的连接如下: + +| 接口组别 | ch32v208rbt6 | WCH-LINK | +| -------------- | ------------ | -------- | +| J2(编程接口) | GND | GND | +| J2(编程接口) | DIO | SWDIO | +| J2(编程接口) | CLK | SWCLK | +| J2(编程接口) | 3V3 | 3V3 | +| J3(通信接口) | GND | GND | +| J3(通信接口) | TX | RX | +| J3(通信接口) | RX | TX | + +连接后如下: + +![cb4d033a1ed826e9cee7acbdc225fab5](imgs/cb4d033a1ed826e9cee7acbdc225fab5.jpeg) + +# 6. WCH-LINK模块固件更新(可选) + +如WCH-LINK模块蓝灯闪烁,代表其固件缺失,需要进行固件烧录或者更新。 + +可以使用[MounRiver Studio](http://www.mounriver.com/download)在线更新。更新步骤如下: + +1. 将WCH-LINK连接至电脑。 + +2. 打开MounRiver Studio,点击`download`图标右边的向下箭头,点击`configuration`,如下所示: + +![image-20240509163525255](imgs/image-20240509163525255.png) + +3. 显示窗口后,点击任意`query`按钮即可进行固件更新,如下: + +image-20240509163753634 + +4. 待WCH-LINK模块红灯亮起,表示固件更新完成。 + +# 7. 烧录 + +1. 下载`WCH-LinkUtility`工具:https://www.wch.cn/downloads/WCH-LinkUtility_ZIP.html + +2. ch32v208rbt6连接电源线(如果电源线只有两根,保证`IN`和其中一个`GND`接地即可),如下: + +5B75D386B81B5235B2A6274534359E34 + +3. 将WCH-LINK连接至电脑,设备管理器显示`WCH-LinkRV`表示连接成功,如下: + + image-20240509164821442 + +4. 打开烧录软件WCH-LinkUtility,如下: + + image-20240509165100764 + + 1)连接 WCH-Link。 + + 2)选择芯片信息,`MCU Core`选择`RISC-V`,`Series`选择`CH32V20X`。 + + 3)添加固件,即[2. 编译](# 2. 编译)中编译好的`XiZi-ch32v208rbt6.bin`文件。 + + 4)设置配置,若芯片为读保护需解除芯片读保护。 + + 5)执行。 + + ## 7.1 指定ROM和RAM大小 + + > 参考资料: + > + > [1]https://www.cnblogs.com/gscw/p/17286307.html + + > [!caution] + > + > WCH-LinkUtility中需要指定ROM和RAM大小,如果大小与源文件`link.ld`中的ROM和RAM大小不一致,可能会导致XiZi启动失败。 + + 在WCH_LinkUtility中,在以下位置指定ROM和RAM大小: + + image-20240613144008865 + + 其中,set按钮用于设置CH32V208的ROM和RAM大小,get按钮用于获取CH32V208的当前ROM和RAM大小。 + + 在`link.ld`中,在以下代码位置配置ROM和RAM大小: + + ```c + /* CH32V20x_D8 - CH32V203RB + CH32V20x_D8W - CH32V208x + FLASH + RAM supports the following configuration + FLASH-128K + RAM-64K + FLASH-144K + RAM-48K + FLASH-160K + RAM-32K + */ + FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 448K + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K + ``` + + 以下是测试成功的RAM和ROM大小配置,如果编译时显示RAM或者ROM不足,则需要调整RAM或者ROM。推荐使用下面的慢速FLASH配置。 + + 1. 仅使用快速FLASH + + | link.ld | WCH-LinkUtility | + | ------------------------- | ------------------ | + | 128K(FLASH)+ 64K(RAM) | 128K ROM + 64K RAM | + | 144K(FLASH)+ 48K(RAM) | 144K ROM + 48K RAM | + | 160K(FLASH)+ 32K(RAM) | 160K ROM + 32K RAM | + + 2. 使用慢速FLASH + + | link.ld | WCH-LinkUtility | + | ------------------------- | ------------------ | + | 448K(FLASH)+ 64K(RAM) | 128K ROM + 64K RAM | + +# 8. 启动 + +烧录完成后,并且将WCH-LINK连接至电脑串口。 + +按下ch32v208rbt6板上的`RST`按钮,即可看到操作系统启动的信息,如下: + +![image-20240509165901360](imgs/image-20240509165901360.png) \ No newline at end of file diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/img/WCHIPSTool_setting.PNG b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/img/WCHIPSTool_setting.PNG deleted file mode 100755 index fb242357a..000000000 Binary files a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/img/WCHIPSTool_setting.PNG and /dev/null differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/img/board.jpg b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/img/board.jpg deleted file mode 100755 index 4d9014b39..000000000 Binary files a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/img/board.jpg and /dev/null differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/img/serial.jpg b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/img/serial.jpg deleted file mode 100755 index 66a4bdf05..000000000 Binary files a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/img/serial.jpg and /dev/null differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/img/terminal.PNG b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/img/terminal.PNG deleted file mode 100755 index 896103b55..000000000 Binary files a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/img/terminal.PNG and /dev/null differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/imgs/5B75D386B81B5235B2A6274534359E34.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/imgs/5B75D386B81B5235B2A6274534359E34.png new file mode 100644 index 000000000..f31fe1b4d Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/imgs/5B75D386B81B5235B2A6274534359E34.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/imgs/cb4d033a1ed826e9cee7acbdc225fab5.jpeg b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/imgs/cb4d033a1ed826e9cee7acbdc225fab5.jpeg new file mode 100644 index 000000000..5e984959c Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/imgs/cb4d033a1ed826e9cee7acbdc225fab5.jpeg differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/imgs/image-20240509155858504.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/imgs/image-20240509155858504.png new file mode 100644 index 000000000..2f2b94e34 Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/imgs/image-20240509155858504.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/imgs/image-20240509163525255.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/imgs/image-20240509163525255.png new file mode 100644 index 000000000..d9fbe83b7 Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/imgs/image-20240509163525255.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/imgs/image-20240509163753634.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/imgs/image-20240509163753634.png new file mode 100644 index 000000000..2419869ae Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/imgs/image-20240509163753634.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/imgs/image-20240509164821442.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/imgs/image-20240509164821442.png new file mode 100644 index 000000000..99cddf32d Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/imgs/image-20240509164821442.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/imgs/image-20240509165100764.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/imgs/image-20240509165100764.png new file mode 100644 index 000000000..dece858b4 Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/imgs/image-20240509165100764.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/imgs/image-20240509165901360.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/imgs/image-20240509165901360.png new file mode 100644 index 000000000..bce8354bc Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/imgs/image-20240509165901360.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/imgs/image-20240613144008865.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/imgs/image-20240613144008865.png new file mode 100644 index 000000000..55c922be8 Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/imgs/image-20240613144008865.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ble/README.md b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ble/README.md new file mode 100644 index 000000000..bfb3915c0 --- /dev/null +++ b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ble/README.md @@ -0,0 +1,52 @@ +# 1. 特殊配置 + +CH32V208支持2Mbps低功耗蓝牙BLE通讯模块。 + +在进行正常程序编译烧录的过程中,需要进行以下特殊配置,其他步骤保持一致。 + +## 1.1 menuconfig + +在menuconfig配置界面中,根据以下路径选择: + +`ch32v208rbt6 feature`->勾选`Using BLE`,如下所示: + +![image-20240613140451994](imgs/image-20240613140451994.png) + +## 1.2 烧录 + +在首次将包含蓝牙的程序烧录进CH32V208时,在WCH-LinkUtility烧录工具中,需要勾选`Erase All`选项,如下所示,此后烧录则无需勾选该选项: + +![image-20240613140951925](imgs/image-20240613140951925.png) + +## 1.3 ROM和RAM大小设置 + +由于蓝牙源文件中有静态库,源文件的ROM大小可能会超过128K,因此最好启用慢速FLASH。详见`Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/README.md`中的`7. 烧录`一节。 + +# 2. 连接蓝牙 + +启动系统完成后,使用`test_ble`命令启动蓝牙。如果在[1.2 烧录](#1.2 烧录)中是首次进行烧录,那么会看到以下内容: + +![image-20240613141557338](imgs/image-20240613141557338.png) + +此时蓝牙并没有启动成功,需要按下CH32V208上的复位按钮,待系统启动完成后再次输入`test_ble`命令,此时蓝牙才可以启动成功,如下所示: + +![image-20240613141821767](imgs/image-20240613141821767.png) + +> [!note] +> +> 此后烧录,如果在`WCH-LinkUtility`中没有勾选`Erase All`,那么可以一次启动蓝牙成功,无需复位。 + +此时,在手机任意蓝牙调试程序中,即可看到`wch_ble_uart`的蓝牙设备,如下: + +image-20240613142109901 + +连接之后,发送信息,即可在串口调试中,看到所发送的信息,表示CH32V208成功收到蓝牙信息,如下图所示: + +![image-20240613142439953](imgs/image-20240613142439953.png) + +# 3. 断开蓝牙 + +目前,测试程序无法自行断开蓝牙,需要在手机上主动断开蓝牙。断开之后,系统程序回到命令行,如下: + +![image-20240613142940868](imgs/image-20240613142940868.png) + diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ble/imgs/image-20240613140451994.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ble/imgs/image-20240613140451994.png new file mode 100644 index 000000000..d186f25f1 Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ble/imgs/image-20240613140451994.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ble/imgs/image-20240613140951925.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ble/imgs/image-20240613140951925.png new file mode 100644 index 000000000..bf2db9eb0 Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ble/imgs/image-20240613140951925.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ble/imgs/image-20240613141557338.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ble/imgs/image-20240613141557338.png new file mode 100644 index 000000000..76c267843 Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ble/imgs/image-20240613141557338.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ble/imgs/image-20240613141821767.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ble/imgs/image-20240613141821767.png new file mode 100644 index 000000000..08e168f8c Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ble/imgs/image-20240613141821767.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ble/imgs/image-20240613142109901.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ble/imgs/image-20240613142109901.png new file mode 100644 index 000000000..d081e137e Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ble/imgs/image-20240613142109901.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ble/imgs/image-20240613142439953.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ble/imgs/image-20240613142439953.png new file mode 100644 index 000000000..7b4f43b93 Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ble/imgs/image-20240613142439953.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ble/imgs/image-20240613142940868.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ble/imgs/image-20240613142940868.png new file mode 100644 index 000000000..858da4a9d Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ble/imgs/image-20240613142940868.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/can/README.md b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/can/README.md new file mode 100644 index 000000000..9dbc7c3ba --- /dev/null +++ b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/can/README.md @@ -0,0 +1,55 @@ +# 1. 特殊配置 + +## 1.1 CAN波特率配置 + +> 参考资料: +> +> [1]https://www.cnblogs.com/wchmcu/p/17546797.html + +如果CAN波特率配置不正确,导致CAN上位机无法识别波特率,那么会导致CAN发送信息失败。 + +在源程序中CAN的计算公式为:$CANbps=tpclk1/((TS1[3:0]+1+TS2[2:0]+1 +1)*(BPR[9:0]+1))$ + +源文件配置CAN波特率的位置为`Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/can/test/can_test.c`的`static int init_can(u8 tsjw, u8 tbs2, u8 tbs1, u16 brp, u8 mode)`方法。 + +初始波特率配置为: + +```c +init_can(CAN_SJW_1tq, CAN_BS2_5tq, CAN_BS1_6tq, 20, CAN_Mode_Normal); +``` + +即$60M/((4+1+5+1+1))*(19+1))=250Kbps$ + +> [!note] +> +> 主频在`Ubiquitous/XiZi_IIoT/arch/risc-v/ch32v208rbt6/User/system_ch32v20x.c`中配置,需要注意tpclk1为主频的1/2,因此主频如果设置为120MHz,那么对应的tpclk1为60MHz。 + +## 1.2 menuconfig + +在menuconfig配置界面中,根据以下路径选择: + +`ch32v208rbt6 feature`->勾选`Using CAN device`,如下所示: + +![image-20240613152126116](imgs/image-20240613152126116.png) + +# 2. 连接USBCAN分析仪 + +此处测试使用的是广成USBCAN-II Pro+分析仪。 + +将CH32V208的CAN_H端口与分析仪CAN1的H端口相连,将CH32V208的CAN_L端口与分析仪CAN1的L端口相连,如下图所示: + +image-20240613153049516 + +# 3. CAN总线发送信息 + +USBCAN上位机注意选择波特率为250K(默认)。注意关闭帧id过滤功能。 + +![image-20240613153336507](imgs/image-20240613153336507.png) + +打开上位机之后,在XiZi命令行输入`test_can`命令,此时程序自动往CAN总线发送信息。如果发送信息成功,命令行会显示以下内容: + +![image-20240613153729116](imgs/image-20240613153729116.png) + +同时在USBCAN上位机显示接受CAN帧成功,如下所示: + +![image-20240613153847722](imgs/image-20240613153847722.png) \ No newline at end of file diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/can/imgs/image-20240613152126116.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/can/imgs/image-20240613152126116.png new file mode 100644 index 000000000..b5f66c185 Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/can/imgs/image-20240613152126116.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/can/imgs/image-20240613153049516.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/can/imgs/image-20240613153049516.png new file mode 100644 index 000000000..9915464fc Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/can/imgs/image-20240613153049516.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/can/imgs/image-20240613153336507.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/can/imgs/image-20240613153336507.png new file mode 100644 index 000000000..1d7d19a7b Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/can/imgs/image-20240613153336507.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/can/imgs/image-20240613153729116.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/can/imgs/image-20240613153729116.png new file mode 100644 index 000000000..04389a1c7 Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/can/imgs/image-20240613153729116.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/can/imgs/image-20240613153847722.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/can/imgs/image-20240613153847722.png new file mode 100644 index 000000000..24b3159e9 Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/can/imgs/image-20240613153847722.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/README.md b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/README.md new file mode 100644 index 000000000..86c24afe5 --- /dev/null +++ b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/README.md @@ -0,0 +1,79 @@ +# 1. 特殊配置 + +## 1.1 IP地址配置 + +目前IP地址配置内容在代码中写死,所在的源文件为`Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/connect_ether.c`。 + +其内容可以自行修改: + +```c +uint8_t IPAddr[4] = { 192, 168, 1, 10 }; // IP address +uint8_t GWIPAddr[4] = { 192, 168, 1, 1 }; // Gateway IP address +uint8_t IPMask[4] = { 255, 255, 255, 0 }; // subnet mask +uint8_t DESIP[4] = { 192, 168, 1, 100 }; // destination IP address +``` + +以上默认配置表示: + +- CH32V208的IP地址为192.168.1.10 +- 网关地址为192.168.1.1 +- 子网掩码为255.255.255.0 +- 目的地址为192.168.1.100(`test_tcp_client`命令连接的服务器地址) + +将CH32V208与电脑连接好网线,并启动XiZi之后,电脑的IP地址配置如下所示: + +image-20240613155912432 + +## 1.2 ROM和RAM大小设置 + +由于以太网源文件中有静态库,源文件的ROM大小可能会超过128K,因此最好启用慢速FLASH。详见`Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/README.md`中的`7. 烧录`一节。 + +## 1.3 Menuconfig + +在menuconfig配置界面中,根据以下路径选择: + +`ch32v208rbt6 feature`->勾选`Using Ethernet`,如下所示: + +![image-20240613172343662](imgs/image-20240613172343662.png) + +# 2. ping + +使用网线连接CH32V208和电脑,并且启动XiZi操作系统后,在命令行输入`ping `。如果CH32V208与电脑网络畅通,会显示以下内容: + +![image-20240613161310960](imgs/image-20240613161310960.png) + +如果CH32V208与电脑网络不畅通,会显示以下内容(使用错误IP地址测试): + +![image-20240613161426964](imgs/image-20240613161426964.png) + +# 3. test_tcp_client + +`test_tcp_client`命令测试CH32V208作为客户端连接服务器。 + +使用`TcpIpDebug`调试工具模拟服务器,下载地址:https://www.wch.cn/downloads/TcpIpDebug_exe.html + +## 3.1 创建服务器 + +在电脑中打开TcpIpDebug工具后,创建服务器,IP地址和端口配置如下: + +![image-20240613162119335](imgs/image-20240613162119335.png) + +## 3.2 启动服务器 + +右键点击刚刚创建的服务器,点击启动服务器,如下所示: + +image-20240613162253358 + +## 3.3 连接服务器 + +在XiZi命令行中键入命令`test_tcp_client`,显示以下内容表示连接服务器成功: + +![image-20240613162645796](imgs/image-20240613162645796.png) + +在TcpIpDebug中可以模拟服务器向客户端发送信息,发送之后在XiZi命令行会显示接收信息的长度,并且向服务器会送同样的内容,如下: + +![image-20240613163035203](imgs/image-20240613163035203.png) + +![image-20240613163159837](imgs/image-20240613163159837.png) + +测试源程序中没有主动断开连接的代码,因此需要服务器主动断开,之后源程序回到XiZi命令行输入。 \ No newline at end of file diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/imgs/image-20240613155912432.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/imgs/image-20240613155912432.png new file mode 100644 index 000000000..c7e5fdbf8 Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/imgs/image-20240613155912432.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/imgs/image-20240613161310960.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/imgs/image-20240613161310960.png new file mode 100644 index 000000000..31b7827c5 Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/imgs/image-20240613161310960.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/imgs/image-20240613161426964.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/imgs/image-20240613161426964.png new file mode 100644 index 000000000..521cdbbe2 Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/imgs/image-20240613161426964.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/imgs/image-20240613162119335.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/imgs/image-20240613162119335.png new file mode 100644 index 000000000..b6be8ac06 Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/imgs/image-20240613162119335.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/imgs/image-20240613162240812.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/imgs/image-20240613162240812.png new file mode 100644 index 000000000..b39e2a51b Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/imgs/image-20240613162240812.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/imgs/image-20240613162253358.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/imgs/image-20240613162253358.png new file mode 100644 index 000000000..b39e2a51b Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/imgs/image-20240613162253358.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/imgs/image-20240613162645796.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/imgs/image-20240613162645796.png new file mode 100644 index 000000000..963982183 Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/imgs/image-20240613162645796.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/imgs/image-20240613163035203.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/imgs/image-20240613163035203.png new file mode 100644 index 000000000..aa36e60f0 Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/imgs/image-20240613163035203.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/imgs/image-20240613163114500.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/imgs/image-20240613163114500.png new file mode 100644 index 000000000..31a115cc4 Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/imgs/image-20240613163114500.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/imgs/image-20240613163159837.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/imgs/image-20240613163159837.png new file mode 100644 index 000000000..96c5679bf Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/imgs/image-20240613163159837.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/imgs/image-20240613172343662.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/imgs/image-20240613172343662.png new file mode 100644 index 000000000..b2fe00173 Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ethernet/imgs/image-20240613172343662.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/rs485/README.md b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/rs485/README.md new file mode 100644 index 000000000..ffae39b7b --- /dev/null +++ b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/rs485/README.md @@ -0,0 +1,32 @@ +RS-485只是电气信号接口,有许多通信协议使用RS-485准位的电气信号,但RS-485规格书本身没有提到通信速度、格式以及资料传输的通信协议。因此使用UART在RS485总线上传输数据。 + +# 1. 特殊配置 + +## 1.1 Menuconfig + +在menuconfig配置界面中,根据以下路径选择: + +`ch32v208rbt6 feature`->勾选`Using RS485`,如下所示: + +![image-20240613172635753](imgs/image-20240613172635753.png) + +# 2. 连接USB转RS485转换器 + +连接CH32V208上的`RS485_A`端口到USB转RS485转换器上的`A`端口,连接CH32V208上的`RS485_B`端口到USB转RS485转换器上的`B`端口,如下图所示: + +image-20240613165104624 + +# 3. test_rs485 + +打开串口调试上位机,并且启动XiZi操作系统后,键入命令`test_rs485`,此时在上位机会看到以下信息,代表CH32V208在RS485总线上发送信息成功: + +![image-20240613170435850](imgs/image-20240613170435850.png) + +同时,在上位机中向RS485总线发送数据,CH32V208也可以收到,如下所示: + +![image-20240613170704386](imgs/image-20240613170704386.png) + +接收达到10行信息后,源程序会退出该命令,回到命令行正常输入模式,如下图所示: + +![image-20240613170902704](imgs/image-20240613170902704.png) + diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/rs485/imgs/image-20240613165104624.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/rs485/imgs/image-20240613165104624.png new file mode 100644 index 000000000..de26aefca Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/rs485/imgs/image-20240613165104624.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/rs485/imgs/image-20240613170435850.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/rs485/imgs/image-20240613170435850.png new file mode 100644 index 000000000..267d37d2f Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/rs485/imgs/image-20240613170435850.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/rs485/imgs/image-20240613170704386.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/rs485/imgs/image-20240613170704386.png new file mode 100644 index 000000000..10207e9c2 Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/rs485/imgs/image-20240613170704386.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/rs485/imgs/image-20240613170902704.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/rs485/imgs/image-20240613170902704.png new file mode 100644 index 000000000..ffec9d02f Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/rs485/imgs/image-20240613170902704.png differ diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/rs485/imgs/image-20240613172635753.png b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/rs485/imgs/image-20240613172635753.png new file mode 100644 index 000000000..c16eb104c Binary files /dev/null and b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/rs485/imgs/image-20240613172635753.png differ