Tag for the LUFA-120730-BETA release.
[pub/USBasp.git] / LUFA / Drivers / USB / Core / UC3 / Endpoint_UC3.h
index a1b2a16..1356952 100644 (file)
                                                                      const uint16_t Size,
                                                                      const uint8_t Banks)
                        {
-                               return Endpoint_ConfigureEndpoint_Prv((Address & ENDPOINT_EPNUM_MASK),
+                               uint8_t Number = (Address & ENDPOINT_EPNUM_MASK);
+                       
+                               if (Number >= ENDPOINT_TOTAL_ENDPOINTS)
+                                 return false;
+
+                               return Endpoint_ConfigureEndpoint_Prv(Number,
                                                                      (AVR32_USBB_ALLOC_MASK |
-                                                                      ((uint32_t)Type      << AVR32_USBB_EPTYPE_OFFSET) |
-                                                                      ((uint32_t)(Address & ENDPOINT_DIR_IN) ? AVR32_USBB_UECFG0_EPDIR_MASK : 0) |
-                                                                      ((uint32_t)Banks     << AVR32_USBB_EPBK_OFFSET)   |
+                                                                      ((uint32_t)Type << AVR32_USBB_EPTYPE_OFFSET) |
+                                                                      ((Address & ENDPOINT_DIR_IN) ? AVR32_USBB_UECFG0_EPDIR_MASK : 0) |
+                                                                      ((Banks > 1) ? AVR32_USBB_UECFG0_EPBK_SINGLE : AVR32_USBB_UECFG0_EPBK_DOUBLE) |
                                                                       Endpoint_BytesToEPSizeMask(Size)));
                        }