summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsommersoft <sommersoft@gmail.com>2018-04-25 03:57:09 +0000
committersommersoft <sommersoft@gmail.com>2018-04-25 03:57:09 +0000
commite70ece4c413b8fa5dce99240bff04e4641edf3a8 (patch)
treed0bf77dfb14ee36e51621c6539134658629312c8
parent8cadcc8e8387122babb398c91413056ff9c1c5c5 (diff)
now checks for proper pin in is_pin_free; initialize GPIO16 as input in reset_pins
-rw-r--r--ports/esp8266/common-hal/microcontroller/Pin.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/ports/esp8266/common-hal/microcontroller/Pin.c b/ports/esp8266/common-hal/microcontroller/Pin.c
index 5c90f4f1a..4b6efb428 100644
--- a/ports/esp8266/common-hal/microcontroller/Pin.c
+++ b/ports/esp8266/common-hal/microcontroller/Pin.c
@@ -33,14 +33,18 @@
#include "eagle_soc.h"
extern volatile bool adc_in_use;
+volatile bool gpio16_in_use __attribute__((aligned(4))) = false;
bool common_hal_mcu_pin_is_free(const mcu_pin_obj_t* pin) {
if (pin == &pin_TOUT) {
return !adc_in_use;
}
- if (pin->gpio_number == NO_GPIO || pin->gpio_number == SPECIAL_CASE) {
+ if (pin->gpio_number == NO_GPIO) {
return false;
}
+ if (pin->gpio_number == 16) {
+ return !gpio16_in_use;
+ }
return (READ_PERI_REG(pin->peripheral) &
(PERIPHS_IO_MUX_FUNC<<PERIPHS_IO_MUX_FUNC_S)) == 0 &&
(GPIO_REG_READ(GPIO_ENABLE_ADDRESS) & (1 << pin->gpio_number)) == 0 &&
@@ -48,7 +52,7 @@ bool common_hal_mcu_pin_is_free(const mcu_pin_obj_t* pin) {
}
void reset_pins(void) {
- for (int i = 0; i < 17; i++) {
+ for (int i = 0; i < 16; i++) {
// 5 is RXD, 6 is TXD
if ((i > 4 && i < 13) || i == 12) {
continue;
@@ -59,4 +63,9 @@ void reset_pins(void) {
// Disable the pin.
gpio_output_set(0x0, 0x0, 0x0, 1 << i);
}
+ // Set GPIO16 as input
+ 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
+ WRITE_PERI_REG(RTC_GPIO_CONF, READ_PERI_REG(RTC_GPIO_CONF) & ~1); //mux configuration for out enable
+ WRITE_PERI_REG(RTC_GPIO_ENABLE, READ_PERI_REG(RTC_GPIO_ENABLE) & ~1); //out disable
+ gpio16_in_use = false;
}