FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
Loading...
Searching...
No Matches
interrupt Namespace Reference

Defines API to handle AVR interruptions. More...

Classes

class  INTSignal
 Handler of an External Interrupt. More...
 
class  PCISignal
 Handler of a Pin Change Interrupt vector. More...
 
struct  PCIType
 Helper class that easily converts a PIN into the right PCISignal. More...
 

Typedefs

template<board::InterruptPin PIN>
using PCI_SIGNAL = typename PCIType< PIN >::TYPE
 Useful alias type to the PCISignal type matching a given board::InterruptPin. More...
 
template<board::Port PORT>
using PCI_PORT_SIGNAL = PCISignal< board_traits::Port_trait< PORT >::PCINT >
 Convert a board::PORT to the matching PCISignal. More...
 

Enumerations

enum class  InterruptTrigger : uint8_t {
  LOW_LEVEL = 0x00 ,
  ANY_CHANGE = 0x55 ,
  FALLING_EDGE = 0xAA ,
  RISING_EDGE = 0xFF
}
 Kind of change that will trigger an External Interrupt for a given pin. More...
 

Functions

template<typename Handler >
void register_handler (Handler &handler)
 Register a class instance containing methods that shall be called back by an ISR. More...
 
template<typename Handler >
void unregister_handler (Handler &handler)
 Unregister a class instance that was previously registered with interrupt::register_handler. More...
 

Detailed Description

Defines API to handle AVR interruptions.

In particular, the following API are provided:

  • generically handle interrupts callbacks
  • handle external interrupt pins
  • handle pin change interrupts

Typedef Documentation

◆ PCI_SIGNAL

template<board::InterruptPin PIN>
using interrupt::PCI_SIGNAL = typedef typename PCIType<PIN>::TYPE

Useful alias type to the PCISignal type matching a given board::InterruptPin.

The following snippet demonstrates usage of PCI_SIGNAL to declare a PCISignal instance for later use in a function:

void f()
{
constexpr const board::InterruptPin PIN = board::InterruptPin::D7;
pci.enable_pin<PIN>();
pci.enable();
...
pci.disable();
}
InterruptPin
Defines all digital output pins of target MCU, usable as pin change interrupt (PCI) pins.
Definition: empty.h:98
typename PCIType< PIN >::TYPE PCI_SIGNAL
Useful alias type to the PCISignal type matching a given board::InterruptPin.
Definition: pci.h:568
See also
PCISignal
PCIType

Definition at line 568 of file pci.h.

◆ PCI_PORT_SIGNAL

template<board::Port PORT>
using interrupt::PCI_PORT_SIGNAL = typedef PCISignal<board_traits::Port_trait<PORT>::PCINT>

Convert a board::PORT to the matching PCISignal.

Definition at line 574 of file pci.h.

Enumeration Type Documentation

◆ InterruptTrigger

enum class interrupt::InterruptTrigger : uint8_t
strong

Kind of change that will trigger an External Interrupt for a given pin.

Actual uint8_t value matches the related mask for EICR, for up to 4 EXT pins (2 bits per pin), hence the 2-bits value is repeated 4 times.

Enumerator
LOW_LEVEL 

Interrupt is triggered whenever pin level is low.

ANY_CHANGE 

Interrupt is triggered whenever pin level is changing (rising or falling).

FALLING_EDGE 

Interrupt is triggered whenever pin level is falling from high to low.

RISING_EDGE 

Interrupt is triggered whenever pin level is rising from low to high.

Definition at line 106 of file int.h.

Function Documentation

◆ register_handler()

template<typename Handler >
void interrupt::register_handler ( Handler &  handler)

Register a class instance containing methods that shall be called back by an ISR.

The class and member function shall be passed to one of REGISTER_XXXX_ISR_METHOD() macros proposed by various FastArduino API, e.g. REGISTER_WATCHDOG_ISR_METHOD(). The same class may have different methods to handle different ISR callbacks.

Warning
you can register different classes, but only one instance of a given class at one time.
Template Parameters
Handlerthe class containing callback methods
Parameters
handlerthe Handler instance which methods will be called back by registered ISR.
See also
unregister_handler()

Definition at line 185 of file interrupts.h.

◆ unregister_handler()

template<typename Handler >
void interrupt::unregister_handler ( Handler &  handler)

Unregister a class instance that was previously registered with interrupt::register_handler.

Note
unregistration will be effective only if handler is the current value held for Handler type.
Warning
in normal circumstances (ISR callback registration) it is unlikely you would need this method because it would crash the ISR needing a callback! This method would be rather used for future::Future callbacks for which lifetime may not be as long as for an ISR.
Template Parameters
Handlerthe class containing callback methods
Parameters
handlerthe Handler instance to be deregistered.
See also
register_handler()

Definition at line 207 of file interrupts.h.