File tree Expand file tree Collapse file tree
ports/esp8266/common-hal/microcontroller Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3333#include "eagle_soc.h"
3434
3535extern volatile bool adc_in_use ;
36+ volatile bool gpio16_in_use __attribute__((aligned (4 ))) = false;
3637
3738bool common_hal_mcu_pin_is_free (const mcu_pin_obj_t * pin ) {
3839 if (pin == & pin_TOUT ) {
3940 return !adc_in_use ;
4041 }
41- if (pin -> gpio_number == NO_GPIO || pin -> gpio_number == SPECIAL_CASE ) {
42+ if (pin -> gpio_number == NO_GPIO ) {
4243 return false;
4344 }
45+ if (pin -> gpio_number == 16 ) {
46+ return !gpio16_in_use ;
47+ }
4448 return (READ_PERI_REG (pin -> peripheral ) &
4549 (PERIPHS_IO_MUX_FUNC <<PERIPHS_IO_MUX_FUNC_S )) == 0 &&
4650 (GPIO_REG_READ (GPIO_ENABLE_ADDRESS ) & (1 << pin -> gpio_number )) == 0 &&
4751 (READ_PERI_REG (pin -> peripheral ) & PERIPHS_IO_MUX_PULLUP ) == 0 ;
4852}
4953
5054void reset_pins (void ) {
51- for (int i = 0 ; i < 17 ; i ++ ) {
55+ for (int i = 0 ; i < 16 ; i ++ ) {
5256 // 5 is RXD, 6 is TXD
5357 if ((i > 4 && i < 13 ) || i == 12 ) {
5458 continue ;
@@ -59,4 +63,9 @@ void reset_pins(void) {
5963 // Disable the pin.
6064 gpio_output_set (0x0 , 0x0 , 0x0 , 1 << i );
6165 }
66+ // Set GPIO16 as input
67+ WRITE_PERI_REG (PAD_XPD_DCDC_CONF , (READ_PERI_REG (PAD_XPD_DCDC_CONF ) & 0xffffffbc ) | 1 ); // mux configuration for XPD_DCDC and rtc_gpio0 connection
68+ WRITE_PERI_REG (RTC_GPIO_CONF , READ_PERI_REG (RTC_GPIO_CONF ) & ~1 ); //mux configuration for out enable
69+ WRITE_PERI_REG (RTC_GPIO_ENABLE , READ_PERI_REG (RTC_GPIO_ENABLE ) & ~1 ); //out disable
70+ gpio16_in_use = false;
6271}
You can’t perform that action at this time.
0 commit comments