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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [h8300/] [h8300h/] [v2_0/] [include/] [mod_regs_sci.h] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
#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 Red Hat, 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 version.
19
//
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
23
// for more details.
24
//
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.
28
//
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.
35
//
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.
38
//
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####
45
//
46
// Author(s):    yoshinori sato
47
// Contributors: yoshinori sato
48
// Date:         2002-02-19
49
//              
50
//####DESCRIPTIONEND####
51
//
52
//==========================================================================
53
 
54
#define CYGARC_SMR0  0xFFFFB0
55
#define CYGARC_BRR0  0xFFFFB1
56
#define CYGARC_SCR0  0xFFFFB2
57
#define CYGARC_TDR0  0xFFFFB3
58
#define CYGARC_SSR0  0xFFFFB4
59
#define CYGARC_RDR0  0xFFFFB5
60
#define CYGARC_SCMR0 0xFFFFB6
61
#define CYGARC_SMR1  0xFFFFB8
62
#define CYGARC_BRR1  0xFFFFB9
63
#define CYGARC_SCR1  0xFFFFBA
64
#define CYGARC_TDR1  0xFFFFBB
65
#define CYGARC_SSR1  0xFFFFBC
66
#define CYGARC_RDR1  0xFFFFBD
67
#define CYGARC_SCMR1 0xFFFFBE
68
#define CYGARC_SMR2  0xFFFFC0
69
#define CYGARC_BRR2  0xFFFFC1
70
#define CYGARC_SCR2  0xFFFFC2
71
#define CYGARC_TDR2  0xFFFFC3
72
#define CYGARC_SSR2  0xFFFFC4
73
#define CYGARC_RDR2  0xFFFFC5
74
#define CYGARC_SCMR2 0xFFFFC6
75
 
76
// Serial Mode Register
77
#define CYGARC_REG_SCSMR_CA             0x80 // communication mode
78
#define CYGARC_REG_SCSMR_CHR            0x40 // character length (7 if set)
79
#define CYGARC_REG_SCSMR_PE             0x20 // parity enable
80
#define CYGARC_REG_SCSMR_OE             0x10 // parity mode
81
#define CYGARC_REG_SCSMR_STOP           0x08 // stop bit length
82
#define CYGARC_REG_SCSMR_MP             0x04 // multiprocessor mode
83
#define CYGARC_REG_SCSMR_CKS1           0x02 // clock select 1
84
#define CYGARC_REG_SCSMR_CKS0           0x01 // clock select 0
85
#define CYGARC_REG_SCSMR_CKSx_MASK      0x03 // mask
86
 
87
// Serial Control Register
88
#define CYGARC_REG_SCSCR_TIE            0x80 // transmit interrupt enable
89
#define CYGARC_REG_SCSCR_RIE            0x40 // receive interrupt enable
90
#define CYGARC_REG_SCSCR_TE             0x20 // transmit enable
91
#define CYGARC_REG_SCSCR_RE             0x10 // receive enable
92
#define CYGARC_REG_SCSCR_MPIE           0x08 // multiprocessor interrupt enable
93
#define CYGARC_REG_SCSCR_TEIE           0x04 // transmit-end interrupt enable
94
#define CYGARC_REG_SCSCR_CKE1           0x02 // clock enable 1
95
#define CYGARC_REG_SCSCR_CKE0           0x01 // clock enable 0
96
 
97
// Serial Status Register
98
#define CYGARC_REG_SCSSR_TDRE           0x80 // transmit data register empty
99
#define CYGARC_REG_SCSSR_RDRF           0x40 // receive data register full
100
#define CYGARC_REG_SCSSR_ORER           0x20 // overrun error
101
#define CYGARC_REG_SCSSR_FER            0x10 // framing error
102
#define CYGARC_REG_SCSSR_PER            0x08 // parity error
103
#define CYGARC_REG_SCSSR_TEND           0x04 // transmit end
104
#define CYGARC_REG_SCSSR_MPB            0x02 // multiprocessor bit
105
#define CYGARC_REG_SCSSR_MPBT           0x01 // multiprocessor bit transfer
106
 
107
// When clearing the status register, always write the value:
108
// CYGARC_REG_SCSSR_CLEARMASK & ~bit
109
// to prevent other bits than the one of interest to be cleared.
110
#define CYGARC_REG_SCSSR_CLEARMASK      0xf8
111
 
112
// Baud rate values calculation, depending on peripheral clock (Pf)
113
// n is CKS setting (0-3)
114
// N = (Pf/(64*2^(2n-1)*B))-1
115
// With CYGARC_SCBRR_CKSx providing the values 1, 4, 16, 64 we get
116
//       N = (Pf/(32*_CKS*B))-1
117
//
118
// The CYGARC_SCBRR_OPTIMAL_CKS macro should compute the minimal CKS
119
// setting for the given baud rate and peripheral clock.
120
//
121
// The error of the CKS+count value can be computed by:
122
//  E(%) = ((Pf/((N+1)*B*(64^(n-1)))-1)*100 
123
//
124
#define CYGARC_SCBRR_PRESCALE(_b_) \
125
((((CYGHWR_HAL_H8300_PROCESSOR_SPEED/32/1/(_b_))-1)<256) ? 1 : \
126
 (((CYGHWR_HAL_H8300_PROCESSOR_SPEED/32/4/(_b_))-1)<256) ? 4 : \
127
 (((CYGHWR_HAL_H8300_PROCESSOR_SPEED/32/16/(_b_))-1)<256) ? 16 : 64)
128
 
129
// Add half the divisor to reduce rounding errors to .5
130
#define CYGARC_SCBRR_ROUNDING(_b_) \
131
  16*CYGARC_SCBRR_PRESCALE(_b_)*(_b_)
132
 
133
// These two macros provide the static values we need to stuff into the
134
// registers.
135
#define CYGARC_SCBRR_CKSx(_b_) \
136
    ((1 == CYGARC_SCBRR_PRESCALE(_b_)) ? 0 : \
137
     (4 == CYGARC_SCBRR_PRESCALE(_b_)) ? 1 : \
138
     (16 == CYGARC_SCBRR_PRESCALE(_b_)) ? 2 : 3)
139
#define CYGARC_SCBRR_N(_b_)     \
140
    (((_b_) < 4800) ? 0 :       \
141
      ((_b_) > 115200) ? 0 :    \
142
       (((CYGHWR_HAL_H8300_PROCESSOR_SPEED+CYGARC_SCBRR_ROUNDING(_b_))/32/CYGARC_SCBRR_PRESCALE(_b_)/(_b_))-1))
143
 
144
#endif

powered by: WebSVN 2.1.0

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