summaryrefslogtreecommitdiff
path: root/digital/avr/modules/uart/uart.avr.c
diff options
context:
space:
mode:
Diffstat (limited to 'digital/avr/modules/uart/uart.avr.c')
-rw-r--r--digital/avr/modules/uart/uart.avr.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/digital/avr/modules/uart/uart.avr.c b/digital/avr/modules/uart/uart.avr.c
index ff735213..c28f2f22 100644
--- a/digital/avr/modules/uart/uart.avr.c
+++ b/digital/avr/modules/uart/uart.avr.c
@@ -245,9 +245,7 @@ void
uart_init (void)
{
/* Set baud rate. */
-#if (UBRR_VAL >> 8) != 0
UBRRH = UBRR_VAL >> 8;
-#endif
UBRRL = UBRR_VAL & 0xff;
UCSRA = 0;
/* Set format and enable uart. */
@@ -263,6 +261,15 @@ uart_init (void)
#endif
}
+/** Change uart speed after init. */
+void
+uart_set_speed (uint32_t speed)
+{
+ uint16_t ubrr_val = AC_FREQ / 16 / speed - 1;
+ UBRRH = ubrr_val >> 8;
+ UBRRL = ubrr_val & 0xff;
+}
+
/** Read a char. */
uint8_t
uart_getc (void)