Dаrren Kitchen Posted May 25, 2010 Share Posted May 25, 2010 I can edit these lines in usb_private.h to change the value: #define VENDOR_ID 0x16C0 #define PRODUCT_ID 0x0482 But is they a way to change them/redefine them in my own code? I tried to use #undef and then use #define again, but to no avail. Quote Link to comment Share on other sites More sharing options...
Sl45h3R Posted May 25, 2010 Share Posted May 25, 2010 Can't you make another header file then redefine them and include it in your app (and delete the original)? Quote Link to comment Share on other sites More sharing options...
Dаrren Kitchen Posted May 25, 2010 Author Share Posted May 25, 2010 I can, but I'd like to have it so my code is all you have to touch, and you don't have to change Paul's code. That way, when he updates Teensyduino, you don't need to change his headers again. Quote Link to comment Share on other sites More sharing options...
Deevd Posted May 27, 2010 Share Posted May 27, 2010 what if there was a header file just for the vendor & product ID ? seperatly from the usb_private.h it would it possible to update Paul's code without having to change anything... But I suppose it is Paul to decide whether he does this or not... Quote Link to comment Share on other sites More sharing options...
Paul Stoffregen Posted May 27, 2010 Share Posted May 27, 2010 Looks like I didn't make any way to do this. Those numbers are part of an array in program memory, so it only matters what their values are when that array is compiled. You could try editing usb.c, and remove "static" from the device descriptor array. Change it from this: static uint8_t PROGMEM device_descriptor[] = { to this: uint8_t PROGMEM device_descriptor[] = { Then, in your program, copy that entire array, and change the VID & PID to whatever you like. It's critically important that you do NOT change the name of the array. It's also pretty important you specify endpoint zero's size correctly, but if you include usb_private.h, you'll have the same definition used within usb.c. The array inside usb.c will still get compiled, and put into a ".a" library, which is then linked with everything you've writtten. The default behavior is supposed to be that any global symbols you've defined will override anything the linker gets from libraries. I know this works for functions. Maybe it'll work for that array? Of course, it's not a global symbol until you remove the "static" from the definition. If this works, I'll remove "static" in a future version, like 0.9-alpha5. I might change the name from "device_descriptor" to "usb_device_descriptor", since it'll become a global symbol. I might also make a couple more of those numbers into proprocessor symbols, so if you re-copy it with those symbols, it'll automatically change correctly when/if you switch between the USB types. I just made this all up and haven't tried it, so please let me know if it works? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.