- /* Private Interface - For use in library only: */
- #if !defined(__DOXYGEN__)
- /* Macros: */
- #define _ENDPOINT_GET_MAXSIZE(n) _ENDPOINT_GET_MAXSIZE2(ENDPOINT_DETAILS_EP ## n)
- #define _ENDPOINT_GET_MAXSIZE2(details) _ENDPOINT_GET_MAXSIZE3(details)
- #define _ENDPOINT_GET_MAXSIZE3(maxsize, db) maxsize
-
- #define _ENDPOINT_GET_DOUBLEBANK(n) _ENDPOINT_GET_DOUBLEBANK2(ENDPOINT_DETAILS_EP ## n)
- #define _ENDPOINT_GET_DOUBLEBANK2(details) _ENDPOINT_GET_DOUBLEBANK3(details)
- #define _ENDPOINT_GET_DOUBLEBANK3(maxsize, db) db
-
- #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
- #define ENDPOINT_DETAILS_EP0 64, true
- #define ENDPOINT_DETAILS_EP1 256, true
- #define ENDPOINT_DETAILS_EP2 64, true
- #define ENDPOINT_DETAILS_EP3 64, true
- #define ENDPOINT_DETAILS_EP4 64, true
- #define ENDPOINT_DETAILS_EP5 64, true
- #define ENDPOINT_DETAILS_EP6 64, true
- #else
- #define ENDPOINT_DETAILS_EP0 64, true
- #define ENDPOINT_DETAILS_EP1 64, false
- #define ENDPOINT_DETAILS_EP2 64, false
- #define ENDPOINT_DETAILS_EP3 64, true
- #define ENDPOINT_DETAILS_EP4 64, true
- #endif
-
- #define Endpoint_ConfigureEndpoint(Number, Type, Direction, Size, Banks) \
- (__builtin_constant_p(Size) ? Endpoint_ConfigureEndpointStatic((Number), \
- (Type), \
- (Direction), \
- Size, Banks) : \
- Endpoint_ConfigureEndpointDynamic((Number), \
- (Type), \
- (Direction), \
- Size, Banks))
-
- /* Function Prototypes: */
- void Endpoint_ClearEndpoints(void);
- uint8_t Endpoint_BytesToEPSizeMaskDynamic(const uint16_t Size);
- bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number,
- const uint8_t UECFG0XData,
- const uint8_t UECFG1XData);
-
- /* Inline Functions: */
- static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST ATTR_ALWAYS_INLINE;
- static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes)
- {
- uint8_t MaskVal = 0;
- uint16_t CheckBytes = 8;
-
- while (CheckBytes < Bytes)
- {
- MaskVal++;
- CheckBytes <<= 1;
- }
-
- return (MaskVal << EPSIZE0);
- }
-
- static inline bool Endpoint_ConfigureEndpointStatic(const uint8_t Number,
- const uint8_t Type,
- const uint8_t Direction,
- const uint16_t Size,
- const uint8_t Banks)
- {
- return Endpoint_ConfigureEndpoint_Prv(Number, (((Type) << EPTYPE0) | (Direction)),
- ((1 << ALLOC) | Banks | Endpoint_BytesToEPSizeMask(Size)));
- }
-
- static inline bool Endpoint_ConfigureEndpointDynamic(const uint8_t Number,
- const uint8_t Type,
- const uint8_t Direction,
- const uint16_t Size,
- const uint8_t Banks)
- {
- return Endpoint_ConfigureEndpoint_Prv(Number, (((Type) << EPTYPE0) | (Direction)),
- ((1 << ALLOC) | Banks | Endpoint_BytesToEPSizeMaskDynamic(Size)));
- }
- #endif
-