1 #ifndef CYGONCE_V85X_V850_SERIAL_H
2 #define CYGONCE_V85X_V850_SERIAL_H
4 // ====================================================================
8 // Device I/O - Description of NEC V850 serial hardware
10 // ====================================================================
11 //####ECOSGPLCOPYRIGHTBEGIN####
12 // -------------------------------------------
13 // This file is part of eCos, the Embedded Configurable Operating System.
14 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
16 // eCos is free software; you can redistribute it and/or modify it under
17 // the terms of the GNU General Public License as published by the Free
18 // Software Foundation; either version 2 or (at your option) any later version.
20 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
21 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
22 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
25 // You should have received a copy of the GNU General Public License along
26 // with eCos; if not, write to the Free Software Foundation, Inc.,
27 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
29 // As a special exception, if other files instantiate templates or use macros
30 // or inline functions from this file, or you compile this file and link it
31 // with other works to produce a work based on this file, this file does not
32 // by itself cause the resulting work to be covered by the GNU General Public
33 // License. However the source code for this file must still be made available
34 // in accordance with section (3) of the GNU General Public License.
36 // This exception does not invalidate any other reasons why a work based on
37 // this file might be covered by the GNU General Public License.
39 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
40 // at http://sources.redhat.com/ecos/ecos-license/
41 // -------------------------------------------
42 //####ECOSGPLCOPYRIGHTEND####
43 // ====================================================================
44 //#####DESCRIPTIONBEGIN####
47 // Contributors: gthomas,jlarmour
49 // Purpose: Internal interfaces for serial I/O drivers
52 //####DESCRIPTIONEND####
54 // ====================================================================
56 // Description of serial ports on NEC V850/SA1 & SB1
58 #include <pkgconf/system.h>
59 #include CYGBLD_HAL_TARGET_H
61 #include <cyg/hal/v850_common.h>
64 unsigned char asim; // Serial interface mode
65 unsigned char _filler0;
66 unsigned char asis; // Serial interface status
67 unsigned char _filler1;
68 unsigned char brgc; // Baud rate control
69 unsigned char _filler2;
70 unsigned char txs; // Transmit shift register
71 unsigned char _filler3;
72 unsigned char rxs; // Receive shift register
73 unsigned char _filler4[5];
74 unsigned char brgm; // Baud rate mode
75 unsigned char _filler5;
76 #if CYGINT_HAL_V850_VARIANT_SB1
77 unsigned char _filler6[0x10];
78 unsigned char brgm1; // Baud rate overflow
82 // Relative interrupt numbers
83 #define INT_ERR 0 // Receive error condition
84 #define INT_Rx 1 // Receive data
85 #define INT_Tx 2 // Transmit data
87 // Serial interface mode
88 #define ASIM_TxRx_MASK (3<<6) // Receive & Transmit enables
89 #define ASIM_TxRx_Rx (1<<6) // Receive enable
90 #define ASIM_TxRx_Tx (2<<6) // Transmit enable
91 #define ASIM_Parity_MASK (3<<4) // Parity mode bits
92 #define ASIM_Parity_none (0<<4) // No parity
93 #define ASIM_Parity_space (1<<4) // Send zero bit, ignore errors
94 #define ASIM_Parity_odd (2<<4) // Odd parity
95 #define ASIM_Parity_even (3<<4) // Even parity
96 #define ASIM_Length_MASK (1<<3) // Character length select
97 #define ASIM_Length_7 (0<<3) // 7 bit chars
98 #define ASIM_Length_8 (1<<3) // 8 bit chars
99 #define ASIM_Stop_MASK (1<<2) // Stop bit select
100 #define ASIM_Stop_1 (0<<2) // 1 stop bit
101 #define ASIM_Stop_2 (1<<2) // 2 stop bits
102 #define ASIM_Error_MASK (1<<1) // Receive error select
103 #define ASIM_Error_enable (0<<1) // Issue interrupt on receive error
104 #define ASIM_Error_disable (1<<1) // No interrupts on receive error
106 // Serial interface status (errors only)
107 #define ASIS_OVE (1<<0) // Overrun error
108 #define ASIS_FE (1<<1) // Framing error
109 #define ASIS_PE (1<<2) // Parity error
111 static unsigned char select_word_length[] = {
112 0xFF, // 5 bits / word (char)
118 static unsigned char select_stop_bits[] = {
120 ASIM_Stop_1, // 1 stop bit
121 0xFF, // 1.5 stop bit
122 ASIM_Stop_2 // 2 stop bits
125 static unsigned char select_parity[] = {
126 ASIM_Parity_none, // No parity
127 ASIM_Parity_even, // Even parity
128 ASIM_Parity_odd, // Odd parity
130 ASIM_Parity_space, // Space parity
133 static struct v850_baud {
135 unsigned int divisor;
137 // Baud rate values, using defined system clock
138 #define BAUDCOUNT(X) ((CYGHWR_HAL_V85X_CPU_FREQ/2)/(X))
148 {BAUDCOUNT(1200), 1}, // 1200
150 {BAUDCOUNT(2400), 1}, // 2400
152 {BAUDCOUNT(4800), 1}, // 4800
154 {BAUDCOUNT(9600), 1}, // 9600
156 {BAUDCOUNT(19200), 1}, // 19200
157 {BAUDCOUNT(38400), 1}, // 38400
163 #endif // CYGONCE_V85X_V850_SERIAL_H
165 // EOF v85x_v850_serial.h