aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--os/hal/platforms/AVR/serial_lld.h22
-rw-r--r--readme.txt2
2 files changed, 23 insertions, 1 deletions
diff --git a/os/hal/platforms/AVR/serial_lld.h b/os/hal/platforms/AVR/serial_lld.h
index c383b6c70..bcaea51c1 100644
--- a/os/hal/platforms/AVR/serial_lld.h
+++ b/os/hal/platforms/AVR/serial_lld.h
@@ -106,7 +106,27 @@ typedef struct {
* @brief Macro for baud rate computation.
* @note Make sure the final baud rate is within tolerance.
*/
-#define UBRR(b) (((F_CPU / b) >> 4) - 1)
+#define UBRR(b) (((F_CPU / b) >> 4) - 1)
+
+/**
+ * @brief Macro for baud rate computationwhen U2Xn == 1.
+ * @note Make sure the final baud rate is within tolerance.
+ */
+#define UBRR2(b) (((F_CPU / b) >> 3) - 1)
+
+/**
+* @brief Macro for baud rate computation.
+* @note Make sure the final baud rate is within tolerance.
+* @note This version uses floating point math for greater accuracy.
+*/
+#define UBRR_F(b) ((((double) F_CPU / (double) b) / 16.0) - 0.5)
+
+/**
+* @brief Macro for baud rate computation when U2Xn == 1.
+* @note Make sure the final baud rate is within tolerance.
+* @note This version uses floating point math for greater accuracy.
+*/
+#define UBRR2_F(b) ((((double) F_CPU / (double) b) / 8.0) - 0.5)
/*===========================================================================*/
/* External declarations. */
diff --git a/readme.txt b/readme.txt
index 8a6a42644..2e057664c 100644
--- a/readme.txt
+++ b/readme.txt
@@ -79,6 +79,8 @@
*** 2.5.0 ***
- NEW: Updated debug plugin 1.0.8 (backported to 2.4.0).
+- NEW: Added more accurate UBRR calculation in AVR serial driver (backported
+ to 2.4.0).
*** 2.3.5 ***
- FIX: Fixed RTC compile problem on STM32F103 (bug 3468445).