RTEMS 7.0-rc1
Loading...
Searching...
No Matches
uart.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0+-with-RTEMS-exception */
2
11/*
12 * This software is Copyright (C) 1998 by T.sqware - all rights limited
13 * It is provided in to the public domain "as is", can be freely modified
14 * as far as this copyright notice is kept unchanged, but does not imply
15 * an endorsement by T.sqware of the product in which it is included.
16 *
17 * Copyright (c) Canon Research France SA.]
18 * Emmanuel Raguet, mailto:raguet@crf.canon.fr
19 *
20 * The license and distribution terms for this file may be
21 * found in the file LICENSE in this distribution or at
22 * http://www.rtems.org/license/LICENSE.
23 */
24
25#ifndef _BSPUART_H
26#define _BSPUART_H
27
28#include <rtems/bspIo.h>
29
30void BSP_uart_init(int uart, int baud, int hwFlow);
31void BSP_uart_set_baud(int aurt, int baud);
32void BSP_uart_intr_ctrl(int uart, int cmd);
33void BSP_uart_throttle(int uart);
34void BSP_uart_unthrottle(int uart);
35int BSP_uart_polled_status(int uart);
36void BSP_uart_polled_write(int uart, int val);
37int BSP_uart_polled_read(int uart);
38void BSP_uart_termios_set(int uart, void *ttyp);
39int BSP_uart_termios_write_com1(int minor, const char *buf, int len);
40int BSP_uart_termios_write_com2(int minor, const char *buf, int len);
41void BSP_uart_termios_isr_com1(void);
42void BSP_uart_termios_isr_com2(void);
43void BSP_uart_dbgisr_com1(void);
44void BSP_uart_dbgisr_com2(void);
45extern unsigned BSP_poll_char_via_serial(void);
46extern void BSP_output_char_via_serial(int val);
47extern int BSPConsolePort;
48extern int BSPBaseBaud;
49/*
50 * Command values for BSP_uart_intr_ctrl(),
51 * values are strange in order to catch errors
52 * with assert
53 */
54#define BSP_UART_INTR_CTRL_DISABLE (0)
55#define BSP_UART_INTR_CTRL_GDB (0xaa) /* RX only */
56#define BSP_UART_INTR_CTRL_ENABLE (0xbb) /* Normal operations */
57#define BSP_UART_INTR_CTRL_TERMIOS (0xcc) /* RX & line status */
58
59/* Return values for uart_polled_status() */
60#define BSP_UART_STATUS_ERROR (-1) /* No character */
61#define BSP_UART_STATUS_NOCHAR (0) /* No character */
62#define BSP_UART_STATUS_CHAR (1) /* Character present */
63#define BSP_UART_STATUS_BREAK (2) /* Break point is detected */
64
65/* PC UART definitions */
66#define BSP_UART_COM1 (0)
67#define BSP_UART_COM2 (1)
68
69/*
70 * Base IO for UART
71 */
72
73#define COM1_BASE_IO 0x3F8
74#define COM2_BASE_IO 0x2F8
75
76/*
77 * Offsets from base
78 */
79
80/* DLAB 0 */
81#define RBR RSRBR /* Rx Buffer Register (read) */
82#define THR RSTHR /* Tx Buffer Register (write) */
83#define IER RSIER /* Interrupt Enable Register */
84
85/* DLAB X */
86#define IIR RSIIR /* Interrupt Ident Register (read) */
87#define FCR RSFCR /* FIFO Control Register (write) */
88#define LCR RSLCR /* Line Control Register */
89#define LSR RSLSR /* Line Status Register */
90
91/* DLAB 1 */
92#define DLL RSDLL /* Divisor Latch, LSB */
93#define DLM RSDLH /* Divisor Latch, MSB */
94
95/* Uart control */
96#define CNT RSCNT /* General Control register */
97
98/*
99 * define bit for CNT
100 */
101#define UART_ENABLE 1
102#define PAD_ENABLE 2
103
104/*
105 * Interrupt source definition via IIR
106 */
107#define NO_MORE_INTR 1
108#define TRANSMITTER_HODING_REGISTER_EMPTY 2
109#define RECEIVER_DATA_AVAIL 4
110#define RECEIVER_ERROR 6
111#define CHARACTER_TIMEOUT_INDICATION 12
112
113/*
114 * Bits definition of IER
115 */
116#define RECEIVE_ENABLE 0x1
117#define TRANSMIT_ENABLE 0x2
118#define RECEIVER_LINE_ST_ENABLE 0x4
119#define INTERRUPT_DISABLE 0x0
120
121/*
122 * Bits definition of the Line Status Register (LSR)
123 */
124#define DR 0x01 /* Data Ready */
125#define OE 0x02 /* Overrun Error */
126#define PE 0x04 /* Parity Error */
127#define FE 0x08 /* Framing Error */
128#define BI 0x10 /* Break Interrupt */
129#define THRE 0x20 /* Transmitter Holding Register Empty */
130#define TEMT 0x40 /* Transmitter Empty */
131#define ERFIFO 0x80 /* Error receive Fifo */
132
133/*
134 * Bits definition of the Line Control Register (LCR)
135 */
136#define CHR_5_BITS 0
137#define CHR_6_BITS 1
138#define CHR_7_BITS 2
139#define CHR_8_BITS 3
140
141#define WL 0x03 /* Word length mask */
142#define STB 0x04 /* 1 Stop Bit, otherwise 2 Stop Bits */
143#define PEN 0x08 /* Parity Enabled */
144#define EPS 0x10 /* Even Parity Select, otherwise Odd */
145#define SP 0x20 /* Stick Parity */
146#define BCB 0x40 /* Break Control Bit */
147#define DLAB 0x80 /* Enable Divisor Latch Access */
148
149/*
150 * Bits definition of the FIFO Control Register : WD16C552 or NS16550
151 */
152
153#define FIFO_CTRL 0x01 /* Set to 1 permit access to other bits */
154#define FIFO_EN 0x01 /* Enable the FIFO */
155#define XMIT_RESET 0x04 /* Transmit FIFO Reset */
156#define RCV_RESET 0x02 /* Receive FIFO Reset */
157#define FCR3 0x08 /* do not understand manual! */
158
159#define RECEIVE_FIFO_TRIGGER1 0x0 /* trigger recieve interrupt after 1 byte */
160#define RECEIVE_FIFO_TRIGGER4 0x40 /* trigger recieve interrupt after 4 byte */
161#define RECEIVE_FIFO_TRIGGER8 0x80 /* trigger recieve interrupt after 8 byte */
162#define RECEIVE_FIFO_TRIGGER12 0xc0 /* trigger recieve interrupt after 14 byte */
163#define TRIG_LEVEL 0xc0 /* Mask for the trigger level */
164
165#endif /* _BSPUART_H */
This header file provides the kernel character input/output support API.