2016-11-11 01:00:34 -05:00
|
|
|
// Copyright 2010-2016 Espressif Systems (Shanghai) PTE LTD
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
2019-12-26 02:25:24 -05:00
|
|
|
#include "sdkconfig.h"
|
2016-11-11 01:00:34 -05:00
|
|
|
#include "bootloader_random.h"
|
2017-01-03 23:36:04 -05:00
|
|
|
#include "soc/cpu.h"
|
2016-11-11 01:00:34 -05:00
|
|
|
#include "soc/wdev_reg.h"
|
2019-05-13 06:02:45 -04:00
|
|
|
#include "soc/rtc_periph.h"
|
|
|
|
#include "soc/sens_periph.h"
|
|
|
|
#include "soc/syscon_periph.h"
|
2017-01-03 23:36:04 -05:00
|
|
|
#include "soc/dport_reg.h"
|
2019-05-13 06:02:45 -04:00
|
|
|
#include "soc/i2s_periph.h"
|
2017-01-03 23:36:04 -05:00
|
|
|
#include "esp_log.h"
|
2019-12-26 02:25:24 -05:00
|
|
|
#include "soc/io_mux_reg.h"
|
2020-07-29 10:03:46 -04:00
|
|
|
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
2019-12-26 02:25:24 -05:00
|
|
|
#include "soc/apb_saradc_reg.h"
|
|
|
|
#endif
|
2016-11-11 01:00:34 -05:00
|
|
|
|
|
|
|
#ifndef BOOTLOADER_BUILD
|
|
|
|
#include "esp_system.h"
|
2019-09-25 03:00:33 -04:00
|
|
|
#include "driver/periph_ctrl.h"
|
2016-11-11 01:00:34 -05:00
|
|
|
|
2020-07-29 10:03:46 -04:00
|
|
|
__attribute__((weak)) void bootloader_fill_random(void *buffer, size_t length)
|
2018-08-15 04:20:16 -04:00
|
|
|
{
|
|
|
|
return esp_fill_random(buffer, length);
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
2020-07-29 10:03:46 -04:00
|
|
|
__attribute__((weak)) void bootloader_fill_random(void *buffer, size_t length)
|
2016-11-11 01:00:34 -05:00
|
|
|
{
|
|
|
|
uint8_t *buffer_bytes = (uint8_t *)buffer;
|
|
|
|
uint32_t random;
|
2017-01-03 23:36:04 -05:00
|
|
|
uint32_t start, now;
|
2018-08-15 04:20:16 -04:00
|
|
|
|
|
|
|
assert(buffer != NULL);
|
2016-11-11 01:00:34 -05:00
|
|
|
|
|
|
|
for (int i = 0; i < length; i++) {
|
|
|
|
if (i == 0 || i % 4 == 0) { /* redundant check is for a compiler warning */
|
2017-01-03 23:36:04 -05:00
|
|
|
/* in bootloader with ADC feeding HWRNG, we accumulate 1
|
|
|
|
bit of entropy per 40 APB cycles (==80 CPU cycles.)
|
2016-11-11 01:00:34 -05:00
|
|
|
|
2017-01-03 23:36:04 -05:00
|
|
|
To avoid reading the entire RNG hardware state out
|
|
|
|
as-is, we repeatedly read the RNG register and XOR all
|
|
|
|
values.
|
2016-11-11 01:00:34 -05:00
|
|
|
*/
|
|
|
|
random = REG_READ(WDEV_RND_REG);
|
2017-01-03 23:36:04 -05:00
|
|
|
RSR(CCOUNT, start);
|
|
|
|
do {
|
|
|
|
random ^= REG_READ(WDEV_RND_REG);
|
|
|
|
RSR(CCOUNT, now);
|
2019-05-27 02:29:43 -04:00
|
|
|
} while (now - start < 80 * 32 * 2); /* extra factor of 2 is precautionary */
|
2016-11-11 01:00:34 -05:00
|
|
|
}
|
|
|
|
buffer_bytes[i] = random >> ((i % 4) * 8);
|
|
|
|
}
|
|
|
|
}
|
2018-08-15 04:20:16 -04:00
|
|
|
#endif // BOOTLOADER_BUILD
|
2017-01-03 23:36:04 -05:00
|
|
|
|
|
|
|
void bootloader_random_enable(void)
|
|
|
|
{
|
2017-02-28 20:02:04 -05:00
|
|
|
/* Ensure the hardware RNG is enabled following a soft reset. This should always be the case already (this clock is
|
|
|
|
never disabled while the CPU is running), this is a "belts and braces" type check.
|
|
|
|
*/
|
2019-09-25 03:00:33 -04:00
|
|
|
#ifdef BOOTLOADER_BUILD
|
2020-07-29 10:03:46 -04:00
|
|
|
#if CONFIG_IDF_TARGET_ESP32S3
|
|
|
|
SET_PERI_REG_MASK(SYSTEM_WIFI_CLK_EN_REG, SYSTEM_WIFI_CLK_RNG_EN);
|
|
|
|
#else
|
2017-05-08 08:03:04 -04:00
|
|
|
DPORT_SET_PERI_REG_MASK(DPORT_WIFI_CLK_EN_REG, DPORT_WIFI_CLK_RNG_EN);
|
2020-07-29 10:03:46 -04:00
|
|
|
#endif
|
2019-09-25 03:00:33 -04:00
|
|
|
#else
|
|
|
|
periph_module_enable(PERIPH_RNG_MODULE);
|
|
|
|
#endif // BOOTLOADER_BUILD
|
2017-02-28 20:02:04 -05:00
|
|
|
|
2017-01-03 23:36:04 -05:00
|
|
|
/* Enable SAR ADC in test mode to feed ADC readings of the 1.1V
|
|
|
|
reference via I2S into the RNG entropy input.
|
|
|
|
|
|
|
|
Note: I2S requires the PLL to be running, so the call to rtc_set_cpu_freq(CPU_80M)
|
|
|
|
in early bootloader startup must have been made.
|
|
|
|
*/
|
2019-12-26 02:25:24 -05:00
|
|
|
#if CONFIG_IDF_TARGET_ESP32
|
2017-01-03 23:36:04 -05:00
|
|
|
SET_PERI_REG_BITS(RTC_CNTL_TEST_MUX_REG, RTC_CNTL_DTEST_RTC, 2, RTC_CNTL_DTEST_RTC_S);
|
|
|
|
SET_PERI_REG_MASK(RTC_CNTL_TEST_MUX_REG, RTC_CNTL_ENT_RTC);
|
|
|
|
SET_PERI_REG_MASK(SENS_SAR_START_FORCE_REG, SENS_SAR2_EN_TEST);
|
|
|
|
|
2019-09-25 03:00:33 -04:00
|
|
|
#ifdef BOOTLOADER_BUILD
|
2017-05-08 08:03:04 -04:00
|
|
|
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_I2S0_CLK_EN);
|
2019-09-25 03:00:33 -04:00
|
|
|
#else
|
|
|
|
periph_module_enable(PERIPH_I2S0_MODULE);
|
|
|
|
#endif // BOOTLOADER_BUILD
|
2017-01-03 23:36:04 -05:00
|
|
|
CLEAR_PERI_REG_MASK(SENS_SAR_START_FORCE_REG, SENS_ULP_CP_FORCE_START_TOP);
|
|
|
|
CLEAR_PERI_REG_MASK(SENS_SAR_START_FORCE_REG, SENS_ULP_CP_START_TOP);
|
2020-01-16 22:47:08 -05:00
|
|
|
#elif CONFIG_IDF_TARGET_ESP32S2
|
2019-12-26 02:25:24 -05:00
|
|
|
/* Disable IO1 digital function for random function. */
|
|
|
|
PIN_INPUT_DISABLE(PERIPHS_IO_MUX_GPIO1_U);
|
|
|
|
PIN_PULLDWN_DIS(PERIPHS_IO_MUX_GPIO1_U);
|
|
|
|
PIN_PULLUP_DIS(PERIPHS_IO_MUX_GPIO1_U);
|
|
|
|
WRITE_PERI_REG(APB_SARADC_SAR1_PATT_TAB1_REG, 0xFFFFFFFF);
|
|
|
|
|
2019-06-13 07:34:01 -04:00
|
|
|
SET_PERI_REG_MASK(SENS_SAR_MEAS2_CTRL1_REG, SENS_SAR2_EN_TEST);
|
|
|
|
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_I2S0_CLK_EN);
|
|
|
|
CLEAR_PERI_REG_MASK(RTC_CNTL_ULP_CP_CTRL_REG, RTC_CNTL_ULP_CP_FORCE_START_TOP);
|
|
|
|
CLEAR_PERI_REG_MASK(RTC_CNTL_ULP_CP_CTRL_REG, RTC_CNTL_ULP_CP_START_TOP);
|
2020-07-29 10:03:46 -04:00
|
|
|
#elif CONFIG_IDF_TARGET_ESP32S3
|
|
|
|
/* Disable IO1 digital function for random function. */
|
|
|
|
PIN_INPUT_DISABLE(PERIPHS_IO_MUX_GPIO1_U);
|
|
|
|
PIN_PULLDWN_DIS(PERIPHS_IO_MUX_GPIO1_U);
|
|
|
|
PIN_PULLUP_DIS(PERIPHS_IO_MUX_GPIO1_U);
|
|
|
|
WRITE_PERI_REG(APB_SARADC_SAR1_PATT_TAB1_REG, 0xFFFFFFFF);
|
|
|
|
|
|
|
|
SET_PERI_REG_MASK(SENS_SAR_MEAS2_CTRL1_REG, SENS_SAR2_EN_TEST);
|
|
|
|
SET_PERI_REG_MASK(SYSTEM_PERIP_CLK_EN0_REG, SYSTEM_I2S0_CLK_EN);
|
|
|
|
CLEAR_PERI_REG_MASK(RTC_CNTL_ULP_CP_CTRL_REG, RTC_CNTL_ULP_CP_FORCE_START_TOP);
|
|
|
|
CLEAR_PERI_REG_MASK(RTC_CNTL_ULP_CP_CTRL_REG, RTC_CNTL_ULP_CP_START_TOP);
|
2019-06-13 07:34:01 -04:00
|
|
|
#endif
|
|
|
|
|
2017-01-03 23:36:04 -05:00
|
|
|
// Test pattern configuration byte 0xAD:
|
|
|
|
//--[7:4] channel_sel: 10-->en_test
|
|
|
|
//--[3:2] bit_width : 3-->12bit
|
|
|
|
//--[1:0] atten : 1-->3dB attenuation
|
2019-12-26 02:25:24 -05:00
|
|
|
#if CONFIG_IDF_TARGET_ESP32
|
2017-01-03 23:36:04 -05:00
|
|
|
WRITE_PERI_REG(SYSCON_SARADC_SAR2_PATT_TAB1_REG, 0xADADADAD);
|
|
|
|
WRITE_PERI_REG(SYSCON_SARADC_SAR2_PATT_TAB2_REG, 0xADADADAD);
|
|
|
|
WRITE_PERI_REG(SYSCON_SARADC_SAR2_PATT_TAB3_REG, 0xADADADAD);
|
|
|
|
WRITE_PERI_REG(SYSCON_SARADC_SAR2_PATT_TAB4_REG, 0xADADADAD);
|
|
|
|
SET_PERI_REG_BITS(SENS_SAR_MEAS_WAIT2_REG, SENS_FORCE_XPD_SAR, 3, SENS_FORCE_XPD_SAR_S);
|
|
|
|
SET_PERI_REG_MASK(SENS_SAR_READ_CTRL_REG, SENS_SAR1_DIG_FORCE);
|
|
|
|
SET_PERI_REG_MASK(SENS_SAR_READ_CTRL2_REG, SENS_SAR2_DIG_FORCE);
|
2020-07-29 10:03:46 -04:00
|
|
|
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
2019-12-26 02:25:24 -05:00
|
|
|
WRITE_PERI_REG(APB_SARADC_SAR2_PATT_TAB1_REG, 0xADADADAD);
|
|
|
|
WRITE_PERI_REG(APB_SARADC_SAR2_PATT_TAB2_REG, 0xADADADAD);
|
|
|
|
WRITE_PERI_REG(APB_SARADC_SAR2_PATT_TAB3_REG, 0xADADADAD);
|
|
|
|
WRITE_PERI_REG(APB_SARADC_SAR2_PATT_TAB4_REG, 0xADADADAD);
|
2019-06-13 07:34:01 -04:00
|
|
|
SET_PERI_REG_BITS(SENS_SAR_POWER_XPD_SAR_REG, SENS_FORCE_XPD_SAR, 3, SENS_FORCE_XPD_SAR_S);
|
|
|
|
SET_PERI_REG_MASK(SENS_SAR_MEAS1_MUX_REG, SENS_SAR1_DIG_FORCE);
|
|
|
|
#endif
|
|
|
|
|
2019-05-27 02:29:43 -04:00
|
|
|
#if CONFIG_IDF_TARGET_ESP32
|
2017-01-03 23:36:04 -05:00
|
|
|
SET_PERI_REG_MASK(SYSCON_SARADC_CTRL_REG, SYSCON_SARADC_SAR2_MUX);
|
|
|
|
SET_PERI_REG_BITS(SYSCON_SARADC_CTRL_REG, SYSCON_SARADC_SAR_CLK_DIV, 4, SYSCON_SARADC_SAR_CLK_DIV_S);
|
|
|
|
SET_PERI_REG_BITS(SYSCON_SARADC_FSM_REG, SYSCON_SARADC_RSTB_WAIT, 8, SYSCON_SARADC_RSTB_WAIT_S); /* was 1 */
|
|
|
|
SET_PERI_REG_BITS(SYSCON_SARADC_FSM_REG, SYSCON_SARADC_START_WAIT, 10, SYSCON_SARADC_START_WAIT_S);
|
|
|
|
SET_PERI_REG_BITS(SYSCON_SARADC_CTRL_REG, SYSCON_SARADC_WORK_MODE, 0, SYSCON_SARADC_WORK_MODE_S);
|
|
|
|
SET_PERI_REG_MASK(SYSCON_SARADC_CTRL_REG, SYSCON_SARADC_SAR_SEL);
|
|
|
|
CLEAR_PERI_REG_MASK(SYSCON_SARADC_CTRL_REG, SYSCON_SARADC_DATA_SAR_SEL);
|
|
|
|
SET_PERI_REG_BITS(I2S_SAMPLE_RATE_CONF_REG(0), I2S_RX_BCK_DIV_NUM, 20, I2S_RX_BCK_DIV_NUM_S);
|
2019-05-27 02:29:43 -04:00
|
|
|
SET_PERI_REG_MASK(SYSCON_SARADC_CTRL_REG, SYSCON_SARADC_DATA_TO_I2S);
|
2020-01-16 22:47:08 -05:00
|
|
|
#elif CONFIG_IDF_TARGET_ESP32S2
|
2019-12-26 02:25:24 -05:00
|
|
|
SET_PERI_REG_BITS(APB_SARADC_CTRL_REG, APB_SARADC_SAR_CLK_DIV, 4, APB_SARADC_SAR_CLK_DIV_S);
|
|
|
|
SET_PERI_REG_BITS(APB_SARADC_FSM_REG, APB_SARADC_RSTB_WAIT, 8, APB_SARADC_RSTB_WAIT_S); /* was 1 */
|
|
|
|
SET_PERI_REG_BITS(APB_SARADC_CTRL_REG, APB_SARADC_WORK_MODE, 0, APB_SARADC_WORK_MODE_S);
|
|
|
|
SET_PERI_REG_MASK(APB_SARADC_CTRL_REG, APB_SARADC_SAR_SEL);
|
|
|
|
CLEAR_PERI_REG_MASK(APB_SARADC_CTRL_REG, APB_SARADC_DATA_SAR_SEL);
|
|
|
|
SET_PERI_REG_BITS(I2S_SAMPLE_RATE_CONF_REG(0), I2S_RX_BCK_DIV_NUM, 20, I2S_RX_BCK_DIV_NUM_S);
|
|
|
|
SET_PERI_REG_MASK(APB_SARADC_CTRL_REG, APB_SARADC_DATA_TO_I2S);
|
|
|
|
#endif
|
2020-07-29 10:03:46 -04:00
|
|
|
#if !CONFIG_IDF_TARGET_ESP32S3
|
2017-01-03 23:36:04 -05:00
|
|
|
CLEAR_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_CAMERA_EN);
|
|
|
|
SET_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_LCD_EN);
|
|
|
|
SET_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_DATA_ENABLE);
|
|
|
|
SET_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_DATA_ENABLE_TEST_EN);
|
|
|
|
SET_PERI_REG_MASK(I2S_CONF_REG(0), I2S_RX_START);
|
2020-07-29 10:03:46 -04:00
|
|
|
#endif
|
2017-01-03 23:36:04 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void bootloader_random_disable(void)
|
|
|
|
{
|
2020-07-29 10:03:46 -04:00
|
|
|
#if !CONFIG_IDF_TARGET_ESP32S3
|
2017-01-03 23:36:04 -05:00
|
|
|
/* Reset some i2s configuration (possibly redundant as we reset entire
|
|
|
|
I2S peripheral further down). */
|
2019-10-28 02:21:59 -04:00
|
|
|
CLEAR_PERI_REG_MASK(I2S_CONF_REG(0), I2S_RX_START);
|
|
|
|
SET_PERI_REG_MASK(I2S_CONF_REG(0), I2S_RX_RESET);
|
|
|
|
CLEAR_PERI_REG_MASK(I2S_CONF_REG(0), I2S_RX_RESET);
|
2017-01-03 23:36:04 -05:00
|
|
|
CLEAR_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_CAMERA_EN);
|
|
|
|
CLEAR_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_LCD_EN);
|
|
|
|
CLEAR_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_DATA_ENABLE_TEST_EN);
|
|
|
|
CLEAR_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_DATA_ENABLE);
|
2020-07-29 10:03:46 -04:00
|
|
|
#endif
|
2019-10-28 02:21:59 -04:00
|
|
|
/* Disable i2s clock */
|
|
|
|
#ifdef BOOTLOADER_BUILD
|
2020-07-29 10:03:46 -04:00
|
|
|
#if CONFIG_IDF_TARGET_ESP32S3
|
|
|
|
CLEAR_PERI_REG_MASK(SYSTEM_PERIP_CLK_EN0_REG, SYSTEM_I2S0_CLK_EN);
|
|
|
|
#else
|
2019-10-28 02:21:59 -04:00
|
|
|
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_I2S0_CLK_EN);
|
2020-07-29 10:03:46 -04:00
|
|
|
#endif
|
2019-10-28 02:21:59 -04:00
|
|
|
#else
|
|
|
|
periph_module_disable(PERIPH_I2S0_MODULE);
|
|
|
|
#endif // BOOTLOADER_BUILD
|
2017-01-03 23:36:04 -05:00
|
|
|
|
|
|
|
/* Restore SYSCON mode registers */
|
2019-06-13 07:34:01 -04:00
|
|
|
#if CONFIG_IDF_TARGET_ESP32
|
2017-01-03 23:36:04 -05:00
|
|
|
CLEAR_PERI_REG_MASK(SENS_SAR_READ_CTRL_REG, SENS_SAR1_DIG_FORCE);
|
|
|
|
CLEAR_PERI_REG_MASK(SENS_SAR_READ_CTRL2_REG, SENS_SAR2_DIG_FORCE);
|
2020-07-29 10:03:46 -04:00
|
|
|
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
2019-06-13 07:34:01 -04:00
|
|
|
CLEAR_PERI_REG_MASK(SENS_SAR_MEAS1_MUX_REG, SENS_SAR1_DIG_FORCE);
|
|
|
|
#endif
|
2017-01-03 23:36:04 -05:00
|
|
|
|
2019-06-13 07:34:01 -04:00
|
|
|
#if CONFIG_IDF_TARGET_ESP32
|
2017-01-03 23:36:04 -05:00
|
|
|
/* Restore SAR ADC mode */
|
|
|
|
CLEAR_PERI_REG_MASK(SENS_SAR_START_FORCE_REG, SENS_SAR2_EN_TEST);
|
2017-01-12 18:26:58 -05:00
|
|
|
CLEAR_PERI_REG_MASK(SYSCON_SARADC_CTRL_REG, SYSCON_SARADC_SAR2_MUX
|
|
|
|
| SYSCON_SARADC_SAR_SEL | SYSCON_SARADC_DATA_TO_I2S);
|
2019-06-13 07:34:01 -04:00
|
|
|
SET_PERI_REG_BITS(SENS_SAR_MEAS_WAIT2_REG, SENS_FORCE_XPD_SAR, 0, SENS_FORCE_XPD_SAR_S);
|
2020-07-29 10:03:46 -04:00
|
|
|
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
2019-06-13 07:34:01 -04:00
|
|
|
CLEAR_PERI_REG_MASK(SENS_SAR_MEAS2_CTRL1_REG, SENS_SAR2_EN_TEST);
|
2019-12-26 02:25:24 -05:00
|
|
|
CLEAR_PERI_REG_MASK(APB_SARADC_CTRL_REG, APB_SARADC_SAR_SEL | APB_SARADC_DATA_TO_I2S);
|
2019-06-13 07:34:01 -04:00
|
|
|
SET_PERI_REG_BITS(SENS_SAR_POWER_XPD_SAR_REG, SENS_FORCE_XPD_SAR, 0, SENS_FORCE_XPD_SAR_S);
|
2019-05-27 02:29:43 -04:00
|
|
|
#endif
|
2019-06-13 07:34:01 -04:00
|
|
|
|
2019-05-27 02:29:43 -04:00
|
|
|
#if CONFIG_IDF_TARGET_ESP32
|
2017-01-12 18:26:58 -05:00
|
|
|
SET_PERI_REG_BITS(SYSCON_SARADC_FSM_REG, SYSCON_SARADC_START_WAIT, 8, SYSCON_SARADC_START_WAIT_S);
|
2019-05-27 02:29:43 -04:00
|
|
|
#endif
|
2017-01-03 23:36:04 -05:00
|
|
|
|
|
|
|
/* Reset i2s peripheral */
|
2019-09-25 03:00:33 -04:00
|
|
|
#ifdef BOOTLOADER_BUILD
|
2020-07-29 10:03:46 -04:00
|
|
|
#if CONFIG_IDF_TARGET_ESP32S3
|
|
|
|
SET_PERI_REG_MASK(SYSTEM_PERIP_RST_EN0_REG, SYSTEM_I2S0_RST);
|
|
|
|
CLEAR_PERI_REG_MASK(SYSTEM_PERIP_RST_EN0_REG, SYSTEM_I2S0_RST);
|
|
|
|
#else
|
2017-05-08 08:03:04 -04:00
|
|
|
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_I2S0_RST);
|
|
|
|
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_I2S0_RST);
|
2020-07-29 10:03:46 -04:00
|
|
|
#endif
|
2019-09-25 03:00:33 -04:00
|
|
|
#else
|
|
|
|
periph_module_reset(PERIPH_I2S0_MODULE);
|
|
|
|
#endif
|
2017-02-20 23:10:49 -05:00
|
|
|
|
2019-12-26 02:25:24 -05:00
|
|
|
#if CONFIG_IDF_TARGET_ESP32
|
2017-02-20 23:10:49 -05:00
|
|
|
/* Disable pull supply voltage to SAR ADC */
|
|
|
|
CLEAR_PERI_REG_MASK(RTC_CNTL_TEST_MUX_REG, RTC_CNTL_ENT_RTC);
|
|
|
|
SET_PERI_REG_BITS(RTC_CNTL_TEST_MUX_REG, RTC_CNTL_DTEST_RTC, 0, RTC_CNTL_DTEST_RTC_S);
|
2019-12-26 02:25:24 -05:00
|
|
|
#endif
|
2017-01-03 23:36:04 -05:00
|
|
|
}
|