1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-09-02 19:02:35 +02:00

Changed ISR registration in ControlPin to class member registration.

This commit is contained in:
Stefan de Bruijn
2021-05-25 11:07:31 +02:00
parent 0de9f12c3a
commit 6eac36c66f
2 changed files with 11 additions and 13 deletions

View File

@@ -8,15 +8,12 @@
void IRAM_ATTR ControlPin::handleISR() {
bool pinState = _pin.read();
_value = pinState;
if (_rtVariable) {
*_rtVariable = pinState;
}
}
void /* IRAM_ATTR */ ControlPin::handle_control_pin(void* arg) {
((ControlPin*)arg)->handleISR();
}
void ControlPin::init() {
if (_pin.defined()) {
grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "%s switch on pin %s", _legend, _pin.name());
@@ -25,6 +22,6 @@ void ControlPin::init() {
attr = attr | Pin::Attr::PullUp;
}
_pin.setAttr(attr);
_pin.attachInterrupt(ControlPin::handle_control_pin, CHANGE, (void*)this);
_pin.attachInterrupt<ControlPin, &ControlPin::handleISR>(this, CHANGE);
}
}

View File

@@ -11,14 +11,15 @@ private:
const char _letter;
volatile bool* _rtVariable;
const char* _legend;
void IRAM_ATTR handleISR();
static void /* IRAM_ATTR */ handle_control_pin(void* arg);
public:
ControlPin(uint8_t bitNum, volatile bool* rtVariable, const char* legend, char letter) :
_invertBitNum(bitNum), _value(false), _letter(letter), _rtVariable(rtVariable), _legend(legend) {}
Pin _pin;
bool get() { return _value; }
const char* legend() { return _legend; }
// char invertBitNum() { return _invertBitNum; }