<?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>Use SPI to interface to SDcard under Zephyr</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/72277/use-spi-to-interface-to-sdcard-under-zephyr</link><description>I&amp;#39;m attempting to connect an SDcard (micro SD) to an nRF52840-DK via a breadboard setup. I&amp;#39;m running Zephyr and it appears that configuration is to be performed via device-tree. I&amp;#39;m following one of the examples in the samples/subsys/fs/fat_fs directory</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 04 Mar 2021 16:08:59 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/72277/use-spi-to-interface-to-sdcard-under-zephyr" /><item><title>RE: Use SPI to interface to SDcard under Zephyr</title><link>https://devzone.nordicsemi.com/thread/297880?ContentTypeID=1</link><pubDate>Thu, 04 Mar 2021 16:08:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7942d9a0-9378-4df9-bbfb-a23a90efcca3</guid><dc:creator>CktDesigner</dc:creator><description>&lt;p&gt;Ok, thanks...&amp;nbsp; &amp;nbsp;I&amp;#39;ve been using Segger Embedded Studio...&lt;/p&gt;
&lt;p&gt;Thanks for your assistance!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Use SPI to interface to SDcard under Zephyr</title><link>https://devzone.nordicsemi.com/thread/297699?ContentTypeID=1</link><pubDate>Thu, 04 Mar 2021 09:01:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5a61e27d-e12b-4dde-90af-0ee1146d0363</guid><dc:creator>Simon</dc:creator><description>[quote user="CktDesigner"]While it works, I still couldn&amp;#39;t find the definition of DT_GPIO_LABEL_BY_IDX() which is in the define of DT_SPI_DEV_CS_GPIOS_LABEL()&amp;nbsp; &amp;nbsp; &amp;nbsp;(in devicetree/spi.h)&amp;nbsp; Yet it compiles!!&amp;nbsp; &amp;nbsp;So it must be somewhere![/quote]
&lt;p&gt;DT_GPIO_LABEL_BY_IDX is defined at &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/5acae16d9ea808785279b1de1cd177108c1b1354/include/devicetree/gpio.h#L102"&gt;zephyr\include\devicetree\gpio.h&lt;/a&gt;. I would recommend you to download Visual Studio Code, which allows you to open the whole NCS and search for variables/functions/macros etc.. If you install &lt;a href="https://marketplace.visualstudio.com/items?itemName=trond-snekvik.kconfig-lang"&gt;Kconfig for the Zephyr Project&lt;/a&gt;&lt;span&gt;&amp;nbsp;and &lt;a href="https://marketplace.visualstudio.com/items?itemName=trond-snekvik.devicetree"&gt;DeviceTree for the Zephyr Project&lt;/a&gt;&amp;nbsp;you can use &amp;quot;Show Definition&amp;quot; to see where it&amp;#39;s defined. As a sidenote, you could also open a Terminal in VS Code and do the actual development in the editor.&lt;/span&gt;&lt;/p&gt;
[quote user="CktDesigner"]I&amp;#39;m also confused when to use CONFIG statements vs defining things via device tree...&amp;nbsp; &amp;nbsp;[/quote]
&lt;p&gt;Stuff that is defined in the device tree has to do with hardware and hardware configuration. E.g. SDA and SCL pins, what UART baud rate to use, pins for LEDs and buttons and so on. The CONFIG statements are used for configuring everything else, what drivers an libraries and drivers to use and to enable other firmware specific features.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Use SPI to interface to SDcard under Zephyr</title><link>https://devzone.nordicsemi.com/thread/297653?ContentTypeID=1</link><pubDate>Thu, 04 Mar 2021 03:16:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fd328178-15e8-4b66-8c8e-153ada021264</guid><dc:creator>CktDesigner</dc:creator><description>&lt;p&gt;Hi Simon,&lt;/p&gt;
&lt;p&gt;Thanks!&amp;nbsp; &amp;nbsp;Adding CONFIG_GPIO=y&amp;nbsp; &amp;nbsp;to prj.conf solved it.&lt;/p&gt;
&lt;p&gt;While it works, I still couldn&amp;#39;t find the definition of DT_GPIO_LABEL_BY_IDX() which is in the define of DT_SPI_DEV_CS_GPIOS_LABEL()&amp;nbsp; &amp;nbsp; &amp;nbsp;(in devicetree/spi.h)&amp;nbsp; Yet it compiles!!&amp;nbsp; &amp;nbsp;So it must be somewhere!&lt;/p&gt;
&lt;p&gt;I&amp;#39;m also confused when to use CONFIG statements vs defining things via device tree...&amp;nbsp; &amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks for your help!!!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Use SPI to interface to SDcard under Zephyr</title><link>https://devzone.nordicsemi.com/thread/297537?ContentTypeID=1</link><pubDate>Wed, 03 Mar 2021 13:45:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a890bd6b-5ca3-4adf-8d7c-360c69722bd2</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Try setting &lt;code&gt;CONFIG_GPIO=y&lt;/code&gt; in the prj.conf file&lt;/p&gt;
&lt;p&gt;The definition fo the macro &lt;code&gt;DT_SPI_DEV_CS_GPIOS_LABEL&lt;/code&gt; is inside&amp;nbsp;\zephyr\include\devicetree\spi.h&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;I think &lt;code&gt;&lt;span&gt;device_get_binding(DT_SPI_DEV_CS_GPIOS_LABEL(SPI_SDHC_NODE))&amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;span&gt;gets converted into&amp;nbsp;device_get_binding(&amp;quot;GPIO_1&amp;quot;). You could try to call this direcly to se if this &amp;quot;device&amp;quot; is actually correctly set up. In order for this to succeed, gpio1 needs to get added into the device tree (it seems like this is okay for you since you found it in zephyr.dts) and the driver needs to get set up as well (set CONFIG_GPIO=y), which will define an init function (&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/5acae16d9ea808785279b1de1cd177108c1b1354/drivers/gpio/gpio_nrfx.c#L489"&gt;DEVICE_DT_DEFINE&lt;/a&gt;--&amp;gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/5acae16d9ea808785279b1de1cd177108c1b1354/drivers/gpio/gpio_nrfx.c#L455"&gt;gpio_nrfx_init()&lt;/a&gt;). If the init function is not called or fails, the device will be&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/5acae16d9ea808785279b1de1cd177108c1b1354/kernel/device.c#L69"&gt; declared not ready&lt;/a&gt; and the call to device_get_binding will fail.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;This is how I remembered how it worked, hopefully I got it correct :P&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Simon&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>