1 /*
2 * Copyright (c) 2021 Yonatan Schachter
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #include <zephyr/drivers/pinctrl.h>
8
9 /* pico-sdk includes */
10 #include <hardware/gpio.h>
11
pinctrl_configure_pin(const pinctrl_soc_pin_t * pin)12 static void pinctrl_configure_pin(const pinctrl_soc_pin_t *pin)
13 {
14 gpio_init(pin->pin_num);
15 gpio_set_function(pin->pin_num, pin->alt_func);
16 gpio_set_pulls(pin->pin_num, pin->pullup, pin->pulldown);
17 gpio_set_drive_strength(pin->pin_num, pin->drive_strength);
18 gpio_set_slew_rate(pin->pin_num, (pin->slew_rate ?
19 GPIO_SLEW_RATE_FAST : GPIO_SLEW_RATE_SLOW));
20 gpio_set_input_hysteresis_enabled(pin->pin_num, pin->schmitt_enable);
21 gpio_set_input_enabled(pin->pin_num, pin->input_enable);
22 gpio_set_oeover(pin->pin_num, pin->oe_override);
23 }
24
pinctrl_configure_pins(const pinctrl_soc_pin_t * pins,uint8_t pin_cnt,uintptr_t reg)25 int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt,
26 uintptr_t reg)
27 {
28 ARG_UNUSED(reg);
29
30 for (uint8_t i = 0U; i < pin_cnt; i++) {
31 pinctrl_configure_pin(pins++);
32 }
33
34 return 0;
35 }
36