diff options
| author | sakumisu <[email protected]> | 2022-03-08 12:39:41 +0800 |
|---|---|---|
| committer | sakumisu <[email protected]> | 2022-03-08 12:39:41 +0800 |
| commit | b8d1fd6b658a3673adc7fb46284eae0e17b4c9bb (patch) | |
| tree | 55a28ab93ed07523f2955d83082714a94dfcbd27 /docs/quick_start/rt-thread | |
| parent | 5772d29f14eef3462982c3a71a7d20eacc2648fa (diff) | |
update doc structure,hosting with readdoc
Diffstat (limited to 'docs/quick_start/rt-thread')
| -rw-r--r-- | docs/quick_start/rt-thread/img/1.png | bin | 28842 -> 0 bytes | |||
| -rw-r--r-- | docs/quick_start/rt-thread/img/2.png | bin | 27620 -> 0 bytes | |||
| -rw-r--r-- | docs/quick_start/rt-thread/img/3.png | bin | 22701 -> 0 bytes | |||
| -rw-r--r-- | docs/quick_start/rt-thread/img/rtt_cdc_demo.png | bin | 9403 -> 0 bytes | |||
| -rw-r--r-- | docs/quick_start/rt-thread/img/rtt_libc.png | bin | 20721 -> 0 bytes | |||
| -rw-r--r-- | docs/quick_start/rt-thread/img/rtt_menuconfig1.png | bin | 33437 -> 0 bytes | |||
| -rw-r--r-- | docs/quick_start/rt-thread/img/rtt_menuconfig2.png | bin | 22927 -> 0 bytes | |||
| -rw-r--r-- | docs/quick_start/rt-thread/img/stm32cubemx.png | bin | 37705 -> 0 bytes | |||
| -rw-r--r-- | docs/quick_start/rt-thread/img/stm32cubemx2.png | bin | 41977 -> 0 bytes | |||
| -rw-r--r-- | docs/quick_start/rt-thread/img/stm32cubemx_clk.png | bin | 16418 -> 0 bytes | |||
| -rw-r--r-- | docs/quick_start/rt-thread/rt-thread.md | 84 | ||||
| -rw-r--r-- | docs/quick_start/rt-thread/rt-thread_zh.md | 148 |
12 files changed, 0 insertions, 232 deletions
diff --git a/docs/quick_start/rt-thread/img/1.png b/docs/quick_start/rt-thread/img/1.png Binary files differdeleted file mode 100644 index 5176a02c..00000000 --- a/docs/quick_start/rt-thread/img/1.png +++ /dev/null diff --git a/docs/quick_start/rt-thread/img/2.png b/docs/quick_start/rt-thread/img/2.png Binary files differdeleted file mode 100644 index 29d30734..00000000 --- a/docs/quick_start/rt-thread/img/2.png +++ /dev/null diff --git a/docs/quick_start/rt-thread/img/3.png b/docs/quick_start/rt-thread/img/3.png Binary files differdeleted file mode 100644 index 82bb35ff..00000000 --- a/docs/quick_start/rt-thread/img/3.png +++ /dev/null diff --git a/docs/quick_start/rt-thread/img/rtt_cdc_demo.png b/docs/quick_start/rt-thread/img/rtt_cdc_demo.png Binary files differdeleted file mode 100644 index 861669e1..00000000 --- a/docs/quick_start/rt-thread/img/rtt_cdc_demo.png +++ /dev/null diff --git a/docs/quick_start/rt-thread/img/rtt_libc.png b/docs/quick_start/rt-thread/img/rtt_libc.png Binary files differdeleted file mode 100644 index 7fd5f00c..00000000 --- a/docs/quick_start/rt-thread/img/rtt_libc.png +++ /dev/null diff --git a/docs/quick_start/rt-thread/img/rtt_menuconfig1.png b/docs/quick_start/rt-thread/img/rtt_menuconfig1.png Binary files differdeleted file mode 100644 index 24caa9c7..00000000 --- a/docs/quick_start/rt-thread/img/rtt_menuconfig1.png +++ /dev/null diff --git a/docs/quick_start/rt-thread/img/rtt_menuconfig2.png b/docs/quick_start/rt-thread/img/rtt_menuconfig2.png Binary files differdeleted file mode 100644 index fbf49ab4..00000000 --- a/docs/quick_start/rt-thread/img/rtt_menuconfig2.png +++ /dev/null diff --git a/docs/quick_start/rt-thread/img/stm32cubemx.png b/docs/quick_start/rt-thread/img/stm32cubemx.png Binary files differdeleted file mode 100644 index a6ca5078..00000000 --- a/docs/quick_start/rt-thread/img/stm32cubemx.png +++ /dev/null diff --git a/docs/quick_start/rt-thread/img/stm32cubemx2.png b/docs/quick_start/rt-thread/img/stm32cubemx2.png Binary files differdeleted file mode 100644 index e29254bb..00000000 --- a/docs/quick_start/rt-thread/img/stm32cubemx2.png +++ /dev/null diff --git a/docs/quick_start/rt-thread/img/stm32cubemx_clk.png b/docs/quick_start/rt-thread/img/stm32cubemx_clk.png Binary files differdeleted file mode 100644 index 41a7aae8..00000000 --- a/docs/quick_start/rt-thread/img/stm32cubemx_clk.png +++ /dev/null diff --git a/docs/quick_start/rt-thread/rt-thread.md b/docs/quick_start/rt-thread/rt-thread.md deleted file mode 100644 index 7c57a47c..00000000 --- a/docs/quick_start/rt-thread/rt-thread.md +++ /dev/null @@ -1,84 +0,0 @@ -# RT-Thread based Software Package Development Guide - -[中文版](rt-thread_zh.md) - -To use CherryUSB package, you need to select it in the RT-Thread package manager. The specific path is as follows: - -``` --> RT-Thread online packages - -> system packages - --- CherryUSB: tiny and portable USB stack for embedded system with USB IP - - CherryUSB Options ----> - USB Speed (FS) ---> - [*] Enable usb device mode - [*] Enable usb cdc acm device - [ ] Enable usb hid device - [ ] Enable usb dfu device - [ ] Enable usb msc device - [ ] Enable usb hub device - [ ] Enable usb audio device - [ ] Enable usb video device - - Version (latest) ---> -``` - -## Based ON STM32 Platform - -Please note that stm32 series have two usb ip. For usb ip, like stm32f0、stm32f1、stm32f3, for usb otg ip(as we know it is from **synopsys**),like stm32f4、stm32f7 and so on. - -### Use USB Device - -- Firstly,you should have a bsp project,and then go to `board\CubeMX_Config` directory, open file that suffix name with `.ioc` in **STM32CubeMX**. -- Enable **USB** or **USB_OTG_FS** or **USB_OTG_HS** in **Connectivity** List,enable USB IRQ in **NVIC Setting**. - - - -- Enable USB Clock for 48Mhz in **Clock configuration**. - - - -- Generate code. -- Copy **SystemClock_Config** into **board.c**. -- ~~Copy **MX_USB_OTG_FS_PCD_Init** or **MX_USB_OTG_HS_PCD_Init** into **main.c** if you use **usb_dc_hal.c**.Also, USB Irq from **it.c** needs the same.~~ -- Implement **usb_dc_low_level_init** and copy codes in from ``HAL_PCD_MspInit``. - -``` -void usb_dc_low_level_init(void) -{ - /* Peripheral clock enable */ - __HAL_RCC_USB_CLK_ENABLE(); - /* USB interrupt Init */ - HAL_NVIC_SetPriority(USB_LP_CAN1_RX0_IRQn, 0, 0); - HAL_NVIC_EnableIRQ(USB_LP_CAN1_RX0_IRQn); - -} -``` - -- Implement **printf** or modify with **rt_kprintf** in **usb_utils.h**, usb stack needs. -- Now we can call some functions provided by **usb_stack**.Your should register descriptors、interfaces and endpoint callback firstly, and then call `usb_dc_init`. Example is as follows: - -``` -int main(void) -{ - extern void cdc_init(void); - cdc_init(); - usb_dc_init(); - while (1) - { - uint8_t data_buffer[10] = { 0x31, 0x32, 0x33, 0x34, 0x35, 0x31, 0x32, 0x33, 0x34, 0x35 }; - usbd_ep_write(0x81, data_buffer, 10, NULL); - rt_thread_mdelay(500); - } -} -``` - -- How to register class you can go to [stm32 class examples](https://github.com/sakumisu/usb_stack/tree/master/demo/stm32/stm32f103c8t6/example) for a reference. - -### CDC Demo Demonstration - - - -### Video manual - -If you have problem from steps above, you can see this video:[Use USB Stack in RT-Thread package manager](https://www.bilibili.com/video/BV1Ef4y1t73d?p=26)。
\ No newline at end of file diff --git a/docs/quick_start/rt-thread/rt-thread_zh.md b/docs/quick_start/rt-thread/rt-thread_zh.md deleted file mode 100644 index 561f657d..00000000 --- a/docs/quick_start/rt-thread/rt-thread_zh.md +++ /dev/null @@ -1,148 +0,0 @@ -# 基于 RT-Thread 软件包开发指南 - -[English Version](rt-thread.md) - -使用 CherryUSB package 需要在 RT-Thread 的包管理器中选择它,具体路径如下: - -``` --> RT-Thread online packages - -> system packages - --- CherryUSB: tiny and portable USB stack for embedded system with USB IP - - CherryUSB Options ----> - USB Speed (FS) ---> - [*] Enable usb device mode - [ ] Enable usb host mode - [*] Enable usb cdc acm device - [ ] Enable usb hid device - [ ] Enable usb dfu device - [ ] Enable usb msc device - [ ] Enable usb hub device - [ ] Enable usb audio device - [ ] Enable usb video device - - Version (latest) ---> -``` - -## 基于 STM32 平台 - -STM32 系列单片机有两种 USB IP,分别是 USB IP 和 USB OTG IP。其中 USB IP,例如 STM32F0、STM32F1、STM32F3等等,USB OTG IP(我们都知道用的是 **synopsys** 公司的)的有 STM32F4、STM32F7、STM32H7等等。当前如果你需要使用 USB Device 功能,porting 接口提供了两种,一种是适配 USB IP的 **fsdev**,另一种是适配 USB OTG IP 的 **synopsys**。 - -### 使用 USB Device 功能 - -- 首先,你需要有一个 bsp 工程,之后进入到 `board\CubeMX_Config` 目录下,使用 **STM32CubeMX** 打开后缀名为 `.ioc` 的文件。 -- 进入 **Connectivity** 选项,选择 **USB** 或者 **USB_OTG_FS** 或者 **USB_OTG_HS**,并使能 device 功能,在 **NVIC Setting** 中开启 USB 中断。 - - - -- 在 **Clock configuration** 栏配置 USB 时钟为 48Mhz. - - - -- 点击 **Generate code**。 -- 复制 **SystemClock_Config** 函数内容到 **board.c** 中。 -- 实现 ``usb_dc_low_level_init``,并将 ``HAL_PCD_MspInit`` 里面内容复制进来,例如: - -``` -void usb_dc_low_level_init(void) -{ - /* Peripheral clock enable */ - __HAL_RCC_USB_CLK_ENABLE(); - /* USB interrupt Init */ - HAL_NVIC_SetPriority(USB_LP_CAN1_RX0_IRQn, 0, 0); - HAL_NVIC_EnableIRQ(USB_LP_CAN1_RX0_IRQn); - -} -``` - -- 由于协议栈默认使用 `printf` 和 `malloc` 和 `free`,所以需要开启 libc 支持或者自己实现。 - - -- 使用 **menuconfig** 配置 **CherryUSB** 软件包,使能 usb device 并勾选需要的 device class。 - - -- 现在我们可以调用 CherryUSB 中的函数来注册描述符、接口、端点中断,并调用 `usb_dc_init`,示例如下: - -``` -#include <rtthread.h> -#include <rtdevice.h> -#include <board.h> -#include <stdio.h> - -extern void usb_dc_init(void); -int main(void) -{ - extern void cdc_init(void); - cdc_init(); - usb_dc_init(); - while (1) - { - uint8_t data_buffer[10] = { 0x31, 0x32, 0x33, 0x34, 0x35, 0x31, 0x32, 0x33, 0x34, 0x35 }; - usbd_ep_write(0x81, data_buffer, 10, NULL); - rt_thread_mdelay(500); - } -} - -``` - -- 关于如何注册 class 类可以参考 [stm32 class examples](https://github.com/sakumisu/usb_stack/tree/master/demo/stm32/stm32f103c8t6/example)。 - -### 使用 USB Host 功能 - -- 首先,你需要有一个 bsp 工程,之后进入到 `board\CubeMX_Config` 目录下,使用 **STM32CubeMX** 打开后缀名为 `.ioc` 的文件。 -- 进入 **Connectivity** 选项,选择 **USB_OTG_FS** 或者 **USB_OTG_HS**,并使能 **host only** 功能,在 **NVIC Setting** 中开启 OTG GLOBAL 中断,其余两个端点中断不需要。 - - - -- 在 **Clock configuration** 栏配置 USB 时钟为 48Mhz. -- 点击 **Generate code**。 -- 复制 **SystemClock_Config** 函数内容到 **board.c** 中。 -- 修改 **usb_hc_synopsys.c** 中 HAL 库头文件包含,例如 `#include "stm32f4xx_hal.h"`。 -- 手动增加 **xxx_hal_hcd.c** 和 **xxx_ll_usb.c** 文件 -- 由于协议栈默认使用 `printf` 和 `malloc` 和 `free`,所以需要开启 libc 支持或者自己实现。 - - -- 使用 **menuconfig** 配置 **CherryUSB** 软件包,使能 usb host(默认加载所有支持的 class)。 - - -- `main.c` 中调用 `usbh_initialize` 初始化 host 协议栈。 - -``` -#include <rtthread.h> -#include <rtdevice.h> -#include <board.h> -#include "usbh_core.h" -/* defined the LED0 pin: PH10 */ -#define LED0_PIN GET_PIN(H, 10) - -int main(void) -{ - /* set LED0 pin mode to output */ - rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT); - usbh_initialize(); - while (1) - { - rt_pin_write(LED0_PIN, PIN_HIGH); - rt_thread_mdelay(500); - rt_pin_write(LED0_PIN, PIN_LOW); - rt_thread_mdelay(500); - } -} - - -``` - -### Demo 演示 - -- cdc acm device demo - - -- host demo - - - - - -### 视频教程 - -如果对上述步骤还有问题,可以参考 [协议栈在 RT-Thread 包管理器中的使用](https://www.bilibili.com/video/BV1Ef4y1t73d?p=26)。
\ No newline at end of file |
