mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user