2021-04-12 02:02:59 -04:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2019-11-21 12:40:59 -05:00
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include "esp_log_private.h"
|
2022-01-17 04:44:25 -05:00
|
|
|
#include "esp_rom_sys.h"
|
2022-07-21 07:24:42 -04:00
|
|
|
#include "esp_cpu.h"
|
2019-11-21 12:40:59 -05:00
|
|
|
|
|
|
|
static int s_lock = 0;
|
|
|
|
|
|
|
|
void esp_log_impl_lock(void)
|
|
|
|
{
|
|
|
|
assert(s_lock == 0);
|
|
|
|
s_lock = 1;
|
|
|
|
}
|
|
|
|
|
2023-02-09 14:29:05 -05:00
|
|
|
bool esp_log_impl_lock_timeout(void)
|
2019-11-21 12:40:59 -05:00
|
|
|
{
|
|
|
|
esp_log_impl_lock();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void esp_log_impl_unlock(void)
|
|
|
|
{
|
|
|
|
assert(s_lock == 1);
|
|
|
|
s_lock = 0;
|
|
|
|
}
|
|
|
|
|
2020-11-05 23:00:07 -05:00
|
|
|
/* FIXME: define an API for getting the timestamp in soc/hal IDF-2351 */
|
2019-11-21 12:40:59 -05:00
|
|
|
uint32_t esp_log_early_timestamp(void)
|
|
|
|
{
|
2022-07-21 07:24:42 -04:00
|
|
|
return esp_cpu_get_cycle_count() / (esp_rom_get_cpu_ticks_per_us() * 1000);
|
2019-11-21 12:40:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t esp_log_timestamp(void) __attribute__((alias("esp_log_early_timestamp")));
|