WPILibC++ 2023.4.3-108-ge5452e3
frc::SynchronousInterrupt Class Reference

Class for handling synchronous (blocking) interrupts. More...

#include <frc/SynchronousInterrupt.h>

Public Types

enum  WaitResult { kTimeout = 0x0 , kRisingEdge = 0x1 , kFallingEdge = 0x100 , kBoth = 0x101 }
 Event trigger combinations for a synchronous interrupt. More...
 

Public Member Functions

 SynchronousInterrupt (DigitalSource &source)
 Construct a Synchronous Interrupt from a Digital Source. More...
 
 SynchronousInterrupt (DigitalSource *source)
 Construct a Synchronous Interrupt from a Digital Source. More...
 
 SynchronousInterrupt (std::shared_ptr< DigitalSource > source)
 Construct a Synchronous Interrupt from a Digital Source. More...
 
 ~SynchronousInterrupt ()
 
 SynchronousInterrupt (SynchronousInterrupt &&)=default
 
SynchronousInterruptoperator= (SynchronousInterrupt &&)=default
 
WaitResult WaitForInterrupt (units::second_t timeout, bool ignorePrevious=true)
 Wait for an interrupt to occur. More...
 
void SetInterruptEdges (bool risingEdge, bool fallingEdge)
 Set which edges cause an interrupt to occur. More...
 
units::second_t GetRisingTimestamp ()
 Get the timestamp (relative to FPGA Time) of the last rising edge. More...
 
units::second_t GetFallingTimestamp ()
 Get the timestamp of the last falling edge. More...
 
void WakeupWaitingInterrupt ()
 Wake up an existing wait call. More...
 

Detailed Description

Class for handling synchronous (blocking) interrupts.

By default, interrupts will occur on rising edge.

Asynchronous interrupts are handled by the AsynchronousInterrupt class.

Member Enumeration Documentation

◆ WaitResult

Event trigger combinations for a synchronous interrupt.

Enumerator
kTimeout 
kRisingEdge 
kFallingEdge 
kBoth 

Constructor & Destructor Documentation

◆ SynchronousInterrupt() [1/4]

frc::SynchronousInterrupt::SynchronousInterrupt ( DigitalSource source)
explicit

Construct a Synchronous Interrupt from a Digital Source.

Parameters
sourcethe DigitalSource the interrupts are triggered from

◆ SynchronousInterrupt() [2/4]

frc::SynchronousInterrupt::SynchronousInterrupt ( DigitalSource source)
explicit

Construct a Synchronous Interrupt from a Digital Source.

Parameters
sourcethe DigitalSource the interrupts are triggered from

◆ SynchronousInterrupt() [3/4]

frc::SynchronousInterrupt::SynchronousInterrupt ( std::shared_ptr< DigitalSource source)
explicit

Construct a Synchronous Interrupt from a Digital Source.

Parameters
sourcethe DigitalSource the interrupts are triggered from

◆ ~SynchronousInterrupt()

frc::SynchronousInterrupt::~SynchronousInterrupt ( )

◆ SynchronousInterrupt() [4/4]

frc::SynchronousInterrupt::SynchronousInterrupt ( SynchronousInterrupt &&  )
default

Member Function Documentation

◆ GetFallingTimestamp()

units::second_t frc::SynchronousInterrupt::GetFallingTimestamp ( )

Get the timestamp of the last falling edge.

This function does not require the interrupt to be enabled to work.

This only works if falling edge was configured using setInterruptEdges.

Returns
the timestamp in seconds relative to getFPGATime

◆ GetRisingTimestamp()

units::second_t frc::SynchronousInterrupt::GetRisingTimestamp ( )

Get the timestamp (relative to FPGA Time) of the last rising edge.

Returns
the timestamp in seconds relative to getFPGATime

◆ operator=()

SynchronousInterrupt & frc::SynchronousInterrupt::operator= ( SynchronousInterrupt &&  )
default

◆ SetInterruptEdges()

void frc::SynchronousInterrupt::SetInterruptEdges ( bool  risingEdge,
bool  fallingEdge 
)

Set which edges cause an interrupt to occur.

Parameters
risingEdgetrue to trigger on rising edge, false otherwise.
fallingEdgetrue to trigger on falling edge, false otherwise

◆ WaitForInterrupt()

WaitResult frc::SynchronousInterrupt::WaitForInterrupt ( units::second_t  timeout,
bool  ignorePrevious = true 
)

Wait for an interrupt to occur.

Both rising and falling edge can be returned if both a rising and falling happened between calls, and ignorePrevious is false.

Parameters
timeoutThe timeout to wait for. 0s or less will return immediately.
ignorePreviousTrue to ignore any previous interrupts, false to return interrupt value if an interrupt has occurred since last call.
Returns
The edge(s) that were triggered, or timeout.

◆ WakeupWaitingInterrupt()

void frc::SynchronousInterrupt::WakeupWaitingInterrupt ( )

Wake up an existing wait call.

Can be called from any thread.


The documentation for this class was generated from the following file: