diff --git a/src/uEncoderISR.h b/src/uEncoderISR.h index 2163400..f49fa5a 100644 --- a/src/uEncoderISR.h +++ b/src/uEncoderISR.h @@ -19,9 +19,12 @@ class uEncoderISR : public uEncoderVirt { noInterrupts(); uint8_t state = _buf & 0xf; _buf >>= 4; + // _state лежит в одном байте с _e0/_e1, а их пишет tickISR. Запись + // битового поля это read-modify-write всего байта, поэтому вне + // критической секции прерывание потеряет своё обновление ног + _state = state ? state : State::Idle; interrupts(); - _state = state ? state : State::Idle; return state; }