OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [sh/] [sh4/] [current/] [include/] [mod_regs_ser.h] - Blame information for rev 867

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//=============================================================================
2
//
3
//      mod_regs_ser.h
4
//
5
//      SCI, SCIF, and IRDA (serial) Module register definitions
6
//
7
//=============================================================================
8
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
9
// -------------------------------------------                              
10
// This file is part of eCos, the Embedded Configurable Operating System.   
11
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
12
//
13
// eCos is free software; you can redistribute it and/or modify it under    
14
// the terms of the GNU General Public License as published by the Free     
15
// Software Foundation; either version 2 or (at your option) any later      
16
// version.                                                                 
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT      
19
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
21
// for more details.                                                        
22
//
23
// You should have received a copy of the GNU General Public License        
24
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
25
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
26
//
27
// As a special exception, if other files instantiate templates or use      
28
// macros or inline functions from this file, or you compile this file      
29
// and link it with other works to produce a work based on this file,       
30
// this file does not by itself cause the resulting work to be covered by   
31
// the GNU General Public License. However the source code for this file    
32
// must still be made available in accordance with section (3) of the GNU   
33
// General Public License v2.                                               
34
//
35
// This exception does not invalidate any other reasons why a work based    
36
// on this file might be covered by the GNU General Public License.         
37
// -------------------------------------------                              
38
// ####ECOSGPLCOPYRIGHTEND####                                              
39
//=============================================================================
40
//#####DESCRIPTIONBEGIN####
41
//
42
// Author(s):   jskov
43
// Contributors:jskov
44
// Date:        2000-10-30
45
// Note:        All three serial module definitions kept in the same file
46
//              since they share some of the information.
47
//####DESCRIPTIONEND####
48
//
49
//=============================================================================
50
 
51
//++++++ Module SCI ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
52
 
53
//--------------------------------------------------------------------------
54
// Serial registers. All 8 bit registers.
55
#define CYGARC_REG_SCSMR1               0xFFE00000 // serial mode register
56
#define CYGARC_REG_SCBRR1               0xFFE00004 // bit rate register
57
#define CYGARC_REG_SCSCR1               0xFFE00008 // serial control register
58
#define CYGARC_REG_SCTDR1               0xFFE0000C // transmit data register
59
#define CYGARC_REG_SCSSR1               0xFFE00010 // serial status register
60
#define CYGARC_REG_SCRDR1               0xFFE00014 // receive data register
61
#define CYGARC_REG_SCRCMR1              0xFFE00018 
62
#define CYGARC_REG_SCSPTR1              0xFFE0001C // serial port register
63
 
64
// Serial Mode Register
65
#define CYGARC_REG_SCSMR1_CA            0x80 // communication mode
66
#define CYGARC_REG_SCSMR1_CHR           0x40 // character length (7 if set)
67
#define CYGARC_REG_SCSMR1_PE            0x20 // parity enable
68
#define CYGARC_REG_SCSMR1_OE            0x10 // parity mode
69
#define CYGARC_REG_SCSMR1_STOP          0x08 // stop bit length
70
#define CYGARC_REG_SCSMR1_MP            0x04 // multiprocessor mode
71
#define CYGARC_REG_SCSMR1_CKS1          0x02 // clock select 1
72
#define CYGARC_REG_SCSMR1_CKS0          0x01 // clock select 0
73
#define CYGARC_REG_SCSMR1_CKSx_MASK     0x03 // mask
74
 
75
// Serial Control Register
76
#define CYGARC_REG_SCSCR1_TIE           0x80 // transmit interrupt enable
77
#define CYGARC_REG_SCSCR1_RIE           0x40 // receive interrupt enable
78
#define CYGARC_REG_SCSCR1_TE            0x20 // transmit enable
79
#define CYGARC_REG_SCSCR1_RE            0x10 // receive enable
80
#define CYGARC_REG_SCSCR1_MPIE          0x08 // multiprocessor interrupt enable
81
#define CYGARC_REG_SCSCR1_TEIE          0x04 // transmit-end interrupt enable
82
#define CYGARC_REG_SCSCR1_CKE1          0x02 // clock enable 1
83
#define CYGARC_REG_SCSCR1_CKE0          0x01 // clock enable 0
84
 
85
// Serial Status Register
86
#define CYGARC_REG_SCSSR1_TDRE          0x80 // transmit data register empty
87
#define CYGARC_REG_SCSSR1_RDRF          0x40 // receive data register full
88
#define CYGARC_REG_SCSSR1_ORER          0x20 // overrun error
89
#define CYGARC_REG_SCSSR1_FER           0x10 // framing error
90
#define CYGARC_REG_SCSSR1_PER           0x08 // parity error
91
#define CYGARC_REG_SCSSR1_TEND          0x04 // transmit end
92
#define CYGARC_REG_SCSSR1_MPB           0x02 // multiprocessor bit
93
#define CYGARC_REG_SCSSR1_MPBT          0x01 // multiprocessor bit transfer
94
 
95
// When clearing the status register, always write the value:
96
// CYGARC_REG_SCSSR_CLEARMASK & ~bit
97
// to prevent other bits than the one of interest to be cleared.
98
#define CYGARC_REG_SCSSR1_CLEARMASK     0xf8
99
 
100
 
101
// Baud rate values calculation, depending on peripheral clock (Pf)
102
// n is CKS setting (0-3)
103
// N = (Pf/(64*2^(2n-1)*B))-1
104
// With CYGARC_SCBRR_CKSx providing the values 1, 4, 16, 64 we get
105
//       N = (Pf/(32*_CKS*B))-1
106
//
107
// The CYGARC_SCBRR_OPTIMAL_CKS macro should compute the minimal CKS
108
// setting for the given baud rate and peripheral clock.
109
//
110
// The error of the CKS+count value can be computed by:
111
//  E(%) = ((Pf/((N+1)*B*(64^(n-1)))-1)*100 
112
//
113
#define CYGARC_SCBRR_PRESCALE(_b_) \
114
((((CYGHWR_HAL_SH_ONCHIP_PERIPHERAL_SPEED/32/1/(_b_))-1)<256) ? 1 : \
115
 (((CYGHWR_HAL_SH_ONCHIP_PERIPHERAL_SPEED/32/4/(_b_))-1)<256) ? 4 : \
116
 (((CYGHWR_HAL_SH_ONCHIP_PERIPHERAL_SPEED/32/16/(_b_))-1)<256) ? 16 : 64)
117
 
118
// Add half the divisor to reduce rounding errors to .5
119
#define CYGARC_SCBRR_ROUNDING(_b_) \
120
  16*CYGARC_SCBRR_PRESCALE(_b_)*(_b_)
121
 
122
// These two macros provide the static values we need to stuff into the
123
// registers.
124
#define CYGARC_SCBRR_CKSx(_b_) \
125
    ((1 == CYGARC_SCBRR_PRESCALE(_b_)) ? 0 : \
126
     (4 == CYGARC_SCBRR_PRESCALE(_b_)) ? 1 : \
127
     (16 == CYGARC_SCBRR_PRESCALE(_b_)) ? 2 : 3)
128
#define CYGARC_SCBRR_N(_b_)     \
129
       (((CYGHWR_HAL_SH_ONCHIP_PERIPHERAL_SPEED+CYGARC_SCBRR_ROUNDING(_b_))/32/CYGARC_SCBRR_PRESCALE(_b_)/(_b_))-1)
130
 
131
//++++++ Module SCIF +++++++++++++++++++++++++++++++++++++++++++++++++++++++
132
#ifdef CYGARC_SH_MOD_SCIF
133
 
134
//--------------------------------------------------------------------------
135
// Serial w FIFO registers
136
 
137
// SCIF1
138
#define CYGARC_REG_SCIF_SCSMR1                0xFFE00000 // serial mode register
139
#define CYGARC_REG_SCIF_SCBRR1                0xFFE00004 // bit rate register
140
#define CYGARC_REG_SCIF_SCSCR1                0xFFE00008 // serial control register
141
#define CYGARC_REG_SCIF_SCTDR1                0xFFE0000C // transmit data register
142
#define CYGARC_REG_SCIF_SCSSR1                0xFFE00010 // serial status register
143
#define CYGARC_REG_SCIF_SCRDR1                0xFFE00014 // receive data register
144
#define CYGARC_REG_SCIF_SCRCMR1               0xFFE00018 
145
#define CYGARC_REG_SCIF_SCSPTR1               0xFFE0001C // serial port register
146
 
147
// SCIF2
148
#define CYGARC_REG_SCIF_SCSMR2               0xffe80000 // Serial mode
149
#define CYGARC_REG_SCIF_SCBRR2               0xffe80004 // Bit rate
150
#define CYGARC_REG_SCIF_SCSCR2               0xffe80008 // Serial control
151
#define CYGARC_REG_SCIF_SCFTDR2              0xffe8000c // Transmit FIFO data
152
#define CYGARC_REG_SCIF_SCFSR2               0xffe80010 // Serial status
153
#define CYGARC_REG_SCIF_SCFRDR2              0xffe80014 // Receive data FIFO
154
#define CYGARC_REG_SCIF_SCFCR2               0xffe80018 // FIFO control register
155
#define CYGARC_REG_SCIF_SCFDR2               0xffe8001c // FIFO data count set
156
#define CYGARC_REG_SCIF_SCSPTR2              0xffe80020 // serial port register
157
#define CYGARC_REG_SCIF_SCLSR2               0xffe80024 // line status register
158
 
159
// Serial Mode Register - normal mode
160
#define CYGARC_REG_SCIF_SCSMR_CHR            0x40 // character length (7 if set)
161
#define CYGARC_REG_SCIF_SCSMR_PE             0x20 // parity enable
162
#define CYGARC_REG_SCIF_SCSMR_OE             0x10 // parity mode
163
#define CYGARC_REG_SCIF_SCSMR_STOP           0x08 // stop bit length
164
#define CYGARC_REG_SCIF_SCSMR_CKS1           0x02 // clock select 1
165
#define CYGARC_REG_SCIF_SCSMR_CKS0           0x01 // clock select 0
166
#define CYGARC_REG_SCIF_SCSMR_CKSx_MASK      0x03 // mask
167
 
168
// Serial Mode Register - IrDA mode alternative definitions
169
#define CYGARC_REG_SCIF_SCSMR_IRMOD          0x80 // IrDA Mode
170
#define CYGARC_REG_SCIF_SCSMR_ICK_MASK       0x78 // IR pulse width
171
#define CYGARC_REG_SCIF_SCSMR_PSEL           0x04 // IR pulse selector(?)
172
 
173
 
174
// Serial Control Register
175
#define CYGARC_REG_SCIF_SCSCR_TIE            0x80 // transmit interrupt enable
176
#define CYGARC_REG_SCIF_SCSCR_RIE            0x40 // receive interrupt enable
177
#define CYGARC_REG_SCIF_SCSCR_TE             0x20 // transmit enable
178
#define CYGARC_REG_SCIF_SCSCR_RE             0x10 // receive enable
179
#define CYGARC_REG_SCIF_SCSCR_CKE1           0x02 // clock enable 1
180
#define CYGARC_REG_SCIF_SCSCR_CKE0           0x01 // clock enable 0
181
 
182
// Serial Status Register
183
#define CYGARC_REG_SCIF_SCSSR_PER_MASK       0xf000 // number of parity errors
184
#define CYGARC_REG_SCIF_SCSSR_PER_shift      12
185
#define CYGARC_REG_SCIF_SCSSR_FER_MASK       0x0f00 // number of framing errors
186
#define CYGARC_REG_SCIF_SCSSR_FER_shift      8
187
#define CYGARC_REG_SCIF_SCSSR_ER             0x0080 // receive error
188
#define CYGARC_REG_SCIF_SCSSR_TEND           0x0040 // transmit end
189
#define CYGARC_REG_SCIF_SCSSR_TDFE           0x0020 // transmit fifo data empty
190
#define CYGARC_REG_SCIF_SCSSR_BRK            0x0010 // break detection
191
#define CYGARC_REG_SCIF_SCSSR_FER            0x0008 // framing error
192
#define CYGARC_REG_SCIF_SCSSR_PER            0x0004 // parity error
193
#define CYGARC_REG_SCIF_SCSSR_RDF            0x0002 // receive fifo data full
194
#define CYGARC_REG_SCIF_SCSSR_DR             0x0001 // receive data ready
195
 
196
// When clearing the status register, always write the value:
197
// CYGARC_REG_SCSSR2_CLEARMASK & ~bit
198
// to prevent other bits than the one of interest to be cleared.
199
#define CYGARC_REG_SCIF_SCSSR_CLEARMASK      0x00f3
200
 
201
// Serial FIFO Control Register
202
#define CYGARC_REG_SCIF_SCFCR_RTRG_MASK      0xc0   // receive fifo data trigger
203
#define CYGARC_REG_SCIF_SCFCR_RTRG_1         0x00   // trigger on 1 char 
204
#define CYGARC_REG_SCIF_SCFCR_RTRG_4         0x40   // trigger on 4 chars
205
#define CYGARC_REG_SCIF_SCFCR_RTRG_8         0x80   // trigger on 8 chars
206
#define CYGARC_REG_SCIF_SCFCR_RTRG_14        0xc0   // trigger on 14 chars 
207
 
208
#define CYGARC_REG_SCIF_SCFCR_TTRG_MASK      0x30   // transmit fifo data trigger
209
#define CYGARC_REG_SCIF_SCFCR_TTRG_8         0x00   // trigger on 8 chars 
210
#define CYGARC_REG_SCIF_SCFCR_TTRG_4         0x10   // trigger on 4 chars
211
#define CYGARC_REG_SCIF_SCFCR_TTRG_2         0x20   // trigger on 2 chars
212
#define CYGARC_REG_SCIF_SCFCR_TTRG_1         0x30   // trigger on 1 char
213
 
214
#define CYGARC_REG_SCIF_SCFCR_MCE            0x08   // modem control enable
215
#define CYGARC_REG_SCIF_SCFCR_TFRST          0x04   // transmit fifo reset
216
#define CYGARC_REG_SCIF_SCFCR_RFRST          0x02   // receive fifo reset
217
#define CYGARC_REG_SCIF_SCFCR_LOOP           0x01   // loop back test
218
 
219
// Serial FIFO Data Count Set Register
220
#define CYGARC_REG_SCIF_SCFDR_RCOUNT_MASK    0x001f // number of chars in r fifo
221
#define CYGARC_REG_SCIF_SCFDR_RCOUNT_shift   0
222
#define CYGARC_REG_SCIF_SCFDR_TCOUNT_MASK    0x1f00 // number of chars in t fifo
223
#define CYGARC_REG_SCIF_SCFDR_TCOUNT_shift   8
224
 
225
// Serial line status register
226
#define CYGARC_REG_SCIF_SCLSR_ORER           0x01   // overrun error
227
 
228
#endif // CYGARC_SH_MOD_SCIF

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.