Jump to content

[Version 1] Usb Vendor Id/product Id

Recommended Posts

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...

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...