summaryrefslogtreecommitdiffstatshomepage
path: root/esp8266/esp_mphal.h
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-04-22 10:35:26 +0100
committerDamien George <damien.p.george@gmail.com>2016-04-22 10:35:26 +0100
commit67a6d31955cb7ff8985f9f96675a70870eea4089 (patch)
treecfbd4f3c8d19ab5581e2ce7735cf87771b3236ac /esp8266/esp_mphal.h
parenta2d5d84ecca175fbfbf42e892d6376efd08758eb (diff)
downloadmicropython-67a6d31955cb7ff8985f9f96675a70870eea4089.tar.gz
micropython-67a6d31955cb7ff8985f9f96675a70870eea4089.zip
esp8266: Allow GPIO16 to be used as a pin in the uPy pin HAL.
Now I2C works with GPIO16 as the SCL or SDA pin.
Diffstat (limited to 'esp8266/esp_mphal.h')
-rw-r--r--esp8266/esp_mphal.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/esp8266/esp_mphal.h b/esp8266/esp_mphal.h
index 4dca17d0a4..a768f9de7c 100644
--- a/esp8266/esp_mphal.h
+++ b/esp8266/esp_mphal.h
@@ -66,8 +66,14 @@ void ets_event_poll(void);
#define mp_hal_pin_obj_t uint32_t
#define mp_hal_get_pin_obj(o) mp_obj_get_pin(o)
void mp_hal_pin_config_od(mp_hal_pin_obj_t pin);
-#define mp_hal_pin_low(p) gpio_output_set(0, 1 << (p), 1 << (p), 0)
-#define mp_hal_pin_od_high(p) gpio_output_set(1 << (p), 0, 1 << (p), 0)
-#define mp_hal_pin_read(p) GPIO_INPUT_GET(GPIO_ID_PIN((p)))
+#define mp_hal_pin_low(p) do { \
+ if ((p) == 16) { WRITE_PERI_REG(RTC_GPIO_ENABLE, (READ_PERI_REG(RTC_GPIO_ENABLE) & ~1) | 1); } \
+ else { gpio_output_set(0, 1 << (p), 1 << (p), 0); } \
+ } while (0)
+#define mp_hal_pin_od_high(p) do { \
+ if ((p) == 16) { WRITE_PERI_REG(RTC_GPIO_ENABLE, (READ_PERI_REG(RTC_GPIO_ENABLE) & ~1)); } \
+ else { gpio_output_set(1 << (p), 0, 1 << (p), 0); } \
+ } while (0)
+#define mp_hal_pin_read(p) pin_get(p)
#endif // _INCLUDED_MPHAL_H_