mirror of
https://github.com/polhenarejos/pico-keys-sdk
synced 2026-06-11 21:08:16 +02:00
Adding timeout for press button of 15 secs.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
@@ -379,17 +379,31 @@ void led_set_blink(uint32_t mode) {
|
|||||||
|
|
||||||
void execute_tasks();
|
void execute_tasks();
|
||||||
|
|
||||||
static void wait_button() {
|
static bool wait_button() {
|
||||||
|
uint32_t start_button = board_millis();
|
||||||
|
bool timeout = false;
|
||||||
led_set_blink((1000 << 16) | 100);
|
led_set_blink((1000 << 16) | 100);
|
||||||
|
|
||||||
while (board_button_read() == false) {
|
while (board_button_read() == false) {
|
||||||
execute_tasks();
|
execute_tasks();
|
||||||
//sleep_ms(10);
|
//sleep_ms(10);
|
||||||
|
if (start_button + 15000 < board_millis()) { /* timeout */
|
||||||
|
timeout = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (!timeout) {
|
||||||
while (board_button_read() == true) {
|
while (board_button_read() == true) {
|
||||||
execute_tasks();
|
execute_tasks();
|
||||||
//sleep_ms(10);
|
//sleep_ms(10);
|
||||||
|
if (start_button + 15000 < board_millis()) { /* timeout */
|
||||||
|
timeout = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
led_set_blink(BLINK_PROCESSING);
|
led_set_blink(BLINK_PROCESSING);
|
||||||
|
return timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
void usb_tx_enable(const uint8_t *buf, uint32_t len) {
|
void usb_tx_enable(const uint8_t *buf, uint32_t len) {
|
||||||
@@ -1419,8 +1433,7 @@ void ccid_task(void) {
|
|||||||
ccid_prepare_receive(c);
|
ccid_prepare_receive(c);
|
||||||
}
|
}
|
||||||
else if (m == EV_PRESS_BUTTON) {
|
else if (m == EV_PRESS_BUTTON) {
|
||||||
wait_button();
|
uint32_t flag = wait_button() ? EV_BUTTON_TIMEOUT : EV_BUTTON_PRESSED;
|
||||||
uint32_t flag = EV_BUTTON_PRESSED;
|
|
||||||
queue_try_add(&c->card_comm, &flag);
|
queue_try_add(&c->card_comm, &flag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ struct apdu {
|
|||||||
#define EV_CMD_AVAILABLE 4
|
#define EV_CMD_AVAILABLE 4
|
||||||
#define EV_EXIT 8
|
#define EV_EXIT 8
|
||||||
#define EV_BUTTON_PRESSED 16
|
#define EV_BUTTON_PRESSED 16
|
||||||
|
#define EV_BUTTON_TIMEOUT 32
|
||||||
|
|
||||||
//Variables set by core1
|
//Variables set by core1
|
||||||
extern queue_t *ccid_comm;
|
extern queue_t *ccid_comm;
|
||||||
|
|||||||
Reference in New Issue
Block a user