AVR-LibC  2.3.0
Standard C library for AVR-GCC
 

AVR-LibC Manual

AVR-LibC Sources

Main Page

User Manual

Lib­rary Refe­rence

FAQ

Exam­ple Pro­jects

Index

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