From 799193888a553de8876052019842538396f92194 Mon Sep 17 00:00:00 2001 From: WEMOS Electronics <11569115@qq.com> Date: Sun, 29 Jul 2018 01:07:01 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20digitalPinToBitMask(),=20portOutputRegist?= =?UTF-8?q?er(),=20portInputRegister()=20=E2=80=A6=20(#4964)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix digitalPinToBitMask(), portOutputRegister(), portInputRegister() and portModeRegister() error when the pin is GPIO16. --- cores/esp8266/Arduino.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cores/esp8266/Arduino.h b/cores/esp8266/Arduino.h index c1e185414..b13817ae8 100644 --- a/cores/esp8266/Arduino.h +++ b/cores/esp8266/Arduino.h @@ -224,12 +224,13 @@ void loop(void); void yield(void); void optimistic_yield(uint32_t interval_us); -#define digitalPinToPort(pin) (0) -#define digitalPinToBitMask(pin) (1UL << (pin)) +#define _PORT_GPIO16 1 +#define digitalPinToPort(pin) (((pin)==16)?(_PORT_GPIO16):(0)) +#define digitalPinToBitMask(pin) (((pin)==16)?(1):(1UL << (pin))) #define digitalPinToTimer(pin) (0) -#define portOutputRegister(port) ((volatile uint32_t*) &GPO) -#define portInputRegister(port) ((volatile uint32_t*) &GPI) -#define portModeRegister(port) ((volatile uint32_t*) &GPE) +#define portOutputRegister(port) (((port)==_PORT_GPIO16)?((volatile uint32_t*) &GP16O):((volatile uint32_t*) &GPO)) +#define portInputRegister(port) (((port)==_PORT_GPIO16)?((volatile uint32_t*) &GP16I):((volatile uint32_t*) &GPI)) +#define portModeRegister(port) (((port)==_PORT_GPIO16)?((volatile uint32_t*) &GP16E):((volatile uint32_t*) &GPE)) #define NOT_A_PIN -1 #define NOT_A_PORT -1