diff options
author | David Crocker <dcrocker@eschertech.com> | 2021-01-31 17:09:00 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2021-01-31 17:09:00 +0300 |
commit | 0d7b6c9a443aaaa610bfae2fcb218c47ffc94c24 (patch) | |
tree | 99dcaf6ccc40220bcd1c8648fb0b9f608ff40037 /src/InputMonitors | |
parent | f4735c0104b643e060a1ee4c1c6fafa075d76e75 (diff) |
Don't try to enable a pin interrupt when the ATE creates a handle
Diffstat (limited to 'src/InputMonitors')
-rw-r--r-- | src/InputMonitors/InputMonitor.cpp | 9 | ||||
-rw-r--r-- | src/InputMonitors/InputMonitor.h | 2 |
2 files changed, 6 insertions, 5 deletions
diff --git a/src/InputMonitors/InputMonitor.cpp b/src/InputMonitors/InputMonitor.cpp index a59ce075..5bc4a97e 100644 --- a/src/InputMonitors/InputMonitor.cpp +++ b/src/InputMonitors/InputMonitor.cpp @@ -18,7 +18,7 @@ InputMonitor * volatile InputMonitor::monitorsList = nullptr; InputMonitor * volatile InputMonitor::freeList = nullptr; ReadWriteLock InputMonitor::listLock; -bool InputMonitor::Activate() noexcept +bool InputMonitor::Activate(bool useInterrupt) noexcept { bool ok = true; if (!active) @@ -27,7 +27,7 @@ bool InputMonitor::Activate() noexcept { // Digital input const irqflags_t flags = cpu_irq_save(); - ok = port.AttachInterrupt(CommonDigitalPortInterrupt, InterruptMode::change, CallbackParameter(this)); + ok = !useInterrupt || port.AttachInterrupt(CommonDigitalPortInterrupt, InterruptMode::change, CallbackParameter(this)); state = port.ReadDigital(); cpu_irq_restore(flags); } @@ -170,7 +170,8 @@ void InputMonitor::AnalogInterrupt(uint16_t reading) noexcept { newMonitor->next = monitorsList; monitorsList = newMonitor; - const bool ok = newMonitor->Activate(); + // Pins used only by the ATE may not have interrupts, and the ATE doesn't need interrupts from them + const bool ok = newMonitor->Activate(msg.handle.u.parts.type != RemoteInputHandle::typeAte); extra = (newMonitor->state) ? 1 : 0; if (!ok) { @@ -211,7 +212,7 @@ void InputMonitor::AnalogInterrupt(uint16_t reading) noexcept switch (msg.action) { case CanMessageChangeInputMonitor::actionDoMonitor: - rslt = (m->Activate()) ? GCodeResult::ok : GCodeResult::error; + rslt = (m->Activate(true)) ? GCodeResult::ok : GCodeResult::error; break; case CanMessageChangeInputMonitor::actionDontMonitor: diff --git a/src/InputMonitors/InputMonitor.h b/src/InputMonitors/InputMonitor.h index 3e127c93..43ee12eb 100644 --- a/src/InputMonitors/InputMonitor.h +++ b/src/InputMonitors/InputMonitor.h @@ -38,7 +38,7 @@ public: static void CommonAnalogPortInterrupt(CallbackParameter cbp, uint16_t reading) noexcept; private: - bool Activate() noexcept; + bool Activate(bool useInterrupt) noexcept; void Deactivate() noexcept; void DigitalInterrupt() noexcept; void AnalogInterrupt(uint16_t reading) noexcept; |