mirror of
https://github.com/polhenarejos/pico-keys-sdk
synced 2026-05-28 17:11:23 +02:00
Add enabled USB interfaces in PHY.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
16
src/fs/phy.c
16
src/fs/phy.c
@@ -65,6 +65,11 @@ int phy_serialize_data(const phy_data_t *phy, uint8_t *data, uint16_t *len) {
|
|||||||
*p++ = 4;
|
*p++ = 4;
|
||||||
p += put_uint32_t_be(phy->enabled_curves, p);
|
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;
|
*len = p - data;
|
||||||
return PICOKEY_OK;
|
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;
|
phy->enabled_curves_present = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PHY_ENABLED_USB_ITF:
|
||||||
|
if (tlen == 1) {
|
||||||
|
phy->enabled_usb_itf = *p++;
|
||||||
|
phy->enabled_usb_itf_present = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
p += tlen;
|
p += tlen;
|
||||||
break;
|
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;
|
return PICOKEY_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
10
src/fs/phy.h
10
src/fs/phy.h
@@ -27,6 +27,7 @@
|
|||||||
#define PHY_UP_BTN 0x8
|
#define PHY_UP_BTN 0x8
|
||||||
#define PHY_USB_PRODUCT 0x9
|
#define PHY_USB_PRODUCT 0x9
|
||||||
#define PHY_ENABLED_CURVES 0xA
|
#define PHY_ENABLED_CURVES 0xA
|
||||||
|
#define PHY_ENABLED_USB_ITF 0xB
|
||||||
|
|
||||||
#define PHY_OPT_WCID 0x1
|
#define PHY_OPT_WCID 0x1
|
||||||
#define PHY_OPT_DIMM 0x2
|
#define PHY_OPT_DIMM 0x2
|
||||||
@@ -45,6 +46,11 @@
|
|||||||
#define PHY_CURVE_CURVE25519 0x200
|
#define PHY_CURVE_CURVE25519 0x200
|
||||||
#define PHY_CURVE_CURVE448 0x400
|
#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 <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
@@ -66,6 +72,7 @@ typedef struct phy_data {
|
|||||||
uint8_t led_gpio;
|
uint8_t led_gpio;
|
||||||
uint8_t led_brightness;
|
uint8_t led_brightness;
|
||||||
uint8_t up_btn;
|
uint8_t up_btn;
|
||||||
|
uint8_t enabled_usb_itf;
|
||||||
|
|
||||||
bool vidpid_present;
|
bool vidpid_present;
|
||||||
bool led_gpio_present;
|
bool led_gpio_present;
|
||||||
@@ -73,10 +80,11 @@ typedef struct phy_data {
|
|||||||
bool up_btn_present;
|
bool up_btn_present;
|
||||||
bool usb_product_present;
|
bool usb_product_present;
|
||||||
bool enabled_curves_present;
|
bool enabled_curves_present;
|
||||||
|
bool enabled_usb_itf_present;
|
||||||
|
|
||||||
} phy_data_t;
|
} 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
|
#ifndef ENABLE_EMULATION
|
||||||
extern int phy_serialize_data(const phy_data_t *phy, uint8_t *data, uint16_t *len);
|
extern int phy_serialize_data(const phy_data_t *phy, uint8_t *data, uint16_t *len);
|
||||||
|
|||||||
Reference in New Issue
Block a user