source: rtems/c/src/lib/libbsp/bfin/TLL6527M/console/console.c @ 1c0663b4

4.115
Last change on this file since 1c0663b4 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 3.8 KB
Line 
1/**
2 *@file console.c
3 *
4 *@brief
5 *  - This file implements uart console for TLL6527M. TLL6527M has BF527 with
6 *  second uart (uart-1) connected to the console.
7 *
8 * Target:   TLL6527v1-0
9 * Compiler:
10 *
11 * COPYRIGHT (c) 2010 by ECE Northeastern University.
12 *
13 * The license and distribution terms for this file may be
14 * found in the file LICENSE in this distribution or at
15 * http://www.rtems.org/license
16 *
17 * @author Rohan Kangralkar, ECE, Northeastern University
18 *         (kangralkar.r@husky.neu.edu)
19 *
20 * LastChange:
21 */
22
23#include <rtems.h>
24#include <rtems/libio.h>
25#include <bsp.h>
26#include <rtems/bspIo.h>
27
28#include <bsp/interrupt.h>
29#include <libcpu/uart.h>
30
31/***************************************************
32LOCAL DEFINES
33 ***************************************************/
34
35
36/***************************************************
37STATIC GLOBALS
38 ***************************************************/
39/**
40 * Declaration of UART
41 */
42static bfin_uart_channel_t channels[] = {
43  {"/dev/console",
44    UART1_BASE_ADDRESS,
45    DMA10_BASE_ADDRESS,
46    DMA11_BASE_ADDRESS,
47    CONSOLE_USE_INTERRUPTS,
48    UART_USE_DMA,
49    CONSOLE_BAUDRATE,
50    NULL,
51    0,
52    0}
53};
54
55/**
56 * Over all configuration
57 */
58static bfin_uart_config_t config = {
59    SCLK,
60    sizeof(channels) / sizeof(channels[0]),
61    channels
62};
63
64
65#if CONSOLE_USE_INTERRUPTS
66/**
67 * The Rx and Tx isr will get the same argument
68 * The isr will have to find if it was the rx that caused the interrupt or
69 * the tx
70 */
71static bfin_isr_t bfinUARTISRs[] = {
72#if UART_USE_DMA
73    /* For First uart */
74    {IRQ_DMA10_UART1_RX, bfinUart_rxDmaIsr, (void *)&channels[0], 0},
75    {IRQ_DMA11_UART1_TX, bfinUart_txDmaIsr, (void *)&channels[0], 0},
76    /* For second uart */
77#else
78    /* For First uart */
79    {IRQ_DMA10_UART1_RX, bfinUart_rxIsr, &channels[0], 0},
80    {IRQ_DMA11_UART1_TX, bfinUart_txIsr, &channels[0], 0},
81    /* For second uart */
82#endif
83};
84#endif
85
86
87static void TLL6527_BSP_output_char(char c) {
88
89  bfin_uart_poll_write(0, c);
90}
91
92static int TLL6527_BSP_poll_char(void) {
93
94  return bfin_uart_poll_read(0);
95}
96
97BSP_output_char_function_type     BSP_output_char = TLL6527_BSP_output_char;
98BSP_polling_getchar_function_type BSP_poll_char   = TLL6527_BSP_poll_char;
99
100
101
102rtems_device_driver console_close(rtems_device_major_number major,
103    rtems_device_minor_number minor,
104    void *arg) {
105
106  return rtems_termios_close(arg);
107}
108
109rtems_device_driver console_read(rtems_device_major_number major,
110    rtems_device_minor_number minor,
111    void *arg) {
112
113  return rtems_termios_read(arg);
114}
115
116rtems_device_driver console_write(rtems_device_major_number major,
117    rtems_device_minor_number minor,
118    void *arg) {
119
120  return rtems_termios_write(arg);
121}
122
123rtems_device_driver console_control(rtems_device_major_number major,
124    rtems_device_minor_number minor,
125    void *arg) {
126
127  return rtems_termios_ioctl(arg);
128}
129
130
131
132/*
133 *  Open entry point
134 */
135rtems_device_driver console_open(rtems_device_major_number major,
136    rtems_device_minor_number minor,
137    void *arg) {
138
139  return bfin_uart_open(major, minor, arg);
140}
141
142
143
144/**
145 *
146 * This routine initializes the console IO driver.
147 *
148 * Parameters
149 * @param major major number
150 * @param minor minor number
151 *
152 * Output parameters:  NONE
153 *
154 * @return void
155 */
156rtems_device_driver console_initialize(rtems_device_major_number major,
157    rtems_device_minor_number minor,
158    void *arg) {
159  rtems_status_code status = RTEMS_NOT_DEFINED;
160#if CONSOLE_USE_INTERRUPTS
161  int               i      = 0;
162#endif
163
164  status = bfin_uart_initialize(major, &config);
165  if (status != RTEMS_SUCCESSFUL) {
166    rtems_fatal_error_occurred(status);
167  }
168
169#if CONSOLE_USE_INTERRUPTS
170  for (i = 0; i < sizeof(bfinUARTISRs) / sizeof(bfinUARTISRs[0]); i++) {
171    bfin_interrupt_register(&bfinUARTISRs[i]);
172#if INTERRUPT_USE_TABLE
173#else
174    bfin_interrupt_enable(&bfinUARTISRs[i], 1);
175#endif
176  }
177#endif
178
179  return RTEMS_SUCCESSFUL;
180}
Note: See TracBrowser for help on using the repository browser.