Fixed interrupt freeing in C++

When interrupts are cancelled on any interruptable class, the resource is now
freed.  Previously, the resource was only freed if the object is destructed
before CancelInterrupts() is called, so it was impossible to create and
destruct more than 8 interrupts.

The interrupts resource object is now in InterruptableSensorBase instead of
SensorBase.

A synchronous interrupt integration test was added.

Change-Id: I0806176340cecd4c1480dd8f043474cc05919f24
This commit is contained in:
Thomas Clark
2014-08-06 09:46:50 -04:00
parent a09f75934a
commit 2356008d8c
5 changed files with 34 additions and 6 deletions

View File

@@ -7,9 +7,12 @@
#include "InterruptableSensorBase.h"
#include "Utility.h"
Resource *InterruptableSensorBase::m_interrupts = NULL;
InterruptableSensorBase::InterruptableSensorBase()
{
m_interrupt = NULL;
Resource::CreateResourceObject(&m_interrupts, interrupt_kNumSystems);
}
InterruptableSensorBase::~InterruptableSensorBase()
@@ -37,6 +40,7 @@ void InterruptableSensorBase::CancelInterrupts()
cleanInterrupts(m_interrupt, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
m_interrupt = NULL;
m_interrupts->Free(m_interruptIndex);
}
/**