- Mon Jun 24, 2019 1:43 am
#82916
As stated earlier, IO state is possible to set with IO_MUX.
From:
https://github.com/esp8266/esp8266-wiki/wiki/Memory-MapCode: Select alliomux Pin Registers (60000804h–60000843h)
31 24 16 8 0
-------- -ffff--- -------- ud--UDEe
`- Function || |||`- Output Enable
|| ||`- Output Enable during sleep
|| |`- Pull-down during sleep
|| `- Pull-up during sleep
|`- Pull-down
`- Pull-up
Bit[2] definition thus differs between the link above and this one:
https://esp8266.ru/esp8266-pin-register ... s-registerThat means, not sure if it's possible to pull IO down during the deep sleep, worth to try. I didn't tried that, not needed.
The Pin-register map is good to locate the register number for your required GPIO.
To set GPIO in pull up state during deep sleep, bits [0], [1], [3] and [7] should be asserted.
It's recommended by read-modify-write process. Example for GPIO14:
Code: Select alluint32_t val = READ_PERI_REG(PERIPHS_IO_MUX + 12);
uint32_t mask = 0x8b; /bits[0,1,3,7] asserted. Same as value to be asserted.
WRITE_PERI_REG(PERIPHS_IO_MUX + 12, (!mask & val) | (mask & 0x8b));
The expression (mask & 0x8b) is universal approach to read-mod-write. It's practically needed only in case you want to set some bits to 0. That is not the case, so just 0x8b is enough here.
The GPIO configuration is reset by MCU boot. Run read-mod-write every boot.