<?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>How do I extra the gpio phandle form a lis3dh device to the C code?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/110469/how-do-i-extra-the-gpio-phandle-form-a-lis3dh-device-to-the-c-code</link><description>I have a lis3dh sensor where I want to configure the interrupts. I am currently struggling to extract the information from the irq-gpios phandle to the c driver. I went through the troubleshooting page for the device tree and found a website explanation</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 26 Apr 2024 06:43:34 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/110469/how-do-i-extra-the-gpio-phandle-form-a-lis3dh-device-to-the-c-code" /><item><title>RE: How do I extra the gpio phandle form a lis3dh device to the C code?</title><link>https://devzone.nordicsemi.com/thread/480803?ContentTypeID=1</link><pubDate>Fri, 26 Apr 2024 06:43:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9d0f7d23-f69c-468c-8f43-eb41fbf08264</guid><dc:creator>runsiv</dc:creator><description>&lt;p&gt;I wonder if it might not be the intellisense giving a false positive. I have seen it reported with the same driver before on devzone. I did acutally get the same warning yesterday with the following config.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;//prj.conf
CONFIG_I2C=y
CONFIG_SENSOR=y
CONFIG_LIS2DH=y
CONFIG_LIS2DH_TRIGGER_GLOBAL_THREAD=y

//devicetree
&amp;amp;i2c1 {
    compatible = &amp;quot;nordic,nrf-twim&amp;quot;;
    status = &amp;quot;okay&amp;quot;;
    lis3dh: lis3dh@18 {
        compatible = &amp;quot;st,lis2dh&amp;quot;,&amp;quot;st,lis2dh12&amp;quot;, &amp;quot;st,lis3dh&amp;quot; ;
        status = &amp;quot;okay&amp;quot;;
        reg = &amp;lt;0x18&amp;gt;;
        irq-gpios = &amp;lt;&amp;amp;gpio0 2 GPIO_ACTIVE_HIGH&amp;gt;,&amp;lt;&amp;amp;gpio1 15 GPIO_ACTIVE_HIGH&amp;gt;;
        disconnect-sdo-sa0-pull-up;
    };
};
 
/{
    aliases {
        accel0 = &amp;amp;lis3dh;
    };
}; &lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;But when I started VScode today it gave me no warning. I would recommend checking if the sensor is included in the generated devicetree with status okay&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Runar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I extra the gpio phandle form a lis3dh device to the C code?</title><link>https://devzone.nordicsemi.com/thread/480726?ContentTypeID=1</link><pubDate>Thu, 25 Apr 2024 13:57:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1e293595-339c-4e5f-84a1-b65ea9c4263f</guid><dc:creator>J0sh1101</dc:creator><description>&lt;p&gt;I do not get any errors, but I get a warning saying that it cannot enabled:&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;-- Including generated dts.cmake file: C:/nordic_play_workfolder/LIS3DH/build_nrf52840_dk/zephyr/dts.cmake

warning: LIS2DH (defined at drivers/sensor/lis2dh/Kconfig:6) was assigned the value &amp;#39;y&amp;#39; but got the
value &amp;#39;n&amp;#39;. Check these unsatisfied dependencies: DT_HAS_ST_LIS2DH_ENABLED (=n). See
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_LIS2DH and/or look up LIS2DH in the
menuconfig/guiconfig interface. The Application Development Primer, Setting Configuration Values,
and Kconfig - Tips and Best Practices sections of the manual might be helpful too.&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I extra the gpio phandle form a lis3dh device to the C code?</title><link>https://devzone.nordicsemi.com/thread/480700?ContentTypeID=1</link><pubDate>Thu, 25 Apr 2024 13:00:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5dfc3594-c8ad-4cdc-ad0c-fd1a0fc8ee59</guid><dc:creator>runsiv</dc:creator><description>&lt;p&gt;Do you get any error when you try to a pristine build?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I have seen in the past doing a pristine build or deleting the build folder might help.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You can also check if it is included in the generated .dts with status okey.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Runar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I extra the gpio phandle form a lis3dh device to the C code?</title><link>https://devzone.nordicsemi.com/thread/480678?ContentTypeID=1</link><pubDate>Thu, 25 Apr 2024 12:09:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2f5f9a8e-78e0-4f61-97a8-9ab4cd676d0b</guid><dc:creator>J0sh1101</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Unfortunately it did not make any difference. I got that it could not set the CONFIG_LIS2DH:&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;br /&gt;&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/Screenshot-2024_2D00_04_2D00_25-140816.png" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Do you know why is this happening?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I extra the gpio phandle form a lis3dh device to the C code?</title><link>https://devzone.nordicsemi.com/thread/480426?ContentTypeID=1</link><pubDate>Wed, 24 Apr 2024 11:21:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:acb5337f-1471-49b3-9242-02e12adeee1c</guid><dc:creator>runsiv</dc:creator><description>&lt;p&gt;Could you try adding the following Kconfig options&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_SENSOR&lt;/span&gt;&lt;span&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_LIS2DH&lt;/span&gt;&lt;span&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_LIS3DH is not a thing so you would need to use LIS2DH. It might also be that you need to set compatible to&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;quot;st,lis3dh&amp;quot;, &amp;quot;st,lis2dh&amp;quot;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;br /&gt;Regards&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Runar&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I extra the gpio phandle form a lis3dh device to the C code?</title><link>https://devzone.nordicsemi.com/thread/480239?ContentTypeID=1</link><pubDate>Tue, 23 Apr 2024 13:52:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:361263fb-b5ed-471d-949b-56220d9221e8</guid><dc:creator>runsiv</dc:creator><description>&lt;p&gt;Thanks for the new info.&amp;nbsp; I will need to get back to you tomorrow after looking a bit more into it. However from what I can see you have not enabled the sensor in your prj.conf, try adding CONFIG_LIS3DH=y&lt;/p&gt;
&lt;p&gt;We have a lesson covering writing custom drivers &lt;a href="https://academy.nordicsemi.com/courses/nrf-connect-sdk-intermediate/lessons/lesson-7-device-driver-model/"&gt;here&lt;/a&gt; which might be helpful&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Runar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I extra the gpio phandle form a lis3dh device to the C code?</title><link>https://devzone.nordicsemi.com/thread/480228?ContentTypeID=1</link><pubDate>Tue, 23 Apr 2024 13:29:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9d7bc185-70ac-4e66-b76e-5d1676f5f9f7</guid><dc:creator>J0sh1101</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
[quote userid="122502" url="~/f/nordic-q-a/110469/how-do-i-extra-the-gpio-phandle-form-a-lis3dh-device-to-the-c-code/480136"]Which version of NCS are you using? [/quote]
&lt;p&gt;I am using the nRF Connect SDK v2.6.&lt;/p&gt;
[quote userid="122502" url="~/f/nordic-q-a/110469/how-do-i-extra-the-gpio-phandle-form-a-lis3dh-device-to-the-c-code/480136"]If you remove the line &amp;quot;const struct gpio_dt_spec int1 = DT_GPIO_CTLR_BY_IDX(I2C1_NODE, irq_gpios, 0);&amp;quot; does it build then?[/quote]
&lt;p&gt;Yes, then it builds. I can extract the data and saved to 2c_dt_spec:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1713876545862v1.png" alt=" " /&gt;&lt;/p&gt;
[quote userid="122502" url="~/f/nordic-q-a/110469/how-do-i-extra-the-gpio-phandle-form-a-lis3dh-device-to-the-c-code/480136"]Could you post your prj.conf?[/quote]
&lt;p&gt;ofc, here is the prj.conf:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;# Logger module
CONFIG_LOG=y
CONFIG_LOG_MODE_MINIMAL=y


CONFIG_NEWLIB_LIBC=y
CONFIG_CBPRINTF_FP_SUPPORT=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y



# Button and LED library
CONFIG_DK_LIBRARY=y
CONFIG_BOOT_BANNER=n
CONFIG_I2C=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="122502" url="~/f/nordic-q-a/110469/how-do-i-extra-the-gpio-phandle-form-a-lis3dh-device-to-the-c-code/480136"] I presume your case is somewhat the same as this &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/104448/lis3dh-interrupt-pins-configuration"&gt;case&lt;/a&gt;[/quote]
&lt;p&gt;Maybe a little. I am trying to write my own driver and he is trying to use the existing driver which I have given up. The interface of the driver is far too complex to just write a few registers and is not intuitive.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="122502" url="~/f/nordic-q-a/110469/how-do-i-extra-the-gpio-phandle-form-a-lis3dh-device-to-the-c-code/480136"]Have you verfied that your address is correct according to your setup?[/quote]
&lt;p&gt;Which address are we talking about?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I talked to someone who knows more about the device tree than I do and he said that the problem is the macro function &amp;quot;DT_NODELABEL(mysensor)&amp;quot; and not DT_GPIO_CTLR_BY_IDX() as I thought at first. This is strange because the macro function I2C_DT_SPEC_GET() works perfectly with DT_NODELABEL(), but DT_NODELABEL does not work with DT_GPIO_CTLR_BY_IDX. DT_NODE_LABEL uses the concatenation to create a define which can be found in devicetree_generated.h. In my case it is &lt;strong&gt;DT_N_S_soc_S_i2c_40003000_S_mysensor_18_P_irq_gpios_IDX_0_PH&lt;/strong&gt;. The problem seems to be that it cannot find the define of &lt;strong&gt;DT_N_S_soc_S_gpio_50000000&lt;/strong&gt;. (Now, the error message makes more sense.) At this point I do not understand why the &lt;strong&gt;DT_N_S_soc_S_gpio_50000000&lt;/strong&gt; is not created.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Do you know anything more about this?&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;(This device tree is really a hell.)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I extra the gpio phandle form a lis3dh device to the C code?</title><link>https://devzone.nordicsemi.com/thread/480136?ContentTypeID=1</link><pubDate>Tue, 23 Apr 2024 08:38:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:06b74548-014f-4078-9058-064033381ee9</guid><dc:creator>runsiv</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Which version of NCS are you using? Have you verfied that your address is correct according to your setup?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The pinconfig looks correct to me so the overlay should be good. If you remove the line &amp;quot;const struct gpio_dt_spec int1 = DT_GPIO_CTLR_BY_IDX(I2C1_NODE, irq_gpios, 0);&amp;quot; does it build then? I presume your case is somewhat the same as this &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/104448/lis3dh-interrupt-pins-configuration"&gt;case&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Could you post your prj.conf?&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Runar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>