1 /* 2 * Copyright (c) 2020 Jefferson Lee. 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include <zephyr/init.h> 8 #include <zephyr/drivers/gpio.h> 9 board_init(void)10static int board_init(void) 11 { 12 13 int res; 14 static const struct gpio_dt_spec pull_up = 15 GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), pull_up_gpios); 16 static const struct gpio_dt_spec user_led = 17 GPIO_DT_SPEC_GET(DT_ALIAS(led4), gpios); 18 19 if (!gpio_is_ready_dt(&pull_up)) { 20 return -ENODEV; 21 } 22 23 if (!gpio_is_ready_dt(&user_led)) { 24 return -ENODEV; 25 } 26 27 res = gpio_pin_configure_dt(&pull_up, GPIO_OUTPUT_HIGH); 28 if (res) { 29 return res; 30 } 31 32 return gpio_pin_configure_dt(&user_led, GPIO_OUTPUT_INACTIVE); 33 } 34 35 SYS_INIT(board_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE); 36