I want to make a device that can have dual USB descriptors. All the USB data needs to be done prior to run time. I do use a bootloader (not sure that helps) but can not think of how this could be done aside from making all data dynamic. I'm not sure that can easily be done.
Is there a way to set data based on PIN macros.
What has pin macros got to do with dual usb descriptors or dynamic data for that matter? Tell us what you want to achieve in 25 words or less. Then we can talk about implementation details.
Using a switch to change from one descriptor to another. If pinb.3 is Low use usb descriptor A if high use B. Which is made before usb insert.
I think I'm jut going to load up my h files and use one macro for the switch and a bunch if if statements checking it.
#define _X_() (PINB & 0x04)==0
Endpoint_Read_Control_Stream_LE(&reportBuffer, sizeof((_X_())?JOYSTICK_EPSIZEX:JOYSTICK_EPSIZE));
etc..
I'm not sure what the macro adds here - especially with the name _X_ as that obscures the meaning rather than explains it.
Using a switch to change from one descriptor to another. If pinb.3 is Low use usb descriptor A if high use B. Which is made before usb insert.
presumably, a "descriptor" is just a data structure?
So isn't it as simple as just
typedef struct { // whatever : : } descriptor_t; descriptor_t this_descriptor = { /* whatever this is */ }; descriptor_t that_descriptor = { /* whatever that is */ }; descriptor_t * p_descriptor_to_use; if( whatever_condition ) { p_descriptor_to_use = &this_descriptor ; } else { p_descriptor_to_use = &that_descriptor ; }
EDIT
Yes, you could use a conditional expression (ternary operator) there if you want.
EDIT 2
And you don't have to go via a pointer = you could just have 1 structure, and set it appropriately in the conditional blocks