@@ 392,6 392,12 @@ uint8_t usb_daint_get_endpoint_number(uint32_t endpoints) {
void usb_handle_endpoint_in_int(usb_device_t* device) {
uint8_t ep_id = usb_daint_get_endpoint_number(reg_read_bits_pos(&device->device->DAINT, USB_OTG_DAINT_IEPINT_Pos, 0xFFFF));
+
+ if (ep_id == 0xFF) {
+ device->state = ERROR;
+ return;
+ }
+
uint32_t interrupt_reg = device->in[ep_id].DIEPINT;
if (interrupt_reg & USB_OTG_DIEPINT_PKTDRPSTS) {
@@ 447,6 453,12 @@ void usb_handle_endpoint_out_int(usb_device_t* device) {
/* device->core->GRXFSIZ; */
uint8_t ep_id = usb_daint_get_endpoint_number(reg_read_bits_pos(&device->device->DAINT, USB_OTG_DAINT_OEPINT_Pos, 0xFFFF));
+
+ if (ep_id == 0xFF) {
+ device->state = ERROR;
+ return;
+ }
+
uint32_t interrupt_reg = device->out[ep_id].DOEPINT;
if (interrupt_reg & USB_OTG_DOEPINT_STPKTRX) {