2022-12-13 04:27:04 -05:00
|
|
|
/*
|
2023-06-30 04:30:03 -04:00
|
|
|
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
2022-12-13 04:27:04 -05:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2019-07-25 11:11:31 -04:00
|
|
|
|
|
|
|
// The HAL layer for RTC IO (common part)
|
|
|
|
|
|
|
|
#include "hal/rtc_io_hal.h"
|
2021-01-06 21:13:17 -05:00
|
|
|
#include "soc/soc_caps.h"
|
2019-07-25 11:11:31 -04:00
|
|
|
|
2020-11-26 00:06:21 -05:00
|
|
|
#if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
|
|
|
|
|
2019-07-25 11:11:31 -04:00
|
|
|
void rtcio_hal_set_direction(int rtcio_num, rtc_gpio_mode_t mode)
|
|
|
|
{
|
|
|
|
switch (mode) {
|
|
|
|
case RTC_GPIO_MODE_INPUT_ONLY:
|
2023-09-15 00:56:13 -04:00
|
|
|
rtcio_ll_output_mode_set(rtcio_num, RTCIO_LL_OUTPUT_NORMAL);
|
2019-07-25 11:11:31 -04:00
|
|
|
rtcio_ll_output_disable(rtcio_num);
|
|
|
|
rtcio_ll_input_enable(rtcio_num);
|
|
|
|
break;
|
|
|
|
case RTC_GPIO_MODE_OUTPUT_ONLY:
|
2023-09-15 00:56:13 -04:00
|
|
|
rtcio_ll_output_mode_set(rtcio_num, RTCIO_LL_OUTPUT_NORMAL);
|
2019-07-25 11:11:31 -04:00
|
|
|
rtcio_ll_output_enable(rtcio_num);
|
|
|
|
rtcio_ll_input_disable(rtcio_num);
|
|
|
|
break;
|
|
|
|
case RTC_GPIO_MODE_INPUT_OUTPUT:
|
2023-09-15 00:56:13 -04:00
|
|
|
rtcio_ll_output_mode_set(rtcio_num, RTCIO_LL_OUTPUT_NORMAL);
|
2019-07-25 11:11:31 -04:00
|
|
|
rtcio_ll_output_enable(rtcio_num);
|
|
|
|
rtcio_ll_input_enable(rtcio_num);
|
|
|
|
break;
|
|
|
|
case RTC_GPIO_MODE_DISABLED:
|
2023-09-15 00:56:13 -04:00
|
|
|
rtcio_ll_output_mode_set(rtcio_num, RTCIO_LL_OUTPUT_NORMAL);
|
2019-07-25 11:11:31 -04:00
|
|
|
rtcio_ll_output_disable(rtcio_num);
|
|
|
|
rtcio_ll_input_disable(rtcio_num);
|
|
|
|
break;
|
|
|
|
case RTC_GPIO_MODE_OUTPUT_OD:
|
2023-09-15 00:56:13 -04:00
|
|
|
rtcio_ll_output_mode_set(rtcio_num, RTCIO_LL_OUTPUT_OD);
|
2019-07-25 11:11:31 -04:00
|
|
|
rtcio_ll_output_enable(rtcio_num);
|
|
|
|
rtcio_ll_input_disable(rtcio_num);
|
|
|
|
break;
|
|
|
|
case RTC_GPIO_MODE_INPUT_OUTPUT_OD:
|
2023-09-15 00:56:13 -04:00
|
|
|
rtcio_ll_output_mode_set(rtcio_num, RTCIO_LL_OUTPUT_OD);
|
2019-07-25 11:11:31 -04:00
|
|
|
rtcio_ll_output_enable(rtcio_num);
|
|
|
|
rtcio_ll_input_enable(rtcio_num);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void rtcio_hal_set_direction_in_sleep(int rtcio_num, rtc_gpio_mode_t mode)
|
|
|
|
{
|
|
|
|
switch (mode) {
|
|
|
|
case RTC_GPIO_MODE_INPUT_ONLY:
|
2022-12-13 04:27:04 -05:00
|
|
|
rtcio_ll_enable_input_in_sleep(rtcio_num);
|
|
|
|
rtcio_ll_disable_output_in_sleep(rtcio_num);
|
2019-07-25 11:11:31 -04:00
|
|
|
rtcio_ll_enable_sleep_setting(rtcio_num);
|
|
|
|
break;
|
|
|
|
case RTC_GPIO_MODE_OUTPUT_ONLY:
|
|
|
|
rtcio_ll_enable_output_in_sleep(rtcio_num);
|
2022-12-13 04:27:04 -05:00
|
|
|
rtcio_ll_disable_input_in_sleep(rtcio_num);
|
2019-07-25 11:11:31 -04:00
|
|
|
rtcio_ll_enable_sleep_setting(rtcio_num);
|
|
|
|
break;
|
|
|
|
case RTC_GPIO_MODE_INPUT_OUTPUT:
|
2022-12-13 04:27:04 -05:00
|
|
|
rtcio_ll_enable_input_in_sleep(rtcio_num);
|
2019-07-25 11:11:31 -04:00
|
|
|
rtcio_ll_enable_output_in_sleep(rtcio_num);
|
|
|
|
rtcio_ll_enable_sleep_setting(rtcio_num);
|
|
|
|
break;
|
|
|
|
case RTC_GPIO_MODE_DISABLED:
|
2022-12-13 04:27:04 -05:00
|
|
|
rtcio_ll_disable_input_in_sleep(rtcio_num);
|
|
|
|
rtcio_ll_disable_output_in_sleep(rtcio_num);
|
2019-07-25 11:11:31 -04:00
|
|
|
rtcio_ll_disable_sleep_setting(rtcio_num);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2020-11-10 02:40:01 -05:00
|
|
|
}
|
2020-11-26 00:06:21 -05:00
|
|
|
|
2023-06-30 04:30:03 -04:00
|
|
|
#if SOC_RTCIO_HOLD_SUPPORTED
|
|
|
|
void rtcio_hal_isolate(int rtcio_num)
|
|
|
|
{
|
|
|
|
rtcio_ll_pullup_disable(rtcio_num);
|
|
|
|
rtcio_ll_pulldown_disable(rtcio_num);
|
|
|
|
rtcio_ll_output_disable(rtcio_num);
|
|
|
|
rtcio_ll_input_disable(rtcio_num);
|
|
|
|
rtcio_ll_force_hold_enable(rtcio_num);
|
|
|
|
}
|
2020-11-26 00:06:21 -05:00
|
|
|
#endif
|
2023-06-30 04:30:03 -04:00
|
|
|
|
|
|
|
#endif //SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
|