Allow delayed ESM state-change #204
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Keep pending AL-Control-Event flag in ESCvar so a state-change request does not need to be serviced immediately. Also add an acknowledge-parameter to the pre_state_change()-callback which may be negated by the routine in order to postpone a state-change to the next run of the slave handler.
When AL-control request is asserted by master, the according AL-event flag is set by the ESC. The according AL-Event flag is cleared on reading the AL-Control register right at the top of ESC_state(); so the routine only ran once per AL-Control-Request. With the ESCvar.ALcontrol_pending flag, a not yet finished state-change allows running the state-change logic again until the state-change gets acknowledged by the pre_state_change() callback.
This approach allows SOES to service other requests (e.g. mailbox) while a state-change is pending.
Why ist this needed?
A slave that needs some time to become (Pre-)Operational, e.g. one that needs to accelerate a rotating mass before entering PreOp needs to be able to delay a state change without setting the ALerror bit