From f547eb36080dacf275cd94fc3ddfb4c618c587fa Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Tue, 25 Aug 2009 14:30:42 +0000 Subject: Optimized Endpoint_Read_Word_* and Pipe_Read_Word_* macros to reduce compiled size. Fixed Programmer's Notepad project file to reflect new location of AVRISP project. --- LUFA/Drivers/USB/LowLevel/Endpoint.h | 24 ++++++++++++++++-------- LUFA/Drivers/USB/LowLevel/Pipe.h | 24 ++++++++++++++++-------- 2 files changed, 32 insertions(+), 16 deletions(-) (limited to 'LUFA/Drivers') diff --git a/LUFA/Drivers/USB/LowLevel/Endpoint.h b/LUFA/Drivers/USB/LowLevel/Endpoint.h index 977c63cfb..652ee8042 100644 --- a/LUFA/Drivers/USB/LowLevel/Endpoint.h +++ b/LUFA/Drivers/USB/LowLevel/Endpoint.h @@ -511,12 +511,16 @@ static inline uint16_t Endpoint_Read_Word_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline uint16_t Endpoint_Read_Word_LE(void) { - uint16_t Data; + union + { + uint16_t Word; + uint8_t Bytes[2]; + } Data; - Data = UEDATX; - Data |= (((uint16_t)UEDATX) << 8); + Data.Bytes[0] = UEDATX; + Data.Bytes[1] = UEDATX; - return Data; + return Data.Word; } /** Reads two bytes from the currently selected endpoint's bank in big endian format, for OUT @@ -529,12 +533,16 @@ static inline uint16_t Endpoint_Read_Word_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline uint16_t Endpoint_Read_Word_BE(void) { - uint16_t Data; + union + { + uint16_t Word; + uint8_t Bytes[2]; + } Data; - Data = (((uint16_t)UEDATX) << 8); - Data |= UEDATX; + Data.Bytes[1] = UEDATX; + Data.Bytes[0] = UEDATX; - return Data; + return Data.Word; } /** Writes two bytes to the currently selected endpoint's bank in little endian format, for IN diff --git a/LUFA/Drivers/USB/LowLevel/Pipe.h b/LUFA/Drivers/USB/LowLevel/Pipe.h index 3931f8530..beee2eb85 100644 --- a/LUFA/Drivers/USB/LowLevel/Pipe.h +++ b/LUFA/Drivers/USB/LowLevel/Pipe.h @@ -566,12 +566,16 @@ static inline uint16_t Pipe_Read_Word_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline uint16_t Pipe_Read_Word_LE(void) { - uint16_t Data; + union + { + uint16_t Word; + uint8_t Bytes[2]; + } Data; - Data = UPDATX; - Data |= (((uint16_t)UPDATX) << 8); + Data.Bytes[0] = UPDATX; + Data.Bytes[1] = UPDATX; - return Data; + return Data.Word; } /** Reads two bytes from the currently selected pipe's bank in big endian format, for OUT @@ -584,12 +588,16 @@ static inline uint16_t Pipe_Read_Word_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline uint16_t Pipe_Read_Word_BE(void) { - uint16_t Data; + union + { + uint16_t Word; + uint8_t Bytes[2]; + } Data; - Data = (((uint16_t)UPDATX) << 8); - Data |= UPDATX; + Data.Bytes[1] = UPDATX; + Data.Bytes[0] = UPDATX; - return Data; + return Data.Word; } /** Writes two bytes to the currently selected pipe's bank in little endian format, for IN -- cgit v1.2.3