aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/USB
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2010-07-21 14:17:18 +0000
committerDean Camera <dean@fourwalledcubicle.com>2010-07-21 14:17:18 +0000
commit83e293a6ec98c7faad1b76dd312b31b86cbeecc1 (patch)
treedcdf2b7cbda1a29eb8e1bd90cf3bb73c94acbad1 /LUFA/Drivers/USB
parent97143bf81480d3f642e33684349c601d5cd0b1ae (diff)
downloadlufa-83e293a6ec98c7faad1b76dd312b31b86cbeecc1.tar.gz
lufa-83e293a6ec98c7faad1b76dd312b31b86cbeecc1.tar.bz2
lufa-83e293a6ec98c7faad1b76dd312b31b86cbeecc1.zip
Replace internal Pipe_BytesToEPSizeMask() routine with a new version which results in smaller code.
Diffstat (limited to 'LUFA/Drivers/USB')
-rw-r--r--LUFA/Drivers/USB/LowLevel/Pipe.h22
1 files changed, 10 insertions, 12 deletions
diff --git a/LUFA/Drivers/USB/LowLevel/Pipe.h b/LUFA/Drivers/USB/LowLevel/Pipe.h
index 0714aa844..ee43babfe 100644
--- a/LUFA/Drivers/USB/LowLevel/Pipe.h
+++ b/LUFA/Drivers/USB/LowLevel/Pipe.h
@@ -1061,18 +1061,16 @@
static inline uint8_t Pipe_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST ATTR_ALWAYS_INLINE;
static inline uint8_t Pipe_BytesToEPSizeMask(const uint16_t Bytes)
{
- if (Bytes <= 8)
- return (0 << EPSIZE0);
- else if (Bytes <= 16)
- return (1 << EPSIZE0);
- else if (Bytes <= 32)
- return (2 << EPSIZE0);
- else if (Bytes <= 64)
- return (3 << EPSIZE0);
- else if (Bytes <= 128)
- return (4 << EPSIZE0);
- else
- return (5 << EPSIZE0);
+ uint8_t MaskVal = 0;
+ uint16_t CheckBytes = 8;
+
+ while ((CheckBytes < Bytes) && (CheckBytes < PIPE_MAX_SIZE))
+ {
+ MaskVal++;
+ CheckBytes <<= 1;
+ }
+
+ return (MaskVal << EPSIZE0);
}
#endif