How does Zephyr brings dts, kernel, driver & user app together?
Stefan Jaritz
Hej,
I like to create an user app that uses 2 IC connected via I2C with my MCU. Doing this is a bit tricky because I am missing some documentation, that is describing how the whole process goes. My setup is simple: 1.) custom board based on the stm32f412RG 1.1) the IC are connected via I2C 1.2) dts changes: &i2c1 { status = "ok"; clock-frequency = <I2C_BITRATE_FAST>; codec1@48 { compatible = "xxx,codec1"; reg = <0x48>; label = "codec1"; }; codec2@46 { compatible = "xxx,codec2"; reg = <0x46>; label = "codec2"; readAddr = <0x8F>; writeAddr = <0x8E>; }; }; 2.) user app 2.1) custom driver (codec1.c and codec2.c) How can I get the value of the I2C slave address from the dts inside of my source code? How can I find and access the c-files after the dts compilation? How Zephyr connects the c code of the dts, kernel, drivers, user drivers and app? Any help is welcome! Stefan
|
|
Erwan Gouriou
Hi Stefan, To generate #define's from dt, you need to provide the matching yaml binding to indicate how fields should be decided, this should be done under dts/bindings/... Generated #define's will be available in build directory, under zephyr/include/generated/generated_... You should be able to use them as you wish. To make your driver somewhat generic (ie not depending on the node address, you'll need to provide intermediate #define in dts_fixup.h file (under soc/ or board/). For more information, you can check in various drivers how DT_xxxx constants are used Cheers Erwan
Le ven. 4 janv. 2019 à 17:30, Stefan Jaritz <stefan@...> a écrit : Hej,
|
|
Stefan Jaritz
Hej ho Thanks Erwan for the reply. I checked the "dts/bindings/sensor/" dir to get an idea. If I get it right I need to create the files "xxx,codec1.yaml" and "xxx,codec2.yaml"? I don't like to dirty the zephyr source tree because I think mixing own stuff and official stuff will create problems on the long run. So how I do create an own "dts/bindings" binding dir and include it into the zephyr build process? I was checking for a zephyr related yaml doc. I put on the search
of official documentation page, but got no
description(https://docs.zephyrproject.org/1.13.0/search.html?q=yaml&check_keywords=yes&area=default).
There is a YAML spec (https://yaml.org/spec/1.2/spec.html) but I
misses the structure and keywords zephyr is using. Any idea were
to search for it? - or maybe a simple explained example Kind regards! Stefan
On 07/01/2019 09:26, Erwan Gouriou
wrote:
|
|