Changeset 6ec438e in rtems for c/src/lib/libbsp/arm/lpc176x


Ignore:
Timestamp:
Oct 7, 2014, 6:29:16 AM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, 5, master
Children:
2fd3e65f
Parents:
d5cc923f
git-author:
Sebastian Huber <sebastian.huber@…> (10/07/14 06:29:16)
git-committer:
Sebastian Huber <sebastian.huber@…> (10/07/14 14:35:20)
Message:

libchip/serial: Add alternative NS16550 driver

Use the Termios device API.

Location:
c/src/lib/libbsp/arm/lpc176x
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/arm/lpc176x/Makefile.am

    rd5cc923f r6ec438e  
    111111
    112112# Console
    113 libbsp_a_SOURCES += ../../shared/console.c
    114 libbsp_a_SOURCES += ../../shared/console_control.c
    115 libbsp_a_SOURCES += ../../shared/console_read.c
    116 libbsp_a_SOURCES += ../../shared/console_select.c
    117 libbsp_a_SOURCES += ../../shared/console_write.c
     113libbsp_a_SOURCES += ../../shared/console-termios-init.c
     114libbsp_a_SOURCES += ../../shared/console-termios.c
    118115libbsp_a_SOURCES += console/console-config.c
    119116
  • c/src/lib/libbsp/arm/lpc176x/console/console-config.c

    rd5cc923f r6ec438e  
    88
    99/*
    10  * Copyright (c) 2008-2011 embedded brains GmbH.  All rights reserved.
     10 * Copyright (c) 2008-2014 embedded brains GmbH.  All rights reserved.
    1111 *
    1212 *  embedded brains GmbH
    13  *  Obere Lagerstr. 30
     13 *  Dornierstr. 4
    1414 *  82178 Puchheim
    1515 *  Germany
     
    2121 */
    2222
    23 #include <libchip/serial.h>
    2423#include <libchip/ns16550.h>
    2524
     
    2726#include <bsp/io.h>
    2827#include <bsp/irq.h>
     28#include <bsp/console-termios.h>
    2929
    3030/**
     
    6363}
    6464
    65 /**
    66  * @brief Represents the uart configuration ports.
    67  */
    68 console_tbl Console_Configuration_Ports[] = {
    6965#ifdef LPC176X_CONFIG_CONSOLE
    70   {
    71     .sDeviceName = "/dev/ttyS0",
    72     .deviceType = SERIAL_NS16550_WITH_FDR,
    73     .pDeviceFns = &ns16550_fns,
    74     .deviceProbe = NULL,
    75     .pDeviceFlow = NULL,
    76     .ulMargin = 16,
    77     .ulHysteresis = 8,
    78     .pDeviceParams = (void *) LPC176X_UART_BAUD,
    79     .ulCtrlPort1 = UART0_BASE_ADDR,
    80     .ulCtrlPort2 = 0,
    81     .ulDataPort = UART0_BASE_ADDR,
    82     .getRegister = lpc176x_uart_get_register,
    83     .setRegister = lpc176x_uart_set_register,
    84     .getData = NULL,
    85     .setData = NULL,
    86     .ulClock = LPC176X_PCLK,
    87     .ulIntVector = LPC176X_IRQ_UART_0
    88   },
     66static ns16550_context lpc176x_uart_context_0 = {
     67  .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("UART 0"),
     68  .get_reg = lpc176x_uart_get_register,
     69  .set_reg = lpc176x_uart_set_register,
     70  .port = UART0_BASE_ADDR,
     71  .irq = LPC176X_IRQ_UART_0,
     72  .clock = LPC176X_PCLK,
     73  .initial_baud = LPC176X_UART_BAUD,
     74  .has_fractional_divider_register = true
     75};
    8976#endif
     77
    9078#ifdef LPC176X_CONFIG_UART_1
    91   {
    92     .sDeviceName = "/dev/ttyS1",
    93     .deviceType = SERIAL_NS16550_WITH_FDR,
    94     .pDeviceFns = &ns16550_fns,
    95     .deviceProbe = lpc176x_uart_probe_1,
    96     .pDeviceFlow = NULL,
    97     .ulMargin = 16,
    98     .ulHysteresis = 8,
    99     .pDeviceParams = (void *) LPC176X_UART_BAUD,
    100     .ulCtrlPort1 = UART1_BASE_ADDR,
    101     .ulCtrlPort2 = 0,
    102     .ulDataPort = UART1_BASE_ADDR,
    103     .getRegister = lpc176x_uart_get_register,
    104     .setRegister = lpc176x_uart_set_register,
    105     .getData = NULL,
    106     .setData = NULL,
    107     .ulClock = LPC176X_PCLK,
    108     .ulIntVector = LPC176X_IRQ_UART_1
    109   },
     79static ns16550_context lpc176x_uart_context_1 = {
     80  .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("UART 1"),
     81  .get_reg = lpc176x_uart_get_register,
     82  .set_reg = lpc176x_uart_set_register,
     83  .port = UART1_BASE_ADDR,
     84  .irq = LPC176X_IRQ_UART_1,
     85  .clock = LPC176X_PCLK,
     86  .initial_baud = LPC176X_UART_BAUD,
     87  .has_fractional_divider_register = true
     88};
    11089#endif
     90
    11191#ifdef LPC176X_CONFIG_UART_2
    112   {
    113     .sDeviceName = "/dev/ttyS2",
    114     .deviceType = SERIAL_NS16550_WITH_FDR,
    115     .pDeviceFns = &ns16550_fns,
    116     .deviceProbe = lpc176x_uart_probe_2,
    117     .pDeviceFlow = NULL,
    118     .ulMargin = 16,
    119     .ulHysteresis = 8,
    120     .pDeviceParams = (void *) LPC176X_UART_BAUD,
    121     .ulCtrlPort1 = UART2_BASE_ADDR,
    122     .ulCtrlPort2 = 0,
    123     .ulDataPort = UART2_BASE_ADDR,
    124     .getRegister = lpc176x_uart_get_register,
    125     .setRegister = lpc176x_uart_set_register,
    126     .getData = NULL,
    127     .setData = NULL,
    128     .ulClock = LPC176X_PCLK,
    129     .ulIntVector = LPC176X_IRQ_UART_2
    130   },
     92static ns16550_context lpc176x_uart_context_2 = {
     93  .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("UART 2"),
     94  .get_reg = lpc176x_uart_get_register,
     95  .set_reg = lpc176x_uart_set_register,
     96  .port = UART2_BASE_ADDR,
     97  .irq = LPC176X_IRQ_UART_2,
     98  .clock = LPC176X_PCLK,
     99  .initial_baud = LPC176X_UART_BAUD,
     100  .has_fractional_divider_register = true
     101};
    131102#endif
     103
    132104#ifdef LPC176X_CONFIG_UART_3
    133   {
    134     .sDeviceName = "/dev/ttyS3",
    135     .deviceType = SERIAL_NS16550_WITH_FDR,
    136     .pDeviceFns = &ns16550_fns,
    137     .deviceProbe = lpc176x_uart_probe_3,
    138     .pDeviceFlow = NULL,
    139     .ulMargin = 16,
    140     .ulHysteresis = 8,
    141     .pDeviceParams = (void *) LPC176X_UART_BAUD,
    142     .ulCtrlPort1 = UART3_BASE_ADDR,
    143     .ulCtrlPort2 = 0,
    144     .ulDataPort = UART3_BASE_ADDR,
    145     .getRegister = lpc176x_uart_get_register,
    146     .setRegister = lpc176x_uart_set_register,
    147     .getData = NULL,
    148     .setData = NULL,
    149     .ulClock = LPC176X_PCLK,
    150     .ulIntVector = LPC176X_IRQ_UART_3
    151   },
     105static ns16550_context lpc176x_uart_context_3 = {
     106  .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("UART 3"),
     107  .get_reg = lpc176x_uart_get_register,
     108  .set_reg = lpc176x_uart_set_register,
     109  .port = UART3_BASE_ADDR,
     110  .irq = LPC176X_IRQ_UART_3,
     111  .clock = LPC176X_PCLK,
     112  .initial_baud = LPC176X_UART_BAUD,
     113  .has_fractional_divider_register = true
     114};
    152115#endif
     116
     117const console_device console_device_table[] = {
     118  #ifdef LPC176X_CONFIG_CONSOLE
     119    {
     120      .device_file = "/dev/ttyS0",
     121      .probe = console_device_probe_default,
     122      .handler = &ns16550_handler_interrupt,
     123      .context = &lpc176x_uart_context_0.base
     124    },
     125  #endif
     126  #ifdef LPC176X_CONFIG_UART_1
     127    {
     128      .device_file = "/dev/ttyS1",
     129      .probe = ns16550_probe,
     130      .handler = &ns16550_handler_interrupt,
     131      .context = &lpc176x_uart_context_1.base
     132    },
     133  #endif
     134  #ifdef LPC176X_CONFIG_UART_2
     135    {
     136      .device_file = "/dev/ttyS2",
     137      .probe = ns16550_probe,
     138      .handler = &ns16550_handler_interrupt,
     139      .context = &lpc176x_uart_context_2.base
     140    },
     141  #endif
     142  #ifdef LPC176X_CONFIG_UART_3
     143    {
     144      .device_file = "/dev/ttyS3",
     145      .probe = ns16550_probe,
     146      .handler = &ns16550_handler_interrupt,
     147      .context = &lpc176x_uart_context_3.base
     148    },
     149  #endif
    153150};
    154151
    155 #define LPC176X_UART_COUNT ( sizeof( Console_Configuration_Ports ) \
    156                              / sizeof( Console_Configuration_Ports[ 0 ] ) )
    157 
    158 unsigned long Console_Configuration_Count = LPC176X_UART_COUNT;
     152const size_t console_device_count = RTEMS_ARRAY_SIZE(console_device_table);
Note: See TracChangeset for help on using the changeset viewer.