Fix USB crash on disconnect
* @{
*/
+
/**
* @}
*/
#define USBD_PID 0xf1d1
#else
#define USBD_VID 0x2C97
-#if TARGET_ID == 0x31000002 // blue
+#if defined(TARGET_BLUE) // blue
#define USBD_PID 0x0000
const uint8_t const USBD_PRODUCT_FS_STRING[] = {
4 * 2 + 2, USB_DESC_TYPE_STRING, 'B', 0, 'l', 0, 'u', 0, 'e', 0,
};
-#elif TARGET_ID == 0x31100002 // nano s
+#elif defined(TARGET_NANOS) // nano s
#define USBD_PID 0x0001
const uint8_t const USBD_PRODUCT_FS_STRING[] = {
6 * 2 + 2, USB_DESC_TYPE_STRING,
@@ -134,7 +135,7 @@ const uint8_t const USBD_PRODUCT_FS_STRING[] = {
' ', 0,
'S', 0,
};
-#elif TARGET_ID == 0x31200002 // aramis
+#elif defined(TARGET_ARAMIS) // aramis
#define USBD_PID 0x0002
const uint8_t const USBD_PRODUCT_FS_STRING[] = {
6 * 2 + 2, USB_DESC_TYPE_STRING,
@@ -462,9 +463,11 @@ uint8_t USBD_HID_DataOut_impl(USBD_HandleTypeDef *pdev, uint8_t epnum,
U2F_MEDIA_USB);
#endif
} else {
+ // avoid troubles when an apdu has not been replied yet
+ if (G_io_apdu_media == IO_APDU_MEDIA_NONE) {
// add to the hid transport
- switch (
- io_usb_hid_receive(io_usb_send_apdu_data, buffer,
+ switch (io_usb_hid_receive(
+ io_usb_send_apdu_data, buffer,
io_seproxyhal_get_ep_rx_size(HID_EPOUT_ADDR))) {
default:
break;
@@ -476,6 +479,7 @@ uint8_t USBD_HID_DataOut_impl(USBD_HandleTypeDef *pdev, uint8_t epnum,
break;
}
}
+ }
return USBD_OK;
}
