esp_rom_sys.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * SPDX-FileCopyrightText: 2010-2023 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include <stdint.h>
  7. #include <stdbool.h>
  8. #include "sdkconfig.h"
  9. #include "esp_attr.h"
  10. #include "soc/soc_caps.h"
  11. #include "esp_rom_caps.h"
  12. IRAM_ATTR void esp_rom_install_channel_putc(int channel, void (*putc)(char c))
  13. {
  14. extern void ets_install_putc1(void (*p)(char c));
  15. extern void ets_install_putc2(void (*p)(char c));
  16. switch (channel) {
  17. case 1:
  18. ets_install_putc1(putc);
  19. break;
  20. case 2:
  21. ets_install_putc2(putc);
  22. break;
  23. default:
  24. break;
  25. }
  26. }
  27. #if ESP_ROM_HAS_ETS_PRINTF_BUG
  28. IRAM_ATTR void esp_rom_install_uart_printf(void)
  29. {
  30. extern void ets_install_uart_printf(void);
  31. extern bool g_uart_print;
  32. extern bool g_usb_print;
  33. // If ROM log is disabled permanently via eFuse or temporarily via RTC storage register,
  34. // this ROM symbol will be set to false, and cause ``esp_rom_printf`` can't work on esp-idf side.
  35. g_uart_print = true;
  36. g_usb_print = true;
  37. ets_install_uart_printf();
  38. }
  39. #endif
  40. #if CONFIG_IDF_TARGET_ESP32
  41. extern uint32_t g_ticks_per_us_pro;
  42. #if SOC_CPU_CORES_NUM > 1
  43. #ifndef CONFIG_FREERTOS_UNICORE
  44. extern uint32_t g_ticks_per_us_app;
  45. #endif
  46. #endif
  47. IRAM_ATTR void esp_rom_set_cpu_ticks_per_us(uint32_t ticks_per_us)
  48. {
  49. /* Update scale factors used by esp_rom_delay_us */
  50. g_ticks_per_us_pro = ticks_per_us;
  51. #if SOC_CPU_CORES_NUM > 1
  52. #ifndef CONFIG_FREERTOS_UNICORE
  53. g_ticks_per_us_app = ticks_per_us;
  54. #endif
  55. #endif
  56. }
  57. #endif // CONFIG_IDF_TARGET_ESP32