rp-usb-serial 0.3.2

USB CDC logging for rp2040&rp2350 with rp2040-hal & rp235x-hal
rp-usb-serial-0.3.2 has been yanked.
Visit the last successful build: rp-usb-serial-0.4.0

RP USB Serial Console

RP 系列 USB CDC 串口控制台

no_std RP2040 RP2350 USB CDC Rust

A lightweight no_std USB CDC serial console for RP2040 and RP2350.
一个轻量级的 no_std USB CDC 虚拟串口控制台模块,支持 RP2040RP2350

It provides a simple global USB serial interface for logging, formatted printing, and host-device communication.
它提供了一个简单的全局 USB 串口接口,可用于日志输出、格式化打印以及主机与设备之间的数据通信。


Table of Contents

目录


Features

功能特性

  • USB CDC ACM virtual serial port
    USB CDC ACM 虚拟串口

  • Supports both RP2040 and RP2350 via Cargo features
    通过 Cargo feature 同时支持 RP2040RP2350

  • no_std compatible
    兼容 no_std

  • Global singleton-style USB console
    全局单例式 USB 控制台

  • Buffered TX queue for outgoing data
    内置发送缓冲队列

  • Automatic USB polling and TX flushing
    自动轮询 USB 协议并自动刷新发送缓冲

  • Formatted output support
    支持格式化输出

  • Easy-to-use APIs:

    • init()
    • write()
    • read()
    • print()
    • println()
  • Convenience macros:

    • usb_print!
    • usb_println!

Supported Platforms

支持平台

RP2040

  • HAL: rp2040-hal
  • USB registers:
    • pac::USBCTRL_REGS
    • pac::USBCTRL_DPRAM

RP2350

  • HAL: rp235x-hal
  • USB registers:
    • pac::USB
    • pac::USB_DPRAM

This implementation is intended for the ARM-based embedded Rust workflow.
此实现面向 ARM 风格的嵌入式 Rust 工作流。


How to use it

如何使用

Example for rp2040 arm

RP2040平台使用例子

#cargo.toml
#default features is rp2040 
rp-usb-serial = "0.3.0"

Example for rp2040 arm

Example for rp2350 arm

RP2350平台使用例子

#cargo.toml
rp-usb-serial = {version = "0.3.0",default-features = false, features = [ "rp2350"]}

Example for rp2350 arm

Example for rp2350 riscv32

RP2350平台使用例子

#cargo.toml
rp-usb-serial = {version = "0.3.0",default-features = false, features = [ "rp2350"]}

Example for rp2350 riscv32