diff --git a/.clang-format b/.clang-format index e45a924..8f5adfb 100644 --- a/.clang-format +++ b/.clang-format @@ -64,7 +64,6 @@ SpacesBeforeTrailingComments: 1 SpacesInAngles: false SpacesInCStyleCastParentheses: false SpacesInContainerLiterals: false -SpacesInParentheses: false SpacesInSquareBrackets: false # Alignment settings diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ebe1cd..46d79cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,9 @@ cmake_minimum_required(VERSION 3.20.0) +# Register the vnd7050aj module before finding Zephyr +list(APPEND ZEPHYR_EXTRA_MODULES ${CMAKE_CURRENT_SOURCE_DIR}/modules/vnd7050aj) + find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(hello_world) target_sources(app PRIVATE src/main.c) -target_include_directories(app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/modules/vnd7050aj/include) -target_link_directories(app PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/modules/vnd7050aj) -target_link_libraries(app PRIVATE vnd7050aj) - -add_subdirectory(modules/vnd7050aj) diff --git a/Kconfig b/Kconfig index 007db71..6391f85 100644 --- a/Kconfig +++ b/Kconfig @@ -1,6 +1 @@ source "${ZEPHYR_BASE}/Kconfig" - -config VND7050AJ - bool "VND7050AJ library support" - help - Enable support for the VND7050AJ high-side driver. \ No newline at end of file diff --git a/modules/Kconfig b/modules/Kconfig new file mode 100644 index 0000000..81846cb --- /dev/null +++ b/modules/Kconfig @@ -0,0 +1,5 @@ +config VND7050AJ + bool "VND7050AJ library support" + default n + help + Enable support for the VND7050AJ high-side driver. diff --git a/modules/vnd7050aj/CMakeLists.txt b/modules/vnd7050aj/CMakeLists.txt index 0166c55..19e4e47 100644 --- a/modules/vnd7050aj/CMakeLists.txt +++ b/modules/vnd7050aj/CMakeLists.txt @@ -1,3 +1,12 @@ -add_library(vnd7050aj STATIC src/vnd7050aj.c) -target_include_directories(vnd7050aj PRIVATE include) -target_link_libraries(vnd7050aj PUBLIC zephyr_interface) +# SPDX-License-Identifier: Apache-2.0 + +if(CONFIG_VND7050AJ) + +zephyr_library() +zephyr_library_sources(src/vnd7050aj.c) +zephyr_library_include_directories(include) + +# Make the header files available globally +zephyr_include_directories(include) + +endif() # CONFIG_VND7050AJ diff --git a/modules/vnd7050aj/Kconfig b/modules/vnd7050aj/Kconfig new file mode 100644 index 0000000..04fb762 --- /dev/null +++ b/modules/vnd7050aj/Kconfig @@ -0,0 +1,34 @@ +# VND7050AJ Driver Configuration + +config VND7050AJ + bool "VND7050AJ driver" + default y + help + Enable the VND7050AJ driver for interfacing with VND7050AJ devices. + This driver provides basic functionality for VND7050AJ operations. + +if VND7050AJ + +config VND7050AJ_INIT_PRIORITY + int "VND7050AJ initialization priority" + default 80 + help + VND7050AJ driver initialization priority. This should be set to a value + that ensures the driver is initialized after the required subsystems + (like GPIO, I2C, SPI) but before application code runs. + +config VND7050AJ_LOG_LEVEL + int "VND7050AJ Log level" + depends on LOG + default 3 + range 0 4 + help + Sets log level for VND7050AJ driver. + Levels are: + 0 OFF, do not write + 1 ERROR, only write LOG_ERR + 2 WARNING, write LOG_WRN in addition to previous level + 3 INFO, write LOG_INF in addition to previous levels + 4 DEBUG, write LOG_DBG in addition to previous levels + +endif # VND7050AJ diff --git a/dts/bindings/vnd7050aj.yaml b/modules/vnd7050aj/dts/bindings/vnd7050aj.yaml similarity index 87% rename from dts/bindings/vnd7050aj.yaml rename to modules/vnd7050aj/dts/bindings/vnd7050aj.yaml index 70aae35..4d2b794 100644 --- a/dts/bindings/vnd7050aj.yaml +++ b/modules/vnd7050aj/dts/bindings/vnd7050aj.yaml @@ -18,4 +18,5 @@ properties: # Add other properties relevant to the VND7050AJ, e.g., # current-sense-gpios: # type: phandle-array - # description: GPIO pin for current sense feedback + # required: false + # description: GPIO pins for current sensing diff --git a/modules/vnd7050aj/zephyr/module.yml b/modules/vnd7050aj/zephyr/module.yml new file mode 100644 index 0000000..488db37 --- /dev/null +++ b/modules/vnd7050aj/zephyr/module.yml @@ -0,0 +1,6 @@ +name: vnd7050aj +build: + cmake: . + kconfig: Kconfig + settings: + dts_root: dts diff --git a/prj.conf b/prj.conf index 7a10fff..fc5345d 100644 --- a/prj.conf +++ b/prj.conf @@ -1,4 +1,4 @@ CONFIG_LOG=y -CONFIG_LOG_DEFAULT_LEVEL=4 +CONFIG_LOG_DEFAULT_LEVEL=3 CONFIG_VND7050AJ=y