<?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>Devicetree: SPI device</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/93607/devicetree-spi-device</link><description>Hello, 
 I wanted to create an SPI shell, similar to what is available for I&amp;#178;C. I am therefore trying to create a generic SPI device in the devicetree: 
 
 
 Somehow I am not able to access the label &amp;quot;spi_sensor&amp;quot;: 
 
 
 If I change the label to &amp;quot;mx25r64</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 22 Nov 2022 13:08:26 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/93607/devicetree-spi-device" /><item><title>RE: Devicetree: SPI device</title><link>https://devzone.nordicsemi.com/thread/396916?ContentTypeID=1</link><pubDate>Tue, 22 Nov 2022 13:08:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b964f3ff-03e9-4b16-bed9-d1b38e526632</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You need to make sure that UART1/SPI1 is not taken by TF-M. However, I do not see how that should cause it to reset only when both SPI1 and SPI3 are used. Which pins are you using for SPI1 and SPI3?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Devicetree: SPI device</title><link>https://devzone.nordicsemi.com/thread/396415?ContentTypeID=1</link><pubDate>Fri, 18 Nov 2022 13:04:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9f76d22e-d086-4781-9133-dac73daeab8b</guid><dc:creator>Bernhard</dc:creator><description>&lt;p&gt;It seems I still have problems with SPI and the devicetree.&lt;/p&gt;
&lt;p&gt;I want to use SPI1 and SPI3, each of them is working fine but if I include them both together in the devicetree than the application is not starting up and just keeps reseting at startup.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;flash_spi: &amp;amp;spi1 {
	compatible = &amp;quot;nordic,nrf-spim&amp;quot;;
	status = &amp;quot;okay&amp;quot;;
	pinctrl-0 = &amp;lt;&amp;amp;spi1_default_alt&amp;gt;;
	pinctrl-1 = &amp;lt;&amp;amp;spi1_sleep_alt&amp;gt;;
	pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
	cs-gpios = &amp;lt;&amp;amp;gpio0 25 GPIO_ACTIVE_LOW&amp;gt;;
	mx25r64: mx25r6435f@0 {
		compatible = &amp;quot;jedec,spi-nor&amp;quot;;
		reg = &amp;lt;0&amp;gt;;
		spi-max-frequency = &amp;lt;80000000&amp;gt;;
		label = &amp;quot;MX25R64&amp;quot;;
		jedec-id = [c2 28 17];
		size = &amp;lt;67108864&amp;gt;;        // 0x4000000
	};
	
};

sensor_spi: &amp;amp;spi3 {                         // do not use spi0 or spi2, as is has shared resources (with uart0, i2c2)
	compatible = &amp;quot;nordic,nrf-spim&amp;quot;;
	status = &amp;quot;okay&amp;quot;;
	pinctrl-0 = &amp;lt;&amp;amp;spi3_default_alt&amp;gt;;
	pinctrl-1 = &amp;lt;&amp;amp;spi3_sleep_alt&amp;gt;;
	pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
	cs-gpios = &amp;lt;&amp;amp;gpio0 21 GPIO_ACTIVE_LOW&amp;gt;;
 	spi_sensor: spi-device@0 {
		compatible = &amp;quot;undock,spi-device&amp;quot;;
		reg = &amp;lt;0&amp;gt;;
		spi-max-frequency = &amp;lt;10000000&amp;gt;;
		label = &amp;quot;SPI dummy&amp;quot;;
	};
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Any ideas on that topic?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you a lot!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Devicetree: SPI device</title><link>https://devzone.nordicsemi.com/thread/394608?ContentTypeID=1</link><pubDate>Tue, 08 Nov 2022 08:55:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bd48eba4-c1b1-4b01-8397-45d858efb549</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;That is great to hear! I am happy 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;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Devicetree: SPI device</title><link>https://devzone.nordicsemi.com/thread/394495?ContentTypeID=1</link><pubDate>Mon, 07 Nov 2022 15:24:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f430accb-e11f-44b6-839e-606160b34b27</guid><dc:creator>Bernhard</dc:creator><description>&lt;p&gt;That worked, thank you a lot!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Devicetree: SPI device</title><link>https://devzone.nordicsemi.com/thread/394481?ContentTypeID=1</link><pubDate>Mon, 07 Nov 2022 15:04:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ded42a9c-2179-43ee-9130-e89be72ae686</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You are correct that you cannot use compatible = &amp;quot;spi-device&amp;quot;; directly. If you want to create your custom SPI device and not use an existing one, you must create bindings for it. Typically the compatible property is on the form &amp;quot;company,device&amp;quot;. I will use &amp;quot;company-name&amp;quot; here.&lt;/p&gt;
&lt;p&gt;What you must to is to create a binding file for the device. The binding file must be located inside the dts/bindings subdirectory of your chosen location (application directory, board directory, module directory, etc.). In the example of company-name and spi-device, the name of the file will be &amp;quot;company-name,spi-device.yaml&amp;quot;. Here you see an example file structure:&lt;/p&gt;
&lt;pre&gt;&lt;span&gt;my_app&lt;/span&gt;
 &lt;span&gt;|&lt;/span&gt;&lt;span&gt;___&lt;/span&gt; src
 &lt;span&gt;|&lt;/span&gt;&lt;span&gt;___&lt;/span&gt; prj.conf
 &lt;span&gt;|&lt;/span&gt;&lt;span&gt;___&lt;/span&gt; CMakeLists.txt
 &lt;span&gt;|&lt;/span&gt;&lt;span&gt;___&lt;/span&gt; dts
       &lt;span&gt;|&lt;/span&gt;&lt;span&gt;___&lt;/span&gt; bindings
            &lt;span&gt;|&lt;/span&gt;&lt;span&gt;___&lt;/span&gt; company-name,spi-device.yaml&lt;/pre&gt;
&lt;p&gt;If you do not want to add anything extra to the SPI device, then all you need to add to company-name,spi-device.yaml is the following:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;description: Company-name SPI device

compatible: &amp;quot;company-name,spi-device&amp;quot;

include: spi-device.yaml&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Then you must change the compatible property in your overlay file:&lt;/p&gt;
&lt;p&gt;&lt;code&gt; compatible = &amp;quot;company-name,spi-device&amp;quot;;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>