[Grbl_Esp32 PR#751] Fixed busy flag in Stepper.cpp by using an atomic compare/exchange op.

未分类 bolang 6个月前 (10-14) 48次浏览

Issue #751 | 状态: 已关闭 | 作者: atlaste | 创建时间: 2021-01-26


2 small changes. First added laser mode to null spindle for testing. It’s not interesting. The other is described below.

We basically have 2 calls to stepperpulsefunc, and we do NOT want concurrency there.

One of them is from I2S, which actually calls the function from a critical section (mutex). In other words, there is no issue there.
The other is from onStepperDriverTimer, which uses a busy flag to check if it’s already in use.

Even though busy was already volatile, that doesn’t mean that the ifbusy = true is atomic. Other threads might mess things up, so it’s better to just get it right. std::atomic with compareexchangestrong does exactly that.

原始Issue: https://github.com/bdring/Grbl_Esp32/pull/751

喜欢 (0)