mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-09-02 19:02:35 +02:00
Fixed a few bugs with ISR binding. Basically you should never call attachInterrupt
without an ISR setMode; the pin might not support it after all.
This commit is contained in:
@@ -77,10 +77,11 @@ void grbl_init() {
|
||||
WebUI::inputBuffer.begin();
|
||||
} catch (const AssertionFailed& ex) {
|
||||
// This means something is terribly broken:
|
||||
grbl_sendf(CLIENT_ALL, "Critical error in run_once: %s", ex.stackTrace.c_str());
|
||||
while (true) {
|
||||
sleep(1000);
|
||||
}
|
||||
|
||||
// Should grbl_sendf always work? Serial is initialized first, so after line 34 it should.
|
||||
grbl_msg_sendf(CLIENT_ALL, MsgLevel::Error, "Critical error in run_once: %s", ex.stackTrace.c_str());
|
||||
sleep(10000);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,10 +128,9 @@ void run_once() {
|
||||
protocol_main_loop();
|
||||
} catch (const AssertionFailed& ex) {
|
||||
// This means something is terribly broken:
|
||||
grbl_sendf(CLIENT_ALL, "Critical error in run_once: %s", ex.stackTrace.c_str());
|
||||
while (true) {
|
||||
sleep(1000);
|
||||
}
|
||||
grbl_msg_sendf(CLIENT_ALL, MsgLevel::Error, "Critical error in run_once: %s", ex.stackTrace.c_str());
|
||||
sleep(10000);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -309,10 +309,11 @@ uint8_t limit_mask = 0;
|
||||
|
||||
void limits_init() {
|
||||
limit_mask = 0;
|
||||
Pin::Attr mode = Pin::Attr::Input | Pin::Attr::PullUp;
|
||||
Pin::Attr mode = Pin::Attr::Input | Pin::Attr::PullUp | Pin::Attr::ISR;
|
||||
#ifdef DISABLE_LIMIT_PIN_PULL_UP
|
||||
mode = Pin::Attr::Input;
|
||||
mode = Pin::Attr::Input | Pin::Attr::ISR;
|
||||
#endif
|
||||
|
||||
auto n_axis = number_axis->get();
|
||||
for (int axis = 0; axis < n_axis; axis++) {
|
||||
for (int gang_index = 0; gang_index < 2; gang_index++) {
|
||||
|
@@ -177,7 +177,6 @@ const char* USER_ANALOG_PIN_2_DEFAULT = USER_ANALOG_PIN_2;
|
||||
#endif
|
||||
const char* USER_ANALOG_PIN_3_DEFAULT = USER_ANALOG_PIN_3;
|
||||
|
||||
|
||||
#ifndef SPINDLE_OUTPUT_PIN
|
||||
# define SPINDLE_OUTPUT_PIN UNDEFINED_PIN
|
||||
#endif
|
||||
|
@@ -143,6 +143,12 @@ namespace Pins {
|
||||
pinModeValue |= OUTPUT;
|
||||
}
|
||||
|
||||
// TODO FIXME: For now, I added PU capabilities to 'value' as well. This *should* be removed once the
|
||||
// code that uses #define's to decide this is gone.
|
||||
if (value.has(PinAttributes::PullUp)) {
|
||||
pinModeValue |= PULLUP;
|
||||
}
|
||||
|
||||
// PU/PD should be specified by the user. Code has nothing to do with them:
|
||||
if (_attributes.has(PinAttributes::PullUp)) {
|
||||
pinModeValue |= PULLUP;
|
||||
@@ -161,12 +167,14 @@ namespace Pins {
|
||||
}
|
||||
|
||||
void GPIOPinDetail::attachInterrupt(void (*callback)(void*), void* arg, int mode) {
|
||||
Assert(_capabilities.has(PinCapabilities::ISR), "Pin has no ISR capability defined. Cannot bind ISR.");
|
||||
Assert(_attributes.has(PinAttributes::ISR),
|
||||
"Pin has no ISR attribute, which means 'setAttr' was not set, or the pin doesn't support ISR's. Cannot bind ISR.");
|
||||
::attachInterruptArg(_index, callback, arg, mode);
|
||||
}
|
||||
|
||||
void GPIOPinDetail::detachInterrupt() {
|
||||
Assert(_capabilities.has(PinCapabilities::ISR), "Pin has no ISR capability defined. Cannot unbind ISR.");
|
||||
Assert(_attributes.has(PinAttributes::ISR),
|
||||
"Pin has no ISR attribute, which means 'setAttr' was not set, or the pin doesn't support ISR's. Cannot unbind ISR.");
|
||||
::detachInterrupt(_index);
|
||||
}
|
||||
|
||||
|
@@ -48,42 +48,42 @@ void system_ini() { // Renamed from system_init() due to conflict with esp32 fi
|
||||
// setup control inputs
|
||||
|
||||
if (ControlSafetyDoorPin->get() != Pin::UNDEFINED) {
|
||||
ControlSafetyDoorPin->get().setAttr(Pin::Attr::Input | Pin::Attr::PullUp);
|
||||
ControlSafetyDoorPin->get().setAttr(Pin::Attr::Input | Pin::Attr::PullUp | Pin::Attr::ISR);
|
||||
ControlSafetyDoorPin->get().attachInterrupt(isr_control_inputs, CHANGE);
|
||||
}
|
||||
|
||||
if (ControlResetPin->get() != Pin::UNDEFINED) {
|
||||
ControlResetPin->get().setAttr(Pin::Attr::Input | Pin::Attr::PullUp);
|
||||
ControlResetPin->get().setAttr(Pin::Attr::Input | Pin::Attr::PullUp | Pin::Attr::ISR);
|
||||
ControlResetPin->get().attachInterrupt(isr_control_inputs, CHANGE);
|
||||
}
|
||||
|
||||
if (ControlFeedHoldPin->get() != Pin::UNDEFINED) {
|
||||
ControlFeedHoldPin->get().setAttr(Pin::Attr::Input | Pin::Attr::PullUp);
|
||||
ControlFeedHoldPin->get().setAttr(Pin::Attr::Input | Pin::Attr::PullUp | Pin::Attr::ISR);
|
||||
ControlFeedHoldPin->get().attachInterrupt(isr_control_inputs, CHANGE);
|
||||
}
|
||||
|
||||
if (ControlCycleStartPin->get() != Pin::UNDEFINED) {
|
||||
ControlCycleStartPin->get().setAttr(Pin::Attr::Input | Pin::Attr::PullUp);
|
||||
ControlCycleStartPin->get().setAttr(Pin::Attr::Input | Pin::Attr::PullUp | Pin::Attr::ISR);
|
||||
ControlCycleStartPin->get().attachInterrupt(isr_control_inputs, CHANGE);
|
||||
}
|
||||
|
||||
if (MacroButton0Pin->get() != Pin::UNDEFINED) {
|
||||
MacroButton0Pin->get().setAttr(Pin::Attr::Input | Pin::Attr::PullUp);
|
||||
MacroButton0Pin->get().setAttr(Pin::Attr::Input | Pin::Attr::PullUp | Pin::Attr::ISR);
|
||||
MacroButton0Pin->get().attachInterrupt(isr_control_inputs, CHANGE);
|
||||
}
|
||||
|
||||
if (MacroButton1Pin->get() != Pin::UNDEFINED) {
|
||||
MacroButton1Pin->get().setAttr(Pin::Attr::Input | Pin::Attr::PullUp);
|
||||
MacroButton1Pin->get().setAttr(Pin::Attr::Input | Pin::Attr::PullUp | Pin::Attr::ISR);
|
||||
MacroButton1Pin->get().attachInterrupt(isr_control_inputs, CHANGE);
|
||||
}
|
||||
|
||||
if (MacroButton2Pin->get() != Pin::UNDEFINED) {
|
||||
MacroButton2Pin->get().setAttr(Pin::Attr::Input | Pin::Attr::PullUp);
|
||||
MacroButton2Pin->get().setAttr(Pin::Attr::Input | Pin::Attr::PullUp | Pin::Attr::ISR);
|
||||
MacroButton2Pin->get().attachInterrupt(isr_control_inputs, CHANGE);
|
||||
}
|
||||
|
||||
if (MacroButton3Pin->get() != Pin::UNDEFINED) {
|
||||
MacroButton3Pin->get().setAttr(Pin::Attr::Input | Pin::Attr::PullUp);
|
||||
MacroButton3Pin->get().setAttr(Pin::Attr::Input | Pin::Attr::PullUp | Pin::Attr::ISR);
|
||||
MacroButton3Pin->get().attachInterrupt(isr_control_inputs, CHANGE);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user