commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r8757 - usrp2/trunk/firmware/lib


From: matt
Subject: [Commit-gnuradio] r8757 - usrp2/trunk/firmware/lib
Date: Mon, 30 Jun 2008 18:26:54 -0600 (MDT)

Author: matt
Date: 2008-06-30 18:26:53 -0600 (Mon, 30 Jun 2008)
New Revision: 8757

Modified:
   usrp2/trunk/firmware/lib/hal_uart.c
Log:
simplified for new uart


Modified: usrp2/trunk/firmware/lib/hal_uart.c
===================================================================
--- usrp2/trunk/firmware/lib/hal_uart.c 2008-06-30 23:14:33 UTC (rev 8756)
+++ usrp2/trunk/firmware/lib/hal_uart.c 2008-07-01 00:26:53 UTC (rev 8757)
@@ -18,7 +18,6 @@
 
 #include "hal_uart.h"
 #include "hal_io.h"
-#include "wb16550.h"
 #include "memory_map.h"
 
 // First pass, no interrupts
@@ -38,74 +37,31 @@
   { 163,  81,  41,  27, 14,  7 },  // 4:  25 MHz
 };
 
-static hal_uart_config_t current_config;
-
-#define UART_LCR_8N1   (UART_LCR_WLEN8)
-
 #define u uart_regs
 
 void
 hal_uart_init(void)
 {
-  u->ier = 0;                  // no interrupts enabled
-  u->lcr = UART_LCR_8N1;
-  u->iir_fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_8 | UART_FCR_CLEAR_RCVR 
| UART_FCR_CLEAR_XMIT;
-  u->iir_fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_8;
-  u->mcr = 0;
-
-  hal_uart_config_t  c;
-  c.speed = US_230400;
-  hal_uart_set_config(&c);
+  u->clkdiv = 217;  // 230400 bps
 }
 
-void 
-hal_uart_set_config(const hal_uart_config_t *c)
-{
-  uint16_t divisor;
-
-  if (c->speed >= NSPEEDS)
-    return;
-
-  current_config = *c;
-
-  if (hwconfig_simulation_p()) // if we're simulating, go fast ;)
-    divisor = 2;
-  else {
-    int t = hwconfig_wishbone_divisor();
-    if (t > MAX_WB_DIV)
-      t = MAX_WB_DIV;
-    divisor = divisor_table[t][current_config.speed];
-  }
-
-  u->lcr = UART_LCR_8N1 | UART_LCR_DLAB;  // enable access to divisor regs
-  u->ier = (divisor >> 8);      // write MSB first
-  u->data = (divisor & 0xff);  // then LSB
-  u->lcr = UART_LCR_8N1;       // back to normal mode
-}
-
 void
-hal_uart_get_config(hal_uart_config_t *c)
-{
-  *c = current_config;
-}
-
-void
 hal_uart_putc(int ch)
 {
   if (ch == '\n')              // FIXME for now map \n -> \r\n
     hal_uart_putc('\r');
 
-  while ((u->lsr & UART_LSR_THRE) == 0)         // wait for fifo to be empty
+  while (u->txlevel == 0)       // wait for fifo to have space
     ;
 
-  u->data = ch;
+  u->txchar = ch;
 }
 
 int
 hal_uart_getc(void)
 {
-  while ((u->lsr & UART_LSR_DR) == 0)  // wait for data to be ready
+  while ((u->rxlevel) == 0)  // wait for data to be ready
     ;
 
-  return u->data;
+  return u->rxchar;
 }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]