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:
Thomas Clark
2014-10-08 14:52:24 -04:00
parent dc09233fca
commit 4d2a720f47
9 changed files with 83 additions and 214 deletions

View File

@@ -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));
}