mirror of
https://github.com/polhenarejos/pico-keys-sdk
synced 2026-05-28 17:11:23 +02:00
Refactor PHY to support more flexible and scalable architecture.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
@@ -53,29 +53,12 @@ queue_t card_to_usb_q = {0};
|
||||
|
||||
#ifndef ENABLE_EMULATION
|
||||
extern tusb_desc_device_t desc_device;
|
||||
extern bool enable_wcid;
|
||||
#endif
|
||||
void usb_init() {
|
||||
#ifndef ENABLE_EMULATION
|
||||
if (file_has_data(ef_phy)) {
|
||||
uint8_t *data = file_get_data(ef_phy);
|
||||
uint16_t opts = 0;
|
||||
if (file_get_size(ef_phy) >= 8) {
|
||||
opts = (data[PHY_OPTS] << 8) | data[PHY_OPTS+1];
|
||||
if (opts & PHY_OPT_WCID) {
|
||||
enable_wcid = true;
|
||||
}
|
||||
if (opts & PHY_OPT_DIMM) {
|
||||
led_dimmable = true;
|
||||
}
|
||||
}
|
||||
if (file_get_size(ef_phy) >= 4 && opts & PHY_OPT_VPID) {
|
||||
desc_device.idVendor = (data[PHY_VID] << 8) | data[PHY_VID+1];
|
||||
desc_device.idProduct = (data[PHY_PID] << 8) | data[PHY_PID+1];
|
||||
}
|
||||
if (opts & PHY_OPT_BTNESS) {
|
||||
led_phy_btness = data[PHY_LED_BTNESS];
|
||||
}
|
||||
if (phy_data.vidpid_present) {
|
||||
desc_device.idVendor = phy_data.vid;
|
||||
desc_device.idProduct = phy_data.pid;
|
||||
}
|
||||
mutex_init(&mutex);
|
||||
#endif
|
||||
|
||||
@@ -40,8 +40,6 @@
|
||||
|
||||
#define MAX_USB_POWER 2
|
||||
|
||||
bool enable_wcid = false;
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Device Descriptors
|
||||
//--------------------------------------------------------------------+
|
||||
@@ -172,7 +170,7 @@ uint8_t const *tud_hid_descriptor_report_cb(uint8_t itf) {
|
||||
#ifndef ESP_PLATFORM
|
||||
uint8_t const *tud_descriptor_configuration_cb(uint8_t index) {
|
||||
(void) index; // for multiple configurations
|
||||
if (enable_wcid) {
|
||||
if (phy_data.opts & PHY_OPT_WCID) {
|
||||
return desc_config;
|
||||
}
|
||||
return desc_config_nowcid;
|
||||
@@ -188,7 +186,7 @@ enum
|
||||
VENDOR_REQUEST_WEBUSB = 1,
|
||||
VENDOR_REQUEST_MICROSOFT = 2
|
||||
};
|
||||
#define URL "www.picokeys.com/pki/"
|
||||
#define URL "www.picokeys.com"
|
||||
static bool web_serial_connected = false;
|
||||
|
||||
const tusb_desc_webusb_url_t desc_url =
|
||||
@@ -279,7 +277,7 @@ uint8_t const desc_bos[] = {
|
||||
};
|
||||
|
||||
uint8_t const *tud_descriptor_bos_cb(void) {
|
||||
if (enable_wcid) {
|
||||
if (phy_data.opts & PHY_OPT_WCID) {
|
||||
return desc_bos;
|
||||
}
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user