mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
Move interrupt methods to InterruptableSensorBase
Analog interrupts work again now, and RequestInterrupts is no longer duplicated three times. Change-Id: I5244b76262d7620852141cd21b2429d627636793
This commit is contained in:
@@ -72,54 +72,3 @@ bool AnalogTriggerOutput::GetAnalogTriggerForRouting()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request interrupts asynchronously on this analog trigger output.
|
||||
* @param handler The address of the interrupt handler function of type tInterruptHandler that
|
||||
* will be called whenever there is an interrupt on the digitial input port.
|
||||
* Request interrupts in synchronus mode where the user program interrupt handler will be
|
||||
* called when an interrupt occurs.
|
||||
*/
|
||||
void AnalogTriggerOutput::RequestInterrupts(InterruptHandlerFunction handler, void *param)
|
||||
{
|
||||
if (StatusIsFatal()) return;
|
||||
uint32_t index = m_interrupts->Allocate("Async Interrupt");
|
||||
if (index == ~0ul)
|
||||
{
|
||||
CloneError(m_interrupts);
|
||||
return;
|
||||
}
|
||||
m_interruptIndex = index;
|
||||
|
||||
AllocateInterrupts(false);
|
||||
|
||||
int32_t status = 0;
|
||||
requestInterrupts(m_interrupt, GetModuleForRouting(), GetChannelForRouting(),
|
||||
GetAnalogTriggerForRouting(), &status);
|
||||
attachInterruptHandler(m_interrupt, handler, param, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
* Request interrupts synchronously on this analog trigger output.
|
||||
* Request interrupts in asynchronus mode where the user program will have to
|
||||
* explicitly wait for the interrupt to occur.
|
||||
*/
|
||||
void AnalogTriggerOutput::RequestInterrupts()
|
||||
{
|
||||
if (StatusIsFatal()) return;
|
||||
uint32_t index = m_interrupts->Allocate("Sync Interrupt");
|
||||
if (index == ~0ul)
|
||||
{
|
||||
CloneError(m_interrupts);
|
||||
return;
|
||||
}
|
||||
m_interruptIndex = index;
|
||||
|
||||
AllocateInterrupts(true);
|
||||
|
||||
int32_t status = 0;
|
||||
requestInterrupts(m_interrupt, GetModuleForRouting(), GetChannelForRouting(),
|
||||
GetAnalogTriggerForRouting(), &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user