Fix the following issues related to the systick counter to no_os_time conversion:
The systick couter is decreasing from SysTick->LOAD to 0 every millisecond (and generating an interrupt once it reaches 0), thus we need to use SysTick->LOAD - SysTick->VAL instead of only SysTick->VAL in order to count microseconds in the [0, 999] in the correct order. The current implmentation assumes the SysTick is increasing it's value.
For the [0, 999] microsecond range, rewrite the expression in order to make it clearer what is being computed.
Capture the values of _system_ticks and SysTick->VAL before computing the time since those operations are not atomic, and the systick's value will change in the meantime. This will result in invalid s and us values.
Disable the systick counter before capturing _system_ticks and SysTick->VAL, since a count to 0 interrupt may be generated in between, leading to invalid time results.
Pull Request Description
Please replace this with a detailed description and motivation of the changes.
You can tick the checkboxes below with an 'x' between square brackets or just check them after publishing the PR.
If this PR contains a breaking change, list dependent PRs and try to push all related PRs at the same time.
PR Type
[ ] Bug fix (change that fixes an issue)
[ ] New feature (change that adds new functionality)
[ ] Breaking change (has dependencies in other repos or will cause CI to fail)
Fix the following issues related to the systick counter to no_os_time conversion:
The systick couter is decreasing from SysTick->LOAD to 0 every millisecond (and generating an interrupt once it reaches 0), thus we need to use SysTick->LOAD - SysTick->VAL instead of only SysTick->VAL in order to count microseconds in the [0, 999] in the correct order. The current implmentation assumes the SysTick is increasing it's value.
For the [0, 999] microsecond range, rewrite the expression in order to make it clearer what is being computed.
Capture the values of _system_ticks and SysTick->VAL before computing the time since those operations are not atomic, and the systick's value will change in the meantime. This will result in invalid s and us values.
Disable the systick counter before capturing _system_ticks and SysTick->VAL, since a count to 0 interrupt may be generated in between, leading to invalid time results.
Pull Request Description
Please replace this with a detailed description and motivation of the changes. You can tick the checkboxes below with an 'x' between square brackets or just check them after publishing the PR. If this PR contains a breaking change, list dependent PRs and try to push all related PRs at the same time.
PR Type
PR Checklist