AVR-LibC  2.2.0
Standard C library for AVR-GCC
 

AVR-LibC Documentation

Logo

AVR-LibC Development Pages

Main Page

User Manual

Library Reference

FAQ

Example Projects

File List

Loading...
Searching...
No Matches
deprecated.h
1/* Copyright (c) 2005,2006 Joerg Wunsch
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#ifndef _COMPAT_DEPRECATED_H_
34#define _COMPAT_DEPRECATED_H_
35
36/** \defgroup deprecated_items <compat/deprecated.h>: Deprecated items
37
38 This header file contains several items that used to be available
39 in previous versions of this library, but have eventually been
40 deprecated over time.
41
42 \code #include <compat/deprecated.h> \endcode
43
44 These items are supplied within that header file for backward
45 compatibility reasons only, so old source code that has been
46 written for previous library versions could easily be maintained
47 until its end-of-life. Use of any of these items in new code is
48 strongly discouraged.
49 */
50
51/** \name Allowing specific system-wide interrupts
52
53 In addition to globally enabling interrupts, each device's particular
54 interrupt needs to be enabled separately if interrupts for this device are
55 desired. While some devices maintain their interrupt enable bit inside
56 the device's register set, external and timer interrupts have system-wide
57 configuration registers.
58
59 Example:
60
61 \code
62 // Enable timer 1 overflow interrupts.
63 timer_enable_int(_BV(TOIE1));
64
65 // Do some work...
66
67 // Disable all timer interrupts.
68 timer_enable_int(0);
69 \endcode
70
71 \note Be careful when you use these functions. If you already have a
72 different interrupt enabled, you could inadvertantly disable it by
73 enabling another intterupt. */
74
75/**@{*/
76
77/** \ingroup deprecated_items
78 \def enable_external_int(mask)
79 \deprecated
80
81 This macro gives access to the \c GIMSK register (or \c EIMSK register
82 if using an AVR Mega device or \c GICR register for others). Although this
83 macro is essentially the same as assigning to the register, it does
84 adapt slightly to the type of device being used. This macro is
85 unavailable if none of the registers listed above are defined. */
86
87/* Define common register definition if available. */
88#if defined(EIMSK)
89# define __EICR EIMSK
90#elif defined(GIMSK)
91# define __EICR GIMSK
92#elif defined(GICR)
93# define __EICR GICR
94#endif
95
96/* If common register defined, define macro. */
97#if defined(__EICR) || defined(__DOXYGEN__)
98#define enable_external_int(mask) (__EICR = mask)
99#endif
100
101/** \ingroup deprecated_items
102 \deprecated
103
104 This function modifies the \c timsk register.
105 The value you pass via \c ints is device specific. */
106
107static __inline__ void timer_enable_int (unsigned char ints)
108{
109#ifdef TIMSK
110 TIMSK = ints;
111#endif
112}
113
114/** \def INTERRUPT(signame)
115 \ingroup deprecated_items
116 \deprecated
117
118 Introduces an interrupt handler function that runs with global interrupts
119 initially enabled. This allows interrupt handlers to be interrupted.
120
121 As this macro has been used by too many unsuspecting people in the
122 past, it has been deprecated, and will be removed in a future
123 version of the library. Users who want to legitimately re-enable
124 interrupts in their interrupt handlers as quickly as possible are
125 encouraged to explicitly declare their handlers as described
126 \ref attr_interrupt "above".
127*/
128
129#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)
130# define __INTR_ATTRS __used__, __externally_visible__
131#else /* GCC < 4.1 */
132# define __INTR_ATTRS __used__
133#endif
134
135#ifdef __cplusplus
136#define INTERRUPT(signame) \
137extern "C" void signame(void); \
138void signame (void) __attribute__ ((__interrupt__,__INTR_ATTRS)); \
139void signame (void)
140#else
141#define INTERRUPT(signame) \
142void signame (void) __attribute__ ((__interrupt__,__INTR_ATTRS)); \
143void signame (void)
144#endif
145
146/**@}*/
147
148/**
149 \name Obsolete IO macros
150
151 Back in a time when AVR-GCC and AVR-LibC could not handle IO port
152 access in the direct assignment form as they are handled now, all
153 IO port access had to be done through specific macros that
154 eventually resulted in inline assembly instructions performing the
155 desired action.
156
157 These macros became obsolete, as reading and writing IO ports can
158 be done by simply using the IO port name in an expression, and all
159 bit manipulation (including those on IO ports) can be done using
160 generic C bit manipulation operators.
161
162 The macros in this group simulate the historical behaviour. While
163 they are supposed to be applied to IO ports, the emulation actually
164 uses standard C methods, so they could be applied to arbitrary
165 memory locations as well.
166*/
167
168/**@{*/
169
170/**
171 \ingroup deprecated_items
172 \def inp(port)
173 \deprecated
174
175 Read a value from an IO port \c port.
176*/
177#define inp(port) (port)
178
179/**
180 \ingroup deprecated_items
181 \def outp(val, port)
182 \deprecated
183
184 Write \c val to IO port \c port.
185*/
186#define outp(val, port) (port) = (val)
187
188/**
189 \ingroup deprecated_items
190 \def inb(port)
191 \deprecated
192
193 Read a value from an IO port \c port.
194*/
195#define inb(port) (port)
196
197/**
198 \ingroup deprecated_items
199 \def outb(port, val)
200 \deprecated
201
202 Write \c val to IO port \c port.
203*/
204#define outb(port, val) (port) = (val)
205
206/**
207 \ingroup deprecated_items
208 \def sbi(port, bit)
209 \deprecated
210
211 Set \c bit in IO port \c port.
212*/
213#define sbi(port, bit) (port) |= (1 << (bit))
214
215/**
216 \ingroup deprecated_items
217 \def cbi(port, bit)
218 \deprecated
219
220 Clear \c bit in IO port \c port.
221*/
222#define cbi(port, bit) (port) &= ~(1 << (bit))
223
224/**@}*/
225
226#endif /* _COMPAT_DEPRECATED_H_ */
static void timer_enable_int(unsigned char ints)
Definition: deprecated.h:107