diff options
author | Damien George <damien.p.george@gmail.com> | 2016-04-22 10:35:26 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2016-04-22 10:35:26 +0100 |
commit | 67a6d31955cb7ff8985f9f96675a70870eea4089 (patch) | |
tree | cfbd4f3c8d19ab5581e2ce7735cf87771b3236ac /esp8266/esp_mphal.h | |
parent | a2d5d84ecca175fbfbf42e892d6376efd08758eb (diff) | |
download | micropython-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.h | 12 |
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_ |