logging: fix timestamp func overwrite on log2
When LOG2 is enabled, timestamp func which was just set according to various conditions, is overwritten using sysclock. Since sysclock is very fast, it will cause uint32_t to wrap very fast and cause the time to start over from 0 often. This commit combines the two statements doing the same thing, to one statement. Signed-off-by: Emil Lindqvist <emil@lindq.gr>
This commit is contained in:
parent
9672180327
commit
bd2eb48c05
1 changed files with 4 additions and 7 deletions
|
@ -538,26 +538,23 @@ static log_timestamp_t default_lf_get_timestamp(void)
|
|||
void log_core_init(void)
|
||||
{
|
||||
uint32_t freq;
|
||||
log_timestamp_get_t _timestamp_func;
|
||||
|
||||
panic_mode = false;
|
||||
dropped_cnt = 0;
|
||||
|
||||
/* Set default timestamp. */
|
||||
if (sys_clock_hw_cycles_per_sec() > 1000000) {
|
||||
timestamp_func = default_lf_get_timestamp;
|
||||
_timestamp_func = default_lf_get_timestamp;
|
||||
freq = 1000U;
|
||||
} else {
|
||||
timestamp_func = default_get_timestamp;
|
||||
_timestamp_func = default_get_timestamp;
|
||||
freq = sys_clock_hw_cycles_per_sec();
|
||||
}
|
||||
|
||||
log_output_timestamp_freq_set(freq);
|
||||
log_set_timestamp_func(_timestamp_func, freq);
|
||||
|
||||
if (IS_ENABLED(CONFIG_LOG2)) {
|
||||
log_set_timestamp_func(default_get_timestamp,
|
||||
IS_ENABLED(CONFIG_LOG_TIMESTAMP_64BIT) ?
|
||||
CONFIG_SYS_CLOCK_TICKS_PER_SEC :
|
||||
sys_clock_hw_cycles_per_sec());
|
||||
if (IS_ENABLED(CONFIG_LOG2_MODE_DEFERRED)) {
|
||||
z_log_msg2_init();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue