Interrupt Pin#
Hardware Interface#
Defined in namespace hal
#include <libhal/interrupt_pin.hpp>
-
class interrupt_pin#
Digital interrupt pin hardware abstraction.
Use this to automatically call a function when a pinβs state has transitioned.
The transition states are:
falling edge: the pin reads a transitions from HIGH to LOW
rising edge: the pin reads a transitions from LOW to HIGH
both: the pin reads any state change
Subclassed by hal::soft::inert_interrupt_pin
Public Types
-
enum class trigger_edge#
The condition in which an interrupt itβs triggered.
Values:
-
enumerator falling#
Trigger the interrupt when a pin transitions from HIGH voltage to LOW voltage.
-
enumerator rising#
Trigger the interrupt when a pin transitions from LOW voltage to HIGH voltage.
-
enumerator both#
Trigger the interrupt when a pin transitions it state.
-
enumerator falling#
-
using handler = void(bool p_state)#
Interrupt pin handler.
param p_state - if true state of the pin when the interrupt was triggered was HIGH, otherwise LOW
Public Functions
-
struct settings#
Generic settings for interrupt pins.
Public Members
-
pin_resistor resistor = pin_resistor::pull_up#
Pull resistor for an interrupt pin.
In general, it is highly advised to either set the pull resistor to something other than βnoneβ or to attach an external pull up resistor to the interrupt pin in order to prevent random interrupt from firing.
-
trigger_edge trigger = trigger_edge::rising#
The trigger condition that will signal the system to run the callback.
-
pin_resistor resistor = pin_resistor::pull_up#
Utilities#
Defined in namespace hal
#include <libhal-util/interrupt_pin.hpp>
- group InterruptPin
Functions
-
constexpr auto operator==(const interrupt_pin::settings &p_lhs, const interrupt_pin::settings &p_rhs)#
Compares two interrupt pin states, compares both their trigger and resistor.
- Parameters:
p_lhs β An interrupt pin
p_rhs β An interrupt pin
- Returns:
A boolean if they are the same or not.
-
constexpr auto operator==(const interrupt_pin::settings &p_lhs, const interrupt_pin::settings &p_rhs)#