GithubHelp home page GithubHelp logo

esp32-s2-usb-host-cdc's Introduction

Simple cdc host example

Simple USB host CDC example which should works with any CDC-ACM device. Tested with arduino tinyusb device built using https://github.com/chegewara/EspTinyUSB library.

Example logs:

Before connecting device

Hello world USB host!
I (627) : USB host setup properly
I (627) : Port powered ON
Waiting for conenction

After connecting device

I (892) : HCD_PORT_EVENT_CONNECTION
I (892) : HCD_PORT_STATE_DISABLED
I (952) : USB device reset
I (952) : HCD_PORT_STATE_ENABLED
...
I (974) : address set: 1
I (978) : set current configuration: 1

Example reading device descriptors and strings

  • device descriptor on EP0
Device descriptor:
Length: 18
Descriptor type: 18
USB version: 2.00
Device class: 0xef (Miscellaneous)
Device subclass: 0x02
Device protocol: 0x01
EP0 max packet size: 64
VID: 0x303a
PID: 0x0002
Revision number: 1.00
Manufacturer id: 1
Product id: 2
Serial id: 3
Configurations num: 1
  • configuration descriptor
Config:
Number of Interfaces: 2
Attributes: 0xa0
Max power: 500 mA

Interface:
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 1
bInterfaceClass: 0x02 (CDC)
bInterfaceSubClass: 0x02
bInterfaceProtocol: 0x00

CS_Interface:

CS_Interface:

CS_Interface:

CS_Interface:

Endpoint:
bEndpointAddress: 0x81
bmAttributes: 0x03
bDescriptorType: 5
wMaxPacketSize: 8
bInterval: 16 ms
Creating transfer requests

Interface:
bInterfaceNumber: 1
bAlternateSetting: 0
bNumEndpoints: 2
bInterfaceClass: 0x0a (CDC-data)
bInterfaceSubClass: 0x00
bInterfaceProtocol: 0x00

Endpoint:
bEndpointAddress: 0x02
bmAttributes: 0x02
bDescriptorType: 5
wMaxPacketSize: 64
bInterval: 0 ms
Creating transfer requests

Endpoint:
bEndpointAddress: 0x82
bmAttributes: 0x02
bDescriptorType: 5
wMaxPacketSize: 64
bInterval: 0 ms
Creating transfer requests
  • manufacturer, product and serial strings
strings: Espressif
strings: ESP32S2 arduino device
strings: 1234-5678
  • set DTR/RTS lines and bitrate, stop bits, parity and data bits
I (7306) Set control line state:
I (7311) Set line coding: Bitrate: 115200, stop bits: 0, parity: 0, bits: 5

Testing

  • after connecting we can start sending data from CDC ACM device to host and see received data in logs,
  • when we send ? from device then host should send back test\n to device

Have a nice play.

esp32-s2-usb-host-cdc's People

Contributors

chegewara avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.