ZephyrOS:如何将驱动模块添加到out of tree项目中

ZephyrOS: how to add driver module to out of tree project

我还没有找到关于如何将驱动程序模块添加到树外 Zephyr 项目的确切信息,所以我将自己提供答案。

变化:

CMakeLists.txt

+set(ZEPHYR_EXTRA_MODULES drivers/ololo)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})

prj.conf

+CONFIG_OLOLO=y

Kconfig

No changes

新文件:

drivers/ololo/CMakeLists.txt

zephyr_library()
zephyr_library_sources_ifdef(CONFIG_OLOLO ololo.c)

drivers/ololo/Kconfig

menuconfig OLOLO
        bool "Ololo driver"
        default y
        select BLAH
        depends on MEH
        help
          Enable support for ololo driver

if OLOLO

module = OLOLO
module-str = ololo
source "subsys/logging/Kconfig.template.log_config"

endif

drivers/ololo/ololo.c

/* Code goes here */

drivers/ololo/zephyr/module.yml

build:
  cmake: .
  kconfig: Kconfig