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

Analog Comparator API. More...

#include "boards/board_traits.h"
#include "interrupts.h"
#include "utilities.h"
Include dependency graph for analog_comparator.h:

Go to the source code of this file.

Classes

class  analog::AnalogComparator
 Handler of the Analog Comparator feature. More...
 

Namespaces

 analog
 Defines all API to manipulate analog input/output.
 

Macros

#define REGISTER_ANALOG_COMPARE_ISR_FUNCTION(CALLBACK)
 Register the necessary ISR (Interrupt Service Routine) that will be notified whenever an analog::AnalogComparator interrupt is triggered. More...
 
#define REGISTER_ANALOG_COMPARE_ISR_METHOD(HANDLER, CALLBACK)
 Register the necessary ISR (Interrupt Service Routine) that will be notified whenever an analog::AnalogComparator interrupt is triggered. More...
 
#define REGISTER_ANALOG_COMPARE_ISR_EMPTY()   EMPTY_INTERRUPT(ANALOG_COMP_vect)
 Register an empty ISR (Interrupt Service Routine) for analog::AnalogComparator interrupts. More...
 
#define DECL_ANALOG_COMPARE_ISR_HANDLERS_FRIEND   friend void ::ANALOG_COMP_vect(void);
 This macro shall be used in a class containing a private callback method, registered by REGISTER_ANALOG_COMPARE_ISR_METHOD. More...
 

Enumerations

enum  analog::ComparatorInterrupt : uint8_t {
  analog::ComparatorInterrupt::NONE = bits::BV8(ACI),
  analog::ComparatorInterrupt::TOGGLE = bits::BV8(ACI, ACIE),
  analog::ComparatorInterrupt::FALLING_EDGE = bits::BV8(ACI, ACIE, ACIS1),
  analog::ComparatorInterrupt::RISING_EDGE = bits::BV8(ACI, ACIE, ACIS1, ACIS0)
}
 Kind of change that will trigger an Analog Comparator Interrupt. More...
 

Detailed Description

Analog Comparator API.

Definition in file analog_comparator.h.

Macro Definition Documentation

◆ REGISTER_ANALOG_COMPARE_ISR_FUNCTION

#define REGISTER_ANALOG_COMPARE_ISR_FUNCTION (   CALLBACK)
Value:
ISR(ANALOG_COMP_vect) \
{ \
CALLBACK(); \
}

Register the necessary ISR (Interrupt Service Routine) that will be notified whenever an analog::AnalogComparator interrupt is triggered.

Parameters
CALLBACKthe function that will be called when the interrupt is triggered
See also
analog::AnalogComparator

Definition at line 37 of file analog_comparator.h.

◆ REGISTER_ANALOG_COMPARE_ISR_METHOD

#define REGISTER_ANALOG_COMPARE_ISR_METHOD (   HANDLER,
  CALLBACK 
)
Value:
ISR(ANALOG_COMP_vect) \
{ \
interrupt::CallbackHandler<void (HANDLER::*)(), CALLBACK>::call(); \
}

Register the necessary ISR (Interrupt Service Routine) that will be notified whenever an analog::AnalogComparator interrupt is triggered.

Parameters
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).
See also
analog::AnalogComparator

Definition at line 53 of file analog_comparator.h.

◆ REGISTER_ANALOG_COMPARE_ISR_EMPTY

#define REGISTER_ANALOG_COMPARE_ISR_EMPTY ( )    EMPTY_INTERRUPT(ANALOG_COMP_vect)

Register an empty ISR (Interrupt Service Routine) for analog::AnalogComparator interrupts.

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.

See also
analog::AnalogComparator

Definition at line 67 of file analog_comparator.h.

◆ DECL_ANALOG_COMPARE_ISR_HANDLERS_FRIEND

#define DECL_ANALOG_COMPARE_ISR_HANDLERS_FRIEND   friend void ::ANALOG_COMP_vect(void);

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