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
15 #include <stdint.h>
16 #include "esp_attr.h"
17
18 #include "sdkconfig.h"
19
20 #ifdef CONFIG_IDF_TARGET_ESP32
21 #include "esp32/rom/rtc.h"
22 #elif CONFIG_IDF_TARGET_ESP32S2
23 #include "esp32s2/rom/rtc.h"
24 #endif
25
esp_rom_install_channel_putc(int channel,void (* putc)(char c))26 IRAM_ATTR void esp_rom_install_channel_putc(int channel, void (*putc)(char c))
27 {
28 extern void ets_install_putc1(void (*p)(char c));
29 extern void ets_install_putc2(void (*p)(char c));
30 switch (channel) {
31 case 1:
32 ets_install_putc1(putc);
33 break;
34 case 2:
35 ets_install_putc2(putc);
36 break;
37 default:
38 break;
39 }
40 }
41
esp_rom_disable_logging(void)42 void esp_rom_disable_logging(void)
43 {
44 #if CONFIG_IDF_TARGET_ESP32 // [refactor-todo]: ESP32S2 seem to also reference disabling logging in its ROM code
45 /* To disable logging in the ROM, only the least significant bit of the register is used,
46 * but since this register is also used to store the frequency of the main crystal (RTC_XTAL_FREQ_REG),
47 * you need to write to this register in the same format.
48 * Namely, the upper 16 bits and lower should be the same.
49 */
50 REG_SET_BIT(RTC_CNTL_STORE4_REG, RTC_DISABLE_ROM_LOG);
51 #endif
52 }
53