Add enabled USB interfaces in PHY.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos 2025-03-22 23:24:36 +01:00
parent f1b1382300
commit c185b35ca3
No known key found for this signature in database
GPG key ID: C0095B7870A4CCD3
2 changed files with 25 additions and 1 deletions

View file

@ -65,6 +65,11 @@ int phy_serialize_data(const phy_data_t *phy, uint8_t *data, uint16_t *len) {
*p++ = 4;
p += put_uint32_t_be(phy->enabled_curves, p);
}
if (phy->enabled_usb_itf_present) {
*p++ = PHY_ENABLED_USB_ITF;
*p++ = 1;
*p++ = phy->enabled_usb_itf;
}
*len = p - data;
return PICOKEY_OK;
@ -129,11 +134,22 @@ int phy_unserialize_data(const uint8_t *data, uint16_t len, phy_data_t *phy) {
phy->enabled_curves_present = true;
}
break;
case PHY_ENABLED_USB_ITF:
if (tlen == 1) {
phy->enabled_usb_itf = *p++;
phy->enabled_usb_itf_present = true;
}
break;
default:
p += tlen;
break;
}
}
if (!phy_data.enabled_usb_itf_present) {
phy_data.enabled_usb_itf = PHY_USB_ITF_CCID | PHY_USB_ITF_WCID | PHY_USB_ITF_HID | PHY_USB_ITF_KB;
phy_data.enabled_usb_itf_present = true;
}
return PICOKEY_OK;
}

View file

@ -27,6 +27,7 @@
#define PHY_UP_BTN 0x8
#define PHY_USB_PRODUCT 0x9
#define PHY_ENABLED_CURVES 0xA
#define PHY_ENABLED_USB_ITF 0xB
#define PHY_OPT_WCID 0x1
#define PHY_OPT_DIMM 0x2
@ -45,6 +46,11 @@
#define PHY_CURVE_CURVE25519 0x200
#define PHY_CURVE_CURVE448 0x400
#define PHY_USB_ITF_CCID 0x1
#define PHY_USB_ITF_WCID 0x2
#define PHY_USB_ITF_HID 0x4
#define PHY_USB_ITF_KB 0x8
#include <stdint.h>
#include <stdbool.h>
@ -66,6 +72,7 @@ typedef struct phy_data {
uint8_t led_gpio;
uint8_t led_brightness;
uint8_t up_btn;
uint8_t enabled_usb_itf;
bool vidpid_present;
bool led_gpio_present;
@ -73,10 +80,11 @@ typedef struct phy_data {
bool up_btn_present;
bool usb_product_present;
bool enabled_curves_present;
bool enabled_usb_itf_present;
} phy_data_t;
#define PHY_MAX_SIZE ((2+4)+(2+4)+(2+32)+(2+2)+(2+1)+(2+1)+(2+1))
#define PHY_MAX_SIZE ((2+4)+(2+4)+(2+32)+(2+2)+(2+1)+(2+1)+(2+1)+(2+1))
#ifndef ENABLE_EMULATION
extern int phy_serialize_data(const phy_data_t *phy, uint8_t *data, uint16_t *len);