pw_chrono_zephyr: Resolve multiple issues SystemTimerZephyr Adds a new system_timer_test.cc file, which runs fine on the native simulator target. The test adds basic coverage for the functionality of the system_timer.cc file, and also covers some specific edge cases where bugs here found and fixed. - When 64 bit timeouts were configured, the implementation computed a `time_until_deadline` that was a negative value, and was not clamped, causing a wait forever. - With 64 bit timeouts, kMaxTimeout effectively was -2, and that value passed as a timeout would either result in an error or no wait. - Using K_TICK_MAX in deriving kMaxTimeout proved to be problematic with 64 bit timeouts on Zephyr, as it turned out there was an overflow in the kernel leading to effectively K_NO_WAIT. The max needed a small adjustment. - If InvokeAt() or InvokeAfter() was called a second time to reschedule the wake-up, the k_work_schedule() function did not do anything as the wake-up was already scheduled. The fix was to call k_work_reschedule() instead, as this both schedules a new wake-up, or reschedules it if already scheduled. - If 32 bit timeouts are used, the compiler complained about a downcast from a long (chrono duration) to an int for the call into the Zephyr API. A static cast is added to eliminate the warning. Bug: b:512561694 Bug: b:512561066 Test: "./pw build pw_smoke_tests" (under zephyr-bazel) Change-Id: Idba728d56e1ca0f01d69c326ca5a4044252acd7d Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/418432
Pigweed is an open source collection of embedded-targeted libraries–or as we like to call them, modules. These modules are building blocks and infrastructure that enable faster and more reliable development on small-footprint MMU-less 32-bit microcontrollers like the STMicroelectronics STM32L452 or the Nordic nRF52832.
For more information please see our website: https://pigweed.dev/.