esp_rom_sys.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * SPDX-FileCopyrightText: 2010-2022 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 interupt
  70. * 4. Enable peripheral interrupt
  71. *
  72. * @param cpu_core The CPU number, which the peripheral interupt will inform to
  73. * @param periph_intr_id The peripheral interrupt source number
  74. * @param cpu_intr_num The CPU interrupt number
  75. */
  76. void esp_rom_route_intr_matrix(int cpu_core, uint32_t periph_intr_id, uint32_t cpu_intr_num);
  77. /**
  78. * @brief Get the real CPU ticks per us
  79. *
  80. * @return CPU ticks per us
  81. */
  82. uint32_t esp_rom_get_cpu_ticks_per_us(void);
  83. #ifdef __cplusplus
  84. }
  85. #endif