esp_rom_sys.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2010-2020 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #include <stdint.h>
  15. #include <stdbool.h>
  16. #include "esp_attr.h"
  17. #include "sdkconfig.h"
  18. IRAM_ATTR void esp_rom_install_channel_putc(int channel, void (*putc)(char c))
  19. {
  20. extern void ets_install_putc1(void (*p)(char c));
  21. extern void ets_install_putc2(void (*p)(char c));
  22. switch (channel) {
  23. case 1:
  24. ets_install_putc1(putc);
  25. break;
  26. case 2:
  27. ets_install_putc2(putc);
  28. break;
  29. default:
  30. break;
  31. }
  32. }
  33. #if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32H2
  34. IRAM_ATTR void esp_rom_install_uart_printf(void)
  35. {
  36. extern void ets_install_uart_printf(void);
  37. extern bool g_uart_print;
  38. // If ROM log is disabled permanently via eFuse or temporarily via RTC storage register,
  39. // this ROM symbol will be set to false, and cause ``esp_rom_printf`` can't work on esp-idf side.
  40. g_uart_print = true;
  41. ets_install_uart_printf();
  42. }
  43. #endif