CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

HID and CDC in one Chip controlled by a switch?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Squintz



Joined: 08 Dec 2009
Posts: 11

View user's profile Send private message

HID and CDC in one Chip controlled by a switch?
PostPosted: Tue Dec 04, 2012 10:40 am     Reply with quote

Is there an easy way to have one PIC18F14K50 switch from having it's USB port setup for HID mode to CDC mode? I want to be able to switch a dip switch to change modes. I know that a lot of the functions are shared which makes things tricky.
Ttelmah



Joined: 11 Mar 2010
Posts: 19499

View user's profile Send private message

PostPosted: Wed Dec 05, 2012 2:36 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group