summaryrefslogtreecommitdiff
path: root/esp8266/esp_mphal.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-04-22 10:04:12 +0100
committerDamien George <damien.p.george@gmail.com>2016-04-22 10:04:12 +0100
commita2d5d84ecca175fbfbf42e892d6376efd08758eb (patch)
tree5d382b3ba3bf0c489f90577e3401f4a701b532da /esp8266/esp_mphal.c
parent624738ca64c71c8f2cccced3fb5d2380bb4ae56b (diff)
esp8266: Convert mp_hal_pin_obj_t from pin ptr to simple integer.
Most pin I/O can be done just knowing the pin number as a simple integer, and it's more efficient this way (code size, speed) because it doesn't require a memory lookup to get the pin id from the pin object. If the full pin object is needed then it can be easily looked up in the pin table.
Diffstat (limited to 'esp8266/esp_mphal.c')
-rw-r--r--esp8266/esp_mphal.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/esp8266/esp_mphal.c b/esp8266/esp_mphal.c
index 0573f3d56..686f54bc3 100644
--- a/esp8266/esp_mphal.c
+++ b/esp8266/esp_mphal.c
@@ -212,3 +212,15 @@ void dupterm_task_init() {
void mp_hal_signal_dupterm_input(void) {
system_os_post(DUPTERM_TASK_ID, 0, 0);
}
+
+void mp_hal_pin_config_od(mp_hal_pin_obj_t pin_id) {
+ const pyb_pin_obj_t *pin = &pyb_pin_obj[pin_id];
+ ETS_GPIO_INTR_DISABLE();
+ PIN_FUNC_SELECT(pin->periph, pin->func);
+ GPIO_REG_WRITE(GPIO_PIN_ADDR(GPIO_ID_PIN(pin->phys_port)),
+ GPIO_REG_READ(GPIO_PIN_ADDR(GPIO_ID_PIN(pin->phys_port)))
+ | GPIO_PIN_PAD_DRIVER_SET(GPIO_PAD_DRIVER_ENABLE)); // open drain
+ GPIO_REG_WRITE(GPIO_ENABLE_ADDRESS,
+ GPIO_REG_READ(GPIO_ENABLE_ADDRESS) | (1 << pin->phys_port));
+ ETS_GPIO_INTR_ENABLE();
+}