From 059307d89cbdd7a45170566f469eb9e02c20b3e1 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Tue, 27 Jul 2010 13:49:16 +0000 Subject: Use static inline intermediatary functions in Endpoint.h to handle the masking for the private endpoint configuration routine, instead of performing the masking in the Endpoint_ConfigureEndpoint() macro. --- LUFA/Drivers/USB/LowLevel/Endpoint.h | 50 ++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 14 deletions(-) (limited to 'LUFA/Drivers/USB') diff --git a/LUFA/Drivers/USB/LowLevel/Endpoint.h b/LUFA/Drivers/USB/LowLevel/Endpoint.h index dd49b8092..eb4b6161c 100644 --- a/LUFA/Drivers/USB/LowLevel/Endpoint.h +++ b/LUFA/Drivers/USB/LowLevel/Endpoint.h @@ -1293,14 +1293,23 @@ #define ENDPOINT_DETAILS_EP4 64, true #endif - #define Endpoint_ConfigureEndpoint(Number, Type, Direction, Size, Banks) \ - Endpoint_ConfigureEndpoint_Prv((Number), \ - (((Type) << EPTYPE0) | (Direction)), \ - ((1 << ALLOC) | (Banks) | \ - (__builtin_constant_p(Size) ? \ - Endpoint_BytesToEPSizeMask(Size) : \ - Endpoint_BytesToEPSizeMaskDynamic(Size)))) - + #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) @@ -1316,13 +1325,26 @@ 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))); + } - /* 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); + 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 /* Disable C linkage for C++ Compilers: */ -- cgit v1.2.3