Re: How does Zephyr brings dts, kernel, driver & user app together?


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,

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




Join devel@lists.zephyrproject.org to automatically receive all group messages.