esp_rom_sys.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * SPDX-FileCopyrightText: 2010-2023 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include "sdkconfig.h"
  8. #include <stdint.h>
  9. #include "soc/reset_reasons.h"
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. /**
  14. * @brief Software Reset digital core include RTC.
  15. *
  16. * It is not recommended to use this function in esp-idf, use
  17. * esp_restart() instead.
  18. */
  19. void esp_rom_software_reset_system(void);
  20. /**
  21. * @brief Software Reset cpu core.
  22. *
  23. * It is not recommended to use this function in esp-idf, use
  24. * esp_restart() instead.
  25. *
  26. * @param cpu_no : The CPU to reset, 0 for PRO CPU, 1 for APP CPU.
  27. */
  28. void esp_rom_software_reset_cpu(int cpu_no);
  29. /**
  30. * @brief Print formated string to console device
  31. * @note float and long long data are not supported!
  32. *
  33. * @param fmt Format string
  34. * @param ... Additional arguments, depending on the format string
  35. * @return int: Total number of characters written on success; A negative number on failure.
  36. */
  37. int esp_rom_printf(const char *fmt, ...);
  38. /**
  39. * @brief Pauses execution for us microseconds
  40. *
  41. * @param us Number of microseconds to pause
  42. */
  43. void esp_rom_delay_us(uint32_t us);
  44. /**
  45. * @brief esp_rom_printf can print message to different channels simultaneously.
  46. * This function can help install the low level putc function for esp_rom_printf.
  47. *
  48. * @param channel Channel number (startting from 1)
  49. * @param putc Function pointer to the putc implementation. Set NULL can disconnect esp_rom_printf with putc.
  50. */
  51. void esp_rom_install_channel_putc(int channel, void (*putc)(char c));
  52. /**
  53. * @brief Install UART1 as the default console channel, equivalent to `esp_rom_install_channel_putc(1, esp_rom_uart_putc)`
  54. */
  55. void esp_rom_install_uart_printf(void);
  56. /**
  57. * @brief Get reset reason of CPU
  58. *
  59. * @param cpu_no CPU number
  60. * @return Reset reason code (see in soc/reset_reasons.h)
  61. */
  62. soc_reset_reason_t esp_rom_get_reset_reason(int cpu_no);
  63. /**
  64. * @brief Route peripheral interrupt sources to CPU's interrupt port by matrix
  65. *
  66. * Usually there're 4 steps to use an interrupt:
  67. * 1. Route peripheral interrupt source to CPU. e.g. esp_rom_route_intr_matrix(0, ETS_WIFI_MAC_INTR_SOURCE, ETS_WMAC_INUM)
  68. * 2. Set interrupt handler for CPU
  69. * 3. Enable CPU interrupt
  70. * 4. Enable peripheral interrupt
  71. *
  72. * @param cpu_core The CPU number, which the peripheral interrupt will inform to
  73. * @param periph_intr_id The peripheral interrupt source number
  74. * @param cpu_intr_num The CPU (external) interrupt number. On targets that use CLIC as their interrupt controller,
  75. * this number represents the external interrupt number. For example, passing `cpu_intr_num = i`
  76. * to this function would in fact bind peripheral source to CPU interrupt `CLIC_EXT_INTR_NUM_OFFSET + i`.
  77. */
  78. void esp_rom_route_intr_matrix(int cpu_core, uint32_t periph_intr_id, uint32_t cpu_intr_num);
  79. /**
  80. * @brief Get the real CPU ticks per us
  81. *
  82. * @return CPU ticks per us
  83. */
  84. uint32_t esp_rom_get_cpu_ticks_per_us(void);
  85. /**
  86. * @brief Set the real CPU tick rate
  87. *
  88. * @note Call this function when CPU frequency is changed, otherwise the `esp_rom_delay_us` can be inaccurate.
  89. *
  90. * @param ticks_per_us CPU ticks per us
  91. */
  92. void esp_rom_set_cpu_ticks_per_us(uint32_t ticks_per_us);
  93. #ifdef __cplusplus
  94. }
  95. #endif