diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2010-02-12 05:01:11 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2010-02-12 05:01:11 +0000 |
commit | a71820b259577c3cb0efd6c04b5168551a16a6e1 (patch) | |
tree | 4ad9bf11ffc79847cde5512342dd94e767e94bd1 /LUFA/Drivers/Peripheral | |
parent | d49cc0f7830319e701294e19937fae4de26ae8e2 (diff) | |
download | lufa-a71820b259577c3cb0efd6c04b5168551a16a6e1.tar.gz lufa-a71820b259577c3cb0efd6c04b5168551a16a6e1.tar.bz2 lufa-a71820b259577c3cb0efd6c04b5168551a16a6e1.zip |
Fixed accuracy of the SERIAL_UBBRVAL() and SERIAL_2X_UBBRVAL() macros for higher baudrates (thanks to Renaud Cerrato).
Diffstat (limited to 'LUFA/Drivers/Peripheral')
-rw-r--r-- | LUFA/Drivers/Peripheral/Serial.h | 4 |
1 files changed, 2 insertions, 2 deletions
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__)
|