0
|
1 |
/*
|
|
2 |
This file is part of CanFestival, a library implementing CanOpen Stack.
|
|
3 |
|
|
4 |
Author: Christian Fortin (canfestival@canopencanada.ca)
|
|
5 |
|
|
6 |
See COPYING file for copyrights details.
|
|
7 |
|
|
8 |
This library is free software; you can redistribute it and/or
|
|
9 |
modify it under the terms of the GNU Lesser General Public
|
|
10 |
License as published by the Free Software Foundation; either
|
|
11 |
version 2.1 of the License, or (at your option) any later version.
|
|
12 |
|
|
13 |
This library is distributed in the hope that it will be useful,
|
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
16 |
Lesser General Public License for more details.
|
|
17 |
|
|
18 |
You should have received a copy of the GNU Lesser General Public
|
|
19 |
License along with this library; if not, write to the Free Software
|
|
20 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
21 |
*/
|
|
22 |
|
|
23 |
/**
|
|
24 |
* Définitions pour le LPC2138.
|
|
25 |
*/
|
|
26 |
|
|
27 |
#if !defined(_LPC2138_DEF_H_)
|
|
28 |
#define _LPC2138_DEF_H_
|
|
29 |
|
|
30 |
#include <stdio.h>
|
|
31 |
|
|
32 |
// #include "types.h"
|
|
33 |
|
|
34 |
#define BITMASK_0 0x00000000
|
|
35 |
#define BITMASK_1 0x00000001
|
|
36 |
#define BITMASK_2 0x00000003
|
|
37 |
#define BITMASK_4 0x0000000F
|
|
38 |
#define BITMASK_8 0x000000FF
|
|
39 |
#define BITMASK_16 0x0000FFFF
|
|
40 |
#define BITMASK_32 0xFFFFFFFF
|
|
41 |
|
|
42 |
typedef volatile unsigned char REG8;
|
|
43 |
typedef volatile unsigned char *REG8_ADDR;
|
|
44 |
typedef volatile unsigned short REG16;
|
|
45 |
typedef volatile unsigned short *REG16_ADDR;
|
|
46 |
typedef volatile unsigned int REG32;
|
|
47 |
typedef volatile unsigned int *REG32_ADDR;
|
|
48 |
|
|
49 |
|
|
50 |
#define SET_EQ_SET =
|
|
51 |
#define SET_EQ_CLR =
|
|
52 |
|
|
53 |
#define P0_IOPIN_ADDR 0xE0028000
|
|
54 |
#define P0_IOSET_ADDR 0xE0028004
|
|
55 |
#define P0_IODIR_ADDR 0xE0028008
|
|
56 |
#define P0_IOCLR_ADDR 0xE002800C
|
|
57 |
#define P0_PINSEL0_ADDR 0xE002C000
|
|
58 |
#define P0_PINSEL1_ADDR 0xE002C004
|
|
59 |
|
|
60 |
#define P1_IOPIN_ADDR 0xE0028010
|
|
61 |
#define P1_IOSET_ADDR 0xE0028014
|
|
62 |
#define P1_IODIR_ADDR 0xE0028018
|
|
63 |
#define P1_IOCLR_ADDR 0xE002801C
|
|
64 |
#define P1_PINSEL2_ADDR 0xE002C014
|
|
65 |
|
|
66 |
#define DACR_ADDR 0xE006C000
|
|
67 |
|
|
68 |
/* Vectored Interrupt Controller (VIC) */
|
|
69 |
#define VICVectAddr_ADDR 0xFFFFF030
|
|
70 |
#define VICVectAddr0_ADDR 0xFFFFF100
|
|
71 |
#define VICVectCntl0_ADDR 0xFFFFF200
|
|
72 |
#define VICIntEnable_ADDR 0xFFFFF010
|
|
73 |
|
|
74 |
/* External Interrupts */
|
|
75 |
#define EXTINT_ADDR 0xE01FC140
|
|
76 |
#define INTWAKE_ADDR 0xE01FC144
|
|
77 |
#define EXTMODE_ADDR 0xE01FC148
|
|
78 |
#define EXTPOLAR_ADDR 0xE01FC14C
|
|
79 |
|
|
80 |
#ifdef TEST
|
|
81 |
#include "test_stubs.h"
|
|
82 |
#endif
|
|
83 |
|
|
84 |
/* Vectored Interrupt Controller (VIC) */
|
|
85 |
#define VICIRQStatus (*((REG32_ADDR) 0xFFFFF000))
|
|
86 |
#define VICFIQStatus (*((REG32_ADDR) 0xFFFFF004))
|
|
87 |
#define VICRawIntr (*((REG32_ADDR) 0xFFFFF008))
|
|
88 |
#define VICIntSelect (*((REG32_ADDR) 0xFFFFF00C))
|
|
89 |
#define VICIntEnable (*((REG32_ADDR) 0xFFFFF010))
|
|
90 |
#define VICIntEnClr (*((REG32_ADDR) 0xFFFFF014))
|
|
91 |
#define VICSoftInt (*((REG32_ADDR) 0xFFFFF018))
|
|
92 |
#define VICSoftIntClr (*((REG32_ADDR) 0xFFFFF01C))
|
|
93 |
#define VICProtection (*((REG32_ADDR) 0xFFFFF020))
|
|
94 |
#define VICVectAddr (*((REG32_ADDR) 0xFFFFF030))
|
|
95 |
#define VICDefVectAddr (*((REG32_ADDR) 0xFFFFF034))
|
|
96 |
#define VICVectAddr0 (*((REG32_ADDR) 0xFFFFF100))
|
|
97 |
#define VICVectAddr1 (*((REG32_ADDR) 0xFFFFF104))
|
|
98 |
#define VICVectAddr2 (*((REG32_ADDR) 0xFFFFF108))
|
|
99 |
#define VICVectAddr3 (*((REG32_ADDR) 0xFFFFF10C))
|
|
100 |
#define VICVectAddr4 (*((REG32_ADDR) 0xFFFFF110))
|
|
101 |
#define VICVectAddr5 (*((REG32_ADDR) 0xFFFFF114))
|
|
102 |
#define VICVectAddr6 (*((REG32_ADDR) 0xFFFFF118))
|
|
103 |
#define VICVectAddr7 (*((REG32_ADDR) 0xFFFFF11C))
|
|
104 |
#define VICVectAddr8 (*((REG32_ADDR) 0xFFFFF120))
|
|
105 |
#define VICVectAddr9 (*((REG32_ADDR) 0xFFFFF124))
|
|
106 |
#define VICVectAddr10 (*((REG32_ADDR) 0xFFFFF128))
|
|
107 |
#define VICVectAddr11 (*((REG32_ADDR) 0xFFFFF12C))
|
|
108 |
#define VICVectAddr12 (*((REG32_ADDR) 0xFFFFF130))
|
|
109 |
#define VICVectAddr13 (*((REG32_ADDR) 0xFFFFF134))
|
|
110 |
#define VICVectAddr14 (*((REG32_ADDR) 0xFFFFF138))
|
|
111 |
#define VICVectAddr15 (*((REG32_ADDR) 0xFFFFF13C))
|
|
112 |
#define VICVectCntl0 (*((REG32_ADDR) 0xFFFFF200))
|
|
113 |
#define VICVectCntl1 (*((REG32_ADDR) 0xFFFFF204))
|
|
114 |
#define VICVectCntl2 (*((REG32_ADDR) 0xFFFFF208))
|
|
115 |
#define VICVectCntl3 (*((REG32_ADDR) 0xFFFFF20C))
|
|
116 |
#define VICVectCntl4 (*((REG32_ADDR) 0xFFFFF210))
|
|
117 |
#define VICVectCntl5 (*((REG32_ADDR) 0xFFFFF214))
|
|
118 |
#define VICVectCntl6 (*((REG32_ADDR) 0xFFFFF218))
|
|
119 |
#define VICVectCntl7 (*((REG32_ADDR) 0xFFFFF21C))
|
|
120 |
#define VICVectCntl8 (*((REG32_ADDR) 0xFFFFF220))
|
|
121 |
#define VICVectCntl9 (*((REG32_ADDR) 0xFFFFF224))
|
|
122 |
#define VICVectCntl10 (*((REG32_ADDR) 0xFFFFF228))
|
|
123 |
#define VICVectCntl11 (*((REG32_ADDR) 0xFFFFF22C))
|
|
124 |
#define VICVectCntl12 (*((REG32_ADDR) 0xFFFFF230))
|
|
125 |
#define VICVectCntl13 (*((REG32_ADDR) 0xFFFFF234))
|
|
126 |
#define VICVectCntl14 (*((REG32_ADDR) 0xFFFFF238))
|
|
127 |
#define VICVectCntl15 (*((REG32_ADDR) 0xFFFFF23C))
|
|
128 |
|
|
129 |
#define P0_IOPIN (*((REG32_ADDR) P0_IOPIN_ADDR))
|
|
130 |
#define P0_IOSET (*((REG32_ADDR) P0_IOSET_ADDR))
|
|
131 |
#define P0_IODIR (*((REG32_ADDR) P0_IODIR_ADDR))
|
|
132 |
#define P0_IOCLR (*((REG32_ADDR) P0_IOCLR_ADDR))
|
|
133 |
#define P0_PINSEL0 (*((REG32_ADDR) P0_PINSEL0_ADDR))
|
|
134 |
#define P0_PINSEL1 (*((REG32_ADDR) P0_PINSEL1_ADDR))
|
|
135 |
|
|
136 |
#define P1_IOPIN (*((REG32_ADDR) P1_IOPIN_ADDR))
|
|
137 |
#define P1_IOSET (*((REG32_ADDR) P1_IOSET_ADDR))
|
|
138 |
#define P1_IODIR (*((REG32_ADDR) P1_IODIR_ADDR))
|
|
139 |
#define P1_IOCLR (*((REG32_ADDR) P1_IOCLR_ADDR))
|
|
140 |
#define P1_PINSEL2 (*((REG32_ADDR) P1_PINSEL2_ADDR))
|
|
141 |
|
|
142 |
#define DACR (*((REG32_ADDR) DACR_ADDR))
|
|
143 |
|
|
144 |
/* External Interrupts */
|
|
145 |
#define EXTINT (*((REG32_ADDR) EXTINT_ADDR))
|
|
146 |
#define INTWAKE (*((REG32_ADDR) INTWAKE_ADDR))
|
|
147 |
#define EXTMODE (*((REG32_ADDR) EXTMODE_ADDR))
|
|
148 |
#define EXTPOLAR (*((REG32_ADDR) EXTPOLAR_ADDR))
|
|
149 |
|
|
150 |
|
|
151 |
/* Timer 0 */
|
|
152 |
#define T0IR (*((REG32_ADDR) 0xE0004000))
|
|
153 |
#define T0TCR (*((REG32_ADDR) 0xE0004004))
|
|
154 |
#define T0TC (*((REG32_ADDR) 0xE0004008))
|
|
155 |
#define T0PR (*((REG32_ADDR) 0xE000400C))
|
|
156 |
#define T0PC (*((REG32_ADDR) 0xE0004010))
|
|
157 |
#define T0MCR (*((REG32_ADDR) 0xE0004014))
|
|
158 |
#define T0MR0 (*((REG32_ADDR) 0xE0004018))
|
|
159 |
#define T0MR1 (*((REG32_ADDR) 0xE000401C))
|
|
160 |
#define T0MR2 (*((REG32_ADDR) 0xE0004020))
|
|
161 |
#define T0MR3 (*((REG32_ADDR) 0xE0004024))
|
|
162 |
#define T0CCR (*((REG32_ADDR) 0xE0004028))
|
|
163 |
#define T0CR0 (*((REG32_ADDR) 0xE000402C))
|
|
164 |
#define T0CR1 (*((REG32_ADDR) 0xE0004030))
|
|
165 |
#define T0CR2 (*((REG32_ADDR) 0xE0004034))
|
|
166 |
#define T0CR3 (*((REG32_ADDR) 0xE0004038))
|
|
167 |
#define T0EMR (*((REG32_ADDR) 0xE000403C))
|
|
168 |
#define T0CTCR (*((REG32_ADDR) 0xE0004070))
|
|
169 |
|
|
170 |
/* Timer 1 */
|
|
171 |
#define T1IR (*((REG32_ADDR) 0xE0008000))
|
|
172 |
#define T1TCR (*((REG32_ADDR) 0xE0008004))
|
|
173 |
#define T1TC (*((REG32_ADDR) 0xE0008008))
|
|
174 |
#define T1PR (*((REG32_ADDR) 0xE000800C))
|
|
175 |
#define T1PC (*((REG32_ADDR) 0xE0008010))
|
|
176 |
#define T1MCR (*((REG32_ADDR) 0xE0008014))
|
|
177 |
#define T1MR0 (*((REG32_ADDR) 0xE0008018))
|
|
178 |
#define T1MR1 (*((REG32_ADDR) 0xE000801C))
|
|
179 |
#define T1MR2 (*((REG32_ADDR) 0xE0008020))
|
|
180 |
#define T1MR3 (*((REG32_ADDR) 0xE0008024))
|
|
181 |
#define T1CCR (*((REG32_ADDR) 0xE0008028))
|
|
182 |
#define T1CR0 (*((REG32_ADDR) 0xE000802C))
|
|
183 |
#define T1CR1 (*((REG32_ADDR) 0xE0008030))
|
|
184 |
#define T1CR2 (*((REG32_ADDR) 0xE0008034))
|
|
185 |
#define T1CR3 (*((REG32_ADDR) 0xE0008038))
|
|
186 |
#define T1EMR (*((REG32_ADDR) 0xE000803C))
|
|
187 |
#define T1CTCR (*((REG32_ADDR) 0xE0008070))
|
|
188 |
|
|
189 |
/* Real Time Clock */
|
|
190 |
#define ILR (*((REG8_ADDR) 0xE0024000))
|
|
191 |
#define CTC (*((REG16_ADDR) 0xE0024004))
|
|
192 |
#define CCR (*((REG8_ADDR) 0xE0024008))
|
|
193 |
#define CIIR (*((REG8_ADDR) 0xE002400C))
|
|
194 |
#define AMR (*((REG8_ADDR) 0xE0024010))
|
|
195 |
#define CTIME0 (*((REG32_ADDR) 0xE0024014))
|
|
196 |
#define CTIME1 (*((REG32_ADDR) 0xE0024018))
|
|
197 |
#define CTIME2 (*((REG32_ADDR) 0xE002401C))
|
|
198 |
#define SEC (*((REG8_ADDR) 0xE0024020))
|
|
199 |
#define MIN (*((REG8_ADDR) 0xE0024024))
|
|
200 |
#define HOUR (*((REG8_ADDR) 0xE0024028))
|
|
201 |
#define DOM (*((REG8_ADDR) 0xE002402C))
|
|
202 |
#define DOW (*((REG8_ADDR) 0xE0024030))
|
|
203 |
#define DOY (*((REG16_ADDR) 0xE0024034))
|
|
204 |
#define MONTH (*((REG8_ADDR) 0xE0024038))
|
|
205 |
#define YEAR (*((REG16_ADDR) 0xE002403C))
|
|
206 |
#define ALSEC (*((REG8_ADDR) 0xE0024060))
|
|
207 |
#define ALMIN (*((REG8_ADDR) 0xE0024064))
|
|
208 |
#define ALHOUR (*((REG8_ADDR) 0xE0024068))
|
|
209 |
#define ALDOM (*((REG8_ADDR) 0xE002406C))
|
|
210 |
#define ALDOW (*((REG8_ADDR) 0xE0024070))
|
|
211 |
#define ALDOY (*((REG16_ADDR) 0xE0024074))
|
|
212 |
#define ALMON (*((REG8_ADDR) 0xE0024078))
|
|
213 |
#define ALYEAR (*((REG16_ADDR) 0xE002407C))
|
|
214 |
#define PREINT (*((REG16_ADDR) 0xE0024080))
|
|
215 |
#define PREFRAC (*((REG16_ADDR) 0xE0024084))
|
|
216 |
|
|
217 |
/* SPI Registers */
|
|
218 |
#define S0SPCR (*((REG32_ADDR) 0xE0020000))
|
|
219 |
#define S0SPSR (*((REG32_ADDR) 0xE0020004))
|
|
220 |
#define S0SPDR (*((REG32_ADDR) 0xE0020008))
|
|
221 |
#define S0SPCCR (*((REG32_ADDR) 0xE002000C))
|
|
222 |
#define S0SPINT (*((REG32_ADDR) 0xE002001C))
|
|
223 |
|
|
224 |
/* SSP Registers */
|
|
225 |
#define SSPCR0 (*((REG32_ADDR) 0xE0068000))
|
|
226 |
#define SSPCR1 (*((REG32_ADDR) 0xE0068004))
|
|
227 |
#define SSPDR (*((REG32_ADDR) 0xE0068008))
|
|
228 |
#define SSPSR (*((REG32_ADDR) 0xE006800C))
|
|
229 |
#define SSPCPSR (*((REG32_ADDR) 0xE0068010))
|
|
230 |
#define SSPIMSC (*((REG32_ADDR) 0xE0068014))
|
|
231 |
#define SSPRIS (*((REG32_ADDR) 0xE0068018))
|
|
232 |
#define SSPMIS (*((REG32_ADDR) 0xE006801C))
|
|
233 |
#define SSPICR (*((REG32_ADDR) 0xE0068020))
|
|
234 |
|
|
235 |
|
|
236 |
typedef enum {
|
|
237 |
LPC2138_MODE_INPUT = 0,
|
|
238 |
LPC2138_MODE_OUTPUT = 1
|
|
239 |
} LPC2138_MODE;
|
|
240 |
|
|
241 |
typedef enum {
|
|
242 |
P0 = 0,
|
|
243 |
P1 = 1
|
|
244 |
} LPC2138_PORT;
|
|
245 |
|
|
246 |
/* === Fonctions "#define" génériques ======================================= */
|
|
247 |
|
|
248 |
#define _cat(a, b) a##b
|
|
249 |
#define _CAT(a, b) _cat(a, b)
|
|
250 |
|
|
251 |
#define _PIN(pin) LPC2138_##pin
|
|
252 |
#define _PORT(pin) LPC2138_##pin##_PORT
|
|
253 |
#define _SIZE(pin) LPC2138_##pin##_SIZE
|
|
254 |
|
|
255 |
/* ((P[0|1]_IOPIN >> pin) & BITMASK_[0-32]) */
|
|
256 |
#define lpc2138_get(pin) \
|
|
257 |
((_CAT(_PORT(pin), _IOPIN) >> _PIN(pin)) & _CAT(BITMASK_, _SIZE(pin)))
|
|
258 |
|
|
259 |
#define lpc2138_set(pin, i) \
|
|
260 |
{ if (_SIZE(pin) == 1) { lpc2138_set_bit(pin, i); } \
|
|
261 |
else { lpc2138_set_all(pin, i); } }
|
|
262 |
|
|
263 |
#define lpc2138_set_bit(pin, i) \
|
|
264 |
{ if ((i) == 1) { _CAT(_PORT(pin), _IOSET) SET_EQ_SET (1 << _PIN(pin)); } \
|
|
265 |
else { _CAT(_PORT(pin), _IOCLR) SET_EQ_CLR (1 << _PIN(pin)); } }
|
|
266 |
|
|
267 |
#define lpc2138_set_all(pin, i) \
|
|
268 |
(_CAT(_PORT(pin), _IOPIN) = \
|
|
269 |
(_CAT(_PORT(pin), _IOPIN) & \
|
|
270 |
~(_CAT(BITMASK_, _SIZE(pin)) << _PIN(pin))) | ((i) << _PIN(pin)))
|
|
271 |
|
|
272 |
/* Identique à lpc2138_set(p, f, nbits, i) sans effet secondaire (plus lent). */
|
|
273 |
#define lpc2138_set_SAFE_(pin, i) \
|
|
274 |
((_SIZE(pin) == 1) && lpc2138_set_bit_SAFE_(pin, (i)) || \
|
|
275 |
lpc2138_set_all(pin, (i)))
|
|
276 |
|
|
277 |
/* Identique à lpc2138_set_bit(p, f, i) sans effet secondaire (plus lent). */
|
|
278 |
#define lpc2138_set_bit_SAFE_(pin, i) \
|
|
279 |
((i == 1) && (_CAT(_PORT(pin), _IOSET) SET_EQ_SET (1 << _PIN(pin))) || \
|
|
280 |
(_CAT(_PORT(pin), _IOCLR) SET_EQ_CLR (1 << _PIN(pin))))
|
|
281 |
|
|
282 |
#define lpc2138_set_mode(pin, mode) \
|
|
283 |
(_CAT(_PORT(pin), _IODIR) = (mode == LPC2138_MODE_OUTPUT) ? \
|
|
284 |
(_CAT(_PORT(pin), _IODIR)|(_CAT(BITMASK_, _SIZE(pin)) << _PIN(pin))) : \
|
|
285 |
(_CAT(_PORT(pin), _IODIR) & ~(_CAT(BITMASK_, _SIZE(pin)) << _PIN(pin))))
|
|
286 |
|
|
287 |
#define lpc2138_set_pinsel(pin, func) \
|
|
288 |
lpc2138_pinsel_set(_PIN(pin), _PORT(pin), _SIZE(pin), func)
|
|
289 |
|
|
290 |
/* === Fonctions pinout "#define" par défaut ================================ */
|
|
291 |
|
|
292 |
#ifndef lpc2138_uart0_tx_set_pinsel
|
|
293 |
#define lpc2138_uart0_tx_set_pinsel(func) lpc2138_set_pinsel(uart0_tx, func)
|
|
294 |
#endif
|
|
295 |
|
|
296 |
#ifndef lpc2138_uart0_rx_set_pinsel
|
|
297 |
#define lpc2138_uart0_rx_set_pinsel(func) lpc2138_set_pinsel(uart0_rx, func)
|
|
298 |
#endif
|
|
299 |
|
|
300 |
#ifndef lpc2138_cs_s1d13706_get
|
|
301 |
#define lpc2138_cs_s1d13706_get() lpc2138_get (cs_s1d13706)
|
|
302 |
#endif
|
|
303 |
|
|
304 |
#ifndef lpc2138_cs_s1d13706_set
|
|
305 |
#define lpc2138_cs_s1d13706_set(i) lpc2138_set (cs_s1d13706, i)
|
|
306 |
#endif
|
|
307 |
|
|
308 |
#ifndef lpc2138_cs_s1d13706_set_mode
|
|
309 |
#define lpc2138_cs_s1d13706_set_mode(mode) lpc2138_set_mode (cs_s1d13706, mode)
|
|
310 |
#endif
|
|
311 |
|
|
312 |
#ifndef lpc2138_cs_s1d13706_set_pinsel
|
|
313 |
#define lpc2138_cs_s1d13706_set_pinsel(func) lpc2138_set_pinsel(cs_s1d13706, func)
|
|
314 |
#endif
|
|
315 |
|
|
316 |
#ifndef lpc2138_cs_sja1000_get
|
|
317 |
#define lpc2138_cs_sja1000_get() lpc2138_get (cs_sja1000)
|
|
318 |
#endif
|
|
319 |
|
|
320 |
#ifndef lpc2138_cs_sja1000_set
|
|
321 |
#define lpc2138_cs_sja1000_set(i) lpc2138_set (cs_sja1000, i)
|
|
322 |
#endif
|
|
323 |
|
|
324 |
#ifndef lpc2138_cs_sja1000_set_mode
|
|
325 |
#define lpc2138_cs_sja1000_set_mode(mode) lpc2138_set_mode (cs_sja1000, mode)
|
|
326 |
#endif
|
|
327 |
|
|
328 |
#ifndef lpc2138_cs_sja1000_set_pinsel
|
|
329 |
#define lpc2138_cs_sja1000_set_pinsel(func) lpc2138_set_pinsel(cs_sja1000, func)
|
|
330 |
#endif
|
|
331 |
|
|
332 |
#ifndef lpc2138_wait_get
|
|
333 |
#define lpc2138_wait_get() lpc2138_get (wait)
|
|
334 |
#endif
|
|
335 |
|
|
336 |
#ifndef lpc2138_wait_set
|
|
337 |
#define lpc2138_wait_set(i) lpc2138_set (wait, i)
|
|
338 |
#endif
|
|
339 |
|
|
340 |
#ifndef lpc2138_wait_set_mode
|
|
341 |
#define lpc2138_wait_set_mode(mode) lpc2138_set_mode (wait, mode)
|
|
342 |
#endif
|
|
343 |
|
|
344 |
#ifndef lpc2138_wait_set_pinsel
|
|
345 |
#define lpc2138_wait_set_pinsel(func) lpc2138_set_pinsel(wait, func)
|
|
346 |
#endif
|
|
347 |
|
|
348 |
#ifndef lpc2138_bhe_get
|
|
349 |
#define lpc2138_bhe_get() lpc2138_get (bhe)
|
|
350 |
#endif
|
|
351 |
|
|
352 |
#ifndef lpc2138_bhe_set
|
|
353 |
#define lpc2138_bhe_set(i) lpc2138_set (bhe, i)
|
|
354 |
#endif
|
|
355 |
|
|
356 |
#ifndef lpc2138_bhe_set_mode
|
|
357 |
#define lpc2138_bhe_set_mode(mode) lpc2138_set_mode (bhe, mode)
|
|
358 |
#endif
|
|
359 |
|
|
360 |
#ifndef lpc2138_bhe_set_pinsel
|
|
361 |
#define lpc2138_bhe_set_pinsel(func) lpc2138_set_pinsel(bhe, func)
|
|
362 |
#endif
|
|
363 |
|
|
364 |
#ifndef lpc2138_interrupt_sja1000_get
|
|
365 |
#define lpc2138_interrupt_sja1000_get() lpc2138_get (interrupt_sja1000)
|
|
366 |
#endif
|
|
367 |
|
|
368 |
#ifndef lpc2138_interrupt_sja1000_set
|
|
369 |
#define lpc2138_interrupt_sja1000_set(i) lpc2138_set (interrupt_sja1000, i)
|
|
370 |
#endif
|
|
371 |
|
|
372 |
#ifndef lpc2138_interrupt_sja1000_set_mode
|
|
373 |
#define lpc2138_interrupt_sja1000_set_mode(mode) lpc2138_set_mode (interrupt_sja1000, mode)
|
|
374 |
#endif
|
|
375 |
|
|
376 |
#ifndef lpc2138_interrupt_sja1000_set_pinsel
|
|
377 |
#define lpc2138_interrupt_sja1000_set_pinsel(func) lpc2138_set_pinsel(interrupt_sja1000, func)
|
|
378 |
#endif
|
|
379 |
|
|
380 |
#ifndef lpc2138_redgreenled_get
|
|
381 |
#define lpc2138_redgreenled_get() lpc2138_get (redgreenled)
|
|
382 |
#endif
|
|
383 |
|
|
384 |
#ifndef lpc2138_redgreenled_set
|
|
385 |
#define lpc2138_redgreenled_set(i) lpc2138_set (redgreenled, i)
|
|
386 |
#endif
|
|
387 |
|
|
388 |
#ifndef lpc2138_redgreenled_set_mode
|
|
389 |
#define lpc2138_redgreenled_set_mode(mode) lpc2138_set_mode (redgreenled, mode)
|
|
390 |
#endif
|
|
391 |
|
|
392 |
#ifndef lpc2138_redgreenled_set_pinsel
|
|
393 |
#define lpc2138_redgreenled_set_pinsel(func) lpc2138_set_pinsel(redgreenled, func)
|
|
394 |
#endif
|
|
395 |
|
|
396 |
#ifndef lpc2138_dac0_set
|
|
397 |
#define lpc2138_dac0_set() lpc2138_set (dac0, i)
|
|
398 |
#endif
|
|
399 |
|
|
400 |
#ifndef lpc2138_dac0_set_value
|
|
401 |
#define lpc2138_dac0_set_value(i) DACR = ((1 << 16) | ((i & 0x3FF) << 6))
|
|
402 |
#endif
|
|
403 |
|
|
404 |
#ifndef lpc2138_dac0_set_pinsel
|
|
405 |
#define lpc2138_dac0_set_pinsel(func) lpc2138_set_pinsel(dac0, func)
|
|
406 |
#endif
|
|
407 |
|
|
408 |
#ifndef lpc2138_spi0_set
|
|
409 |
#define lpc2138_spi0_set() lpc2138_set (spi0, i)
|
|
410 |
#endif
|
|
411 |
|
|
412 |
#ifndef lpc2138_spi0_set_value
|
|
413 |
#define lpc2138_spi0_set_value(i) SSPDR = i
|
|
414 |
#endif
|
|
415 |
|
|
416 |
#ifndef lpc2138_spi0_set_pinsel
|
|
417 |
#define lpc2138_spi0_set_pinsel(func) lpc2138_set_pinsel(spi0, func)
|
|
418 |
#endif
|
|
419 |
|
|
420 |
#ifndef lpc2138_ale_get
|
|
421 |
#define lpc2138_ale_get() lpc2138_get (ale)
|
|
422 |
#endif
|
|
423 |
|
|
424 |
#ifndef lpc2138_ale_set
|
|
425 |
#define lpc2138_ale_set(i) lpc2138_set (ale, i)
|
|
426 |
#endif
|
|
427 |
|
|
428 |
#ifndef lpc2138_ale_set_mode
|
|
429 |
#define lpc2138_ale_set_mode(mode) lpc2138_set_mode (ale, mode)
|
|
430 |
#endif
|
|
431 |
#ifndef lpc2138_ale_set_pinsel
|
|
432 |
#define lpc2138_ale_set_pinsel(func) lpc2138_set_pinsel(ale, func)
|
|
433 |
#endif
|
|
434 |
|
|
435 |
#ifndef lpc2138_rd_get
|
|
436 |
#define lpc2138_rd_get() lpc2138_get (rd)
|
|
437 |
#endif
|
|
438 |
|
|
439 |
#ifndef lpc2138_rd_set
|
|
440 |
#define lpc2138_rd_set(i) lpc2138_set (rd, i)
|
|
441 |
#endif
|
|
442 |
|
|
443 |
#ifndef lpc2138_rd_set_mode
|
|
444 |
#define lpc2138_rd_set_mode(mode) lpc2138_set_mode (rd, mode)
|
|
445 |
#endif
|
|
446 |
|
|
447 |
#ifndef lpc2138_rd_set_pinsel
|
|
448 |
#define lpc2138_rd_set_pinsel(func) lpc2138_set_pinsel(rd, func)
|
|
449 |
#endif
|
|
450 |
|
|
451 |
#ifndef lpc2138_wr_get
|
|
452 |
#define lpc2138_wr_get() lpc2138_get (wr)
|
|
453 |
#endif
|
|
454 |
|
|
455 |
#ifndef lpc2138_wr_set
|
|
456 |
#define lpc2138_wr_set(i) lpc2138_set (wr, i)
|
|
457 |
#endif
|
|
458 |
|
|
459 |
#ifndef lpc2138_wr_set_mode
|
|
460 |
#define lpc2138_wr_set_mode(mode) lpc2138_set_mode (wr, mode)
|
|
461 |
#endif
|
|
462 |
|
|
463 |
#ifndef lpc2138_wr_set_pinsel
|
|
464 |
#define lpc2138_wr_set_pinsel(func) lpc2138_set_pinsel(wr, func)
|
|
465 |
#endif
|
|
466 |
|
|
467 |
#ifndef lpc2138_data_get
|
|
468 |
#define lpc2138_data_get() lpc2138_get (data)
|
|
469 |
#endif
|
|
470 |
|
|
471 |
#ifndef lpc2138_data_set
|
|
472 |
#define lpc2138_data_set(i) lpc2138_set (data, i)
|
|
473 |
#endif
|
|
474 |
|
|
475 |
#ifndef lpc2138_data_set_mode
|
|
476 |
#define lpc2138_data_set_mode(mode) lpc2138_set_mode (data, mode)
|
|
477 |
#endif
|
|
478 |
|
|
479 |
#ifndef lpc2138_data_set_pinsel
|
|
480 |
#define lpc2138_data_set_pinsel(func) lpc2138_set_pinsel(data, func)
|
|
481 |
#endif
|
|
482 |
|
|
483 |
#ifndef lpc2138_addresses_get
|
|
484 |
#define lpc2138_addresses_get() ((lpc2138_get (a17_mr) << 17) | \
|
|
485 |
(lpc2138_get (a16) << 16) | \
|
|
486 |
(lpc2138_get (a0_a15)))
|
|
487 |
#endif
|
|
488 |
|
|
489 |
#ifndef lpc2138_addresses_set
|
|
490 |
#define lpc2138_addresses_set(i) lpc2138_set (a17_mr, ((i >> 17) & BITMASK_1)); \
|
|
491 |
lpc2138_set (a16, ((i >> 16) & BITMASK_1)); \
|
|
492 |
lpc2138_set (a0_a15, ((i) & BITMASK_16))
|
|
493 |
#endif
|
|
494 |
|
|
495 |
#ifndef lpc2138_addresses_set_mode
|
|
496 |
#define lpc2138_addresses_set_mode(mode) (lpc2138_set_mode (a17_mr, mode), \
|
|
497 |
lpc2138_set_mode (a16, mode), \
|
|
498 |
lpc2138_set_mode (a0_a15, mode))
|
|
499 |
#endif
|
|
500 |
|
|
501 |
#ifndef lpc2138_addresses_set_pinsel
|
|
502 |
#define lpc2138_addresses_set_pinsel(func) (lpc2138_set_pinsel(a17_mr, func), \
|
|
503 |
lpc2138_set_pinsel(a16, func), \
|
|
504 |
lpc2138_set_pinsel(a0_a15, func))
|
|
505 |
#endif
|
|
506 |
|
|
507 |
#define CMR 1
|
|
508 |
#define RRB 2 // 1=released message in fifo are released
|
|
509 |
#define AT 1 // 1= cancel next tranmission
|
|
510 |
#define SR 2
|
|
511 |
#define TBS 2 // 1=released the cpu may write a message in the transmit buffer
|
|
512 |
#define SRR 4 // 1=present a message shall be transmit and receive sim
|
|
513 |
#define TR 0 // 1=present a message shall be transmit
|
|
514 |
|
|
515 |
|
|
516 |
/*
|
|
517 |
FLASH
|
|
518 |
*/
|
|
519 |
#define EE_SEC_L 1 // Flash sector where EEPROM begins (see UM for details)
|
|
520 |
#define EE_SEC_H 3 // Flash sector where EEPROM ends (see UM for details)
|
|
521 |
#define EE_ADDR_L 0x00001000 // Must match the EE_SEC_L Flash sector start address
|
|
522 |
#define EE_ADDR_H 0x00003FFF // Must match the EE_SEC_H Flash sector end address
|
|
523 |
#define EE_CCLK 60000 // system clock cclk expressed in kHz (5*12 MHz)
|
|
524 |
#define EE_BUFFER_SIZE 256
|
|
525 |
#define EE_START_MASK 0xFFFFFF00
|
|
526 |
#define EE_BUFFER_MASK 0x000000F0
|
|
527 |
|
|
528 |
|
|
529 |
#endif
|