2021-06-03 07:40:09 -04:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2021-04-06 08:38:34 -04:00
|
|
|
#include "sdkconfig.h"
|
|
|
|
|
|
|
|
#if CONFIG_IDF_TARGET_ESP32
|
|
|
|
|
2017-02-20 02:44:49 -05:00
|
|
|
#include <stdio.h>
|
|
|
|
#include "unity.h"
|
2020-07-21 01:07:34 -04:00
|
|
|
#include "esp_rom_sys.h"
|
2019-05-13 06:02:45 -04:00
|
|
|
#include "soc/rtc_periph.h"
|
|
|
|
#include "soc/sens_periph.h"
|
2017-02-20 02:44:49 -05:00
|
|
|
|
|
|
|
TEST_CASE("can control TSENS using registers", "[rtc][ignore]")
|
|
|
|
{
|
|
|
|
SET_PERI_REG_BITS(SENS_SAR_MEAS_WAIT2_REG, SENS_FORCE_XPD_SAR, 3, SENS_FORCE_XPD_SAR_S);
|
|
|
|
SET_PERI_REG_BITS(SENS_SAR_TSENS_CTRL_REG, SENS_TSENS_CLK_DIV, 10, SENS_TSENS_CLK_DIV_S);
|
|
|
|
CLEAR_PERI_REG_MASK(SENS_SAR_TSENS_CTRL_REG, SENS_TSENS_POWER_UP);
|
|
|
|
CLEAR_PERI_REG_MASK(SENS_SAR_TSENS_CTRL_REG, SENS_TSENS_DUMP_OUT);
|
|
|
|
SET_PERI_REG_MASK(SENS_SAR_TSENS_CTRL_REG, SENS_TSENS_POWER_UP_FORCE);
|
|
|
|
SET_PERI_REG_MASK(SENS_SAR_TSENS_CTRL_REG, SENS_TSENS_POWER_UP);
|
2020-07-21 01:07:34 -04:00
|
|
|
esp_rom_delay_us(100);
|
2017-02-20 02:44:49 -05:00
|
|
|
SET_PERI_REG_MASK(SENS_SAR_TSENS_CTRL_REG, SENS_TSENS_DUMP_OUT);
|
2020-07-21 01:07:34 -04:00
|
|
|
esp_rom_delay_us(5);
|
2017-02-20 02:44:49 -05:00
|
|
|
int res = GET_PERI_REG_BITS2(SENS_SAR_SLAVE_ADDR3_REG, SENS_TSENS_OUT, SENS_TSENS_OUT_S);
|
|
|
|
printf("res=%d\n", res);
|
|
|
|
}
|
2021-04-06 08:38:34 -04:00
|
|
|
|
|
|
|
|
|
|
|
#endif // CONFIG_IDF_TARGET_ESP32
|