log_noos.c 815 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include <assert.h>
  7. #include "esp_log_private.h"
  8. #include "hal/cpu_hal.h" // for cpu_hal_get_cycle_count()
  9. static int s_lock = 0;
  10. void esp_log_impl_lock(void)
  11. {
  12. assert(s_lock == 0);
  13. s_lock = 1;
  14. }
  15. bool esp_log_lock_impl_timeout(void)
  16. {
  17. esp_log_impl_lock();
  18. return true;
  19. }
  20. void esp_log_impl_unlock(void)
  21. {
  22. assert(s_lock == 1);
  23. s_lock = 0;
  24. }
  25. /* FIXME: define an API for getting the timestamp in soc/hal IDF-2351 */
  26. uint32_t esp_log_early_timestamp(void)
  27. {
  28. extern uint32_t ets_get_cpu_frequency(void);
  29. return cpu_hal_get_cycle_count() / (ets_get_cpu_frequency() * 1000);
  30. }
  31. uint32_t esp_log_timestamp(void) __attribute__((alias("esp_log_early_timestamp")));