【简介】
S32K3 的GPIO 驱动在 zephyr 的如下路径\zephyr\drivers\gpio 以下两个文件分别对应S32K3 的siul2 的 GPIO 驱动和对应的配置文件

以下是对应的GPIO的驱动配置
# Copyright 2022, 2025 NXP # SPDX-License-Identifier: Apache-2.0 config GPIO_NXP_SIUL2 bool "NXP SIUL2 GPIO driver" default y depends on DT_HAS_NXP_SIUL2_GPIO_ENABLED select NOCACHE_MEMORY if ARCH_HAS_NOCACHE_MEMORY_SUPPORT help Enable the GPIO driver for NXP SIUL2.
对应Cmake 中对应配置和驱动文件的关联如下

工程如果需要编译GPIO驱动只要在工程中加入“CONFIG_GPIO=y”即可将驱动文件加入编译。
menuconfig GPIO bool "General-Purpose Input/Output (GPIO) drivers" help Include GPIO drivers in system config if GPIO module = GPIO module-str = gpio source "subsys/logging/Kconfig.template.log_config" config GPIO_SHELL bool "GPIO Shell" depends on SHELL help Enable GPIO Shell for testing. config GPIO_SHELL_INFO_CMD bool "GPIO Shell info command" default y depends on GPIO_SHELL help Enable GPIO Shell information command. This command provides a shell user extra information about gpio controller reserved pins and line names. config GPIO_SHELL_TOGGLE_CMD bool "GPIO Shell toggle command" default y depends on GPIO_SHELL help Enable GPIO Shell toggle command. config GPIO_SHELL_BLINK_CMD bool "GPIO Shell blink command" default y depends on GPIO_SHELL help Enable GPIO Shell blink command. This command provides a shell user the ability to 'blink' a pin at 1Hz. config GPIO_INIT_PRIORITY int "GPIO init priority" default KERNEL_INIT_PRIORITY_DEFAULT help GPIO driver device initialization priority. config GPIO_GET_DIRECTION bool "Support for querying GPIO direction [EXPERIMENTAL]" select EXPERIMENTAL help Enable this option if the application does not maintain its own GPIO direction state. With this option enabled, the application may query GPIO direction via gpio_port_get_direction(), gpio_pin_is_input(), and gpio_pin_is_output(). config GPIO_GET_CONFIG bool "Support for get configuration function [EXPERIMENTAL]" select EXPERIMENTAL help This option enables the support for getting the current configurations of GPIOs. The driver must implement it to work. config GPIO_HOGS bool "Support for GPIO hogs" default $(dt_gpio_hogs_enabled) help Enable support for GPIO hogs. GPIO hogging is a mechanism for providing automatic GPIO configuration via devicetree. config GPIO_HOGS_INIT_PRIORITY int "GPIO hogs init priority" default 41 depends on GPIO_HOGS help GPIO hogs initialization priority. GPIO hogs must be initialized after the GPIO controller drivers. config GPIO_ENABLE_DISABLE_INTERRUPT bool "Support for enable/disable interrupt without re-config [EXPERIMENTAL]" select EXPERIMENTAL help This option enables the support for enabling/disabling interrupt with previous configuration, and enabling/disabling the interrupt only turns on/off the interrupt signal without changing other registers, such as pending register, etc. The driver must implement it to work. # zephyr-keep-sorted-start ... source "drivers/gpio/Kconfig.nxp_siul2" ... # zephyr-keep-sorted-stop endif # GPIO
上述配置会加载 Kconfig.nxp_siul2 的配置,对应配置如下:
config GPIO_NXP_SIUL2 bool "NXP SIUL2 GPIO driver" default y depends on DT_HAS_NXP_SIUL2_GPIO_ENABLED select NOCACHE_MEMORY if ARCH_HAS_NOCACHE_MEMORY_SUPPORT
只要在设备树中开启 DT_HAS_NXP_SIUL2_GPIO_ENABLED 就会生成CONFIG_GPIO_NXP_SIUL2 的配置从而将驱动文件加入到工程中,工程中加入CONFIG_GPIO_SHELL的配置就会在shell中添加gpio 的命令。本地的shell 的工程配置中添加如下的配置加入gpio 测试命令。

编译完成后shell 中已经添加了gpio的测试命令。

我要赚赏金
