diff options
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_ |