rtthread.rst 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. RT-Thread Software Package Development Guide
  2. =============================================
  3. .. note:: CherryUSB has been added to the RT-Thread mainline and you can choose to use the mainline version with the same configuration method.
  4. This section mainly introduces using the software package manager provided by RT-Thread to configure projects, demonstrated with env. The operations in this section are the same for different chips and won't be repeated later. After opening env, use menuconfig to enter the package manager and select CherryUSB in the path shown in the figure.
  5. .. figure:: img/env0.png
  6. Device Configuration
  7. --------------------------
  8. * Select Enable USB device mode and press Enter to enter.
  9. * The first configuration is to configure USB speed, divided into **FS, HS**, indicating whether to use full-speed or high-speed functionality. High-speed functionality requires built-in high-speed PHY or external PHY
  10. * The second configuration is to select the USB device IP. If you are not sure which IP your chip uses, refer to the README in the corresponding `port` directory.
  11. * Select the class you want to use
  12. * Choose whether to use a demo template
  13. .. figure:: img/env1.png
  14. * Finally exit and save.
  15. * Copy `cherryusb_config_template.h` file to your project directory, rename it to `usb_config.h`, add the corresponding header file path, and modify the following content:
  16. .. code-block:: C
  17. #include "rtthread.h"
  18. #define CONFIG_USB_PRINTF(...) rt_kprintf(__VA_ARGS__)
  19. * USB IP related config needs to be modified by the user according to the actual chip situation
  20. * Implement the `usb_dc_low_level_init` function in code
  21. * Call `USBD_IRQHandler` in the USB interrupt function and pass in `busid`
  22. * Call `usbd_initialize` and fill in `busid` and USB IP's `reg base`. `busid` starts from 0 and cannot exceed `CONFIG_USBDEV_MAX_BUS`
  23. * Use `scons --target=mdk5` or `scons` to compile. If using mdk, you need to use the AC6 compiler
  24. * If the chip has cache, refer to the :ref:`usb_cache` chapter for cache modifications
  25. Host Configuration
  26. --------------------------
  27. * Select Enable usb host mode and press Enter
  28. * Select USB host ip. If you're not sure which ip your chip uses, refer to the readme under the corresponding **port** directory
  29. * Check class drivers as needed
  30. * Choose whether to enable template demo, recommended not to use
  31. .. figure:: img/env2.png
  32. * Finally exit and save.
  33. * Copy `cherryusb_config_template.h` file to your project directory, rename it to `usb_config.h`, add the corresponding header file path, and implement the following content:
  34. .. code-block:: C
  35. #include "rtthread.h"
  36. #define CONFIG_USB_PRINTF(...) rt_kprintf(__VA_ARGS__)
  37. * USB IP related config needs to be modified by the user according to the actual chip situation
  38. * Implement the `usb_hc_low_level_init` function in code
  39. * Call `USBH_IRQHandler` in the USB interrupt function and pass in `busid`
  40. * Call `usbh_initialize` and fill in `busid` and USB IP's `reg base` and `event_handler` (can be omitted as NULL). `busid` starts from 0 and cannot exceed `CONFIG_USBHOST_MAX_BUS`
  41. * Use `scons --target=mdk5` or `scons` to compile. If using mdk, you need to use the AC6 compiler
  42. * For linker script modifications, refer to the :ref:`usbh_link_script` chapter
  43. * If the chip has cache, refer to the :ref:`usb_cache` chapter for cache modifications