$treeview $search $mathjax $extrastylesheet
avr-libc  2.0.0
$projectbrief
$projectbrief
$searchbox

AVR Libc Home Page

AVRs

AVR Libc Development Pages

Main Page

User Manual

Library Reference

FAQ

Example Projects

deprecated.h

00001 /* Copyright (c) 2005,2006 Joerg Wunsch
00002    All rights reserved.
00003 
00004    Redistribution and use in source and binary forms, with or without
00005    modification, are permitted provided that the following conditions are met:
00006 
00007    * Redistributions of source code must retain the above copyright
00008      notice, this list of conditions and the following disclaimer.
00009 
00010    * Redistributions in binary form must reproduce the above copyright
00011      notice, this list of conditions and the following disclaimer in
00012      the documentation and/or other materials provided with the
00013      distribution.
00014 
00015    * Neither the name of the copyright holders nor the names of
00016      contributors may be used to endorse or promote products derived
00017      from this software without specific prior written permission.
00018 
00019   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00020   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00021   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00022   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00023   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00024   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00025   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00026   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00027   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00028   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00029   POSSIBILITY OF SUCH DAMAGE. */
00030 
00031 /* $Id$ */
00032 
00033 #ifndef _COMPAT_DEPRECATED_H_
00034 #define _COMPAT_DEPRECATED_H_
00035 
00036 /** \defgroup deprecated_items <compat/deprecated.h>: Deprecated items
00037 
00038     This header file contains several items that used to be available
00039     in previous versions of this library, but have eventually been
00040     deprecated over time.
00041 
00042     \code #include <compat/deprecated.h> \endcode
00043 
00044     These items are supplied within that header file for backward
00045     compatibility reasons only, so old source code that has been
00046     written for previous library versions could easily be maintained
00047     until its end-of-life.  Use of any of these items in new code is
00048     strongly discouraged.
00049   */
00050 
00051 /** \name Allowing specific system-wide interrupts
00052 
00053     In addition to globally enabling interrupts, each device's particular
00054     interrupt needs to be enabled separately if interrupts for this device are
00055     desired.  While some devices maintain their interrupt enable bit inside
00056     the device's register set, external and timer interrupts have system-wide
00057     configuration registers. 
00058 
00059     Example:
00060 
00061     \code
00062     // Enable timer 1 overflow interrupts.
00063     timer_enable_int(_BV(TOIE1));
00064 
00065     // Do some work...
00066 
00067     // Disable all timer interrupts.
00068     timer_enable_int(0);
00069     \endcode
00070 
00071     \note Be careful when you use these functions. If you already have a
00072     different interrupt enabled, you could inadvertantly disable it by
00073     enabling another intterupt. */
00074 
00075 /*@{*/
00076 
00077 /** \ingroup deprecated_items
00078     \def enable_external_int(mask)
00079     \deprecated
00080 
00081     This macro gives access to the \c GIMSK register (or \c EIMSK register
00082     if using an AVR Mega device or \c GICR register for others). Although this
00083     macro is essentially the same as assigning to the register, it does
00084     adapt slightly to the type of device being used. This macro is 
00085     unavailable if none of the registers listed above are defined. */
00086 
00087 /* Define common register definition if available. */
00088 #if defined(EIMSK)
00089 #  define __EICR  EIMSK
00090 #elif defined(GIMSK)
00091 #  define __EICR  GIMSK
00092 #elif defined(GICR)
00093 #  define __EICR  GICR
00094 #endif
00095 
00096 /* If common register defined, define macro. */
00097 #if defined(__EICR) || defined(__DOXYGEN__)
00098 #define enable_external_int(mask)               (__EICR = mask)
00099 #endif
00100 
00101 /** \ingroup deprecated_items
00102     \deprecated
00103 
00104     This function modifies the \c timsk register.
00105     The value you pass via \c ints is device specific. */
00106 
00107 static __inline__ void timer_enable_int (unsigned char ints)
00108 {
00109 #ifdef TIMSK
00110     TIMSK = ints;
00111 #endif
00112 }
00113 
00114 /** \def INTERRUPT(signame)
00115     \ingroup deprecated_items
00116     \deprecated
00117 
00118     Introduces an interrupt handler function that runs with global interrupts
00119     initially enabled. This allows interrupt handlers to be interrupted.
00120 
00121     As this macro has been used by too many unsuspecting people in the
00122     past, it has been deprecated, and will be removed in a future
00123     version of the library.  Users who want to legitimately re-enable
00124     interrupts in their interrupt handlers as quickly as possible are
00125     encouraged to explicitly declare their handlers as described
00126     \ref attr_interrupt "above".
00127 */
00128 
00129 #if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)
00130 #  define __INTR_ATTRS used, externally_visible
00131 #else /* GCC < 4.1 */
00132 #  define __INTR_ATTRS used
00133 #endif
00134 
00135 #ifdef __cplusplus
00136 #define INTERRUPT(signame)              \
00137 extern "C" void signame(void);              \
00138 void signame (void) __attribute__ ((interrupt,__INTR_ATTRS));   \
00139 void signame (void)
00140 #else
00141 #define INTERRUPT(signame)              \
00142 void signame (void) __attribute__ ((interrupt,__INTR_ATTRS));   \
00143 void signame (void)
00144 #endif
00145 
00146 /*@}*/
00147 
00148 /**
00149    \name Obsolete IO macros
00150 
00151    Back in a time when AVR-GCC and avr-libc could not handle IO port
00152    access in the direct assignment form as they are handled now, all
00153    IO port access had to be done through specific macros that
00154    eventually resulted in inline assembly instructions performing the
00155    desired action.
00156 
00157    These macros became obsolete, as reading and writing IO ports can
00158    be done by simply using the IO port name in an expression, and all
00159    bit manipulation (including those on IO ports) can be done using
00160    generic C bit manipulation operators.
00161 
00162    The macros in this group simulate the historical behaviour.  While
00163    they are supposed to be applied to IO ports, the emulation actually
00164    uses standard C methods, so they could be applied to arbitrary
00165    memory locations as well.
00166 */
00167 
00168 /*@{*/
00169 
00170 /**
00171    \ingroup deprecated_items
00172    \def inp(port)
00173    \deprecated
00174 
00175    Read a value from an IO port \c port.
00176 */
00177 #define inp(port) (port)
00178 
00179 /**
00180    \ingroup deprecated_items
00181    \def outp(val, port)
00182    \deprecated
00183 
00184    Write \c val to IO port \c port.
00185 */
00186 #define outp(val, port) (port) = (val)
00187 
00188 /**
00189    \ingroup deprecated_items
00190    \def inb(port)
00191    \deprecated
00192 
00193    Read a value from an IO port \c port.
00194 */
00195 #define inb(port) (port)
00196 
00197 /**
00198    \ingroup deprecated_items
00199    \def outb(port, val)
00200    \deprecated
00201 
00202    Write \c val to IO port \c port.
00203 */
00204 #define outb(port, val) (port) = (val)
00205 
00206 /**
00207    \ingroup deprecated_items
00208    \def sbi(port, bit)
00209    \deprecated
00210 
00211    Set \c bit in IO port \c port.
00212 */
00213 #define sbi(port, bit) (port) |= (1 << (bit))
00214 
00215 /**
00216    \ingroup deprecated_items
00217    \def cbi(port, bit)
00218    \deprecated
00219 
00220    Clear \c bit in IO port \c port.
00221 */
00222 #define cbi(port, bit) (port) &= ~(1 << (bit))
00223 
00224 /*@}*/
00225 
00226 #endif /* _COMPAT_DEPRECATED_H_ */
 All Data Structures Files Functions Variables Typedefs Enumerations Defines