esp_timer_private.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * SPDX-FileCopyrightText: 2017-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. /**
  8. * @file esp_private/esp_timer_private.h
  9. *
  10. * @brief Interface between common and platform-specific parts of esp_timer.
  11. *
  12. * The functions in this header file are implemented for each supported SoC.
  13. * High level functions defined in esp_timer.c call the functions here to
  14. * interact with the hardware.
  15. *
  16. * Note: The functions from this file are marked as private and are used exclusively
  17. * inside the IDF in the power management and sleep files.
  18. */
  19. #include <stdint.h>
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. /**
  24. * @brief Notify esp_timer implementation that APB frequency has changed
  25. *
  26. * Called by the frequency switching code.
  27. *
  28. * @param apb_ticks_per_us new number of APB clock ticks per microsecond
  29. */
  30. void esp_timer_private_update_apb_freq(uint32_t apb_ticks_per_us);
  31. /**
  32. * @brief Set esp_timer time to a certain value
  33. *
  34. * Called from light sleep code to synchronize esp_timer time with RTC time.
  35. *
  36. * @param new_us the value to be set to esp_timer time, in microseconds
  37. */
  38. void esp_timer_private_set(uint64_t new_us);
  39. /**
  40. * @brief Adjust current esp_timer time by a certain value
  41. *
  42. * @param time_diff_us adjustment to apply to esp_timer time, in microseconds
  43. */
  44. void esp_timer_private_advance(int64_t time_diff_us);
  45. /**
  46. * @brief obtain internal critical section used in the esp_timer implementation
  47. * This can be used when a sequence of calls to esp_timer has to be made,
  48. * and it is necessary that the state of the timer is consistent between
  49. * the calls. Should be treated in the same way as a spinlock.
  50. * Call esp_timer_private_unlock to release the lock
  51. */
  52. void esp_timer_private_lock(void);
  53. /**
  54. * @brief counterpart of esp_timer_lock
  55. */
  56. void esp_timer_private_unlock(void);
  57. #ifdef __cplusplus
  58. }
  59. #endif