mirror of
https://github.com/polhenarejos/pico-keys-sdk
synced 2026-05-28 17:11:23 +02:00
Add UP button timeout to PHY.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
@@ -45,6 +45,11 @@ int phy_serialize_data(const phy_data_t *phy, uint8_t *data, uint16_t *len) {
|
|||||||
*p++ = PHY_OPTS;
|
*p++ = PHY_OPTS;
|
||||||
*p++ = phy->opts >> 8;
|
*p++ = phy->opts >> 8;
|
||||||
*p++ = phy->opts & 0xff;
|
*p++ = phy->opts & 0xff;
|
||||||
|
if (phy->up_btn_present) {
|
||||||
|
*p++ = PHY_UP_BTN;
|
||||||
|
*p++ = phy->up_btn;
|
||||||
|
}
|
||||||
|
|
||||||
*len = p - data;
|
*len = p - data;
|
||||||
return PICOKEY_OK;
|
return PICOKEY_OK;
|
||||||
}
|
}
|
||||||
@@ -77,6 +82,10 @@ int phy_unserialize_data(const uint8_t *data, uint16_t len, phy_data_t *phy) {
|
|||||||
phy->opts = (*p << 8) | *(p + 1);
|
phy->opts = (*p << 8) | *(p + 1);
|
||||||
p += 2;
|
p += 2;
|
||||||
break;
|
break;
|
||||||
|
case PHY_UP_BTN:
|
||||||
|
phy->up_btn = *p++;
|
||||||
|
phy->up_btn_present = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return PICOKEY_OK;
|
return PICOKEY_OK;
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#define PHY_LED_GPIO 0x4
|
#define PHY_LED_GPIO 0x4
|
||||||
#define PHY_LED_BTNESS 0x5
|
#define PHY_LED_BTNESS 0x5
|
||||||
#define PHY_OPTS 0x6
|
#define PHY_OPTS 0x6
|
||||||
|
#define PHY_UP_BTN 0x8
|
||||||
|
|
||||||
#define PHY_OPT_WCID 0x1
|
#define PHY_OPT_WCID 0x1
|
||||||
#define PHY_OPT_DIMM 0x2
|
#define PHY_OPT_DIMM 0x2
|
||||||
@@ -42,14 +43,16 @@ typedef struct phy_data {
|
|||||||
uint8_t led_gpio;
|
uint8_t led_gpio;
|
||||||
uint8_t led_brightness;
|
uint8_t led_brightness;
|
||||||
uint16_t opts;
|
uint16_t opts;
|
||||||
|
uint8_t up_btn;
|
||||||
bool vidpid_present;
|
bool vidpid_present;
|
||||||
bool led_gpio_present;
|
bool led_gpio_present;
|
||||||
bool led_brightness_present;
|
bool led_brightness_present;
|
||||||
|
bool up_btn_present;
|
||||||
} phy_data_t;
|
} phy_data_t;
|
||||||
|
|
||||||
#define PHY_OPT_MASK (PHY_OPT_SECURE_LOCK | PHY_OPT_SECURE_BOOT | PHY_OPT_DIMM | PHY_OPT_WCID)
|
#define PHY_OPT_MASK (PHY_UP_BTN | PHY_OPT_SECURE_LOCK | PHY_OPT_SECURE_BOOT | PHY_OPT_DIMM | PHY_OPT_WCID)
|
||||||
|
|
||||||
#define PHY_MAX_SIZE 8
|
#define PHY_MAX_SIZE 9
|
||||||
|
|
||||||
#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);
|
||||||
|
|||||||
@@ -99,7 +99,6 @@ bool is_req_button_pending() {
|
|||||||
return req_button_pending;
|
return req_button_pending;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t button_timeout = 15000;
|
|
||||||
bool cancel_button = false;
|
bool cancel_button = false;
|
||||||
|
|
||||||
#ifdef ENABLE_EMULATION
|
#ifdef ENABLE_EMULATION
|
||||||
@@ -182,6 +181,13 @@ bool button_pressed_state = false;
|
|||||||
uint32_t button_pressed_time = 0;
|
uint32_t button_pressed_time = 0;
|
||||||
uint8_t button_press = 0;
|
uint8_t button_press = 0;
|
||||||
bool wait_button() {
|
bool wait_button() {
|
||||||
|
uint32_t button_timeout = 15000;
|
||||||
|
if (phy_data.up_btn_present) {
|
||||||
|
button_timeout = phy_data.up_btn * 1000;
|
||||||
|
if (button_timeout == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
uint32_t start_button = board_millis();
|
uint32_t start_button = board_millis();
|
||||||
bool timeout = false;
|
bool timeout = false;
|
||||||
cancel_button = false;
|
cancel_button = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user