Add checks to the endpoint and pipe configure functions and fail if the requested endpoint or pipe number is above the maximum for that device.
This commit is contained in:
parent
9ab445518a
commit
c41bbf9fcc
6 changed files with 24 additions and 4 deletions
|
@ -246,8 +246,12 @@
|
|||
{
|
||||
uint8_t EPConfigMask = (USB_EP_INTDSBL_bm | ((Banks > 1) ? USB_EP_PINGPONG_bm : 0) | Endpoint_BytesToEPSizeMask(Size));
|
||||
|
||||
if ((Address & ENDPOINT_EPNUM_MASK) >= ENDPOINT_TOTAL_ENDPOINTS)
|
||||
return false;
|
||||
|
||||
// TODO - Fix once limitations are lifted
|
||||
if ((Banks > 1) || (Size > 64))
|
||||
EPConfigMask &= ~USB_EP_PINGPONG_bm;
|
||||
if (Size > 64)
|
||||
return false;
|
||||
|
||||
switch (Type)
|
||||
|
|
|
@ -76,7 +76,7 @@ void USB_Init(
|
|||
USB.CAL1 = pgm_read_byte(offsetof(NVM_PROD_SIGNATURES_t, USBCAL1));
|
||||
NVM.CMD = 0;
|
||||
|
||||
/* Ugly workaround to ensure an aligned table, since __BIGGEST_ALIGNMENT__ == 1 for 8-bit AVR-GCC */
|
||||
/* Ugly workaround to ensure an aligned table, since __BIGGEST_ALIGNMENT__ == 1 for the 8-bit AVR-GCC toochain */
|
||||
USB.EPPTR = ((intptr_t)&USB_EndpointTable[1] & ~(1 << 0));
|
||||
USB.CTRLA = (USB_STFRNUM_bm | ((ENDPOINT_TOTAL_ENDPOINTS - 1) << USB_MAXEP_gp));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue