system_internal.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. #include "esp_system.h"
  11. #include "soc/soc_caps.h"
  12. #if SOC_TIMER_GROUPS >= 2
  13. /* All the targets that have more than one timer group are using
  14. * APB clock by default, which frequency is 80MHz.
  15. * Thus, we can determine the default parameter for the prescaler here */
  16. #define MWDT0_TICK_PRESCALER 40000
  17. #define MWDT0_TICKS_PER_US 500
  18. #define MWDT1_TICK_PRESCALER 40000
  19. #define MWDT1_TICKS_PER_US 500
  20. #else
  21. /* The targets that have a single timer group use a 40MHz clock for the
  22. * Timer Group 0. Let's adapt the prescaler value accordingly.
  23. */
  24. #define MWDT0_TICK_PRESCALER 20000
  25. #define MWDT0_TICKS_PER_US 500
  26. #endif
  27. /**
  28. * @brief Internal function to restart PRO and APP CPUs.
  29. *
  30. * @note This function should not be called from FreeRTOS applications.
  31. * Use esp_restart instead.
  32. *
  33. * This is an internal function called by esp_restart. It is called directly
  34. * by the panic handler and brownout detector interrupt.
  35. */
  36. void esp_restart_noos(void) __attribute__ ((noreturn));
  37. /**
  38. * @brief Similar to esp_restart_noos, but resets all the digital peripherals.
  39. */
  40. void esp_restart_noos_dig(void) __attribute__ ((noreturn));
  41. /**
  42. * @brief Internal function to set reset reason hint
  43. *
  44. * The hint is used do distinguish different reset reasons when software reset
  45. * is performed.
  46. *
  47. * The hint is stored in RTC store register, RTC_RESET_CAUSE_REG.
  48. *
  49. * @param hint Desired esp_reset_reason_t value for the real reset reason
  50. */
  51. void esp_reset_reason_set_hint(esp_reset_reason_t hint);
  52. /**
  53. * @brief Internal function to get the reset hint value
  54. * @return - Reset hint value previously stored into RTC_RESET_CAUSE_REG using
  55. * esp_reset_reason_set_hint function
  56. * - ESP_RST_UNKNOWN if the value in RTC_RESET_CAUSE_REG is invalid
  57. */
  58. esp_reset_reason_t esp_reset_reason_get_hint(void);
  59. /**
  60. * @brief Get the time in microseconds since startup
  61. *
  62. * @returns time since g_startup_time; definition should be fixed by system time provider
  63. * no matter the underlying timer used.
  64. */
  65. int64_t esp_system_get_time(void);
  66. /**
  67. * @brief Get the resolution of the time returned by `esp_system_get_time`.
  68. *
  69. * @returns the resolution in nanoseconds
  70. */
  71. uint32_t esp_system_get_time_resolution(void);
  72. #ifdef __cplusplus
  73. }
  74. #endif