mirror of
https://github.com/espressif/esp-idf.git
synced 2025-10-04 12:29:40 +00:00
esp_rom: extract common GPIO apis into esp_rom_gpio.h
This commit is contained in:
@@ -19,13 +19,15 @@
|
||||
#include "esp32/rom/ets_sys.h"
|
||||
#include "esp32/rom/rtc.h"
|
||||
#include "esp32/rom/uart.h"
|
||||
#include "esp32/rom/gpio.h"
|
||||
#include "esp_rom_gpio.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "soc/rtc_periph.h"
|
||||
#include "soc/sens_periph.h"
|
||||
#include "soc/dport_reg.h"
|
||||
#include "soc/efuse_periph.h"
|
||||
#include "soc/apb_ctrl_reg.h"
|
||||
#include "soc/gpio_struct.h"
|
||||
#include "hal/gpio_ll.h"
|
||||
#include "i2c_rtc_clk.h"
|
||||
#include "soc_log.h"
|
||||
#include "sdkconfig.h"
|
||||
@@ -174,22 +176,27 @@ void rtc_clk_32k_bootstrap(uint32_t cycle)
|
||||
if (cycle){
|
||||
const uint32_t pin_32 = 32;
|
||||
const uint32_t pin_33 = 33;
|
||||
const uint32_t mask_32 = (1 << (pin_32 - 32));
|
||||
const uint32_t mask_33 = (1 << (pin_33 - 32));
|
||||
|
||||
gpio_pad_select_gpio(pin_32);
|
||||
gpio_pad_select_gpio(pin_33);
|
||||
gpio_output_set_high(mask_32, mask_33, mask_32 | mask_33, 0);
|
||||
esp_rom_gpio_pad_select_gpio(pin_32);
|
||||
esp_rom_gpio_pad_select_gpio(pin_33);
|
||||
gpio_ll_output_enable(&GPIO, pin_32);
|
||||
gpio_ll_output_enable(&GPIO, pin_33);
|
||||
gpio_ll_set_level(&GPIO, pin_32, 1);
|
||||
gpio_ll_set_level(&GPIO, pin_33, 0);
|
||||
|
||||
const uint32_t delay_us = (1000000 / RTC_SLOW_CLK_FREQ_32K / 2);
|
||||
while(cycle){
|
||||
gpio_output_set_high(mask_32, mask_33, mask_32 | mask_33, 0);
|
||||
gpio_ll_set_level(&GPIO, pin_32, 1);
|
||||
gpio_ll_set_level(&GPIO, pin_33, 0);
|
||||
ets_delay_us(delay_us);
|
||||
gpio_output_set_high(mask_33, mask_32, mask_32 | mask_33, 0);
|
||||
gpio_ll_set_level(&GPIO, pin_33, 1);
|
||||
gpio_ll_set_level(&GPIO, pin_32, 0);
|
||||
ets_delay_us(delay_us);
|
||||
cycle--;
|
||||
}
|
||||
gpio_output_set_high(0, 0, 0, mask_32 | mask_33); // disable pins
|
||||
// disable pins
|
||||
gpio_ll_output_disable(&GPIO, pin_32);
|
||||
gpio_ll_output_disable(&GPIO, pin_33);
|
||||
}
|
||||
|
||||
CLEAR_PERI_REG_MASK(RTC_IO_XTAL_32K_PAD_REG, RTC_IO_XPD_XTAL_32K);
|
||||
|
Reference in New Issue
Block a user