mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21: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:
@@ -222,78 +222,6 @@ bool DigitalOutput::GetAnalogTriggerForRouting()
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request interrupts asynchronously on this digital 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 output port.
|
||||
* Request interrupts in synchronus mode where the user program interrupt handler will be
|
||||
* called when an interrupt occurs.
|
||||
* The default is interrupt on rising edges only.
|
||||
*/
|
||||
void DigitalOutput::RequestInterrupts(InterruptHandlerFunction handler, void *param)
|
||||
{
|
||||
if (StatusIsFatal()) return;
|
||||
uint32_t index = m_interrupts->Allocate("Sync Interrupt");
|
||||
if (index == ~0ul)
|
||||
{
|
||||
CloneError(m_interrupts);
|
||||
return;
|
||||
}
|
||||
m_interruptIndex = index;
|
||||
|
||||
// Creates a manager too
|
||||
AllocateInterrupts(false);
|
||||
|
||||
int32_t status = 0;
|
||||
requestInterrupts(m_interrupt, 1, GetChannelForRouting(),
|
||||
GetAnalogTriggerForRouting(), &status);
|
||||
SetUpSourceEdge(true, false);
|
||||
attachInterruptHandler(m_interrupt, handler, param, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
* Request interrupts synchronously on this digital output.
|
||||
* Request interrupts in synchronus mode where the user program will have to explicitly
|
||||
* wait for the interrupt to occur.
|
||||
* The default is interrupt on rising edges only.
|
||||
*/
|
||||
void DigitalOutput::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));
|
||||
SetUpSourceEdge(true, false);
|
||||
}
|
||||
|
||||
void DigitalOutput::SetUpSourceEdge(bool risingEdge, bool fallingEdge)
|
||||
{
|
||||
if (StatusIsFatal()) return;
|
||||
if (m_interrupt == NULL)
|
||||
{
|
||||
wpi_setWPIErrorWithContext(NullParameter, "You must call RequestInterrupts before SetUpSourceEdge");
|
||||
return;
|
||||
}
|
||||
if (m_interrupt != NULL)
|
||||
{
|
||||
int32_t status = 0;
|
||||
setInterruptUpSourceEdge(m_interrupt, risingEdge, fallingEdge, &status);
|
||||
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
}
|
||||
}
|
||||
|
||||
void DigitalOutput::ValueChanged(ITable* source, const std::string& key, EntryValue value, bool isNew) {
|
||||
Set(value.b);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user