1 |
786 |
skrzyp |
#ifndef CYGONCE_HAL_VAR_INTR_H
|
2 |
|
|
#define CYGONCE_HAL_VAR_INTR_H
|
3 |
|
|
//==========================================================================
|
4 |
|
|
//
|
5 |
|
|
// var_intr.h
|
6 |
|
|
//
|
7 |
|
|
// mcfxxxx Variant interrupt and clock support
|
8 |
|
|
//
|
9 |
|
|
//
|
10 |
|
|
//==========================================================================
|
11 |
|
|
// ####ECOSGPLCOPYRIGHTBEGIN####
|
12 |
|
|
// -------------------------------------------
|
13 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
14 |
|
|
// Copyright (C) 2003, 2006, 2007, 2008 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): bartv
|
46 |
|
|
// Date: 2003-06-04
|
47 |
|
|
//
|
48 |
|
|
//####DESCRIPTIONEND####
|
49 |
|
|
//=============================================================================
|
50 |
|
|
|
51 |
|
|
#include <pkgconf/hal.h>
|
52 |
|
|
#include <cyg/infra/cyg_type.h>
|
53 |
|
|
|
54 |
|
|
// Include any processor specific interrupt definitions.
|
55 |
|
|
#include <cyg/hal/proc_intr.h>
|
56 |
|
|
|
57 |
|
|
// ColdFire defines some extra exceptions
|
58 |
|
|
// The debug vector is for hardware breakpoints. These are not used
|
59 |
|
|
// at present.
|
60 |
|
|
#define CYGNUM_HAL_VECTOR_DEBUG 12
|
61 |
|
|
#define CYGNUM_HAL_VECTOR_FORMAT 14
|
62 |
|
|
|
63 |
|
|
// The following implementation should suffice for most platforms. If
|
64 |
|
|
// any of them need special VSR's then they can define their own version.
|
65 |
|
|
#if !defined(HAL_VSR_SET_TO_ECOS_HANDLER) && !defined(_HAL_M68K_NO_VSR_SET_)
|
66 |
|
|
# define HAL_VSR_SET_TO_ECOS_HANDLER( _vector_, _poldvsr_) \
|
67 |
|
|
CYG_MACRO_START \
|
68 |
|
|
if ( (_vector_) <= CYGNUM_HAL_VECTOR_TRAPLAST) { \
|
69 |
|
|
HAL_VSR_SET( (_vector_), &hal_m68k_exception_vsr, (_poldvsr_) ); \
|
70 |
|
|
} else { \
|
71 |
|
|
HAL_VSR_SET( (_vector_), &hal_m68k_interrupt_vsr, (_poldvsr_) ); \
|
72 |
|
|
} \
|
73 |
|
|
CYG_MACRO_END
|
74 |
|
|
#endif
|
75 |
|
|
|
76 |
|
|
// ----------------------------------------------------------------------------
|
77 |
|
|
// On ColdFires with 5282-style interrupt controllers, many of the
|
78 |
|
|
// interrupt-related macros can be provided here rather than duplicated
|
79 |
|
|
// in the processor HALs. Of course there complications, for example there
|
80 |
|
|
// may be one or two interrupt controllers.
|
81 |
|
|
|
82 |
|
|
#ifdef HAL_MCFxxxx_HAS_MCF5282_INTC
|
83 |
|
|
|
84 |
|
|
# ifndef HAL_INTERRUPT_MASK
|
85 |
|
|
// Masking interrupts is straightforward: there are 32-bit read-write
|
86 |
|
|
// mask registers. Often the vector argument will be a constant so the
|
87 |
|
|
// compiler gets a chance to optimise these macros. There is also some
|
88 |
|
|
// compile-time optimization based around the maximum number of
|
89 |
|
|
// interrupt vectors. to avoid worrying about interrupts 32-63 if only
|
90 |
|
|
// the bottom half of INTC0 is of interest, or interrupts 96-127 if
|
91 |
|
|
// only the bottom half of INTC1 is of interest.
|
92 |
|
|
//
|
93 |
|
|
// Some newer ColdFires have additional set/clear mask registers.
|
94 |
|
|
|
95 |
|
|
# ifdef HAL_MCFxxxx_INTCx_SIMR
|
96 |
|
|
# if (1 == HAL_MCFxxxx_HAS_MCF5282_INTC)
|
97 |
|
|
# define HAL_INTERRUPT_MASK(_vector_) \
|
98 |
|
|
CYG_MACRO_START \
|
99 |
|
|
HAL_WRITE_UINT8(HAL_MCFxxxx_INTC0_BASE + HAL_MCFxxxx_INTCx_SIMR, (_vector_)); \
|
100 |
|
|
CYG_MACRO_END
|
101 |
|
|
# elif (2 == HAL_MCFxxxx_HAS_MCF5282_INTC)
|
102 |
|
|
# define HAL_INTERRUPT_MASK(_vector_) \
|
103 |
|
|
CYG_MACRO_START \
|
104 |
|
|
cyg_uint32 _vec_ = (_vector_); \
|
105 |
|
|
if (_vec_ < 64) { \
|
106 |
|
|
HAL_WRITE_UINT8(HAL_MCFxxxx_INTC0_BASE + HAL_MCFxxxx_INTCx_SIMR, _vec_); \
|
107 |
|
|
} else { \
|
108 |
|
|
HAL_WRITE_UINT8(HAL_MCFxxxx_INTC1_BASE + HAL_MCFxxxx_INTCx_SIMR, _vec_ - 64); \
|
109 |
|
|
} \
|
110 |
|
|
CYG_MACRO_END
|
111 |
|
|
# else
|
112 |
|
|
# error At most two interrupt controllers supported at present.
|
113 |
|
|
# endif
|
114 |
|
|
# else // ! SIMR
|
115 |
|
|
# if (1 == HAL_MCFxxxx_HAS_MCF5282_INTC)
|
116 |
|
|
# define HAL_INTERRUPT_MASK(_vector_) \
|
117 |
|
|
CYG_MACRO_START \
|
118 |
|
|
cyg_uint32 _shift_ = (_vector_); \
|
119 |
|
|
cyg_uint32 _reg_; \
|
120 |
|
|
cyg_uint32 _bits_; \
|
121 |
|
|
if ( (CYGNUM_HAL_ISR_MAX < 32) || (_shift_ < 32)) { \
|
122 |
|
|
_reg_ = HAL_MCFxxxx_INTC0_BASE + HAL_MCFxxxx_INTCx_IMRL; \
|
123 |
|
|
} else { \
|
124 |
|
|
_reg_ = HAL_MCFxxxx_INTC0_BASE + HAL_MCFxxxx_INTCx_IMRH; \
|
125 |
|
|
_shift_ -= 32; \
|
126 |
|
|
} \
|
127 |
|
|
HAL_READ_UINT32(_reg_, _bits_); \
|
128 |
|
|
_bits_ |= (0x01 << _shift_); \
|
129 |
|
|
HAL_WRITE_UINT32(_reg_, _bits_); \
|
130 |
|
|
CYG_MACRO_END
|
131 |
|
|
# elif (2 == HAL_MCFxxxx_HAS_MCF5282_INTC)
|
132 |
|
|
# define HAL_INTERRUPT_MASK(_vector_) \
|
133 |
|
|
CYG_MACRO_START \
|
134 |
|
|
cyg_uint32 _shift_ = (_vector_); \
|
135 |
|
|
cyg_uint32 _reg_; \
|
136 |
|
|
cyg_uint32 _bits_; \
|
137 |
|
|
if ( (CYGNUM_HAL_ISR_MAX < 32) || (_shift_ < 32)) { \
|
138 |
|
|
_reg_ = HAL_MCFxxxx_INTC0_BASE + HAL_MCFxxxx_INTCx_IMRL; \
|
139 |
|
|
} else if ((CYGNUM_HAL_ISR_MAX < 64) || (_shift_ < 64)) { \
|
140 |
|
|
_reg_ = HAL_MCFxxxx_INTC0_BASE + HAL_MCFxxxx_INTCx_IMRH; \
|
141 |
|
|
_shift_ -= 32; \
|
142 |
|
|
} else if ((CYGNUM_HAL_ISR_MAX < 96) || (_shift_ < 96)) { \
|
143 |
|
|
_reg_ = HAL_MCFxxxx_INTC1_BASE + HAL_MCFxxxx_INTCx_IMRL; \
|
144 |
|
|
_shift_ -= 64; \
|
145 |
|
|
} else { \
|
146 |
|
|
_reg_ = HAL_MCFxxxx_INTC1_BASE + HAL_MCFxxxx_INTCx_IMRH; \
|
147 |
|
|
_shift_ -= 96; \
|
148 |
|
|
} \
|
149 |
|
|
HAL_READ_UINT32(_reg_, _bits_); \
|
150 |
|
|
_bits_ |= (0x01 << _shift_); \
|
151 |
|
|
HAL_WRITE_UINT32(_reg_, _bits_); \
|
152 |
|
|
CYG_MACRO_END
|
153 |
|
|
# else
|
154 |
|
|
# error At most two interrupt controllers supported at present.
|
155 |
|
|
# endif // HAL_MCFxxxx_HAS_MCF5282_INTC == 1/2/many
|
156 |
|
|
# endif // SIMR
|
157 |
|
|
# endif // !defined(HAL_INTERRUPT_MASK)
|
158 |
|
|
|
159 |
|
|
// Care has to be taken with bit 0 of the IMRL registers. Writing a 1 to
|
160 |
|
|
// this masks all interrupts.
|
161 |
|
|
# ifndef HAL_INTERRUPT_UNMASK
|
162 |
|
|
# ifdef HAL_MCFxxxx_INTCx_CIMR
|
163 |
|
|
# if (1 == HAL_MCFxxxx_HAS_MCF5282_INTC)
|
164 |
|
|
# define HAL_INTERRUPT_UNMASK(_vector_) \
|
165 |
|
|
CYG_MACRO_START \
|
166 |
|
|
HAL_WRITE_UINT8(HAL_MCFxxxx_INTC0_BASE + HAL_MCFxxxx_INTCx_CIMR, (_vector_)); \
|
167 |
|
|
CYG_MACRO_END
|
168 |
|
|
# elif (2 == HAL_MCFxxxx_HAS_MCF5282_INTC)
|
169 |
|
|
# define HAL_INTERRUPT_UNMASK(_vector_) \
|
170 |
|
|
CYG_MACRO_START \
|
171 |
|
|
cyg_uint32 _vec_ = (_vector_); \
|
172 |
|
|
if (_vec_ < 64) { \
|
173 |
|
|
HAL_WRITE_UINT8(HAL_MCFxxxx_INTC0_BASE + HAL_MCFxxxx_INTCx_CIMR, _vec_); \
|
174 |
|
|
} else { \
|
175 |
|
|
HAL_WRITE_UINT8(HAL_MCFxxxx_INTC1_BASE + HAL_MCFxxxx_INTCx_CIMR, _vec_ - 64); \
|
176 |
|
|
} \
|
177 |
|
|
CYG_MACRO_END
|
178 |
|
|
# else
|
179 |
|
|
# error At most two interrupt controllers supported at present.
|
180 |
|
|
# endif
|
181 |
|
|
# else
|
182 |
|
|
# if (1 == HAL_MCFxxxx_HAS_MCF5282_INTC)
|
183 |
|
|
# define HAL_INTERRUPT_UNMASK(_vector_) \
|
184 |
|
|
CYG_MACRO_START \
|
185 |
|
|
cyg_uint32 _vec_ = (_vector_); \
|
186 |
|
|
cyg_uint32 _reg_; \
|
187 |
|
|
cyg_uint32 _bits_; \
|
188 |
|
|
if ( (CYGNUM_HAL_ISR_MAX < 32) || (_vec_ < 32)) { \
|
189 |
|
|
_reg_ = HAL_MCFxxxx_INTC0_BASE + HAL_MCFxxxx_INTCx_IMRL; \
|
190 |
|
|
HAL_READ_UINT32(_reg_, _bits_); \
|
191 |
|
|
_bits_ &= ~((0x01 << _vec_) | 0x01); \
|
192 |
|
|
HAL_WRITE_UINT32(_reg_, _bits_); \
|
193 |
|
|
} else { \
|
194 |
|
|
_reg_ = HAL_MCFxxxx_INTC0_BASE + HAL_MCFxxxx_INTCx_IMRH; \
|
195 |
|
|
HAL_READ_UINT32(_reg_, _bits_); \
|
196 |
|
|
_bits_ &= ~(0x01 << (_vec_ - 32)); \
|
197 |
|
|
HAL_WRITE_UINT32(_reg_, _bits_); \
|
198 |
|
|
} \
|
199 |
|
|
CYG_MACRO_END
|
200 |
|
|
# elif (2 == HAL_MCFxxxx_HAS_MCF5282_INTC)
|
201 |
|
|
# define HAL_INTERRUPT_UNMASK(_vector_) \
|
202 |
|
|
CYG_MACRO_START \
|
203 |
|
|
cyg_uint32 _vec_ = (_vector_); \
|
204 |
|
|
cyg_uint32 _reg_; \
|
205 |
|
|
cyg_uint32 _bits_; \
|
206 |
|
|
if ( (CYGNUM_HAL_ISR_MAX < 32) || (_vec_ < 32)) { \
|
207 |
|
|
_reg_ = HAL_MCFxxxx_INTC0_BASE + HAL_MCFxxxx_INTCx_IMRL; \
|
208 |
|
|
HAL_READ_UINT32(_reg_, _bits_); \
|
209 |
|
|
_bits_ &= ~((0x01 << _vec_) | 0x01); \
|
210 |
|
|
HAL_WRITE_UINT32(_reg_, _bits_); \
|
211 |
|
|
} else if ((CYGNUM_HAL_ISR_MAX < 64) || (_vec_ < 64)) { \
|
212 |
|
|
_reg_ = HAL_MCFxxxx_INTC0_BASE + HAL_MCFxxxx_INTCx_IMRH; \
|
213 |
|
|
HAL_READ_UINT32(_reg_, _bits_); \
|
214 |
|
|
_bits_ &= ~(0x01 << (_vec_ - 32)); \
|
215 |
|
|
HAL_WRITE_UINT32(_reg_, _bits_); \
|
216 |
|
|
} else if ((CYGNUM_HAL_ISR_MAX < 96) || (_vec_ < 96)) { \
|
217 |
|
|
_reg_ = HAL_MCFxxxx_INTC1_BASE + HAL_MCFxxxx_INTCx_IMRL; \
|
218 |
|
|
HAL_READ_UINT32(_reg_, _bits_); \
|
219 |
|
|
_bits_ &= ~((0x01 << (_vec_ - 64)) | 0x01); \
|
220 |
|
|
HAL_WRITE_UINT32(_reg_, _bits_); \
|
221 |
|
|
} else { \
|
222 |
|
|
_reg_ = HAL_MCFxxxx_INTC1_BASE + HAL_MCFxxxx_INTCx_IMRH; \
|
223 |
|
|
HAL_READ_UINT32(_reg_, _bits_); \
|
224 |
|
|
_bits_ &= ~(0x01 << (_vec_ - 96)); \
|
225 |
|
|
HAL_WRITE_UINT32(_reg_, _bits_); \
|
226 |
|
|
} \
|
227 |
|
|
CYG_MACRO_END
|
228 |
|
|
# else
|
229 |
|
|
# error At most two interrupt controllers supported at present.
|
230 |
|
|
# endif // HAL_MCFxxxx_HAS_MCF5282_INTC == 1/2/many
|
231 |
|
|
# endif // HAL_MCFxxxx_INTCx_CIMR
|
232 |
|
|
# endif // !defined(HAL_INTERRUPT_UNMASK)
|
233 |
|
|
|
234 |
|
|
# ifndef HAL_INTERRUPT_SET_LEVEL
|
235 |
|
|
// Each interrupt vector has its own priority register. This consists
|
236 |
|
|
// of an M68K IPL level between 1 and 7, plus a priority within each
|
237 |
|
|
// level between 0 and 7, giving a total of 56 legal priorities. All
|
238 |
|
|
// active interrupt vectors within each interrupt vector must be given
|
239 |
|
|
// unique priorities, otherwise the system's behaviour is undefined
|
240 |
|
|
// (and can include the interrupt controller supplying the wrong
|
241 |
|
|
// interrupt vector in the IACK cycle).
|
242 |
|
|
# if (1 == HAL_MCFxxxx_HAS_MCF5282_INTC)
|
243 |
|
|
|
244 |
|
|
# define HAL_INTERRUPT_SET_LEVEL(_vector_, _prilevel_) \
|
245 |
|
|
CYG_MACRO_START \
|
246 |
|
|
cyg_uint32 _vec_ = (_vector_); \
|
247 |
|
|
cyg_uint32 _reg_; \
|
248 |
|
|
_reg_ = HAL_MCFxxxx_INTC0_BASE + HAL_MCFxxxx_INTCx_ICR00 + _vec_; \
|
249 |
|
|
HAL_WRITE_UINT8(_reg_, _prilevel_); \
|
250 |
|
|
CYG_MACRO_END
|
251 |
|
|
|
252 |
|
|
# elif (2 == HAL_MCFxxxx_HAS_MCF5282_INTC)
|
253 |
|
|
# define HAL_INTERRUPT_SET_LEVEL(_vector_, _prilevel_) \
|
254 |
|
|
CYG_MACRO_START \
|
255 |
|
|
cyg_uint32 _vec_ = (_vector_); \
|
256 |
|
|
cyg_uint32 _reg_; \
|
257 |
|
|
if( _vec_ < 64 ) \
|
258 |
|
|
_reg_ = HAL_MCFxxxx_INTC0_BASE + HAL_MCFxxxx_INTCx_ICR00 + _vec_; \
|
259 |
|
|
else \
|
260 |
|
|
_reg_ = HAL_MCFxxxx_INTC1_BASE + HAL_MCFxxxx_INTCx_ICR00 + _vec_ - 64;\
|
261 |
|
|
HAL_WRITE_UINT8(_reg_, _prilevel_); \
|
262 |
|
|
CYG_MACRO_END
|
263 |
|
|
|
264 |
|
|
# else
|
265 |
|
|
# error At most two interrupt controllers supported at present.
|
266 |
|
|
# endif // HAL_MCFxxxx_HAS_MCF5282_INTC == 1/2/many
|
267 |
|
|
# endif // !defined(HAL_INTERRUPT_SET_LEVEL)
|
268 |
|
|
|
269 |
|
|
#endif // HAL_MCFxxxx_HAS_MCF5282_INTC
|
270 |
|
|
|
271 |
|
|
#ifdef HAL_MCFxxxx_HAS_MCF5282_EPORT
|
272 |
|
|
// There is no acknowledgement support inside the interrupt
|
273 |
|
|
// controller. Instead each device has its own way of clearing the
|
274 |
|
|
// interrupt, so it is left to device drivers to clear interrupts at
|
275 |
|
|
// an appropriate time. The exception is for the edge port interrupts
|
276 |
|
|
// which can be handled easily here.
|
277 |
|
|
# ifndef HAL_INTERRUPT_ACKNOWLEDGE
|
278 |
|
|
# if (1 == HAL_MCFxxxx_HAS_MCF5282_EPORT)
|
279 |
|
|
|
280 |
|
|
# define HAL_INTERRUPT_ACKNOWLEDGE(_vector_) \
|
281 |
|
|
CYG_MACRO_START \
|
282 |
|
|
cyg_uint32 _vec_ = (_vector_); \
|
283 |
|
|
if ((_vec_ >= HAL_MCFxxxx_EPORT0_VECMIN) && (_vec_ <= HAL_MCFxxxx_EPORT0_VECMAX)) { \
|
284 |
|
|
HAL_WRITE_UINT8(HAL_MCFxxxx_EPORT0_BASE + HAL_MCFxxxx_EPORTx_EPFR, \
|
285 |
|
|
0x01 << (_vec_ - HAL_MCFxxxx_EPORT0_VECBASE)); \
|
286 |
|
|
} \
|
287 |
|
|
CYG_MACRO_END
|
288 |
|
|
|
289 |
|
|
# elif (2 == HAL_MCFxxxx_HAS_MCF5282_EPORT)
|
290 |
|
|
# define HAL_INTERRUPT_ACKNOWLEDGE(_vector_) \
|
291 |
|
|
CYG_MACRO_START \
|
292 |
|
|
cyg_uint32 _vec_ = (_vector_); \
|
293 |
|
|
if ((_vec_ >= HAL_MCFxxxx_EPORT0_VECMIN) && (_vec_ <= HAL_MCFxxxx_EPORT0_VECMAX)) { \
|
294 |
|
|
HAL_WRITE_UINT8(HAL_MCFxxxx_EPORT0_BASE + HAL_MCFxxxx_EPORTx_EPFR, \
|
295 |
|
|
0x01 << (_vec_ - HAL_MCFxxxx_EPORT0_VECBASE)); \
|
296 |
|
|
} else if ((_vec_ >= HAL_MCFxxxx_EPORT1_VECMIN) && (_vec_ <= HAL_MCFxxxx_EPORT1_VECMAX)) { \
|
297 |
|
|
HAL_WRITE_UINT8(HAL_MCFxxxx_EPORT1_BASE + HAL_MCFxxxx_EPORTx_EPFR, \
|
298 |
|
|
0x01 << (_vec_ - HAL_MCFxxxx_EPORT1_VECBASE)); \
|
299 |
|
|
} \
|
300 |
|
|
CYG_MACRO_END
|
301 |
|
|
|
302 |
|
|
|
303 |
|
|
# else
|
304 |
|
|
# error At most two edge port modules are supported at present.
|
305 |
|
|
# endif // HAL_MCFxxxx_HAS_MCF5282_EPORT == 1/2/many
|
306 |
|
|
# endif // !defined(HAL_INTERRUPT_ACKNOWLEDGE)
|
307 |
|
|
|
308 |
|
|
# ifndef HAL_INTERRUPT_CONFIGURE
|
309 |
|
|
|
310 |
|
|
// Interrupt level/edge control only applies to the edge port
|
311 |
|
|
// interrupts. It is possible to select level-low, rising edge, or
|
312 |
|
|
// falling edge. The hardware does not support level-high. It does
|
313 |
|
|
// support rising-or-falling edge, but the eCos API does not export
|
314 |
|
|
// that functionality. Instead code can manipulate the edge port
|
315 |
|
|
// registers directly.
|
316 |
|
|
//
|
317 |
|
|
// This macro also manipulates the edge port data direction and
|
318 |
|
|
// interrupt enable registers, to ensure that the edge port really
|
319 |
|
|
// will generate interrupts.
|
320 |
|
|
|
321 |
|
|
# if (1 == HAL_MCFxxxx_HAS_MCF5282_EPORT)
|
322 |
|
|
|
323 |
|
|
#define HAL_INTERRUPT_CONFIGURE( _vector_, _level_triggered_, _up_) \
|
324 |
|
|
CYG_MACRO_START \
|
325 |
|
|
cyg_uint32 _vec_ = (_vector_); \
|
326 |
|
|
if ((_vec_ >= HAL_MCFxxxx_EPORT0_VECMIN) && (_vec_ <= HAL_MCFxxxx_EPORT0_VECMAX)) { \
|
327 |
|
|
cyg_uint32 _base_; \
|
328 |
|
|
cyg_uint16 _reg16_; \
|
329 |
|
|
cyg_uint8 _reg8_; \
|
330 |
|
|
_base_ = HAL_MCFxxxx_EPORT0_BASE; \
|
331 |
|
|
_vec_ -= HAL_MCFxxxx_EPORT0_VECBASE; \
|
332 |
|
|
HAL_READ_UINT16(_base_ + HAL_MCFxxxx_EPORTx_EPPAR, _reg16_); \
|
333 |
|
|
_reg16_ &= ~(0x03 << (2 * _vec_)); \
|
334 |
|
|
if (_level_triggered_) { \
|
335 |
|
|
/* 00 is level-triggered so nothing to be done */ \
|
336 |
|
|
} else if (_up_) { \
|
337 |
|
|
_reg16_ |= (HAL_MCFxxxx_EPORTx_EPPAR_EPPAx_RISING << (2 * _vec_)); \
|
338 |
|
|
} else { \
|
339 |
|
|
_reg16_ |= (HAL_MCFxxxx_EPORTx_EPPAR_EPPAx_FALLING << (2 * _vec_)); \
|
340 |
|
|
} \
|
341 |
|
|
HAL_WRITE_UINT16(_base_ + HAL_MCFxxxx_EPORTx_EPPAR, _reg16_); \
|
342 |
|
|
HAL_READ_UINT8( _base_ + HAL_MCFxxxx_EPORTx_EPDDR, _reg8_); \
|
343 |
|
|
_reg8_ &= ~(0x01 << _vec_); \
|
344 |
|
|
HAL_WRITE_UINT8(_base_ + HAL_MCFxxxx_EPORTx_EPDDR, _reg8_); \
|
345 |
|
|
HAL_READ_UINT8( _base_ + HAL_MCFxxxx_EPORTx_EPIER, _reg8_); \
|
346 |
|
|
_reg8_ |= (0x01 << _vec_); \
|
347 |
|
|
HAL_WRITE_UINT8(_base_ + HAL_MCFxxxx_EPORTx_EPIER, _reg8_); \
|
348 |
|
|
} \
|
349 |
|
|
CYG_MACRO_END
|
350 |
|
|
|
351 |
|
|
# elif (2 == HAL_MCFxxxx_HAS_MCF5282_EPORT)
|
352 |
|
|
|
353 |
|
|
#define HAL_INTERRUPT_CONFIGURE( _vector_, _level_triggered_, _up_) \
|
354 |
|
|
CYG_MACRO_START \
|
355 |
|
|
cyg_uint32 _vec_ = (_vector_); \
|
356 |
|
|
if (((_vec_ >= HAL_MCFxxxx_EPORT0_VECMIN) && (_vec_ <= HAL_MCFxxxx_EPORT0_VECMAX)) || \
|
357 |
|
|
((_vec_ >= HAL_MCFxxxx_EPORT1_VECMIN) && (_vec_ <= HAL_MCFxxxx_EPORT1_VECMAX))) { \
|
358 |
|
|
cyg_uint32 _base_; \
|
359 |
|
|
cyg_uint16 _reg16_; \
|
360 |
|
|
cyg_uint8 _reg8_; \
|
361 |
|
|
if ((_vec_ >= HAL_MCFxxxx_EPORT0_VECMIN) && (_vec_ <= HAL_MCFxxxx_EPORT0_VECMAX)) { \
|
362 |
|
|
_base_ = HAL_MCFxxxx_EPORT0_BASE; \
|
363 |
|
|
_vec_ -= HAL_MCFxxxx_EPORT0_VECBASE; \
|
364 |
|
|
} else { \
|
365 |
|
|
_base_ = HAL_MCFxxxx_EPORT1_BASE; \
|
366 |
|
|
_vec_ -= HAL_MCFxxxx_EPORT1_VECBASE; \
|
367 |
|
|
} \
|
368 |
|
|
HAL_READ_UINT16(_base_ + HAL_MCFxxxx_EPORTx_EPPAR, _reg16_); \
|
369 |
|
|
_reg16_ &= ~(0x03 << (2 * _vec_)); \
|
370 |
|
|
if (_level_triggered_) { \
|
371 |
|
|
/* 00 is level-triggered so nothing to be done */ \
|
372 |
|
|
} else if (_up_) { \
|
373 |
|
|
_reg16_ |= (HAL_MCFxxxx_EPORTx_EPPAR_EPPAx_RISING << (2 * _vec_)); \
|
374 |
|
|
} else { \
|
375 |
|
|
_reg16_ |= (HAL_MCFxxxx_EPORTx_EPPAR_EPPAx_FALLING << (2 * _vec_)); \
|
376 |
|
|
} \
|
377 |
|
|
HAL_WRITE_UINT16(_base_ + HAL_MCFxxxx_EPORTx_EPPAR, _reg16_); \
|
378 |
|
|
HAL_READ_UINT8( _base_ + HAL_MCFxxxx_EPORTx_EPDDR, _reg8_); \
|
379 |
|
|
_reg8_ &= ~(0x01 << _vec_); \
|
380 |
|
|
HAL_WRITE_UINT8(_base_ + HAL_MCFxxxx_EPORTx_EPDDR, _reg8_); \
|
381 |
|
|
HAL_READ_UINT8( _base_ + HAL_MCFxxxx_EPORTx_EPIER, _reg8_); \
|
382 |
|
|
_reg8_ |= (0x01 << _vec_); \
|
383 |
|
|
HAL_WRITE_UINT8(_base_ + HAL_MCFxxxx_EPORTx_EPIER, _reg8_); \
|
384 |
|
|
} \
|
385 |
|
|
CYG_MACRO_END
|
386 |
|
|
|
387 |
|
|
# else
|
388 |
|
|
# endif // HAL_MCFxxxx_HAS_MCF5282_EPORT == 1/2/many
|
389 |
|
|
# endif // !defined(HAL_INTERRUPT_CONFIGURE)
|
390 |
|
|
|
391 |
|
|
#endif
|
392 |
|
|
|
393 |
|
|
#ifndef HAL_INTERRUPT_MASK
|
394 |
|
|
# error Processor or platform HAL_ should have provided HAL_INTERRUPT_MASK() macro
|
395 |
|
|
#endif
|
396 |
|
|
#ifndef HAL_INTERRUPT_UNMASK
|
397 |
|
|
# error Processor or platform HAL_ should have provided HAL_INTERRUPT_UNMASK() macro
|
398 |
|
|
#endif
|
399 |
|
|
#ifndef HAL_INTERRUPT_SET_LEVEL
|
400 |
|
|
# error Processor or platform HAL_ should have provided HAL_INTERRUPT_SET_LEVEL() macro
|
401 |
|
|
#endif
|
402 |
|
|
#ifndef HAL_INTERRUPT_ACKNOWLEDGE
|
403 |
|
|
# error Processor or platform HAL_ should have provided HAL_INTERRUPT_ACKNOWLEDGE() macro
|
404 |
|
|
#endif
|
405 |
|
|
#ifndef HAL_INTERRUPT_CONFIGURE
|
406 |
|
|
# error Processor or platform HAL_ should have provided HAL_INTERRUPT_CONFIGURE() macro
|
407 |
|
|
#endif
|
408 |
|
|
|
409 |
|
|
// ----------------------------------------------------------------------------
|
410 |
|
|
// On ColdFires with 5282-style programmable interrupt timers, typically
|
411 |
|
|
// one of those will be used for the system clock.
|
412 |
|
|
#ifdef HAL_MCFxxxx_HAS_MCF5282_PIT
|
413 |
|
|
|
414 |
|
|
# if (!defined(HAL_CLOCK_INIITALIZE) || !defined(HAL_CLOCK_RESET) || !defined(HAL_CLOCK_READ))
|
415 |
|
|
# if !defined(_HAL_MCFxxxx_CLOCK_PIT_BASE_)
|
416 |
|
|
# error The processor HAL should specify the programmable interrupt timer used for the system clock
|
417 |
|
|
# elif !defined(_HAL_MCFxxxx_CLOCK_PIT_PRE_)
|
418 |
|
|
# error The processor or platform HAL should specify the timer prescaler
|
419 |
|
|
# else
|
420 |
|
|
|
421 |
|
|
# if !defined(HAL_CLOCK_INITIALIZE)
|
422 |
|
|
# define HAL_CLOCK_INITIALIZE(_period_) \
|
423 |
|
|
CYG_MACRO_START \
|
424 |
|
|
cyg_uint32 _base_ = _HAL_MCFxxxx_CLOCK_PIT_BASE_; \
|
425 |
|
|
HAL_WRITE_UINT16(_base_ + HAL_MCFxxxx_PITx_PCSR, \
|
426 |
|
|
_HAL_MCFxxxx_CLOCK_PIT_PRE_ | \
|
427 |
|
|
HAL_MCFxxxx_PITx_PCSR_OVW | HAL_MCFxxxx_PITx_PCSR_PIE | \
|
428 |
|
|
HAL_MCFxxxx_PITx_PCSR_PIF | HAL_MCFxxxx_PITx_PCSR_RLD); \
|
429 |
|
|
HAL_WRITE_UINT16(_base_ + HAL_MCFxxxx_PITx_PMR, _period_); \
|
430 |
|
|
HAL_WRITE_UINT16(_base_ + HAL_MCFxxxx_PITx_PCSR, \
|
431 |
|
|
_HAL_MCFxxxx_CLOCK_PIT_PRE_ | \
|
432 |
|
|
HAL_MCFxxxx_PITx_PCSR_OVW | HAL_MCFxxxx_PITx_PCSR_PIE | \
|
433 |
|
|
HAL_MCFxxxx_PITx_PCSR_PIF | HAL_MCFxxxx_PITx_PCSR_RLD | \
|
434 |
|
|
HAL_MCFxxxx_PITx_PCSR_EN); \
|
435 |
|
|
CYG_MACRO_END
|
436 |
|
|
# endif
|
437 |
|
|
|
438 |
|
|
# if !defined(HAL_CLOCK_RESET)
|
439 |
|
|
// The clock resets automatically but the interrupt must be cleared. This could
|
440 |
|
|
// be done by rewriting the period, but that introduces a risk of drift. A
|
441 |
|
|
// better approach is to write the PIF bit in the control register, which means
|
442 |
|
|
// writing all the other bits as well.
|
443 |
|
|
//
|
444 |
|
|
// Note: this could interfere with power management since the doze/halted
|
445 |
|
|
// bits may get cleared inadvertently.
|
446 |
|
|
# define HAL_CLOCK_RESET(_vector_, _period_) \
|
447 |
|
|
CYG_MACRO_START \
|
448 |
|
|
cyg_uint32 _base_ = _HAL_MCFxxxx_CLOCK_PIT_BASE_; \
|
449 |
|
|
HAL_WRITE_UINT16(_base_ + HAL_MCFxxxx_PITx_PCSR, \
|
450 |
|
|
_HAL_MCFxxxx_CLOCK_PIT_PRE_ | \
|
451 |
|
|
HAL_MCFxxxx_PITx_PCSR_OVW | HAL_MCFxxxx_PITx_PCSR_PIE | \
|
452 |
|
|
HAL_MCFxxxx_PITx_PCSR_PIF | HAL_MCFxxxx_PITx_PCSR_RLD | \
|
453 |
|
|
HAL_MCFxxxx_PITx_PCSR_EN); \
|
454 |
|
|
CYG_MACRO_END
|
455 |
|
|
# endif
|
456 |
|
|
|
457 |
|
|
# if !defined(HAL_CLOCK_READ)
|
458 |
|
|
# define HAL_CLOCK_READ(_pvalue_) \
|
459 |
|
|
CYG_MACRO_START \
|
460 |
|
|
cyg_uint32 _base_ = _HAL_MCFxxxx_CLOCK_PIT_BASE_; \
|
461 |
|
|
cyg_uint16 _period_, _counter_; \
|
462 |
|
|
HAL_READ_UINT16(_base_ + HAL_MCFxxxx_PITx_PMR, _period_); \
|
463 |
|
|
HAL_READ_UINT16(_base_ + HAL_MCFxxxx_PITx_PCNTR, _counter_); \
|
464 |
|
|
*(_pvalue_) = _period_ - _counter_; \
|
465 |
|
|
CYG_MACRO_END
|
466 |
|
|
# endif
|
467 |
|
|
# endif
|
468 |
|
|
# endif
|
469 |
|
|
#endif
|
470 |
|
|
|
471 |
|
|
#ifndef HAL_CLOCK_INITIALIZE
|
472 |
|
|
# error Processor or platform HAL should have provided HAL_CLOCK_INITIALIZE() macro
|
473 |
|
|
#endif
|
474 |
|
|
#ifndef HAL_CLOCK_RESET
|
475 |
|
|
# error Processor or platform HAL should have provided HAL_CLOCK_RESET() macro
|
476 |
|
|
#endif
|
477 |
|
|
#ifndef HAL_CLOCK_READ
|
478 |
|
|
# error Processor or platform HAL should have provided HAL_CLOCK_READ() macro
|
479 |
|
|
#endif
|
480 |
|
|
|
481 |
|
|
#ifndef HAL_CLOCK_LATENCY
|
482 |
|
|
# define HAL_CLOCK_LATENCY(_pvalue_) HAL_CLOCK_READ(_pvalue_)
|
483 |
|
|
#endif
|
484 |
|
|
|
485 |
|
|
// ----------------------------------------------------------------------------
|
486 |
|
|
// Where possible use a 5282-compatible reset controller to generate a
|
487 |
|
|
// software reset. The architectural HAL has a fall-back
|
488 |
|
|
// implementation which goes through the reset exception vector slot.
|
489 |
|
|
#if !defined(HAL_PLATFORM_RESET) && defined(HAL_MCFxxxx_HAS_MCF5282_RST)
|
490 |
|
|
# define HAL_PLATFORM_RESET() \
|
491 |
|
|
CYG_MACRO_START \
|
492 |
|
|
HAL_WRITE_UINT8(HAL_MCFxxxx_RST_BASE + HAL_MCFxxxx_RST_RCR, \
|
493 |
|
|
HAL_MCFxxxx_RST_RCR_SOFTRST); \
|
494 |
|
|
CYG_MACRO_END
|
495 |
|
|
# endif
|
496 |
|
|
|
497 |
|
|
//---------------------------------------------------------------------------
|
498 |
|
|
#endif // ifndef CYGONCE_HAL_VAR_INTR_H
|