1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 23:48:12 +00:00

New usbDelay that delays and handles USB requests

Added usbDelay that polls usb port (for system requests) while delaying.
This is called instead of delay in the button and pin delay functions.
Experimental evaluation gave that the cycle count should be roughly divided
by 28.5.
This commit is contained in:
Jochen Hoenicke 2015-04-29 19:10:48 +02:00
parent b56cf9246b
commit 218b9984bb
3 changed files with 10 additions and 2 deletions

View File

@ -57,7 +57,7 @@ bool protectButton(ButtonRequestType type, bool confirm_only)
// button acked - check buttons // button acked - check buttons
if (acked) { if (acked) {
delay(100000); usbDelay(3500);
buttonUpdate(); buttonUpdate();
if (button.YesUp) { if (button.YesUp) {
result = true; result = true;
@ -165,7 +165,7 @@ bool protectPin(bool use_cached)
} }
layoutDialog(DIALOG_ICON_INFO, NULL, NULL, NULL, "Wrong PIN entered", NULL, "Please wait", secstr, "to continue ...", NULL); layoutDialog(DIALOG_ICON_INFO, NULL, NULL, NULL, "Wrong PIN entered", NULL, "Please wait", secstr, "to continue ...", NULL);
// wait one second // wait one second
delay(24000000); usbDelay(840000);
} }
} }
const char *pin; const char *pin;

View File

@ -332,3 +332,10 @@ void usbTiny(char set)
{ {
tiny = set; tiny = set;
} }
void usbDelay(int cycles)
{
while (cycles--) {
usbd_poll(usbd_dev);
}
}

View File

@ -24,5 +24,6 @@ void usbInit(void);
void usbPoll(void); void usbPoll(void);
void usbReconnect(void); void usbReconnect(void);
void usbTiny(char set); void usbTiny(char set);
void usbDelay(int cycles);
#endif #endif