Ttelmah
Joined: 11 Mar 2010 Posts: 19529
|
|
Posted: Wed Dec 05, 2012 2:36 am |
|
|
How late is your compiler?.
If you have a recent version, then look at ex_usb_hid_and_cdc_.h.
This creates both an HID (keyboard), and a CDC device, and routes the USB data to both.
The data routing, shows how to transfer data between the two virtual devices. You will need to implement this, but according to the switch setting, select only one of the descriptors for the device during enumeration. It'll need to be a 'boot' change really (you could do it by disconnecting, and then re-enumerating, but boot will be easier).
99% of the code will be common to both, this doesn't make things tricky, but easier. It is the bits that differ that are harder, with your code having to change how it talks/responds. If you look at the main for this code, it switches stuff at compile time, but you'll have to have this selected based on your switch setting. Obviously the differences between the devices will change according to 'what HID device' is involved. A keyboard has to respond with scancodes etc..
Best Wishes |
|