AVR Libc Home Page AVRs AVR Libc Development Pages
Main Page User Manual Reference FAQ Example Projects

deprecated.8h

01	1 Copyright (c) 2005,2006 Joerg Wunsch
	022All rights reserved.
	033
	044Redistribution and use in source and binary forms, with or without
	055modification, are permitted provided that the following conditions are met:
	066
	077* Redistributions of source code must retain the above copyright
	088notice, this list of conditions and the following disclaimer.
	099
	1010* Redistributions in binary form must reproduce the above copyright
	1111notice, this list of conditions and the following disclaimer in
	1212the documentation and/or other materials provided with the
	1313distribution.
	1414
	1515* Neither the name of the copyright holders nor the names of
	1616contributors may be used to endorse or promote products derived
	1717from this software without specific prior written permission.
	1818
	1919THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
	2020AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
	2121IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
	2222ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
	2323LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
	2424CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
	2525SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
	2626INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
	2727CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
	2828ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
	2929POSSIBILITY OF SUCH DAMAGE. */
	3030
	3131/* $Id: deprecated.h 1724 2008-07-30 21:31:33Z arcanum $ */
	3232
	3333#ifndef _COMPAT_DEPRECATED_H_
	3434#define _COMPAT_DEPRECATED_H_
	3535
	3636/** \defgroup deprecated_items <compat/deprecated.h>: Deprecated items
	3737
	3838This header file contains several items that used to be available
	3939in previous versions of this library, but have eventually been
	4040deprecated over time.
	4141
	4242\code #include <compat/deprecated.h> \endcode
	4343
	4444These items are supplied within that header file for backward
	4545compatibility reasons only, so old source code that has been
	4646written for previous library versions could easily be maintained
	4747until its end-of-life.  Use of any of these items in new code is
	4848strongly discouraged.
	4949*/
	5050
	5151/** \name Allowing specific system-wide interrupts
	5252
	5353In addition to globally enabling interrupts, each device's particular
	5454interrupt needs to be enabled separately if interrupts for this device are
	5555desired.  While some devices maintain their interrupt enable bit inside
	5656the device's register set, external and timer interrupts have system-wide
	5757configuration registers.
	5858
	5959Example:
	6060
	6161\code
	6262// Enable timer 1 overflow interrupts.
	6363timer_enable_int(_BV(TOIE1));
	6464
	6565// Do some work...
	6666
	6767// Disable all timer interrupts.
	6868timer_enable_int(0);
	6969\endcode
	7070
	7171\note Be careful when you use these functions. If you already have a
	7272different interrupt enabled, you could inadvertantly disable it by
	7373enabling another intterupt. */
	7474
	7575/*@{*/
	7676
	7777/** \ingroup deprecated_items
	7878\def enable_external_int(mask)
	7979\deprecated
	8080
	8181This macro gives access to the \c GIMSK register (or \c EIMSK register
	8282if using an AVR Mega device or \c GICR register for others). Although this
	8383macro is essentially the same as assigning to the register, it does
	8484adapt slightly to the type of device being used. This macro is
	8585unavailable if none of the registers listed above are defined. */
	8686
	8787/* Define common register definition if available. */
	8888#if defined(EIMSK)
	8989#  define __EICR  EIMSK
	9090#elif defined(GIMSK)
	9191#  define __EICR  GIMSK
	9292#elif defined(GICR)
	9393#  define __EICR  GICR
	9494#endif
	9595
	9696/* If common register defined, define macro. */
	9797#if defined(__EICR) || defined(__DOXYGEN__)
	98   98#define enable_external_int(mask)               (__EICR = mask)
	9999#endif
	100100
	101101/** \ingroup deprecated_items
	102102\deprecated
	103103
	104104This function modifies the \c timsk register.
	105105The value you pass via \c ints is device specific. */
	106106
	107  107
static __inline__ void timer_enable_int (unsigned char ints)
	108108{
	109109#ifdef TIMSK
	110110TIMSK = ints;
	111111#endif
	112112}
	113113
	114114/** \def INTERRUPT(signame)
	115115\ingroup deprecated_items
	116116\deprecated
	117117
	118118Introduces an interrupt handler function that runs with global interrupts
	119119initially enabled. This allows interrupt handlers to be interrupted.
	120120
	121121As this macro has been used by too many unsuspecting people in the
	122122past, it has been deprecated, and will be removed in a future
	123123version of the library.  Users who want to legitimately re-enable
	124124interrupts in their interrupt handlers as quickly as possible are
	125125encouraged to explicitly declare their handlers as described
	126126\ref attr_interrupt "above".
	127127*/
	128128
	129129#if (__GNUC__ == 4 && __GNUC_MINOR__ >> = 1) || (__GNUC__ >> 4)
	130130#  define __INTR_ATTRS used, externally_visible
	131131#else /* GCC < 4.1 */
	132132#  define __INTR_ATTRS used
	133133#endif
	134134
	135135#ifdef __cplusplus
	136136#define INTERRUPT(signame)              \
	137137 extern "C" void signame(void);              \
	138138 void signame (void) __attribute__ ((interrupt,__INTR_ATTRS));   \
	139139 void signame (void)
	140140#else
	141  141#define INTERRUPT(signame)              \
	142142 void signame (void) __attribute__ ((interrupt,__INTR_ATTRS));   \
	143143 void signame (void)
	144144#endif
	145145
	146146/*@}*/
	147147
	148148/**
	149149\name Obsolete IO macros
	150150
	151151Back in a time when AVR-GCC and avr-libc could not handle IO port
	152152access in the direct assignment form as they are handled now, all
	153153IO port access had to be done through specific macros that
	154154eventually resulted in inline assembly instructions performing the
	155155desired action.
	156156
	157157These macros became obsolete, as reading and writing IO ports can
	158158be done by simply using the IO port name in an expression, and all
	159159bit manipulation (including those on IO ports) can be done using
	160160generic C bit manipulation operators.
	161161
	162162The macros in this group simulate the historical behaviour.  While
	163163they are supposed to be applied to IO ports, the emulation actually
	164164uses standard C methods, so they could be applied to arbitrary
	165165memory locations as well.
	166166*/
	167167
	168168/*@{*/
	169169
	170170/**
	171171\ingroup deprecated_items
	172172\def inp(port)
	173173\deprecated
	174174
	175175Read a value from an IO port \c port.
	176176*/
	177  177#define inp(port) (port)
	178178
	179179/**
	180180\ingroup deprecated_items
	181181\def outp(val, port)
	182182\deprecated
	183183
	184184Write \c val to IO port \c port.
	185185*/
	186  186#define outp(val, port) (port) = (val)
	187187
	188188/**
	189189\ingroup deprecated_items
	190190\def inb(port)
	191191\deprecated
	192192
	193193Read a value from an IO port \c port.
	194194*/
	195  195#define inb(port) (port)
	196196
	197197/**
	198198\ingroup deprecated_items
	199199\def outb(port, val)
	200200\deprecated
	201201
	202202Write \c val to IO port \c port.
	203203*/
	204  204#define outb(port, val) (port) = (val)
	205205
	206206/**
	207207\ingroup deprecated_items
	208208\def sbi(port, bit)
	209209\deprecated
	210210
	211211Set \c bit in IO port \c port.
	212212*/
	213  213#define sbi(port, bit) (port) |= (1 << (bit))
	214214
	215215/**
	216216\ingroup deprecated_items
	217217\def cbi(port, bit)
	218218\deprecated
	219219
	220220Clear \c bit in IO port \c port.
	221221*/
	222  222#define cbi(port, bit) (port) &= ~(1 << (bit))
	223223
	224224/*@}*/
	225225
	226226#endif /* _COMPAT_DEPRECATED_H_ */
	

timer_enable_int static __inline__ void timer_enable_int(unsigned char ints)

Definition: deprecated.h:107