DeqingSun / ch55xduino

An Arduino-like programming API for the CH55X
GNU Lesser General Public License v2.1
448 stars 86 forks source link

Is HID Keyboard + USBSerial (CDC VCP) possible? #143

Closed arduino12 closed 1 year ago

arduino12 commented 1 year ago

Hi,

I want my CH552 to act as a USBSerial (CDC VCP) at start and be able to switch to HID keyboard afterwards. (will be great to keep the USBSerial simultaneously, but switching between them is good enough for me).

I see that the USBSerial (USBCDC.c) is at the core, and the USBHIDKeyboard.c is external, I found USBInit but no way to uninitialize the USB HID Keyboard. For USBSerial I didn't found any initialize or uninitialize functions.

  1. Is it possible to add USBDeinit function to the USB examples? (maybe name like Keyboard_begin , Keyboard_end, USBSerial_begin, USBSerial_end..?)
  2. Is it possible to add an example of HID Keyboard + USBSerial?

Thanks, Arad :)

DeqingSun commented 1 year ago

CH552 is not a chip with a lot of RAM or ROM so the USB stuff is hard coded and not able to be uninitialized.

If you want to use CDC+HID, check this project

https://github.com/Noteolvides/CubeTouch/tree/main/Examples/CDC_KEYBOARD