avr-libc  2.0.0
Standard C library for AVR-GCC

AVR Libc Home Page

AVRs

AVR Libc Development Pages

Main Page

User Manual

Library Reference

FAQ

Example Projects

<compat/deprecated.h>: Deprecated items

Allowing specific system-wide interrupts

In addition to globally enabling interrupts, each device's particular interrupt needs to be enabled separately if interrupts for this device are desired. While some devices maintain their interrupt enable bit inside the device's register set, external and timer interrupts have system-wide configuration registers.

例:

// Enable timer 1 overflow interrupts.
// Do some work...
// Disable all timer interrupts.
注意
Be careful when you use these functions. If you already have a different interrupt enabled, you could inadvertantly disable it by enabling another intterupt.
static __inline__ void timer_enable_int (unsigned char ints)
 
#define enable_external_int(mask)    (__EICR = mask)
 
#define INTERRUPT(signame)
 
#define __INTR_ATTRS   used
 

Obsolete IO macros

Back in a time when AVR-GCC and avr-libc could not handle IO port access in the direct assignment form as they are handled now, all IO port access had to be done through specific macros that eventually resulted in inline assembly instructions performing the desired action.

These macros became obsolete, as reading and writing IO ports can be done by simply using the IO port name in an expression, and all bit manipulation (including those on IO ports) can be done using generic C bit manipulation operators.

The macros in this group simulate the historical behaviour. While they are supposed to be applied to IO ports, the emulation actually uses standard C methods, so they could be applied to arbitrary memory locations as well.

#define inp(port)   (port)
 
#define outp(val, port)   (port) = (val)
 
#define inb(port)   (port)
 
#define outb(port, val)   (port) = (val)
 
#define sbi(port, bit)   (port) |= (1 << (bit))
 
#define cbi(port, bit)   (port) &= ~(1 << (bit))
 

説明詳細

This header file contains several items that used to be available in previous versions of this library, but have eventually been deprecated over time.

#include <compat/deprecated.h>

These items are supplied within that header file for backward compatibility reasons only, so old source code that has been written for previous library versions could easily be maintained until its end-of-life. Use of any of these items in new code is strongly discouraged.

マクロ定義説明

#define cbi (   port,
  bit 
)    (port) &= ~(1 << (bit))
廃止:

Clear bit in IO port port.

#define enable_external_int (   mask)    (__EICR = mask)
廃止:

This macro gives access to the GIMSK register (or EIMSK register if using an AVR Mega device or GICR register for others). Although this macro is essentially the same as assigning to the register, it does adapt slightly to the type of device being used. This macro is unavailable if none of the registers listed above are defined.

#define inb (   port)    (port)
廃止:

Read a value from an IO port port.

#define inp (   port)    (port)
廃止:

Read a value from an IO port port.

#define INTERRUPT (   signame)
値:
void signame (void) __attribute__ ((interrupt,__INTR_ATTRS)); \
void signame (void)
static __inline void __attribute__((__always_inline__)) __power_all_enable()
Definition: power.h:1148
廃止:

Introduces an interrupt handler function that runs with global interrupts initially enabled. This allows interrupt handlers to be interrupted.

As this macro has been used by too many unsuspecting people in the past, it has been deprecated, and will be removed in a future version of the library. Users who want to legitimately re-enable interrupts in their interrupt handlers as quickly as possible are encouraged to explicitly declare their handlers as described above.

#define outb (   port,
  val 
)    (port) = (val)
廃止:

Write val to IO port port.

#define outp (   val,
  port 
)    (port) = (val)
廃止:

Write val to IO port port.

#define sbi (   port,
  bit 
)    (port) |= (1 << (bit))
廃止:

Set bit in IO port port.

関数説明

static __inline__ void timer_enable_int ( unsigned char  ints)
static
廃止:

This function modifies the timsk register. The value you pass via ints is device specific.