source: rtems/cpukit/score/cpu/avr/avr/common.h @ 04a62dce

4.104.11
Last change on this file since 04a62dce was 04a62dce, checked in by Joel Sherrill <joel.sherrill@…>, on Aug 6, 2009 at 2:52:07 PM

2009-08-05 Josh Switnicki <josh.switnicki@…>

  • Makefile.am: added AVR specific Header files to score/cpu/avr/avr. These are from avr-libc 1.6 and assumed to exist by AVR applications.
  • preinstall.am: Regenerated.
  • Property mode set to 100644
File size: 7.7 KB
Line 
1/* Copyright (c) 2007 Eric B. Weddington
2   All rights reserved.
3
4   Redistribution and use in source and binary forms, with or without
5   modification, are permitted provided that the following conditions are met:
6
7   * Redistributions of source code must retain the above copyright
8     notice, this list of conditions and the following disclaimer.
9
10   * Redistributions in binary form must reproduce the above copyright
11     notice, this list of conditions and the following disclaimer in
12     the documentation and/or other materials provided with the
13     distribution.
14
15   * Neither the name of the copyright holders nor the names of
16     contributors may be used to endorse or promote products derived
17     from this software without specific prior written permission.
18
19  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  POSSIBILITY OF SUCH DAMAGE. */
30
31/* $Id$ */
32
33
34#ifndef _AVR_COMMON_H
35#define _AVR_COMMON_H
36
37#include <avr/sfr_defs.h>
38
39/*
40This purpose of this header is to define registers that have not been
41previously defined in the individual device IO header files, and to define
42other symbols that are common across AVR device families.
43
44This file is designed to be included in <avr/io.h> after the individual
45device IO header files, and after <avr/sfr_defs.h>
46
47*/
48
49/*------------ Registers Not Previously Defined ------------*/
50
51/*
52These are registers that are not previously defined in the individual
53IO header files, OR they are defined here because they are used in parts of
54avr-libc even if a device is not selected but a general architecture has
55been selected.
56*/
57
58
59/*
60Stack pointer register.
61
62AVR architecture 1 has no RAM, thus no stack pointer.
63
64All other architectures do have a stack pointer.  Some devices have only
65less than 256 bytes of possible RAM locations (128 Bytes of SRAM
66and no option for external RAM), thus SPH is officially "reserved"
67for them.
68*/
69#if __AVR_ARCH__ >= 100
70#  ifndef SPL
71#    define SPL _SFR_MEM8(0x3D)
72#  endif
73#  ifndef SPH
74#    define SPH _SFR_MEM8(0x3E)
75#  endif
76#  ifndef SP
77#    define SP _SFR_MEM16(0x3D)
78#  endif
79#elif __AVR_ARCH__ != 1
80#  ifndef SPL
81#    define SPL _SFR_IO8(0x3D)
82#  endif
83#  if XRAMEND < 0x100 && !defined(__COMPILING_AVR_LIBC__)
84#    ifndef SP
85#      define SP  _SFR_IO8(0x3D)
86#    endif
87#  else
88#    ifndef SP
89#      define SP  _SFR_IO16(0x3D)
90#    endif
91#    ifndef SPH
92#      define SPH _SFR_IO8(0x3E)
93#    endif
94#  endif /* XRAMEND < 0x100 && !defined(__COMPILING_AVR_LIBC__) */
95#endif /* __AVR_ARCH__ != 1 */
96
97
98/* Status Register */
99#ifndef SREG
100#  if __AVR_ARCH__ >= 100
101#    define SREG _SFR_MEM8(0x3F)
102#  else
103#    define SREG _SFR_IO8(0x3F)
104#  endif
105#endif
106
107
108/* SREG bit definitions */
109#ifndef SREG_C
110#  define SREG_C  (0)
111#endif
112#ifndef SREG_Z
113#  define SREG_Z  (1)
114#endif
115#ifndef SREG_N
116#  define SREG_N  (2)
117#endif
118#ifndef SREG_V
119#  define SREG_V  (3)
120#endif
121#ifndef SREG_S
122#  define SREG_S  (4)
123#endif
124#ifndef SREG_H
125#  define SREG_H  (5)
126#endif
127#ifndef SREG_T
128#  define SREG_T  (6)
129#endif
130#ifndef SREG_I
131#  define SREG_I  (7)
132#endif
133
134
135#if defined(__COMPILING_AVR_LIBC__)
136
137/* AVR 6 Architecture */
138#  if __AVR_ARCH__ == 6
139#    ifndef EIND
140#      define EIND  _SFR_IO8(0X3C)
141#    endif
142/* XMEGA Architectures */
143#  elif __AVR_ARCH__ >= 100
144#    ifndef EIND
145#      define EIND  _SFR_MEM8(0x3C)
146#    endif
147#  endif
148
149/*
150Only few devices come without EEPROM.  In order to assemble the
151EEPROM library components without defining a specific device, we
152keep the EEPROM-related definitions here.
153*/
154
155/* EEPROM Control Register */
156#  ifndef EECR
157#    define EECR   _SFR_IO8(0x1C)
158#  endif
159
160/* EEPROM Data Register */
161#  ifndef EEDR
162#    define EEDR   _SFR_IO8(0x1D)
163#  endif
164
165/* EEPROM Address Register */
166#  ifndef EEAR
167#    define EEAR   _SFR_IO16(0x1E)
168#  endif
169#  ifndef EEARL
170#    define EEARL  _SFR_IO8(0x1E)
171#  endif
172#  ifndef EEARH
173#    define EEARH  _SFR_IO8(0x1F)
174#  endif
175
176/* EEPROM Control Register bits */
177#  ifndef EERE
178#    define EERE   (0)
179#  endif
180#  ifndef EEWE
181#    define EEWE   (1)
182#  endif
183#  ifndef EEMWE
184#    define EEMWE  (2)
185#  endif
186#  ifndef EERIE
187#    define EERIE  (3)
188#  endif
189
190#endif /* __COMPILING_AVR_LIBC__ */
191
192
193
194/*------------ Common Symbols ------------*/
195
196/*
197Generic definitions for registers that are common across multiple AVR devices
198and families.
199*/
200
201/* Pointer registers definitions */
202#if __AVR_ARCH__ != 1  /* avr1 does not have X and Y pointers */
203#  define XL  r26
204#  define XH  r27
205#  define YL  r28
206#  define YH  r29
207#endif /* #if __AVR_ARCH__ != 1 */
208#define ZL  r30
209#define ZH  r31
210
211
212/* Status Register */
213#if defined(SREG)
214#  define AVR_STATUS_REG   SREG
215#  if __AVR_ARCH__ >= 100
216#    define AVR_STATUS_ADDR  _SFR_MEM_ADDR(SREG)
217#  else
218#    define AVR_STATUS_ADDR  _SFR_IO_ADDR(SREG)
219#  endif
220#endif
221
222/* Stack Pointer (combined) Register */
223#if defined(SP)
224#  define AVR_STACK_POINTER_REG   SP
225#  if __AVR_ARCH__ >= 100
226#    define AVR_STACK_POINTER_ADDR  _SFR_MEM_ADDR(SP)
227#  else
228#    define AVR_STACK_POINTER_ADDR  _SFR_IO_ADDR(SP)
229#  endif
230#endif
231
232/* Stack Pointer High Register */
233#if defined(SPH)
234#  define _HAVE_AVR_STACK_POINTER_HI 1
235#  define AVR_STACK_POINTER_HI_REG   SPH
236#  if __AVR_ARCH__ >= 100
237#    define AVR_STACK_POINTER_HI_ADDR  _SFR_MEM_ADDR(SPH)
238#  else
239#    define AVR_STACK_POINTER_HI_ADDR  _SFR_IO_ADDR(SPH)
240#  endif
241#endif
242
243/* Stack Pointer Low Register */
244#if defined(SPL)
245#  define AVR_STACK_POINTER_LO_REG   SPL
246#  if __AVR_ARCH__ >= 100
247#    define AVR_STACK_POINTER_LO_ADDR  _SFR_MEM_ADDR(SPL)
248#  else
249#    define AVR_STACK_POINTER_LO_ADDR  _SFR_IO_ADDR(SPL)
250#  endif
251#endif
252
253/* RAMPD Register */
254#if defined(RAMPD)
255#  define AVR_RAMPD_REG   RAMPD
256#  if __AVR_ARCH__ >= 100
257#    define AVR_RAMPD_ADDR  _SFR_MEM_ADDR(RAMPD)
258#  else
259#    define AVR_RAMPD_ADDR  _SFR_IO_ADDR(RAMPD)
260#  endif
261#endif
262
263/* RAMPX Register */
264#if defined(RAMPX)
265#  define AVR_RAMPX_REG   RAMPX
266#  if __AVR_ARCH__ >= 100
267#    define AVR_RAMPX_ADDR  _SFR_MEM_ADDR(RAMPX)
268#  else
269#    define AVR_RAMPX_ADDR  _SFR_IO_ADDR(RAMPX)
270#  endif
271#endif
272
273/* RAMPY Register */
274#if defined(RAMPY)
275#  define AVR_RAMPY_REG   RAMPY
276#  if __AVR_ARCH__ >= 100
277#    define AVR_RAMPY_ADDR  _SFR_MEM_ADDR(RAMPY)
278#  else
279#    define AVR_RAMPY_ADDR  _SFR_IO_ADDR(RAMPY)
280#  endif
281#endif
282
283/* RAMPZ Register */
284#if defined(RAMPZ)
285#  define AVR_RAMPZ_REG   RAMPZ
286#  if __AVR_ARCH__ >= 100
287#    define AVR_RAMPZ_ADDR  _SFR_MEM_ADDR(RAMPZ)
288#  else
289#    define AVR_RAMPZ_ADDR  _SFR_IO_ADDR(RAMPZ)
290#  endif
291#endif
292
293/* Extended Indirect Register */
294#if defined(EIND)
295#  define AVR_EXTENDED_INDIRECT_REG   EIND
296#  if __AVR_ARCH__ >= 100
297#    define AVR_EXTENDED_INDIRECT_ADDR  _SFR_MEM_ADDR(EIND)
298#  else
299#    define AVR_EXTENDED_INDIRECT_ADDR  _SFR_IO_ADDR(EIND)
300#  endif
301#endif
302
303/*------------ Workaround to old compilers (4.1.2 and earlier)  ------------*/
304
305#ifndef __AVR_HAVE_MOVW__
306# if  defined(__AVR_ENHANCED__) && __AVR_ENHANCED__
307#  define __AVR_HAVE_MOVW__ 1
308# endif
309#endif
310
311#ifndef __AVR_HAVE_LPMX__
312# if  defined(__AVR_ENHANCED__) && __AVR_ENHANCED__
313#  define __AVR_HAVE_LPMX__ 1
314# endif
315#endif
316
317#ifndef __AVR_HAVE_MUL__
318# if  defined(__AVR_ENHANCED__) && __AVR_ENHANCED__
319#  define __AVR_HAVE_MUL__ 1
320# endif
321#endif
322
323#endif /* _AVR_COMMON_H */
Note: See TracBrowser for help on using the repository browser.