-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Update ticker to map closely to hardware #5028
Conversation
16258ad
to
f644020
Compare
/morph test |
Result: FAILUREYour command has finished executing! Here's what you wrote!
OutputTest failed! |
f644020
to
31189f2
Compare
/morph test-nightly |
Result: FAILUREYour command has finished executing! Here's what you wrote!
OutputTest failed! |
Please look at failures, tickers mostly
👍 for the info structure addition, still pending reviews |
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.
Quite happy with that change, it really remove all the conversion and overflow bookkeeping from target code.
I would ask for another review to ensure nothing has been missed.
hal/mbed_ticker_api.c
Outdated
uint32_t frequency = info->frequency; | ||
if (info->frequency == 0) { | ||
MBED_ASSERT(0); | ||
frequency = 1; |
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.
100000 ?
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.
I'll update this to default to 1MHz rather than 1Hz.
hal/mbed_ticker_api.c
Outdated
MBED_ASSERT(0); | ||
bits = 32; | ||
} | ||
uint32_t max_delta = 0x7 << (bits - 4); // 7/16th |
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.
If bits is less than 3 this operation is undefined. Might be worthy to constraint bits in the range [32:4].
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.
done
hal/mbed_ticker_api.c
Outdated
return; | ||
} | ||
|
||
uint64_t new_ticks = (ticker_time - queue->tick_last_read) & queue->bitmask; |
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.
I'd use the wording elapsed_ticks
and elapsed_us
which seems to me more precise but I might be completely wrong here 😄 .
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.
sound good. I updated the variables
PR #5096 is needed before testing will pass on this PR. This is because |
31189f2
to
37fcaf8
Compare
Addressed @pan-'s comments and rebased to master |
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.
Should we add here now that deep sleep locking info?
hal/ticker_api.h
Outdated
uint64_t max_delta_us; /**< Largest delta in us that can be used when scheduling */ | ||
uint32_t tick_last_read; /**< Last tick read */ | ||
uint64_t tick_remainder; /**< Ticks that have not been added to base_time */ | ||
us_timestamp_t base_time; |
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.
why are we missing docs for base time? I dont see base_time used anywhere in this patch.
what are units for max delta (might not be that clear diff vs max_delta_us for someone?).
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.
This wasn't actually being used so I removed it. I also updated the comments next to max_delta to indicate that the delta was in ticks.
8225481
to
3ecba30
Compare
separate PR. |
hal/mbed_ticker_api.c
Outdated
if (match_tick > prev_tick) { | ||
return (cur_tick >= match_tick) || (cur_tick < prev_tick); | ||
} else { | ||
return (cur_tick < match_tick) && (cur_tick >= prev_tick); |
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.
If match_tick <= prev_tick, how could prev_tick <= cur_tick < match_tick?
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.
Good catch! This is a bug.
3ecba30
to
6712718
Compare
Rebased to master and fixed ticker mismatch calculation. Diff for the new changes can be found in 6712718 |
/morph test-nightly |
Result: FAILUREYour command has finished executing! Here's what you wrote!
OutputTest failed! |
Result: FAILUREYour command has finished executing! Here's what you wrote!
OutputTest failed! |
Result: FAILUREYour command has finished executing! Here's what you wrote!
OutputTest failed! |
Result: FAILUREYour command has finished executing! Here's what you wrote!
OutputTest failed! |
Result: FAILUREYour command has finished executing! Here's what you wrote!
OutputTest failed! |
Besides couple of nightly runs, I reviewed few, |
This PR won't pass testing without #5242 |
@c1728p9 It looks like this needs a rebase. |
Allow tickers to specify their native frequency and number of bits. This allows the conversion to happen in common code rather than in each vendor's implementation.
Add optimizations for the most common use cases of the us ticker, 1MHz, and the lp ticker, 32KHz.
Add weak implementations of *_ticker_get_info which returns 1MHz and a width of 32 bits. This allows the updated Ticker API to work with existing devices. Note - in the future when all targets have implemented *_ticker_get_info these weak functions will be removed.
Increase the hal ticker test time from 30s to 60s to prevent a timeout from occurring on slower devices, such as the nrf51.
9f5b922
to
77dd420
Compare
rebased onto master |
cc @bulislaw @scartmell-arm |
/morph test-nightly |
retest uvisor |
Result: SUCCESSYour command has finished executing! Here's what you wrote!
OutputAll builds and test passed! |
It is now ready for integration. @c1728p9 This is backward compatible, thus not required to be minor, is that correct? |
Hi @0xc0170, yes this is backwards compatible. |
@AnotherButler More new APIs here. |
Build : ABORTEDBuild number : 87 |
@theotherjimmy Thanks. I've made a note of that and talked to @c1728p9 about docs. This should not affect this PR being merged. |
Allow tickers to specify their native frequency and number of bits. This allows the conversion to happen in common code rather than in each vendor's implementation.