-
Notifications
You must be signed in to change notification settings - Fork 3k
STM32_us_ticker_16b: keep code to cope with past event #5012
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
cc @pan- |
What is this fixing? What regression was introduced ? I would keep the else part, but if delta is negative - should be handled by ticker implementation in the above layer ? |
@0xc0170 As explained in description, this fixes #5004. The test of #5004 works fine before merge of #4644 and fails just after => this is the regression. In us_ticker_set_interrupt we need to read timestamp again, so delta can be positive when read from above layer, then negative when reading again in us_ticker_set_interrupt. Therefore I think that we cannot get rid of this check. |
As this fixes a regression already introduced in a PR marked for 5.6, we need to also get this one in for 5.6. |
That reading is fine, but the first condtion could be removed. have you tested it with only |
@0xc0170 Before reverting the full function, I did the test with only the else part and the test fails. |
@0xc0170 actually this makes me think that maybe the same applies to us_ticker_32b.c except the probability is just very low ... |
as delta is only int (very short range), we do not know if it was in the past or in the future (it could have wrapped around by the time). We cleaned all targets , to remove this check, the upper layer does it and knows better as using 64bit timestamp. See https://github.com/ARMmbed/mbed-os/blob/master/hal/mbed_ticker_api.c#L120 . The set interrupt function should only receive positive deltas (new match timestamp is in the future, even very near future). Aren't we missing something else here? Fire interrupt does not touch oc int part, should it? @pan- What is your view on this one? |
Actually the condition of event being in the future in line 120 can have changed when line 129 is reached and the call is done, or even inside the set_interrupt function. BUT there is another sanity check few lines later here https://github.com/ARMmbed/mbed-os/blob/master/hal/mbed_ticker_api.c#L130 which does the job indeed. I first thought this may be buggy in some way, but ...
Good catch. oc_int part is the counter of 16bits wrap-ups until next interrupt must be triggered. When event is in the past or when we fire interrupt, this needs to be reset to 0. When fixing this in fire_intterrupt, the tests are PASSED again. I will update my PR accordingly. |
Fixing regression introduced in commit "Ticker: add fire interrupt now function". In above mentioned commit, the management of timestamp being in the past has been moved to higher layer (hal/mbed_ticker_api.c), but the reset of oc_int was missing when implementing the new us_ticker_fire_interrupt function - which is fixed now.
3704ff7
to
f2eb77a
Compare
@0xc0170 I just pushed the new version of the patch |
And Ticker tests passed ok |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@LMESTM 👍 Should be all OK, in case not, we should write a test (however mbed ticker API has extensive testing via mocks), and tick classes are now getting also test updates, teh coverage should increase soon |
/morph test |
Result: FAILUREYour command has finished executing! Here's what you wrote!
OutputExample Build failed! |
/morph test |
Result: ABORTEDYour command has finished executing! Here's what you wrote!
OutputBuild Prep failed! |
/morph test |
Result: SUCCESSYour command has finished executing! Here's what you wrote!
OutputAll builds and test passed! |
Description
Fixes test suggested in #5004.
Fixing regression introduced in commit
"Ticker: add fire interrupt now function".
In above mentioned commit, the management of timestamp being in the past
has been moved to higher layer (hal/mbed_ticker_api.c), but the reset of
oc_int was missing when implementing the new us_ticker_fire_interrupt
function - which is fixed now.
Status
READY
Todos