logging: add log_output_timestamp_to_us() helper function
So far we only have log_msg_timestamp_get() function, which returns internal timestamp representation. This is either clock cycles or uptime in ms, depending on main clock precision. Introduce log_output_timestamp_to_us() helper function, which allows to convert internal logging timestamp to us. Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
This commit is contained in:
parent
de16299c62
commit
552028dd20
|
@ -200,6 +200,14 @@ static inline void log_output_hostname_set(const struct log_output *output,
|
|||
*/
|
||||
void log_output_timestamp_freq_set(uint32_t freq);
|
||||
|
||||
/** @brief Convert timestamp of the message to us.
|
||||
*
|
||||
* @param timestamp Message timestamp
|
||||
*
|
||||
* @return Timestamp value in us.
|
||||
*/
|
||||
uint64_t log_output_timestamp_to_us(uint32_t timestamp);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
@ -753,3 +753,10 @@ void log_output_timestamp_freq_set(uint32_t frequency)
|
|||
|
||||
freq = frequency;
|
||||
}
|
||||
|
||||
uint64_t log_output_timestamp_to_us(uint32_t timestamp)
|
||||
{
|
||||
timestamp /= timestamp_div;
|
||||
|
||||
return ((uint64_t) timestamp * 1000000U) / freq;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue