mirror of https://github.com/ArduPilot/ardupilot
AP_HAL: GPIO: PWMSource: add destructor to detach interurupt
This commit is contained in:
parent
54a9239e62
commit
36498cb4a0
|
@ -6,6 +6,15 @@
|
||||||
|
|
||||||
extern const AP_HAL::HAL& hal;
|
extern const AP_HAL::HAL& hal;
|
||||||
|
|
||||||
|
AP_HAL::PWMSource::~PWMSource()
|
||||||
|
{
|
||||||
|
if (interrupt_attached) {
|
||||||
|
// Assume this is always successful
|
||||||
|
hal.gpio->detach_interrupt(_pin);
|
||||||
|
interrupt_attached = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool AP_HAL::PWMSource::set_pin(int16_t new_pin, const char *subsystem)
|
bool AP_HAL::PWMSource::set_pin(int16_t new_pin, const char *subsystem)
|
||||||
{
|
{
|
||||||
if (new_pin == _pin) {
|
if (new_pin == _pin) {
|
||||||
|
|
|
@ -19,6 +19,9 @@ public:
|
||||||
class AP_HAL::PWMSource {
|
class AP_HAL::PWMSource {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
// Destructor detaches interrupt
|
||||||
|
~PWMSource();
|
||||||
|
|
||||||
bool set_pin(int16_t new_pin, const char *subsystem);
|
bool set_pin(int16_t new_pin, const char *subsystem);
|
||||||
int16_t pin() const { return _pin; } // returns pin this is attached to
|
int16_t pin() const { return _pin; } // returns pin this is attached to
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue