Yuqiang Wang e1498cabc9 SDK build (#47) 7 сар өмнө
..
.settings 4795f3d206 更新fsp为2.2.0 8 сар өмнө
board 64ec089d19 [HAL_Drivers]新增CAN和CANFD切换的宏 10 сар өмнө
figures eef1e05537 Improve engineering documentation and upload user manual 1 жил өмнө
packages 89ecd4344c upload project(usb pcdc、pmsc) 1 жил өмнө
rzn 0e9a0dfdbd fix iar link source 7 сар өмнө
rzn_cfg 0e9a0dfdbd fix iar link source 7 сар өмнө
rzn_gen 0e9a0dfdbd fix iar link source 7 сар өмнө
script 4795f3d206 更新fsp为2.2.0 8 сар өмнө
src 89ecd4344c upload project(usb pcdc、pmsc) 1 жил өмнө
.api_xml 89ecd4344c upload project(usb pcdc、pmsc) 1 жил өмнө
.config 4795f3d206 更新fsp为2.2.0 8 сар өмнө
.cproject 4795f3d206 更新fsp为2.2.0 8 сар өмнө
.gitignore 43669c1c97 Fixed some known issues 1 жил өмнө
.project 89ecd4344c upload project(usb pcdc、pmsc) 1 жил өмнө
.secure_azone 89ecd4344c upload project(usb pcdc、pmsc) 1 жил өмнө
.secure_rzone 4795f3d206 更新fsp为2.2.0 8 сар өмнө
.secure_xml 4795f3d206 更新fsp为2.2.0 8 сар өмнө
Kconfig 4795f3d206 更新fsp为2.2.0 8 сар өмнө
README.md e1498cabc9 SDK build (#47) 7 сар өмнө
README_zh.md e1498cabc9 SDK build (#47) 7 сар өмнө
SConscript 0e9a0dfdbd fix iar link source 7 сар өмнө
SConstruct 89ecd4344c upload project(usb pcdc、pmsc) 1 жил өмнө
buildinfo.ipcf 0e9a0dfdbd fix iar link source 7 сар өмнө
buildinfo.json 4795f3d206 更新fsp为2.2.0 8 сар өмнө
configuration.xml 4795f3d206 更新fsp为2.2.0 8 сар өмнө
envsetup.sh 89ecd4344c upload project(usb pcdc、pmsc) 1 жил өмнө
mklinks.bat 89ecd4344c upload project(usb pcdc、pmsc) 1 жил өмнө
mklinks.sh 89ecd4344c upload project(usb pcdc、pmsc) 1 жил өмнө
ozone_scons.jdebug 384e7a31df 修复scons固件无法运行的问题,添加ozone调试脚本 1 жил өмнө
project.ewd 0e9a0dfdbd fix iar link source 7 сар өмнө
project.ewp 0e9a0dfdbd fix iar link source 7 сар өмнө
project.ewt 0e9a0dfdbd fix iar link source 7 сар өмнө
project.eww 89ecd4344c upload project(usb pcdc、pmsc) 1 жил өмнө
rtconfig.h 4795f3d206 更新fsp为2.2.0 8 сар өмнө
rtconfig.py 384e7a31df 修复scons固件无法运行的问题,添加ozone调试脚本 1 жил өмнө
rzn_cfg.txt 4795f3d206 更新fsp为2.2.0 8 сар өмнө
template.ewd 0e9a0dfdbd fix iar link source 7 сар өмнө
template.ewp 0e9a0dfdbd fix iar link source 7 сар өмнө
template.eww 89ecd4344c upload project(usb pcdc、pmsc) 1 жил өмнө

README.md

USB-PCDC Driver Usage Instructions

English | 中文

Introduction

This example demonstrates how to implement a virtual serial port over USB. USB PCDC (USB Communication Device Class) is a subclass of the USB communication device class (CDC) that is commonly used to implement virtual serial communication functionality. In embedded device development, USB PCDC is often used to simulate a serial communication port (such as a COM port) over a USB interface, allowing data interaction with a host.

Hardware Requirements

image-20241126111451833

EtherKit provides a USB-Device peripheral, located on the development board as shown below:

image-20241126111503789

FSP Configuration Instructions

  • Open the project’s configuration.xml file using FSP and add the usb_pmcs stack:

image-20241126112205300

  • Add g_rm_block_media0:

image-20241126111550254

  • Select g_basic0_usb and set the interrupt callback function to usb_apl_callback:

image-20241126112229660

  • Next, configure the USB pins. Find USB_HS and enable it:

image-20241126111620891

Build Configuration

Locate the file at the specified path in the project: .\rzn\SConscript, and replace its content with the following:

Import('RTT_ROOT')
Import('rtconfig')
from building import *
from gcc import *

cwd = GetCurrentDir()
src = []
group = []
CPPPATH = []

if rtconfig.PLATFORM in ['iccarm'] + GetGCCLikePLATFORM():
    if rtconfig.PLATFORM == 'iccarm' or GetOption('target') != 'mdk5':
        src += Glob('./fsp/src/bsp/mcu/all/*.c')
        src += Glob('./fsp/src/bsp/mcu/all/cr/*.c')
        src += Glob('./fsp/src/bsp/mcu/r*/*.c')
        src += Glob('./fsp/src/bsp/cmsis/Device/RENESAS/Source/*.c')
        src += Glob('./fsp/src/bsp/cmsis/Device/RENESAS/Source/cr/*.c')
        src += Glob('./fsp/src/r_*/*.c')
        src += Glob('./fsp/src/r_usb_basic/src/driver/*.c')
        src += Glob('./fsp/src/r_usb_basic/src/hw/*.c')
        src += Glob('./fsp/src/r_usb_pcdc/src/*.c')
        CPPPATH = [ cwd + '/arm/CMSIS_5/CMSIS/Core_R/Include',
                    cwd + '/fsp/inc',
                    cwd + '/fsp/src/inc',
                    cwd + '/fsp/inc/api',
                    cwd + '/fsp/inc/instances',
                    cwd + '/fsp/src/r_usb_basic/src/driver/inc',
                    cwd + '/fsp/src/r_usb_basic/src/hw/inc',
                    cwd + '/fsp/src/r_usb_pcdc/src/inc',]

group = DefineGroup('rzn', src, depend = [''], CPPPATH = CPPPATH)
Return('group')

If you are using Studio for development, right-click on the project and select Sync SCons Configuration to Project. For IAR development, right-click within the current project to open the environment, and run the following command to regenerate the configuration: scons --target=iar

RT-Thread Settings Configuration

The USB example currently uses the FreeRTOS interface driver, so we also need to enable the FreeRTOS compatibility layer package:

image-20241126111643871

Compilation & Download

  • RT-Thread Studio: Download the EtherKit resource package in the RT-Thread Studio package manager, create a new project, and compile it.
  • IAR: First, double-click mklinks.bat to create the link between the rt-thread and libraries folders. Then, use Env to generate the IAR project. Finally, double-click project.eww to open the IAR project and compile it.

Once the compilation is complete, connect the Jlink interface of the development board to the PC and download the firmware to the board.

Running Results

After generating the FSP configuration, compile and download the firmware to the development board. The example will automatically start, and you will see an additional USB device in the file manager:

image-20241126112248530

Next, open the virtual serial port device and test character input:

image-20241126112301592