@@ -164,40 +164,41 @@ extern void IRAM_ATTR __pinMode(uint8_t pin, uint8_t mode)
164
164
return ;
165
165
}
166
166
167
- uint32_t rtc_reg = rtc_io_desc [pin ].reg ;
167
+ int8_t rtc_io = esp32_gpioMux [pin ].rtc ;
168
+ uint32_t rtc_reg = (rtc_io != -1 )?rtc_io_desc [rtc_io ].reg :0 ;
168
169
if (mode == ANALOG ) {
169
170
if (!rtc_reg ) {
170
171
return ;//not rtc pin
171
172
}
172
173
#if CONFIG_IDF_TARGET_ESP32S2
173
174
SENS .sar_io_mux_conf .iomux_clk_gate_en = 1 ;
174
175
#endif
175
- SET_PERI_REG_MASK (rtc_io_desc [pin ].reg , (rtc_io_desc [pin ].mux ));
176
- SET_PERI_REG_BITS (rtc_io_desc [pin ].reg , RTC_IO_TOUCH_PAD1_FUN_SEL_V , SOC_PIN_FUNC_RTC_IO , rtc_io_desc [pin ].func );
176
+ SET_PERI_REG_MASK (rtc_io_desc [rtc_io ].reg , (rtc_io_desc [rtc_io ].mux ));
177
+ SET_PERI_REG_BITS (rtc_io_desc [rtc_io ].reg , RTC_IO_TOUCH_PAD1_FUN_SEL_V , SOC_PIN_FUNC_RTC_IO , rtc_io_desc [rtc_io ].func );
177
178
178
- RTCIO .pin [pin ].pad_driver = 0 ;//OD = 1
179
- RTCIO .enable_w1tc .w1tc = (1U << pin );
180
- CLEAR_PERI_REG_MASK (rtc_io_desc [pin ].reg , rtc_io_desc [pin ].ie );
179
+ RTCIO .pin [rtc_io ].pad_driver = 0 ;//OD = 1
180
+ RTCIO .enable_w1tc .w1tc = (1U << rtc_io );
181
+ CLEAR_PERI_REG_MASK (rtc_io_desc [rtc_io ].reg , rtc_io_desc [rtc_io ].ie );
181
182
182
- if (rtc_io_desc [pin ].pullup ) {
183
- CLEAR_PERI_REG_MASK (rtc_io_desc [pin ].reg , rtc_io_desc [pin ].pullup );
183
+ if (rtc_io_desc [rtc_io ].pullup ) {
184
+ CLEAR_PERI_REG_MASK (rtc_io_desc [rtc_io ].reg , rtc_io_desc [rtc_io ].pullup );
184
185
}
185
- if (rtc_io_desc [pin ].pulldown ) {
186
- CLEAR_PERI_REG_MASK (rtc_io_desc [pin ].reg , rtc_io_desc [pin ].pulldown );
186
+ if (rtc_io_desc [rtc_io ].pulldown ) {
187
+ CLEAR_PERI_REG_MASK (rtc_io_desc [rtc_io ].reg , rtc_io_desc [rtc_io ].pulldown );
187
188
}
188
189
ESP_REG (DR_REG_IO_MUX_BASE + esp32_gpioMux [pin ].reg ) = ((uint32_t )GPIO_FUNC << MCU_SEL_S ) | ((uint32_t )2 << FUN_DRV_S ) | FUN_IE ;
189
190
return ;
190
191
}
191
192
192
193
//RTC pins PULL settings
193
- if (esp32_gpioMux [ pin ]. rtc != -1 ) {
194
- ESP_REG (rtc_reg ) = ESP_REG (rtc_reg ) & ~(rtc_io_desc [pin ].mux );
194
+ if (rtc_reg ) {
195
+ ESP_REG (rtc_reg ) = ESP_REG (rtc_reg ) & ~(rtc_io_desc [rtc_io ].mux );
195
196
if (mode & PULLUP ) {
196
- ESP_REG (rtc_reg ) = (ESP_REG (rtc_reg ) | rtc_io_desc [pin ].pullup ) & ~(rtc_io_desc [pin ].pulldown );
197
+ ESP_REG (rtc_reg ) = (ESP_REG (rtc_reg ) | rtc_io_desc [rtc_io ].pullup ) & ~(rtc_io_desc [rtc_io ].pulldown );
197
198
} else if (mode & PULLDOWN ) {
198
- ESP_REG (rtc_reg ) = (ESP_REG (rtc_reg ) | rtc_io_desc [pin ].pulldown ) & ~(rtc_io_desc [pin ].pullup );
199
+ ESP_REG (rtc_reg ) = (ESP_REG (rtc_reg ) | rtc_io_desc [rtc_io ].pulldown ) & ~(rtc_io_desc [rtc_io ].pullup );
199
200
} else {
200
- ESP_REG (rtc_reg ) = ESP_REG (rtc_reg ) & ~(rtc_io_desc [pin ].pullup | rtc_io_desc [pin ].pulldown );
201
+ ESP_REG (rtc_reg ) = ESP_REG (rtc_reg ) & ~(rtc_io_desc [rtc_io ].pullup | rtc_io_desc [rtc_io ].pulldown );
201
202
}
202
203
}
203
204
0 commit comments