Skip to content

ztimer: add ztimer_is_set() to user API#15780

Merged
kaspar030 merged 2 commits intoRIOT-OS:masterfrom
haukepetersen:opt_ztimer_isset
Jan 20, 2021
Merged

ztimer: add ztimer_is_set() to user API#15780
kaspar030 merged 2 commits intoRIOT-OS:masterfrom
haukepetersen:opt_ztimer_isset

Conversation

@haukepetersen
Copy link
Copy Markdown
Contributor

Contribution description

To improve the low power support I am currently porting NimBLE to use ztimer as RIOT timer backend. Mapping the ztimer API works mostly flawless, the only thing missing is a is_set() function. The current implementation uses an ugly hack by using xtimer internal struct members to do this check -> so for the improved port I'd like to have this less error prone :-)

This PR simply exposes ztimers internal _is_set() function by wrapping it into a critical section inside a newly added ztimer_is_set() user API function. Should be pretty straight forward.

Testing procedure

I added a call to the new ztimer_is_set() function in tests/ztimer_periodic. So simply run tests/ztimer_periodic on any platform -> it should succeed as expected.

Issues/PRs references

none

@haukepetersen haukepetersen added Type: new feature The issue requests / The PR implemements a new feature for RIOT CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Area: timers Area: timer subsystems labels Jan 15, 2021
Copy link
Copy Markdown
Contributor

@kaspar030 kaspar030 left a comment

Choose a reason for hiding this comment

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

LGTM.

Please fix the uncrustify suggestion, ztimer is no-discission uncrustify (like core). You can squash it in directly.

@kaspar030
Copy link
Copy Markdown
Contributor

This PR simply exposes ztimers internal _is_set() function by wrapping it into a critical section inside a newly added ztimer_is_set() user API function. Should be pretty straight forward.

I didn't expose it because it feels a bit dangerous to say "false" if the wrong clock is parsed. On the other hand, I didn't want to add an extra "clock" field to ztimer_t just to be able to remove the clock parameter from is_set()...

@haukepetersen
Copy link
Copy Markdown
Contributor Author

fixed (and squashed) uncrustify issue

Copy link
Copy Markdown
Contributor

@kaspar030 kaspar030 left a comment

Choose a reason for hiding this comment

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

ACK.

@kaspar030 kaspar030 merged commit a125096 into RIOT-OS:master Jan 20, 2021
@haukepetersen haukepetersen deleted the opt_ztimer_isset branch January 29, 2021 10:50
@kaspar030 kaspar030 added this to the Release 2021.04 milestone Apr 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: timers Area: timer subsystems CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: new feature The issue requests / The PR implemements a new feature for RIOT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants