AVR-LibC  2.3.0git
Standard C library for AVR-GCC
 

AVR-LibC Documen­tation

AVR-LibC Development Pages

Main Page

User Manual

Library Refe­rence

FAQ

Example Projects

File List

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