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

General API for handling External Interrupt pins. More...

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

Go to the source code of this file.

Classes

class  interrupt::INTSignal< EXTPIN_ >
 Handler of an External Interrupt. More...
 

Namespaces

namespace  board
 Defines all types and constants specific to support a specific MCU target.
 
namespace  interrupt
 Defines API to handle AVR interruptions.
 

Macros

#define REGISTER_INT_ISR_METHOD(INT_NUM, PIN, HANDLER, CALLBACK)
 Register the necessary ISR (Interrupt Service Routine) for an External Interrupt pin. More...
 
#define REGISTER_INT_ISR_FUNCTION(INT_NUM, PIN, CALLBACK)
 Register the necessary ISR (Interrupt Service Routine) for an External Interrupt pin. More...
 
#define REGISTER_INT_ISR_EMPTY(INT_NUM, PIN)
 Register an empty ISR (Interrupt Service Routine) for an External Interrupt pin. More...
 
#define DECL_INT_ISR_HANDLERS_FRIEND
 This macro shall be used in a class containing a private callback method, registered by REGISTER_INT_ISR_METHOD. More...
 

Enumerations

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

Functions

template<ExternalInterruptPin EXT>
constexpr DigitalPin board::EXT_PIN ()
 Convert an ExternalInterruptPin to the matching DigitalPin. More...
 

Detailed Description

General API for handling External Interrupt pins.

Definition in file int.h.

Macro Definition Documentation

◆ REGISTER_INT_ISR_METHOD

#define REGISTER_INT_ISR_METHOD (   INT_NUM,
  PIN,
  HANDLER,
  CALLBACK 
)
Value:
ISR(CAT3(INT, INT_NUM, _vect)) \
{ \
interrupt::isr_handler_int::int_method<INT_NUM, PIN, HANDLER, CALLBACK>(); \
}

Register the necessary ISR (Interrupt Service Routine) for an External Interrupt pin.

Parameters
INT_NUMthe number of the INT vector for this PIN
PINthe board::ExternalInterruptPin for INT_NUM; if PIN and INT_NUM do not match, compilation will fail.
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).

Definition at line 39 of file int.h.

◆ REGISTER_INT_ISR_FUNCTION

#define REGISTER_INT_ISR_FUNCTION (   INT_NUM,
  PIN,
  CALLBACK 
)
Value:
ISR(CAT3(INT, INT_NUM, _vect)) \
{ \
interrupt::isr_handler_int::int_function<INT_NUM, PIN, CALLBACK>(); \
}

Register the necessary ISR (Interrupt Service Routine) for an External Interrupt pin.

Parameters
INT_NUMthe number of the INT vector for this PIN
PINthe board::ExternalInterruptPin for INT_NUM; if PIN and INT_NUM do not match, compilation will fail.
CALLBACKthe function that will be called when the interrupt is triggered

Definition at line 54 of file int.h.

◆ REGISTER_INT_ISR_EMPTY

#define REGISTER_INT_ISR_EMPTY (   INT_NUM,
  PIN 
)
Value:
extern "C" void CAT3(INT, INT_NUM, _vect)(void) NAKED_SIGNAL; \
void CAT3(INT, INT_NUM, _vect)(void) \
{ \
interrupt::isr_handler_int::check_int_pin<INT_NUM, PIN>(); \
__asm__ __volatile__("reti" ::); \
}
#define NAKED_SIGNAL
Specific GCC attribute for AVR target, declaring a signal handler (aka ISR, or Interrupt Service Rout...
Definition: defines.h:91

Register an empty ISR (Interrupt Service Routine) for an External Interrupt pin.

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
INT_NUMthe number of the INT vector for this PIN
PINthe board::ExternalInterruptPin for INT_NUM; if PIN and INT_NUM do not match, compilation will fail.

Definition at line 69 of file int.h.

◆ DECL_INT_ISR_HANDLERS_FRIEND

#define DECL_INT_ISR_HANDLERS_FRIEND
Value:
friend struct interrupt::isr_handler_int; \
DECL_INT_ISR_FRIENDS

This macro shall be used in a class containing a private callback method, registered by REGISTER_INT_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 83 of file int.h.