[rtems commit] bsps/shared: Allow setting baud rate for zynq uart

Jan Sommer jan at rtems.org
Fri Mar 5 18:09:39 UTC 2021


Module:    rtems
Branch:    master
Commit:    6ebf376bf221ed833f38e8427bfe7830d6b6fdd8
Changeset: http://git.rtems.org/rtems/commit/?id=6ebf376bf221ed833f38e8427bfe7830d6b6fdd8

Author:    Jan Sommer <jan.sommer at dlr.de>
Date:      Mon Feb 22 16:39:59 2021 +0100

bsps/shared: Allow setting baud rate for zynq uart

---

 bsps/shared/dev/serial/zynq-uart.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/bsps/shared/dev/serial/zynq-uart.c b/bsps/shared/dev/serial/zynq-uart.c
index 8f17d3c..cd0d0e7 100644
--- a/bsps/shared/dev/serial/zynq-uart.c
+++ b/bsps/shared/dev/serial/zynq-uart.c
@@ -144,14 +144,22 @@ static bool zynq_uart_set_attributes(
 {
   zynq_uart_context *ctx = (zynq_uart_context *) context;
   volatile zynq_uart *regs = ctx->regs;
+  int32_t baud;
   uint32_t brgr = 0;
   uint32_t bauddiv = 0;
   uint32_t mode = 0;
   int rc;
 
-  rc = zynq_cal_baud_rate(115200, &brgr, &bauddiv, regs->mode);
-  if (rc != 0)
-    return rc;
+  /*
+   * Determine the baud rate
+   */
+  baud = rtems_termios_baud_to_number(term->c_ospeed);
+
+  if (baud > 0) {
+    rc = zynq_cal_baud_rate(baud, &brgr, &bauddiv, regs->mode);
+    if (rc != 0)
+      return rc;
+  }
 
   /*
    * Configure the mode register
@@ -202,8 +210,11 @@ static bool zynq_uart_set_attributes(
 
   regs->control &= ~(ZYNQ_UART_CONTROL_RXEN | ZYNQ_UART_CONTROL_TXEN);
   regs->mode = mode;
-  regs->baud_rate_gen = ZYNQ_UART_BAUD_RATE_GEN_CD(brgr);
-  regs->baud_rate_div = ZYNQ_UART_BAUD_RATE_DIV_BDIV(bauddiv);
+  /* Ignore baud rate of B0. There are no modem control lines to de-assert */
+  if (baud > 0) {
+    regs->baud_rate_gen = ZYNQ_UART_BAUD_RATE_GEN_CD(brgr);
+    regs->baud_rate_div = ZYNQ_UART_BAUD_RATE_DIV_BDIV(bauddiv);
+  }
   regs->control |= ZYNQ_UART_CONTROL_RXEN | ZYNQ_UART_CONTROL_TXEN;
 
   return true;



More information about the vc mailing list