-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Remove direct usage of CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC #15619
Remove direct usage of CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC #15619
Conversation
All checks are passing now. Review history of this comment for details about previous failed status. |
077ef66
to
6d7a01e
Compare
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 fails to build on SAM0 due to static assert failures in the RTC.
drivers/timer/sam0_rtc_timer.c
Outdated
@@ -23,7 +23,7 @@ | |||
#define RTC0 ((RtcMode0 *) DT_RTC_SAM0_BASE_ADDRESS) | |||
|
|||
/* Number of sys timer cycles per on tick. */ | |||
#define CYCLES_PER_TICK (CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC \ | |||
#define CYCLES_PER_TICK (sys_clock_hw_cycles_per_sec() \ |
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 fails to build on SAM0, since the BUILD_ASSERT(s) below are no longer reference a constant.
In this case it should likely be SOC_ATMEL_SAM0_GCLK0_FREQ_HZ
since that's the actual source of the RTC clock, currently (it's also the source of the undivided CPU clock, so it works out either way at present).
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.
Fixed. Thank you. Please check if the fix is correct.
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.
Looks good to me now.
49abe29
to
28a956b
Compare
On some SoCs the frequency of the system clock is obtained at run time as the exact configuration of the hardware is not known at compile time. On such platforms using CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC define directly introduces timing errors. This commit replaces CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC by the call to inline function sys_clock_hw_cycles_per_sec() which always returns correct frequency of the system clock. Signed-off-by: Piotr Zięcik <[email protected]>
On some SoCs the frequency of the system clock is obtained at run time as the exact configuration of the hardware is not known at compile time. On such platforms using CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC define directly introduces timing errors. This commit replaces CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC by the call to inline function sys_clock_hw_cycles_per_sec() which always returns correct frequency of the system clock. Signed-off-by: Piotr Zięcik <[email protected]>
On some SoCs the frequency of the system clock is obtained at run time as the exact configuration of the hardware is not known at compile time. On such platforms using CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC define directly introduces timing errors. This commit replaces CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC by the call to inline function sys_clock_hw_cycles_per_sec() which always returns correct frequency of the system clock. Signed-off-by: Piotr Zięcik <[email protected]>
On some SoCs the frequency of the system clock is obtained at run time as the exact configuration of the hardware is not known at compile time. On such platforms using CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC define directly introduces timing errors. This commit replaces CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC by the call to inline function sys_clock_hw_cycles_per_sec() which always returns correct frequency of the system clock. Signed-off-by: Piotr Zięcik <[email protected]>
28a956b
to
4165736
Compare
Aren't we missing a bunch of usages of Just in
|
subsys/logging/log_core.c
Outdated
@@ -282,7 +282,7 @@ void log_hexdump_sync(struct log_msg_ids src_level, const char *metadata, | |||
|
|||
static u32_t timestamp_get(void) |
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.
in that form it will not be optimal as on every timestamp_get there will be runtime evaluation of cycles per sec.
You can remove that function and instead do something like in log_core_init:
timestamp_func = (sys_clock_hw_cycles_per_sec() > 1000000) ? k_uptime_get_32 : k_cycle_get_32;
which replaces:
timestamp_func = timestamp_get;
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.
Updated. Please check the solution.
6100320
to
fccd2b8
Compare
On some SoCs the frequency of the system clock is obtained at run time as the exact configuration of the hardware is not known at compile time. On such platforms using CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC define directly introduces timing errors. This commit replaces CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC by the call to inline function sys_clock_hw_cycles_per_sec() which always returns correct frequency of the system clock. Signed-off-by: Piotr Zięcik <[email protected]>
On some SoCs the frequency of the system clock is obtained at run time as the exact configuration of the hardware is not known at compile time. On such platforms using CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC define directly introduces timing errors. This commit replaces CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC by the call to inline function sys_clock_hw_cycles_per_sec() which always returns correct frequency of the system clock. Signed-off-by: Piotr Zięcik <[email protected]>
fccd2b8
to
e03f705
Compare
On some SoCs the frequency of the system clock is obtained at run time
as the exact configuration of the hardware is not known at compile time.
On such platforms using CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC define directly
introduces timing errors.
This PR replaces CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC by the call to
inline function sys_clock_hw_cycles_per_sec() which always returns correct
frequency of the system clock.
Brings us closer to: #15363