FastArduino  v1.7
C++ library to build fast but small Arduino/AVR projects
pci.h File Reference

General API for handling Pin Change Interrupts. More...

#include "boards/board.h"
#include "boards/board_traits.h"
#include <avr/interrupt.h>
#include "interrupts.h"
#include "utilities.h"
Include dependency graph for pci.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  interrupt::PCISignal< PCINT_ >
 Handler of a Pin Change Interrupt vector. More...
 
struct  interrupt::PCIType< PIN >
 Helper class that easily converts a PIN into the right PCISignal. More...
 

Namespaces

 board
 Defines all types and constants specific to support Arduino MEGA board (ATmega644 MCU target).
 
 interrupt
 Defines API to handle AVR interruptions.
 

Macros

#define REGISTER_PCI_ISR_METHOD(PCI_NUM, HANDLER, CALLBACK, PIN, ...)
 Register the necessary ISR (Interrupt Service Routine) for a Pin Change Interrupt vector. More...
 
#define REGISTER_PCI_ISR_FUNCTION(PCI_NUM, CALLBACK, PIN, ...)
 Register the necessary ISR (Interrupt Service Routine) for a Pin Change Interrupt vector. More...
 
#define REGISTER_PCI_ISR_EMPTY(PCI_NUM, PIN, ...)
 Register an empty ISR (Interrupt Service Routine) for a Pin Change Interrupt vector. More...
 
#define DECL_PCI_ISR_HANDLERS_FRIEND
 This macro shall be used in a class containing a private callback method, registered by REGISTER_PCI_ISR_METHOD. More...
 

Typedefs

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

Functions

template<InterruptPin PCI>
constexpr DigitalPin board::PCI_PIN ()
 Convert an InterruptPin to the matching DigitalPin.
 

Detailed Description

General API for handling Pin Change Interrupts.

The basic principle is to instantiate one interrupt::PCI per PCINT vector you need to handle, whatever the number of pins you need in this PCINT. If you add a callback, it will be called for whatever pin may have changed state in the list of pins supported by your interrupt::PCI instance.

Definition in file pci.h.

Macro Definition Documentation

◆ REGISTER_PCI_ISR_METHOD

#define REGISTER_PCI_ISR_METHOD (   PCI_NUM,
  HANDLER,
  CALLBACK,
  PIN,
  ... 
)
Value:
ISR(CAT3(PCINT, PCI_NUM, _vect)) \
{ \
interrupt::isr_handler_pci::pci_method<PCI_NUM, HANDLER, CALLBACK, PIN, ##__VA_ARGS__>(); \
}

Register the necessary ISR (Interrupt Service Routine) for a Pin Change Interrupt vector.

Parameters
PCI_NUMthe number of the PCINT vector for the given PIN pins
HANDLERthe class holding the callback method
CALLBACKthe method of HANDLER that will be called when the interrupt is triggered; this must be a proper PTMF (pointer to member function).
PINthe board::InterruptPin pins for PCI_NUM; if any of the given PIN does not match with PCI_NUM, compilation will fail.

Definition at line 44 of file pci.h.

◆ REGISTER_PCI_ISR_FUNCTION

#define REGISTER_PCI_ISR_FUNCTION (   PCI_NUM,
  CALLBACK,
  PIN,
  ... 
)
Value:
ISR(CAT3(PCINT, PCI_NUM, _vect)) \
{ \
interrupt::isr_handler_pci::pci_function<PCI_NUM, CALLBACK, PIN, ##__VA_ARGS__>(); \
}

Register the necessary ISR (Interrupt Service Routine) for a Pin Change Interrupt vector.

Parameters
PCI_NUMthe number of the PCINT vector for the given PIN pins
CALLBACKthe function that will be called when the interrupt is triggered
PINthe board::InterruptPin pins for PCI_NUM; if any of the given PIN does not match with PCI_NUM, compilation will fail.

Definition at line 59 of file pci.h.

◆ REGISTER_PCI_ISR_EMPTY

#define REGISTER_PCI_ISR_EMPTY (   PCI_NUM,
  PIN,
  ... 
)
Value:
extern "C" void CAT3(PCINT, PCI_NUM, _vect)(void) NAKED_SIGNAL; \
void CAT3(PCINT, PCI_NUM, _vect)(void) \
{ \
interrupt::isr_handler_pci::check_pci_pins<PCI_NUM, PIN, ##__VA_ARGS__>(); \
__asm__ __volatile__("reti" ::); \
}

Register an empty ISR (Interrupt Service Routine) for a Pin Change Interrupt vector.

This can be useful if you just need to wake up the MCU from an external signal, but do not need to perform any sepcific stuff with a callback.

Parameters
PCI_NUMthe number of the PCINT vector for the given PIN pins
PINthe board::InterruptPin pins for PCI_NUM; if any of the given PIN does not match with PCI_NUM, compilation will fail.

Definition at line 74 of file pci.h.

◆ DECL_PCI_ISR_HANDLERS_FRIEND

#define DECL_PCI_ISR_HANDLERS_FRIEND
Value:
friend struct interrupt::isr_handler_pci; \
DECL_PCINT_ISR_FRIENDS

This macro shall be used in a class containing a private callback method, registered by REGISTER_PCI_ISR_METHOD.

It declares the class where it is used as a friend of all necessary functions so that the private callback method can be called properly.

Definition at line 88 of file pci.h.

NAKED_SIGNAL
#define NAKED_SIGNAL
Specific GCC attribute for AVR target, declaring a signal handler (aka ISR, or Interrupt Service Rout...
Definition: defines.h:96