From a71820b259577c3cb0efd6c04b5168551a16a6e1 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Fri, 12 Feb 2010 05:01:11 +0000 Subject: Fixed accuracy of the SERIAL_UBBRVAL() and SERIAL_2X_UBBRVAL() macros for higher baudrates (thanks to Renaud Cerrato). --- LUFA/Drivers/Peripheral/Serial.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'LUFA/Drivers') diff --git a/LUFA/Drivers/Peripheral/Serial.h b/LUFA/Drivers/Peripheral/Serial.h index ba466f314..d00f9c1c0 100644 --- a/LUFA/Drivers/Peripheral/Serial.h +++ b/LUFA/Drivers/Peripheral/Serial.h @@ -68,12 +68,12 @@ /** Macro for calculating the baud value from a given baud rate when the U2X (double speed) bit is * not set. */ - #define SERIAL_UBBRVAL(baud) (((F_CPU / 16) / (baud)) - 1) + #define SERIAL_UBBRVAL(baud) ((((F_CPU / 16) + (baud / 2)) / (baud)) - 1) /** Macro for calculating the baud value from a given baud rate when the U2X (double speed) bit is * set. */ - #define SERIAL_2X_UBBRVAL(baud) (((F_CPU / 8) / (baud)) - 1) + #define SERIAL_2X_UBBRVAL(baud) ((((F_CPU / 8) + (baud / 2)) / (baud)) - 1) /* Pseudo-Function Macros: */ #if defined(__DOXYGEN__) -- cgit v1.2.3