RTEMS 6.1-rc5
Loading...
Searching...
No Matches
m340uart.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
11/*
12 * Header file for console driver
13 * defines for accessing M68340/68349 UART registers
14 *
15 * Author:
16 * Geoffroy Montel
17 * France Telecom - CNET/DSM/TAM/CAT
18 * 4, rue du Clos Courtel
19 * 35512 CESSON-SEVIGNE
20 * FRANCE
21 *
22 * e-mail: g_montel@yahoo.com
23 *
24 *
25 * COPYRIGHT (c) 1989-2008.
26 * On-Line Applications Research Corporation (OAR).
27 *
28 * Redistribution and use in source and binary forms, with or without
29 * modification, are permitted provided that the following conditions
30 * are met:
31 * 1. Redistributions of source code must retain the above copyright
32 * notice, this list of conditions and the following disclaimer.
33 * 2. Redistributions in binary form must reproduce the above copyright
34 * notice, this list of conditions and the following disclaimer in the
35 * documentation and/or other materials provided with the distribution.
36 *
37 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
38 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
40 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
41 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
42 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
43 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
44 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
45 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
47 * POSSIBILITY OF SUCH DAMAGE.
48 */
49
50#ifndef __m340uart_H__
51#define __m340uart_H__
52
53#include <sys/types.h>
54
55/* UART initialisation */
56#define UART_CHANNEL_A 0
57#define UART_CHANNEL_B 1
58#define UART_NUMBER_OF_CHANNELS 2
59#define UART_CONSOLE_NAME "/dev/console"
60#define UART_RAW_IO_NAME "/dev/tty1"
61#define UART_FIFO_FULL 0
62#define UART_CRR 1
63#define UART_INTERRUPTS 0
64#define UART_POLLING 1
65#define UART_TERMIOS_CONSOLE 0
66#define UART_TERMIOS_RAW 1
67#define UART_TERMIOS_MIN_DEFAULT 1
68#define UART_TERMIOS_TIME_DEFAULT 0
69
70void Init_UART_Table(void);
71
72typedef struct {
73 uint8_t enable;
74 uint16_t rx_buffer_size; /* NOT IMPLEMENTED */
75 uint16_t tx_buffer_size; /* NOT IMPLEMENTED */
77
78typedef struct { /* for one channel */
79 uint8_t enable; /* use this channel */
80 char name[64]; /* use UART_CONSOLE_NAME for console purpose */
81 uint8_t parity_mode; /* parity mode, see MR1 section for defines */
82 uint8_t bits_per_char; /* bits per character, see MR1 section for defines */
83 float rx_baudrate; /* Rx baudrate */
84 float tx_baudrate; /* Tx baudrate */
85 uint8_t rx_mode; /* FIFO Full (UART_FIFO_FULL) or ChannelReceiverReady (UART_CRR) */
86 uint8_t mode; /* use interrupts (UART_INTERRUPTS) or polling (UART_POLLING) */
87 uart_termios_config termios;
89
90extern uart_channel_config m340_uart_config[UART_NUMBER_OF_CHANNELS];
91
92typedef struct {
93 int set; /* number of the m340 baud speed set */
94 int rcs; /* RCS for the needed baud set */
95 int tcs; /* TCS for the needed baud set */
97
98typedef struct {
99 t_baud_speed baud_speed_table[2];
100 short nb;
102
104Find_Right_m340_UART_Config(float ChannelA_ReceiverBaudRate, float ChannelA_TransmitterBaudRate, uint8_t enableA,
105 float ChannelB_ReceiverBaudRate, float ChannelB_TransmitterBaudRate, uint8_t enableB);
106
107extern rtems_isr InterruptHandler (rtems_vector_number v);
108
109extern int dbugRead (int minor);
110extern ssize_t dbugWrite (int minor, const char *buf, size_t len);
111
112extern float m340_Baud_Rates_Table[16][2];
113
114/* SR */
115#define m340_Rx_RDY 1
116#define m340_FFULL (1<<1)
117#define m340_Tx_RDY (1<<2)
118#define m340_TxEMP (1<<3)
119#define m340_OE (1<<4)
120#define m340_PE (1<<5)
121#define m340_FE (1<<6)
122#define m340_RB (1<<7)
123
124/* IER */
125#define m340_TxRDYA 1
126#define m340_RxRDYA (1<<1)
127#define m340_TxRxRDYA 0x3
128#define m340_TxRDYB (1<<4)
129#define m340_RxRDYB (1<<5)
130#define m340_TxRxRDYB 0x30
131
132/* CR */
133#define m340_Reset_Error_Status 0x40
134#define m340_Reset_Receiver 0x20
135#define m340_Reset_Transmitter 0x30
136#define m340_Transmitter_Enable (1<<2)
137#define m340_Receiver_Enable 1
138#define m340_Transmitter_Disable (2<<2)
139#define m340_Receiver_Disable 2
140
141/* ACR */
142#define m340_BRG_Set1 0
143#define m340_BRG_Set2 (1<<7)
144
145/* OPCR */
146#define m340_OPCR_Gal 0x0
147#define m340_OPCR_Aux 0xFF
148
149/* ISR */
150#define m340_COS (1<<7)
151#define m340_DBB (1<<6)
152#define m340_XTAL_RDY (1<<3)
153#define m340_DBA (1<<2)
154
155/* MR1 */
156#define m340_RxRTS (1<<7)
157#define m340_R_F (1<<6) /* character or block mode */
158#define m340_ERR (1<<5)
159#define m340_RxRTX (1<<7)
160#define m340_Even_Parity 0
161#define m340_Odd_Parity (1<<2)
162#define m340_Low_Parity (2<<2)
163#define m340_High_Parity (3<<2)
164#define m340_No_Parity (4<<2)
165#define m340_Data_Character (6<<2)
166#define m340_Address_Character (7<<2)
167#define m340_5bpc 0x0
168#define m340_6bpc 0x1
169#define m340_7bpc 0x2
170#define m340_8bpc 0x3
171
172/* MR2 */
173#define m340_normal (0<<6)
174#define m340_automatic_echo (1<<6)
175#define m340_local_loopback (2<<6)
176#define m340_remote_loopback (3<<6)
177#define m340_TxRTS (1<<5)
178#define m340_TxCTS (1<<4)
179
180/* Baud rates for Transmitter/Receiver */
181#define SCLK 1 /* put your own SCLK value here */
182
183#endif
ISR_Handler rtems_isr
This type defines the return type of interrupt service routines.
Definition: intr.h:123
ISR_Vector_number rtems_vector_number
This integer type represents interrupt vector numbers.
Definition: intr.h:102
Definition: m340uart.h:98
Definition: m340uart.h:92
Definition: m340uart.h:78
Definition: m340uart.h:72