Changeset 9bc1913e in rtems


Ignore:
Timestamp:
May 5, 2013, 10:02:07 PM (6 years ago)
Author:
Eugeniy Meshcheryakov <eugen@…>
Branches:
4.11, master
Children:
86b79fb
Parents:
847e2cac
git-author:
Eugeniy Meshcheryakov <eugen@…> (05/05/13 22:02:07)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/06/13 07:38:33)
Message:

bsp/lm3s69xx: Use interrupts for UART receive

This makes continuous UART polling unnecessary.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/arm/lm3s69xx/console/uart.c

    r847e2cac r9bc1913e  
    2020#include <bsp/syscon.h>
    2121#include <bsp/lm3s69xx.h>
     22#include <rtems/irq-extension.h>
     23#include <assert.h>
     24
     25#define LM3S69XX_UART_FIFO_DEPTH 16
    2226
    2327static volatile lm3s69xx_uart *get_uart_regs(int minor)
     
    4448}
    4549
     50static void irq_handler(void *arg)
     51{
     52  int minor = (int)arg;
     53  console_data *cd = &Console_Port_Data [minor];
     54  volatile lm3s69xx_uart *uart = get_uart_regs(minor);
     55
     56  do {
     57    char buf[LM3S69XX_UART_FIFO_DEPTH];
     58    int i = 0;
     59    uint32_t status = uart->fr;
     60
     61    while (((status & UARTFR_RXFE) == 0) && (i < LM3S69XX_UART_FIFO_DEPTH)) {
     62      uint32_t d = uart->dr;
     63
     64      if ((d & UARTDR_ERROR_MSK) == 0) {
     65        buf[i] = UARTDR_DATA_GET(d);
     66        i++;
     67      }
     68
     69      status = uart->fr;
     70    }
     71
     72    if (i > 0)
     73      rtems_termios_enqueue_raw_characters(cd->termios_data, buf, i);
     74  } while (uart->mis != 0);
     75}
     76
    4677static void initialize(int minor)
    4778{
     79  const console_tbl *ct = Console_Port_Tbl[minor];
    4880  volatile lm3s69xx_uart *uart = get_uart_regs(minor);
    4981  unsigned int num = get_uart_number(minor);
     
    5991  uart->lcrh = UARTLCRH_WLEN(0x3) | UARTLCRH_FEN;
    6092  uart->ctl = UARTCTL_RXE | UARTCTL_TXE | UARTCTL_UARTEN;
     93
     94  int rv = rtems_interrupt_handler_install(ct->ulIntVector, "UART",
     95      RTEMS_INTERRUPT_UNIQUE, irq_handler, (void *)minor);
     96  assert(rv == RTEMS_SUCCESSFUL);
    6197}
    6298
     
    66102  struct rtems_termios_tty *tty = (struct rtems_termios_tty *) oc->iop->data1;
    67103  console_data *cd = &Console_Port_Data [minor];
     104  volatile lm3s69xx_uart *uart = get_uart_regs(minor);
    68105
    69106  cd->termios_data = tty;
    70107  rtems_termios_set_initial_baud(tty, LM3S69XX_UART_BAUD);
     108
     109  /* Drain the RX FIFO. */
     110  while ((uart->fr & UARTFR_RXFE) == 0)
     111    (void)uart->dr;
     112
     113  uart->im = UARTI_RX | UARTI_RT;
    71114
    72115  return 0;
     
    75118static int last_close(int major, int minor, void *arg)
    76119{
     120  volatile lm3s69xx_uart *uart = get_uart_regs(minor);
     121  uart->im = 0;
     122
    77123  return 0;
    78 }
    79 
    80 static int read_polled(int minor)
    81 {
    82   volatile lm3s69xx_uart *uart = get_uart_regs(minor);
    83 
    84   if ((uart->fr & UARTFR_RXFE) != 0) {
    85     return -1;
    86   } else {
    87     return UARTDR_DATA(uart->dr);
    88   }
    89124}
    90125
     
    124159  .deviceFirstOpen = first_open,
    125160  .deviceLastClose = last_close,
    126   .deviceRead = read_polled,
     161  .deviceRead = NULL,
    127162  .deviceWrite = write_support_polled,
    128163  .deviceInitialize = initialize,
    129164  .deviceWritePolled = write_polled,
    130165  .deviceSetAttributes = set_attribues,
    131   .deviceOutputUsesInterrupts = false
     166  .deviceOutputUsesInterrupts = TERMIOS_POLLED
    132167};
Note: See TracChangeset for help on using the changeset viewer.