<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Device Tree Magic Macros</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/103194/device-tree-magic-macros</link><description>I am trying to understand what is compiled when &amp;quot;Device Tree Magic Macros&amp;quot; are used to extract information from the device tree. For example, I would like to see what is compiled when the following statements are encountered by the preprocessor: 
 
 #define</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 30 Aug 2023 14:29:53 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/103194/device-tree-magic-macros" /><item><title>RE: Device Tree Magic Macros</title><link>https://devzone.nordicsemi.com/thread/443766?ContentTypeID=1</link><pubDate>Wed, 30 Aug 2023 14:29:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c9e26b10-7b7e-4626-8a06-3195b5ab5233</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi Jerry,&lt;/p&gt;
&lt;p&gt;Thank you for the kind words. It&amp;#39;s good to know I was able to help &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Hieu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Device Tree Magic Macros</title><link>https://devzone.nordicsemi.com/thread/443743?ContentTypeID=1</link><pubDate>Wed, 30 Aug 2023 13:17:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:65b348d8-7d58-4395-b0c7-a470250efbf8</guid><dc:creator>Jerry Easley</dc:creator><description>&lt;p&gt;Hi Hieu,&lt;/p&gt;
&lt;p&gt;Your response is very helpful; thank you so much!&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Jerry&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Device Tree Magic Macros</title><link>https://devzone.nordicsemi.com/thread/443361?ContentTypeID=1</link><pubDate>Mon, 28 Aug 2023 11:51:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5ee61da3-11da-4a97-8e02-6f19fd65d2b5</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi Jerry,&lt;/p&gt;
[quote user=""]My intuition is to run the compiler with -E flag set but I can&amp;#39;t figure out how to do that under vscode/nrf_sdk.[/quote]
&lt;p&gt;There is a relevant discussion on this on GitHub here:&amp;nbsp;&lt;a href="https://github.com/zephyrproject-rtos/zephyr/issues/8329"&gt;https://github.com/zephyrproject-rtos/zephyr/issues/8329&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;There is also a method to keep preprocessed source files explained here:&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.4.1/zephyr/build/dts/troubleshooting.html#look-at-the-preprocessor-output"&gt;Troubleshooting devicetree — Zephyr Project documentation (nRF Connect SDK) (nordicsemi.com)&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Trying to expand the macro like&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/patrick"&gt;Patrick&lt;/a&gt;&amp;nbsp;said is an option. I could not get it to work like they said, but hover the mouse over the macro gives me its expanded form. I searched further and can replace it inline using the IDE with the method described here:&amp;nbsp;&lt;a href="https://github.com/microsoft/vscode-cpptools/issues/4183#issuecomment-865443907"&gt;https://github.com/microsoft/vscode-cpptools/issues/4183#issuecomment-865443907&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;However, my understanding is that you want to understand how the macros are expanded. If so, you will want to look into these resources:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.4.1/zephyr/build/dts/api-usage.html"&gt;Devicetree access from C/C++ — Zephyr Project documentation (nRF Connect SDK) (nordicsemi.com)&lt;/a&gt;&lt;br /&gt;You might want to get a general idea of the terms used from this page.&lt;br /&gt;It&amp;#39;s also a good idea to understand the the relevant&amp;nbsp;concepts from the parent page here:&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.4.1/zephyr/build/dts/index.html"&gt;Devicetree — Zephyr Project documentation (nRF Connect SDK) (nordicsemi.com)&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;The macros are defined in&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.3.99-ncs1/include/zephyr/devicetree.h"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/v3.3.99-ncs1/include/zephyr/devicetree.h&lt;br /&gt;&lt;br /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;The header file where all the Devicetree nodes are compiled and generated is &amp;lt;build directory&amp;gt;/zephyr/include/generated/devicetree_generated.h&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Hieu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Device Tree Magic Macros</title><link>https://devzone.nordicsemi.com/thread/443243?ContentTypeID=1</link><pubDate>Sat, 26 Aug 2023 22:42:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:94cae236-ceb4-43d7-8e57-2f572bce49f0</guid><dc:creator>Patrick</dc:creator><description>&lt;p&gt;In VSCode, when you right click a macro, click refactor, then &amp;quot;Expand Macro&amp;quot;. This will show you what code that macro has generated.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>