<?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>Clarification on intended driver to communicating with generic SPI device on nRF52 DK running Zephyr</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/61900/clarification-on-intended-driver-to-communicating-with-generic-spi-device-on-nrf52-dk-running-zephyr</link><description>I apologize if this has been asked in a different way but I have come across several older threads that seem outdated and was hoping for the new &amp;quot;best practices&amp;quot; for the current release of the nRF Connect SDK (v1.2.0) at the time of this writing. 
 I</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 12 Jun 2020 07:27:02 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/61900/clarification-on-intended-driver-to-communicating-with-generic-spi-device-on-nrf52-dk-running-zephyr" /><item><title>RE: Clarification on intended driver to communicating with generic SPI device on nRF52 DK running Zephyr</title><link>https://devzone.nordicsemi.com/thread/254611?ContentTypeID=1</link><pubDate>Fri, 12 Jun 2020 07:27:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c1d6f289-f734-4a82-a04d-c83e3f692ead</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;nRF9160 has the NRF_SPIM peripheral only, not the legacy NRF_SPI peripheral.&lt;/p&gt;
&lt;p&gt;Have you manually created a driver for the rhd2132&amp;nbsp;in the zephyr tree (dts + .c / .h)? If not, that overlay section related to &amp;quot;rhd2132@22&amp;quot; will not work as you intend it to, and you should remove it from the overlay file.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Clarification on intended driver to communicating with generic SPI device on nRF52 DK running Zephyr</title><link>https://devzone.nordicsemi.com/thread/254567?ContentTypeID=1</link><pubDate>Thu, 11 Jun 2020 17:54:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bfdb3c9e-a280-4612-8b8a-b631fdfe7352</guid><dc:creator>Neuroengineer</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;H&amp;aring;kon,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I have finally had some more time to work on this. I decided I wanted to try and get the &amp;quot;Zephyr&amp;quot; option working so I was referring to the nrf9160 example you sent. At the moment I am just trying to get the &amp;quot;device_get_binding()&amp;quot; function to&amp;nbsp;run properly and identify the SPI controller I am hoping to use. During complilation I get an error from the nrfx_spi library that says&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;quot;&amp;#39;DT_NORDIC_NRF_SPI_SPI_1_IRQ_0_PRIORITY&amp;#39; undeclared (first use in this function); did you mean &amp;#39;DT_NORDIC_NRF_SPIM_SPI_1_IRQ_0_PRIORITY&amp;#39;?&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The surrounding code in the driver is this:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;	static int spi_##idx##_init(struct device *dev)			       \
	{								       \
		IRQ_CONNECT(NRFX_IRQ_NUMBER_GET(NRF_SPI##idx),		       \
			    DT_NORDIC_NRF_SPI_SPI_##idx##_IRQ_0_PRIORITY,      \
			    nrfx_isr, nrfx_spi_##idx##_irq_handler, 0);	       \
		return init_spi(dev);					       \
	}	
	
	...
	
		static const struct spi_nrfx_config spi_##idx##z_config = {	       \
		.spi = NRFX_SPI_INSTANCE(idx),				       \
		.config = {						       \
			.sck_pin   = DT_NORDIC_NRF_SPI_SPI_##idx##_SCK_PIN,    \
			.mosi_pin  = DT_NORDIC_NRF_SPI_SPI_##idx##_MOSI_PIN,   \
			.miso_pin  = DT_NORDIC_NRF_SPI_SPI_##idx##_MISO_PIN,   \
			.ss_pin    = NRFX_SPI_PIN_NOT_USED,		       \
			.orc       = CONFIG_SPI_##idx##_NRF_ORC,	       \
			.frequency = NRF_SPI_FREQ_4M,			       \
			.mode      = NRF_SPI_MODE_0,			       \
			.bit_order = NRF_SPI_BIT_ORDER_MSB_FIRST,	       \
			.miso_pull = SPI_NRFX_MISO_PULL(idx),		       \
		}							       \
	};	&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I also get some errors around where the pin assigments are made (also in code snippet above). For the record it looks like changing the SPI port I am trying to configure does properly populate the &amp;quot;idx&amp;quot; variable.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Also here is my most up-to-date overlay file and proj.conf file&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;# GPIO
CONFIG_GPIO=y

# SPI - Copied from Nordic nrf9160 samples
CONFIG_SPI=y
CONFIG_SPI_NRFX=y
CONFIG_SPI_1=y
CONFIG_SPI_1_NRF_SPIM=y&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;spi1 {
	compatible = &amp;quot;nordic,nrf-spim&amp;quot;;
	status = &amp;quot;okay&amp;quot;;
	sck-pin = &amp;lt;25&amp;gt;;
	mosi-pin = &amp;lt;23&amp;gt;;
	miso-pin = &amp;lt;24&amp;gt;;
    rhd2132@22 {
        compatible = &amp;quot;spi-device&amp;quot;;
        reg = &amp;lt;22&amp;gt;;
        spi-max-frequency = &amp;lt;24000000&amp;gt;;
        label = &amp;quot;RHD2132&amp;quot;;
    };
};&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Any ideas? In order to get things working in the short term I may just switch to the nrfx library that you suggested.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks again&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Clarification on intended driver to communicating with generic SPI device on nRF52 DK running Zephyr</title><link>https://devzone.nordicsemi.com/thread/252190?ContentTypeID=1</link><pubDate>Thu, 28 May 2020 12:57:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3f4075db-f857-4ed4-a277-c9f3a6c83fd2</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi again,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Small update:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I also have a old sample to interface zephyr spi API here:&amp;nbsp;&lt;a href="https://github.com/Rallare/fw-nrfconnect-nrf/blob/nrf9160_samples/samples/nrf9160/spi/src/main.c"&gt;https://github.com/Rallare/fw-nrfconnect-nrf/blob/nrf9160_samples/samples/nrf9160/spi/src/main.c&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This will highly likely not compile with latest NCS, and&amp;nbsp;especially towards&amp;nbsp;nrf52-series (SPIM3 not present in most nRF52-series devices), but let me know if you want to try and get stuck somewhere.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Clarification on intended driver to communicating with generic SPI device on nRF52 DK running Zephyr</title><link>https://devzone.nordicsemi.com/thread/252189?ContentTypeID=1</link><pubDate>Thu, 28 May 2020 12:51:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e89e7bc1-77c8-4e98-89db-9e8b59fdfc95</guid><dc:creator>Neuroengineer</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;H&amp;aring;kon,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks very much for the detailed reply and links to resources. I will spend some time digging into this.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Clarification on intended driver to communicating with generic SPI device on nRF52 DK running Zephyr</title><link>https://devzone.nordicsemi.com/thread/252186?ContentTypeID=1</link><pubDate>Thu, 28 May 2020 12:47:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6650e9e9-9ffd-4af2-a745-00f48088307c</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]Is this the appropriate driver to use. If so could you point me in the direction of the documentation for this driver and/or and example of it being used including the devicetree overlay file necessary? I assume I need to use this one if I want to take advantage of the DMA features of the nrf devices.[/quote]
&lt;p&gt;When you set compatible = &amp;quot;&lt;span&gt;nordic,nrf-spim&amp;quot;;, you&amp;#39;re telling dts to target the NRF_SPIM peripheral, which is DMA only.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If you were to switch it out with &amp;quot;nordic,nrf-spi&amp;quot;, you will use the older NRF_SPI module, which is not DMA capable. NRF_SPI is only supported on nRF51 and nRF52-series devices.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Drivers-wise, you essentially have two options (zephyr choice is divided into two options):&lt;/p&gt;
&lt;p&gt;1. Use the generic Zephyr driver API&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; a. Hard way: Create a full-blown zephyr based driver - this is normally not done unless you plan to do a pull-request to the zephyr-rtos project.&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; b. Easier way: Setup the SPI instance in your application, then add the communication protocol on-top.&lt;/p&gt;
&lt;p&gt;2. Use the nordic specific nrfx driver directly&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;You can use the Zephyr API to create your own driver. This includes creating Kconfig menu, device tree, and developing the sensor src and porting to use the spi.h API. This would then be a portable driver, which can theoretically run on any of the supported SPI &amp;quot;backends&amp;quot; (ie: x86, arm, xtensa, etc), but its not a straight forward process.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;You also have the option to use the nrfx_spim driver directly in your application, by adding CONFIG_NRFX_SPIM=y, then adding for instance CONFIG_NRFX_SPIM1=y.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I made a quick example, based on zephyr/samples/basic/blinky/, where I added nrfx_spim, so that you can have a look at the steps for manually adding a nrfx driver to a sample.&lt;/p&gt;
&lt;p&gt;The sequence is very similar on other&amp;nbsp;nrfx drivers (pdm, i2s, rtc, etc).&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-f965eb73b1d1474dbc2a569db847a3df/nrfx_5F00_spim.zip"&gt;devzone.nordicsemi.com/.../nrfx_5F00_spim.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I tested this on both nrf52_pca10040 board, and nrf9160_pca10090 board. You short MISO and MOSI pin to receive what you transmit.&lt;/p&gt;
&lt;p&gt;I also added a .overlay file for nrf52_pca10040, in case you want to look&amp;nbsp;into adding the zephyr SPI driver.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user=""]Again, I apologize for the confusion I think I am getting tripped up in the change from nRF5 to nRF Connect SDK and want to use the &amp;quot;most&amp;quot; supported method of communicating with SPI devices on nRF chips.[/quote]
&lt;p&gt;&amp;nbsp;This is nothing to apologize for. It is a huge change, and it is very understandable that you ask questions. Have you seen this blog post series?&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/nordic/nrf-connect-sdk-guides/b/getting-started/posts/nrf-connect-sdk-tutorial"&gt;https://devzone.nordicsemi.com/nordic/nrf-connect-sdk-guides/b/getting-started/posts/nrf-connect-sdk-tutorial&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;That should help with understanding how it all is tied together.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>