Skip to content

Commit

Permalink
fix: add usb otg out_maxsize assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
elagil committed Apr 18, 2023
1 parent e4ad729 commit a74a2ed
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld.c
Expand Up @@ -956,6 +956,9 @@ void usb_lld_reset(USBDriver *usbp) {
otgp->DIEPTXF0 = DIEPTXF_INEPTXFD(ep0config.in_maxsize / 4) |
DIEPTXF_INEPTXSA(otg_ram_alloc(usbp,
ep0config.in_maxsize / 4));

osalDbgAssert(ep0config.out_maxsize <= usbp->otgparams->rx_fifo_size * 4,
"Endpoint 0 out_maxsize exceeds RX FIFO buffer.");
}

/**
Expand Down Expand Up @@ -1004,6 +1007,10 @@ void usb_lld_init_endpoint(USBDriver *usbp, usbep_t ep) {
/* OUT endpoint activation or deactivation.*/
otgp->oe[ep].DOEPTSIZ = 0;
if (usbp->epc[ep]->out_state != NULL) {
osalDbgAssert(usbp->epc[ep]->out_maxsize <=
usbp->otgparams->rx_fifo_size * 4,
"Endpoint out_maxsize exceeds RX FIFO buffer.");

otgp->oe[ep].DOEPCTL = ctl | DOEPCTL_MPSIZ(usbp->epc[ep]->out_maxsize);
otgp->DAINTMSK |= DAINTMSK_OEPM(ep);
}
Expand Down

0 comments on commit a74a2ed

Please sign in to comment.