<?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>nrf52840 SPI slave configuration event_handler</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/69034/nrf52840-spi-slave-configuration-event_handler</link><description>I use zephyr to do a spi communication on nrf52840, and my nrf52840 is spi slvae 
 I refer to the example of zephyr spi\zephyr\tests\drivers\spi\spi_loopback\src\spi.c At present they all use simple spi_write/spi_read to read/write spi buffer And in zephyr</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 11 Dec 2020 13:41:27 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/69034/nrf52840-spi-slave-configuration-event_handler" /><item><title>RE: nrf52840 SPI slave configuration event_handler</title><link>https://devzone.nordicsemi.com/thread/284553?ContentTypeID=1</link><pubDate>Fri, 11 Dec 2020 13:41:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4a04a768-e048-47ca-8f5f-2a492e041dee</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;
[quote user="hmw"]What I want is to have an IRQ_Handler that allows me to give semaphore behavior when an interrupt occurs[/quote]
&lt;p&gt;Then disabling the zephyr SPI driver (CONFIG_SPI*=n) and using the CONFIG_NRFX_SPIS driver directly is a possibility.&lt;/p&gt;
&lt;p&gt;You should not mix &amp;quot;spi_nrfx_spis&amp;quot; into the mix here, as this is the port file for the zephyr SPI driver.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you look at the nRF5 SDK example in peripheral/spis/, it has a slightly modified API (legacy API), but shows the flow of how to use the nrfx_spis driver.&lt;/p&gt;
&lt;p&gt;Note that you should also add CONFIG_NRFX_SPISx=y to choose which instance you want to use.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840 SPI slave configuration event_handler</title><link>https://devzone.nordicsemi.com/thread/284505?ContentTypeID=1</link><pubDate>Fri, 11 Dec 2020 12:06:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7e0e8661-2542-4ccf-a059-64fc00e1bfb1</guid><dc:creator>hmw</dc:creator><description>&lt;p&gt;Hello&lt;br /&gt;Thank you for the code, but I have used it before and it doesn&amp;rsquo;t meet my requirements&lt;br /&gt;What I want is to have an IRQ_Handler that allows me to give semaphore behavior when an interrupt occurs&lt;br /&gt;At present, I am directly using nordic&amp;#39;s spis code in zephyr to achieve this goal, but in the long run, it seems like it is not a good way.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Poyi&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840 SPI slave configuration event_handler</title><link>https://devzone.nordicsemi.com/thread/284468?ContentTypeID=1</link><pubDate>Fri, 11 Dec 2020 10:13:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bb910d75-06a8-417f-b473-a5dc3deea724</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;Here&amp;#39;s a simplified spis example:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/7181.spis_5F00_test.zip"&gt;devzone.nordicsemi.com/.../7181.spis_5F00_test.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Could you try this?&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: nrf52840 SPI slave configuration event_handler</title><link>https://devzone.nordicsemi.com/thread/283977?ContentTypeID=1</link><pubDate>Wed, 09 Dec 2020 09:22:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2f4f29f3-aaab-4ab3-a389-0ca5f0bfd758</guid><dc:creator>hmw</dc:creator><description>&lt;p&gt;Hello&lt;br /&gt;Set as follows in my proj.conf&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_DEBUG=y

CONFIG_GPIO=y

CONFIG_SPI=y
CONFIG_SPI_NRFX=y

CONFIG_SPI_SLAVE=y
CONFIG_SPI_0=y

CONFIG_SPI_0_OP_MODES=2

CONFIG_SPI_0_NRF_ORC=0xff
CONFIG_NRFX_SPIS0=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I also printk in the event_handler of spi_nrfx_spis.c to confirm whether this function will be reached&lt;br /&gt;The result will be&lt;br /&gt;How can I reference this event_handler in my main code?&lt;br /&gt;So that I can provide semaphore in the event handler&lt;/p&gt;
&lt;p&gt;thanks,&lt;/p&gt;
&lt;p&gt;Poyi&lt;/p&gt;
&lt;div style="left:-30px;position:absolute;top:293px;" id="gtx-trans"&gt;
&lt;div class="gtx-trans-icon"&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840 SPI slave configuration event_handler</title><link>https://devzone.nordicsemi.com/thread/283473?ContentTypeID=1</link><pubDate>Mon, 07 Dec 2020 08:41:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0629facf-c694-467c-8fcb-5a8c7189fff9</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;You either use the NRFX (CONFIG_NRFX_SPIS) library, or the zephyr library (CONFIG_SPI*), not both at the same time.&lt;/p&gt;
&lt;p&gt;They&amp;#39;re two different libraries, interfacing the same peripheral.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="hmw"]Or is there something similar to spi_async_call_cb used in #if (CONFIG_SPI_ASYNC) to make&amp;nbsp;&lt;span&gt;CONFIG_NRFX_SPIS=y can do event handler&lt;/span&gt;?[/quote]
&lt;p&gt;If you use CONFIG_SPI_ASYNC, you should follow the integration algorithm that is shown in the former test sample, by providing a specific thread where you poll for the spi data.&lt;/p&gt;
&lt;p&gt;This will, from the driver, only provide a signal when anything happens on the SPIS bus.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you want to use NRFX driver directly instead, there&amp;#39;s unfortunately no example available, but you can have a look at the SPIS example in nrf5 sdk, and add the following to route the interrupt (this shows rtc as an example):&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/Rallare/fw-nrfconnect-nrf/blob/nrf9160_samples/samples/nrf9160/nrfx/rtc/src/main.c#L59-L63"&gt;https://github.com/Rallare/fw-nrfconnect-nrf/blob/nrf9160_samples/samples/nrf9160/nrfx/rtc/src/main.c#L59-L63&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&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: nrf52840 SPI slave configuration event_handler</title><link>https://devzone.nordicsemi.com/thread/283258?ContentTypeID=1</link><pubDate>Fri, 04 Dec 2020 08:48:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:92fb45e8-85cb-4e8d-8c6b-107bbb8c83d2</guid><dc:creator>hmw</dc:creator><description>[quote userid="2115" url="~/f/nordic-q-a/69034/nrf52840-spi-slave-configuration-event_handler/283098#283098"]If you use nrfx_spis (CONFIG_NRFX_SPIS=y) directly; you can do this using the approach with a event_handler.[/quote]
&lt;p&gt;Hello&lt;br /&gt;I just set CONFIG_NRFX_SPIS=y in prj.cpnf&lt;br /&gt;But I still don&amp;rsquo;t know how to use event_handler&lt;br /&gt;Do you mean that I can call the event handler directly in the main function?&lt;br /&gt;In addition to #include &amp;quot;spi_slave.h&amp;quot; and #include &amp;lt;nrfx_spis.h&amp;gt; in the main function, to directly use the event handler in spi_nrfx_spis.c?&lt;br /&gt;Or is there something similar to spi_async_call_cb used in #if (CONFIG_SPI_ASYNC) to make&amp;nbsp;&lt;span&gt;CONFIG_NRFX_SPIS=y can do event handler&lt;/span&gt;?&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Po-Yi,Lin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840 SPI slave configuration event_handler</title><link>https://devzone.nordicsemi.com/thread/283098?ContentTypeID=1</link><pubDate>Thu, 03 Dec 2020 13:32:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ce8a606d-97d4-4017-a942-3b421466ab43</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;The zephyr spis driver assumes that you use a dedicated thread, and use the k_poll functionality (signalled from the evt handler here: &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v2.4.0-ncs1/drivers/spi/spi_nrfx_spis.c#L227"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/v2.4.0-ncs1/drivers/spi/spi_nrfx_spis.c#L227&lt;/a&gt;), when you require asynchronous SPIS behavior:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v2.4.0-ncs1/tests/drivers/spi/spi_loopback/src/spi.c#L470-L550"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/v2.4.0-ncs1/tests/drivers/spi/spi_loopback/src/spi.c#L470-L550&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;And this is the thread define:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v2.4.0-ncs1/tests/drivers/spi/spi_loopback/src/spi.c#L603-L609"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/v2.4.0-ncs1/tests/drivers/spi/spi_loopback/src/spi.c#L603-L609&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;See the implementation that is guarded with #if (&lt;span&gt;CONFIG_SPI_ASYNC) in the above spi.c file for further information.&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;If you use nrfx_spis (CONFIG_NRFX_SPIS=y) directly; you can do this using the approach with a event_handler.&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;Kind regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Håkon&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>