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 if … busy = 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.