|
|
hai 7 meses | |
|---|---|---|
| .. | ||
| .settings | hai 7 meses | |
| board | hai 10 meses | |
| figures | hai 1 ano | |
| packages | hai 1 ano | |
| rzn | hai 7 meses | |
| rzn_cfg | hai 7 meses | |
| rzn_gen | hai 7 meses | |
| script | hai 7 meses | |
| src | hai 1 ano | |
| .api_xml | hai 1 ano | |
| .config | hai 7 meses | |
| .cproject | hai 7 meses | |
| .gitignore | hai 1 ano | |
| .project | hai 1 ano | |
| .secure_azone | hai 1 ano | |
| .secure_rzone | hai 7 meses | |
| .secure_xml | hai 7 meses | |
| Kconfig | hai 7 meses | |
| README.md | hai 7 meses | |
| README_zh.md | hai 7 meses | |
| SConscript | hai 7 meses | |
| SConstruct | hai 1 ano | |
| buildinfo.ipcf | hai 7 meses | |
| buildinfo.json | hai 7 meses | |
| configuration.xml | hai 7 meses | |
| envsetup.sh | hai 1 ano | |
| mklinks.bat | hai 1 ano | |
| mklinks.sh | hai 1 ano | |
| ozone_scons.jdebug | hai 1 ano | |
| project.ewd | hai 7 meses | |
| project.ewp | hai 7 meses | |
| project.ewt | hai 7 meses | |
| project.eww | hai 1 ano | |
| rtconfig.h | hai 7 meses | |
| rtconfig.py | hai 1 ano | |
| rzn_cfg.txt | hai 7 meses | |
| template.ewd | hai 7 meses | |
| template.ewp | hai 7 meses | |
| template.eww | hai 1 ano | |
English | 中文
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.
EtherKit provides a USB-Device peripheral, located on the development board as shown below:
configuration.xml file using FSP and add the usb_pmcs stack:g_rm_block_media0:g_basic0_usb and set the interrupt callback function to usb_apl_callback:USB_HS and enable it: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
The USB example currently uses the FreeRTOS interface driver, so we also need to enable the FreeRTOS compatibility layer package:
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.
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:
Next, open the virtual serial port device and test character input: