1 /* 2 * Copyright (c) 2021 Argentum Systems Ltd. 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include <zephyr/devicetree.h> 8 #include <zephyr/drivers/gpio.h> 9 #include <zephyr/init.h> 10 radio_off_setup(void)11static int radio_off_setup(void) 12 { 13 int ret; 14 const struct gpio_dt_spec reset = GPIO_DT_SPEC_GET(DT_NODELABEL(lora), reset_gpios); 15 const struct gpio_dt_spec cs = GPIO_DT_SPEC_GET(DT_NODELABEL(sercom4), cs_gpios); 16 17 if (!gpio_is_ready_dt(&reset) || !gpio_is_ready_dt(&cs)) { 18 return -ENODEV; 19 } 20 21 ret = gpio_pin_configure_dt(&reset, GPIO_OUTPUT_ACTIVE); 22 if (ret < 0) { 23 return ret; 24 } 25 26 ret = gpio_pin_configure_dt(&cs, GPIO_OUTPUT_INACTIVE); 27 if (ret < 0) { 28 return ret; 29 } 30 31 return 0; 32 } 33 34 SYS_INIT(radio_off_setup, PRE_KERNEL_1, 99); 35