ESP8266 GPIO registers confusion
Posted: Sat May 07, 2022 5:26 pm
AVR have DDRx for pin configure (direction), PORTx for setting output and PINx for reading input.
ARM (at least STM32) have GPIOx_CRL (and GPIOx_CRH, or GPIOx_MODER) for pin configure (direction), GPIOx_ODR (and alternatively GPIOx_BSRR and GPIOx_BRR for atomic operations) for setting output and GPIOx_IDR for reading input.
PIC (at least PIC16F877A) have TRISx for pin configure (direction) and PORTx for both setting output and reading input.
What stands for those functions in ESP8266? I'm reading technical reference I had downloaded from Espressif website and I can't get a proper grasp at that.
Configure pin (direction)
Section 2.2.2 lists GPIO_ENABLE output register (and its two companions GPIO_ENABLE_W1TS and GPIO_ENABLE_W1TC for atomic operations) which enables the output. It doesn't state explicitly that disabling the output configures a pin as an input. Does doing so configure a pin as an input?
Configure pin (function)
Section 2.2.1 states that it's not enough to just choose a GPIOx and set its direction, instead I have to define its function number first. PERIPHS_IO_MUX_x register is mentioned in regard to this role. But first, this register isn't listed in Appendix 1 (GPIO registers), and secondly, where are the function numbers listed?
Setting output
Okay, this one looks clear. Section 2.2.2 lists GPIO_OUT output register (and its two companions GPIO_OUT_W1TS and GPIO_OUT_W1TC for atomic operations).
Reading input
Section 2.2.3 mentions GPIO input register, but doesn't name it. Is GPIO_IN_DATA from Appendix 1 impied? And why make input read register writable (section 2.2.3 mentions it as r / w)?
ARM (at least STM32) have GPIOx_CRL (and GPIOx_CRH, or GPIOx_MODER) for pin configure (direction), GPIOx_ODR (and alternatively GPIOx_BSRR and GPIOx_BRR for atomic operations) for setting output and GPIOx_IDR for reading input.
PIC (at least PIC16F877A) have TRISx for pin configure (direction) and PORTx for both setting output and reading input.
What stands for those functions in ESP8266? I'm reading technical reference I had downloaded from Espressif website and I can't get a proper grasp at that.
Configure pin (direction)
Section 2.2.2 lists GPIO_ENABLE output register (and its two companions GPIO_ENABLE_W1TS and GPIO_ENABLE_W1TC for atomic operations) which enables the output. It doesn't state explicitly that disabling the output configures a pin as an input. Does doing so configure a pin as an input?
Configure pin (function)
Section 2.2.1 states that it's not enough to just choose a GPIOx and set its direction, instead I have to define its function number first. PERIPHS_IO_MUX_x register is mentioned in regard to this role. But first, this register isn't listed in Appendix 1 (GPIO registers), and secondly, where are the function numbers listed?
Setting output
Okay, this one looks clear. Section 2.2.2 lists GPIO_OUT output register (and its two companions GPIO_OUT_W1TS and GPIO_OUT_W1TC for atomic operations).
Reading input
Section 2.2.3 mentions GPIO input register, but doesn't name it. Is GPIO_IN_DATA from Appendix 1 impied? And why make input read register writable (section 2.2.3 mentions it as r / w)?