log_noos.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2019 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #include <assert.h>
  15. #include "esp_log_private.h"
  16. #include "soc/cpu.h" // for esp_cpu_get_ccount()
  17. static int s_lock = 0;
  18. void esp_log_impl_lock(void)
  19. {
  20. assert(s_lock == 0);
  21. s_lock = 1;
  22. }
  23. bool esp_log_lock_impl_timeout(void)
  24. {
  25. esp_log_impl_lock();
  26. return true;
  27. }
  28. void esp_log_impl_unlock(void)
  29. {
  30. assert(s_lock == 1);
  31. s_lock = 0;
  32. }
  33. /* FIXME: define an API for getting the timestamp in soc/hal */
  34. uint32_t esp_log_early_timestamp(void)
  35. {
  36. extern uint32_t g_ticks_per_us_pro;
  37. return esp_cpu_get_ccount() / (g_ticks_per_us_pro * 1000);
  38. }
  39. uint32_t esp_log_timestamp(void) __attribute__((alias("esp_log_early_timestamp")));