This is an automated email from the ASF dual-hosted git repository.

sjanc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit fc245085febc37d00feb75d99576d27d8ed813a1
Author: Wiktor Kwiatkowski <[email protected]>
AuthorDate: Wed Apr 29 12:16:06 2026 +0200

    hw/mcu/atmel: Add GPIO deinit
    
    Add missing hal_gpio_deinit function. It restores the pin to its
    default state
---
 hw/mcu/atmel/samd21xx/src/hal_gpio.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/hw/mcu/atmel/samd21xx/src/hal_gpio.c 
b/hw/mcu/atmel/samd21xx/src/hal_gpio.c
index 3d0d003fe..1d4f66469 100644
--- a/hw/mcu/atmel/samd21xx/src/hal_gpio.c
+++ b/hw/mcu/atmel/samd21xx/src/hal_gpio.c
@@ -270,6 +270,31 @@ hal_gpio_toggle(int pin)
     return hal_gpio_read(pin);
 }
 
+int
+hal_gpio_deinit(int pin)
+{
+    struct port_config cfg;
+
+    int port = GPIO_PORT(pin);
+    int port_pin = GPIO_PIN(pin);
+
+    if (port > GPIO_MAX_PORT) {
+        return -1;
+    }
+
+    if ((port_pin & valid_pins[port]) == 0) {
+        return -1;
+    }
+
+    cfg.direction = PORT_PIN_DIR_INPUT;
+    cfg.input_pull = PORT_PIN_PULL_NONE;
+    cfg.powersave = true;
+
+    port_pin_set_config(pin, &cfg);
+
+    return 0;
+}
+
 /*
  * Interrupt handler for gpio.
  */

Reply via email to