2022-12-13 09:27:04 +00:00
|
|
|
/*
|
2023-06-30 08:30:03 +00:00
|
|
|
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
2022-12-13 09:27:04 +00:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2019-07-25 15:11:31 +00:00
|
|
|
|
|
|
|
// The HAL layer for RTC IO (common part)
|
|
|
|
|
|
|
|
#include "hal/rtc_io_hal.h"
|
2021-01-07 02:13:17 +00:00
|
|
|
#include "soc/soc_caps.h"
|
2019-07-25 15:11:31 +00:00
|
|
|
|
2020-11-26 05:06:21 +00:00
|
|
|
#if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
|
|
|
|
|
2019-07-25 15:11:31 +00: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 04:56:13 +00:00
|
|
|
rtcio_ll_output_mode_set(rtcio_num, RTCIO_LL_OUTPUT_NORMAL);
|
2019-07-25 15:11:31 +00:00
|
|
|
rtcio_ll_output_disable(rtcio_num);
|
|
|
|
rtcio_ll_input_enable(rtcio_num);
|
|
|
|
break;
|
|
|
|
case RTC_GPIO_MODE_OUTPUT_ONLY:
|
2023-09-15 04:56:13 +00:00
|
|
|
rtcio_ll_output_mode_set(rtcio_num, RTCIO_LL_OUTPUT_NORMAL);
|
2019-07-25 15:11:31 +00:00
|
|
|
rtcio_ll_output_enable(rtcio_num);
|
|
|
|
rtcio_ll_input_disable(rtcio_num);
|
|
|
|
break;
|
|
|
|
case RTC_GPIO_MODE_INPUT_OUTPUT:
|
2023-09-15 04:56:13 +00:00
|
|
|
rtcio_ll_output_mode_set(rtcio_num, RTCIO_LL_OUTPUT_NORMAL);
|
2019-07-25 15:11:31 +00:00
|
|
|
rtcio_ll_output_enable(rtcio_num);
|
|
|
|
rtcio_ll_input_enable(rtcio_num);
|
|
|
|
break;
|
|
|
|
case RTC_GPIO_MODE_DISABLED:
|
2023-09-15 04:56:13 +00:00
|
|
|
rtcio_ll_output_mode_set(rtcio_num, RTCIO_LL_OUTPUT_NORMAL);
|
2019-07-25 15:11:31 +00:00
|
|
|
rtcio_ll_output_disable(rtcio_num);
|
|
|
|
rtcio_ll_input_disable(rtcio_num);
|
|
|
|
break;
|
|
|
|
case RTC_GPIO_MODE_OUTPUT_OD:
|
2023-09-15 04:56:13 +00:00
|
|
|
rtcio_ll_output_mode_set(rtcio_num, RTCIO_LL_OUTPUT_OD);
|
2019-07-25 15:11:31 +00:00
|
|
|
rtcio_ll_output_enable(rtcio_num);
|
|
|
|
rtcio_ll_input_disable(rtcio_num);
|
|
|
|
break;
|
|
|
|
case RTC_GPIO_MODE_INPUT_OUTPUT_OD:
|
2023-09-15 04:56:13 +00:00
|
|
|
rtcio_ll_output_mode_set(rtcio_num, RTCIO_LL_OUTPUT_OD);
|
2019-07-25 15:11:31 +00: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 09:27:04 +00:00
|
|
|
rtcio_ll_enable_input_in_sleep(rtcio_num);
|
|
|
|
rtcio_ll_disable_output_in_sleep(rtcio_num);
|
2019-07-25 15:11:31 +00: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 09:27:04 +00:00
|
|
|
rtcio_ll_disable_input_in_sleep(rtcio_num);
|
2019-07-25 15:11:31 +00:00
|
|
|
rtcio_ll_enable_sleep_setting(rtcio_num);
|
|
|
|
break;
|
|
|
|
case RTC_GPIO_MODE_INPUT_OUTPUT:
|
2022-12-13 09:27:04 +00:00
|
|
|
rtcio_ll_enable_input_in_sleep(rtcio_num);
|
2019-07-25 15:11:31 +00: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 09:27:04 +00:00
|
|
|
rtcio_ll_disable_input_in_sleep(rtcio_num);
|
|
|
|
rtcio_ll_disable_output_in_sleep(rtcio_num);
|
2019-07-25 15:11:31 +00:00
|
|
|
rtcio_ll_disable_sleep_setting(rtcio_num);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2020-11-10 07:40:01 +00:00
|
|
|
}
|
2020-11-26 05:06:21 +00:00
|
|
|
|
2023-06-30 08:30:03 +00: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 05:06:21 +00:00
|
|
|
#endif
|
2023-06-30 08:30:03 +00:00
|
|
|
|
|
|
|
#endif //SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
|