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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [h8300/] [h8s/] [current/] [include/] [mod_regs_sci.h] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#ifndef CYGONCE_MOD_REGS_SCI_H
2
#define CYGONCE_MOD_REGS_SCI_H
3
 
4
//==========================================================================
5
//
6
//      mod_regs_sci.h
7
//
8
//      Serial Communication Interface Register
9
//
10
//==========================================================================
11
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
12
// -------------------------------------------                              
13
// This file is part of eCos, the Embedded Configurable Operating System.   
14
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
15
//
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      
19
// version.                                                                 
20
//
21
// eCos is distributed in the hope that it will be useful, but WITHOUT      
22
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
23
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
24
// for more details.                                                        
25
//
26
// You should have received a copy of the GNU General Public License        
27
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
28
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
29
//
30
// As a special exception, if other files instantiate templates or use      
31
// macros or inline functions from this file, or you compile this file      
32
// and link it with other works to produce a work based on this file,       
33
// this file does not by itself cause the resulting work to be covered by   
34
// the GNU General Public License. However the source code for this file    
35
// must still be made available in accordance with section (3) of the GNU   
36
// General Public License v2.                                               
37
//
38
// This exception does not invalidate any other reasons why a work based    
39
// on this file might be covered by the GNU General Public License.         
40
// -------------------------------------------                              
41
// ####ECOSGPLCOPYRIGHTEND####                                              
42
//==========================================================================
43
//#####DESCRIPTIONBEGIN####
44
//
45
// Author(s):    yoshinori sato
46
// Contributors: yoshinori sato
47
// Date:         2002-02-19
48
//              
49
//####DESCRIPTIONEND####
50
//
51
//==========================================================================
52
 
53
#define CYGARC_SMR0  0xFFFF78
54
#define CYGARC_BRR0  0xFFFF79
55
#define CYGARC_SCR0  0xFFFF7A
56
#define CYGARC_TDR0  0xFFFF7B
57
#define CYGARC_SSR0  0xFFFF7C
58
#define CYGARC_RDR0  0xFFFF7D
59
#define CYGARC_SCMR0 0xFFFF7E
60
#define CYGARC_SMR1  0xFFFF80
61
#define CYGARC_BRR1  0xFFFF81
62
#define CYGARC_SCR1  0xFFFF82
63
#define CYGARC_TDR1  0xFFFF83
64
#define CYGARC_SSR1  0xFFFF84
65
#define CYGARC_RDR1  0xFFFF85
66
#define CYGARC_SCMR1 0xFFFF86
67
#define CYGARC_SMR2  0xFFFF88
68
#define CYGARC_BRR2  0xFFFF89
69
#define CYGARC_SCR2  0xFFFF8A
70
#define CYGARC_TDR2  0xFFFF8B
71
#define CYGARC_SSR2  0xFFFF8C
72
#define CYGARC_RDR2  0xFFFF8D
73
#define CYGARC_SCMR2 0xFFFF8E
74
 
75
#define CYGARC_IRCR0 0xFFFE1E
76
#define CYGARC_SEMR  0xFFFDA8
77
 
78
// Serial Mode Register
79
#define CYGARC_REG_SCSMR_CA             0x80 // communication mode
80
#define CYGARC_REG_SCSMR_CHR            0x40 // character length (7 if set)
81
#define CYGARC_REG_SCSMR_PE             0x20 // parity enable
82
#define CYGARC_REG_SCSMR_OE             0x10 // parity mode
83
#define CYGARC_REG_SCSMR_STOP           0x08 // stop bit length
84
#define CYGARC_REG_SCSMR_MP             0x04 // multiprocessor mode
85
#define CYGARC_REG_SCSMR_CKS1           0x02 // clock select 1
86
#define CYGARC_REG_SCSMR_CKS0           0x01 // clock select 0
87
#define CYGARC_REG_SCSMR_CKSx_MASK      0x03 // mask
88
 
89
// Serial Control Register
90
#define CYGARC_REG_SCSCR_TIE            0x80 // transmit interrupt enable
91
#define CYGARC_REG_SCSCR_RIE            0x40 // receive interrupt enable
92
#define CYGARC_REG_SCSCR_TE             0x20 // transmit enable
93
#define CYGARC_REG_SCSCR_RE             0x10 // receive enable
94
#define CYGARC_REG_SCSCR_MPIE           0x08 // multiprocessor interrupt enable
95
#define CYGARC_REG_SCSCR_TEIE           0x04 // transmit-end interrupt enable
96
#define CYGARC_REG_SCSCR_CKE1           0x02 // clock enable 1
97
#define CYGARC_REG_SCSCR_CKE0           0x01 // clock enable 0
98
 
99
// Serial Status Register
100
#define CYGARC_REG_SCSSR_TDRE           0x80 // transmit data register empty
101
#define CYGARC_REG_SCSSR_RDRF           0x40 // receive data register full
102
#define CYGARC_REG_SCSSR_ORER           0x20 // overrun error
103
#define CYGARC_REG_SCSSR_FER            0x10 // framing error
104
#define CYGARC_REG_SCSSR_PER            0x08 // parity error
105
#define CYGARC_REG_SCSSR_TEND           0x04 // transmit end
106
#define CYGARC_REG_SCSSR_MPB            0x02 // multiprocessor bit
107
#define CYGARC_REG_SCSSR_MPBT           0x01 // multiprocessor bit transfer
108
 
109
// When clearing the status register, always write the value:
110
// CYGARC_REG_SCSSR_CLEARMASK & ~bit
111
// to prevent other bits than the one of interest to be cleared.
112
#define CYGARC_REG_SCSSR_CLEARMASK      0xf8
113
 
114
// Baud rate values calculation, depending on peripheral clock (Pf)
115
// n is CKS setting (0-3)
116
// N = (Pf/(64*2^(2n-1)*B))-1
117
// With CYGARC_SCBRR_CKSx providing the values 1, 4, 16, 64 we get
118
//       N = (Pf/(32*_CKS*B))-1
119
//
120
// The CYGARC_SCBRR_OPTIMAL_CKS macro should compute the minimal CKS
121
// setting for the given baud rate and peripheral clock.
122
//
123
// The error of the CKS+count value can be computed by:
124
//  E(%) = ((Pf/((N+1)*B*(64^(n-1)))-1)*100 
125
//
126
#define CYGARC_SCBRR_PRESCALE(_b_) \
127
((((CYGHWR_HAL_H8300_PROCESSOR_SPEED/32/1/(_b_))-1)<256) ? 1 : \
128
 (((CYGHWR_HAL_H8300_PROCESSOR_SPEED/32/4/(_b_))-1)<256) ? 4 : \
129
 (((CYGHWR_HAL_H8300_PROCESSOR_SPEED/32/16/(_b_))-1)<256) ? 16 : 64)
130
 
131
// Add half the divisor to reduce rounding errors to .5
132
#define CYGARC_SCBRR_ROUNDING(_b_) \
133
  16*CYGARC_SCBRR_PRESCALE(_b_)*(_b_)
134
 
135
// These two macros provide the static values we need to stuff into the
136
// registers.
137
#define CYGARC_SCBRR_CKSx(_b_) \
138
    ((1 == CYGARC_SCBRR_PRESCALE(_b_)) ? 0 : \
139
     (4 == CYGARC_SCBRR_PRESCALE(_b_)) ? 1 : \
140
     (16 == CYGARC_SCBRR_PRESCALE(_b_)) ? 2 : 3)
141
#define CYGARC_SCBRR_N(_b_)     \
142
    (((_b_) < 4800) ? 0 :       \
143
      ((_b_) > 115200) ? 0 :    \
144
       (((CYGHWR_HAL_H8300_PROCESSOR_SPEED+CYGARC_SCBRR_ROUNDING(_b_))/32/CYGARC_SCBRR_PRESCALE(_b_)/(_b_))-1))
145
 
146
#endif

powered by: WebSVN 2.1.0

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