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::inert_interrupt_pin, hal::lpc40::interrupt_pin, hal::mock::interrupt_pin, 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
-
inline void configure(settings const &p_settings)#
Configure the interrupt pin to match the settings supplied.
- Parameters:
p_settings β - settings to apply to interrupt pin
- Throws:
hal::operation_not_supported β - if the settings could not be achieved.
-
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