Skip to content
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

Merged
merged 4 commits into from
Oct 13, 2017

Conversation

c1728p9
Copy link
Contributor

@c1728p9 c1728p9 commented Sep 5, 2017

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.

@c1728p9
Copy link
Contributor Author

c1728p9 commented Sep 14, 2017

/morph test

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 1303

Test failed!

@c1728p9 c1728p9 changed the title Add support for various ticker implementations Update ticker to map closely to hardware Sep 19, 2017
@c1728p9
Copy link
Contributor Author

c1728p9 commented Sep 19, 2017

/morph test-nightly

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 1341

Test failed!

@0xc0170
Copy link
Contributor

0xc0170 commented Sep 20, 2017

Please look at failures, tickers mostly

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.

👍 for the info structure addition, still pending reviews

Copy link
Member

@pan- pan- left a 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.

uint32_t frequency = info->frequency;
if (info->frequency == 0) {
MBED_ASSERT(0);
frequency = 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

100000 ?

Copy link
Contributor Author

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.

MBED_ASSERT(0);
bits = 32;
}
uint32_t max_delta = 0x7 << (bits - 4); // 7/16th
Copy link
Member

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].

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

return;
}

uint64_t new_ticks = (ticker_time - queue->tick_last_read) & queue->bitmask;
Copy link
Member

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 😄 .

Copy link
Contributor Author

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

@c1728p9
Copy link
Contributor Author

c1728p9 commented Sep 20, 2017

PR #5096 is needed before testing will pass on this PR. This is because us_ticker_read() and lp_ticker_read() no longer returns the same value as ticker_read(ticker). The call to ticker_read(ticker) both scales the frequency and starts counting from 0.

@c1728p9
Copy link
Contributor Author

c1728p9 commented Sep 20, 2017

Addressed @pan-'s comments and rebased to master

Copy link
Contributor

@0xc0170 0xc0170 left a 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;
Copy link
Contributor

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?).

Copy link
Contributor Author

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.

@c1728p9 c1728p9 force-pushed the ticker_api_changes branch 2 times, most recently from 8225481 to 3ecba30 Compare September 21, 2017 15:49
@c1728p9
Copy link
Contributor Author

c1728p9 commented Sep 21, 2017

Should we add here now that deep sleep locking info?

This PR is big enough as it is, it might be best as a separate PR on top of this. What do you think @0xc0170 and @pan-?

@pan-
Copy link
Member

pan- commented Sep 21, 2017

separate PR.

if (match_tick > prev_tick) {
return (cur_tick >= match_tick) || (cur_tick < prev_tick);
} else {
return (cur_tick < match_tick) && (cur_tick >= prev_tick);

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?

Copy link
Contributor Author

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.

@c1728p9
Copy link
Contributor Author

c1728p9 commented Sep 27, 2017

Rebased to master and fixed ticker mismatch calculation. Diff for the new changes can be found in 6712718

@mbed-bot
Copy link

/morph test-nightly

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 1458

Test failed!

@mbed-bot
Copy link

mbed-bot commented Oct 1, 2017

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 1458

Test failed!

Output

mbed Build Number: 1463

Test failed!

@mbed-bot
Copy link

mbed-bot commented Oct 1, 2017

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 1458

Test failed!

Output

mbed Build Number: 1463

Test failed!

Output

mbed Build Number: 1469

Test failed!

@mbed-bot
Copy link

mbed-bot commented Oct 1, 2017

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 1458

Test failed!

Output

mbed Build Number: 1463

Test failed!

Output

mbed Build Number: 1469

Test failed!

Output

mbed Build Number: 1474

Test failed!

@mbed-bot
Copy link

mbed-bot commented Oct 2, 2017

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 1458

Test failed!

Output

mbed Build Number: 1463

Test failed!

Output

mbed Build Number: 1469

Test failed!

Output

mbed Build Number: 1474

Test failed!

Output

mbed Build Number: 1479

Test failed!

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 2, 2017

Besides couple of nightly runs, I reviewed few, ticker or lp_timeout fail, please review the latest test results

@c1728p9
Copy link
Contributor Author

c1728p9 commented Oct 3, 2017

This PR won't pass testing without #5242

@theotherjimmy
Copy link
Contributor

@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.
@c1728p9
Copy link
Contributor Author

c1728p9 commented Oct 5, 2017

rebased onto master

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 6, 2017

cc @bulislaw @scartmell-arm

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 9, 2017

/morph test-nightly

@theotherjimmy
Copy link
Contributor

retest uvisor

@mbed-bot
Copy link

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 1553

All builds and test passed!

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 10, 2017

It is now ready for integration.

@c1728p9 This is backward compatible, thus not required to be minor, is that correct?

@c1728p9
Copy link
Contributor Author

c1728p9 commented Oct 10, 2017

Hi @0xc0170, yes this is backwards compatible.

@theotherjimmy
Copy link
Contributor

@AnotherButler More new APIs here.

@mbed-ci
Copy link

mbed-ci commented Oct 11, 2017

Build : ABORTED

Build number : 87
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/5028/

@AnotherButler
Copy link
Contributor

@theotherjimmy Thanks. I've made a note of that and talked to @c1728p9 about docs. This should not affect this PR being merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants