esp_rom_sys.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 Print formated string to console device
  15. * @note float and long long data are not supported!
  16. *
  17. * @param fmt Format string
  18. * @param ... Additional arguments, depending on the format string
  19. * @return int: Total number of characters written on success; A negative number on failure.
  20. */
  21. int esp_rom_printf(const char *fmt, ...);
  22. /**
  23. * @brief Pauses execution for us microseconds
  24. *
  25. * @param us Number of microseconds to pause
  26. */
  27. void esp_rom_delay_us(uint32_t us);
  28. /**
  29. * @brief esp_rom_printf can print message to different channels simultaneously.
  30. * This function can help install the low level putc function for esp_rom_printf.
  31. *
  32. * @param channel Channel number (startting from 1)
  33. * @param putc Function pointer to the putc implementation. Set NULL can disconnect esp_rom_printf with putc.
  34. */
  35. void esp_rom_install_channel_putc(int channel, void (*putc)(char c));
  36. /**
  37. * @brief Install UART1 as the default console channel, equivalent to `esp_rom_install_channel_putc(1, esp_rom_uart_putc)`
  38. */
  39. void esp_rom_install_uart_printf(void);
  40. /**
  41. * @brief Get reset reason of CPU
  42. *
  43. * @param cpu_no CPU number
  44. * @return Reset reason code (see in soc/reset_reasons.h)
  45. */
  46. soc_reset_reason_t esp_rom_get_reset_reason(int cpu_no);
  47. /**
  48. * @brief Route peripheral interrupt sources to CPU's interrupt port by matrix
  49. *
  50. * Usually there're 4 steps to use an interrupt:
  51. * 1. Route peripheral interrupt source to CPU. e.g. esp_rom_route_intr_matrix(0, ETS_WIFI_MAC_INTR_SOURCE, ETS_WMAC_INUM)
  52. * 2. Set interrupt handler for CPU
  53. * 3. Enable CPU interupt
  54. * 4. Enable peripheral interrupt
  55. *
  56. * @param cpu_core The CPU number, which the peripheral interupt will inform to
  57. * @param periph_intr_id The peripheral interrupt source number
  58. * @param cpu_intr_num The CPU interrupt number
  59. */
  60. void esp_rom_route_intr_matrix(int cpu_core, uint32_t periph_intr_id, uint32_t cpu_intr_num);
  61. /**
  62. * @brief Get the real CPU ticks per us
  63. *
  64. * @return CPU ticks per us
  65. */
  66. uint32_t esp_rom_get_cpu_ticks_per_us(void);
  67. #ifdef __cplusplus
  68. }
  69. #endif