Added support for dynamic USB_VID / USB_PID.

It can be changed on runtime without rebuilding or patching.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos
2024-04-16 00:04:23 +02:00
parent b6b53010cc
commit 6f7ab69a9d
3 changed files with 13 additions and 3 deletions

View File

@@ -26,7 +26,9 @@
#include "pico_keys.h"
#include "usb.h"
#include "apdu.h"
#ifndef ENABLE_EMULATION
#include "tusb.h"
#endif
// For memcpy
#include <string.h>
@@ -158,8 +160,10 @@ queue_t usb_to_card_q;
queue_t card_to_usb_q;
#endif
#ifndef ENABLE_EMULATION
extern uint16_t usb_vid, usb_pid;
extern tusb_desc_device_t desc_device;
#endif
void usb_init()
{
#ifndef ENABLE_EMULATION

View File

@@ -25,6 +25,7 @@
#endif
#include "pico_keys_version.h"
#include "usb.h"
#include "pico_keys.h"
#ifndef USB_VID
#define USB_VID 0xFEFF
@@ -39,11 +40,14 @@
#define MAX_USB_POWER 1
uint16_t usb_vid = USB_VID;
uint16_t usb_pid = USB_PID;
//--------------------------------------------------------------------+
// Device Descriptors
//--------------------------------------------------------------------+
tusb_desc_device_t const desc_device = {
tusb_desc_device_t desc_device = {
.bLength = sizeof(tusb_desc_device_t),
.bDescriptorType = TUSB_DESC_DEVICE,
.bcdUSB = (USB_BCD),