1
/* Copyright (c) 2007 Eric B. Weddington
4
Redistribution and use in source and binary forms, with or without
5
modification, are permitted provided that the following conditions are met:
7
* Redistributions of source code must retain the above copyright
8
notice, this list of conditions and the following disclaimer.
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
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.
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. */
31
/* $Id: common.h,v 1.3.2.2 2007/07/10 05:04:50 arcanum Exp $ */
37
#include <avr/sfr_defs.h>
40
This purpose of this header is to define registers that have not been
41
previously defined in the individual device IO header files, and to define
42
other symbols that are common across AVR device families.
44
This file is designed to be included in <avr/io.h> after the individual
45
device IO header files, and after <avr/sfr_defs.h>
49
/*------------ Registers Not Previously Defined ------------*/
52
These are registers that are not previously defined in the individual
53
IO header files, OR they are defined here because they are used in parts of
54
avr-libc even if a device is not selected but a general architecture has
60
Stack pointer register.
62
AVR architecture 1 has no RAM, thus no stack pointer.
64
All other architectures do have a stack pointer. Some devices have only
65
less than 256 bytes of possible RAM locations (128 Bytes of SRAM
66
and no option for external RAM), thus SPH is officially "reserved"
73
# define SPL _SFR_IO8(0x3D)
77
# define SP _SFR_IO8(0x3D)
81
# define SP _SFR_IO16(0x3D)
84
# define SPH _SFR_IO8(0x3E)
86
# endif /* XRAMEND < 0x100 && !defined(__COMPILING_AVR_LIBC__) */
88
#endif /* __AVR_ARCH__ != 1 */
93
# define SREG _SFR_IO8(0x3F)
96
/* SREG bit definitions */
123
/* AVR 6 Architecture */
124
#if __AVR_ARCH__ == 6
126
# define EIND _SFR_IO8(0X3C)
128
#endif /* __AVR_ARCH__ == 6 */
132
#if defined(__COMPILING_AVR_LIBC__)
135
Only few devices come without EEPROM. In order to assemble the
136
EEPROM library components without defining a specific device, we
137
keep the EEPROM-related definitions here.
140
/* EEPROM Control Register */
142
# define EECR _SFR_IO8(0x1C)
145
/* EEPROM Data Register */
147
# define EEDR _SFR_IO8(0x1D)
150
/* EEPROM Address Register */
152
# define EEAR _SFR_IO16(0x1E)
155
# define EEARL _SFR_IO8(0x1E)
158
# define EEARH _SFR_IO8(0x1F)
161
/* EEPROM Control Register bits */
175
#endif /* __COMPILING_AVR_LIBC__ */
179
/*------------ Common Symbols ------------*/
182
Generic definitions for registers that are common across multiple AVR devices
186
/* Pointer registers definitions */
187
#if __AVR_ARCH__ != 1 /* avr1 does not have X and Y pointers */
192
#endif /* #if __AVR_ARCH__ != 1 */
197
/* Status Register */
199
# define AVR_STATUS_REG SREG
200
# define AVR_STATUS_ADDR _SFR_IO_ADDR(SREG)
203
/* Stack Pointer (combined) Register */
205
# define AVR_STACK_POINTER_REG SP
206
# define AVR_STACK_POINTER_ADDR _SFR_IO_ADDR(SP)
209
/* Stack Pointer High Register */
211
# define _HAVE_AVR_STACK_POINTER_HI 1
212
# define AVR_STACK_POINTER_HI_REG SPH
213
# define AVR_STACK_POINTER_HI_ADDR _SFR_IO_ADDR(SPH)
216
/* Stack Pointer Low Register */
218
# define AVR_STACK_POINTER_LO_REG SPL
219
# define AVR_STACK_POINTER_LO_ADDR _SFR_IO_ADDR(SPL)
224
# define AVR_RAMPZ_REG RAMPZ
225
# define AVR_RAMPZ_ADDR _SFR_IO_ADDR(RAMPZ)
228
/* Extended Indirect Register */
230
# define AVR_EXTENDED_INDIRECT_REG EIND
231
# define AVR_EXTENDED_INDIRECT_ADDR _SFR_IO_ADDR(EIND)
235
#endif /* _AVR_COMMON_H */