<?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>Deinitialize SPI</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/106183/deinitialize-spi</link><description>Hi, 
 i am creating a BLE application based on a NRF52832 with a coustum board. 
 I have a very small battery and thus need to save power in the best way possible. I already made made sure that I can shut down all my peripherals by GPIOs. 
 But the problem</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 06 Dec 2023 13:05:00 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/106183/deinitialize-spi" /><item><title>RE: Deinitialize SPI</title><link>https://devzone.nordicsemi.com/thread/459184?ContentTypeID=1</link><pubDate>Wed, 06 Dec 2023 13:05:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b206b265-7a09-47f3-aa2d-465ba27723b7</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Thank you for providing the additional details on how to make this work.&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Deinitialize SPI</title><link>https://devzone.nordicsemi.com/thread/459175?ContentTypeID=1</link><pubDate>Wed, 06 Dec 2023 12:35:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:40a2632b-672d-4ad9-a9bb-61ccca63ee8b</guid><dc:creator>Paul123</dc:creator><description>&lt;p&gt;Hey Kenneth,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;thanks for the advice. I was able to suspend the SPI and reduce the supply current to 13uA.&lt;br /&gt;&lt;span style="font-family:courier new, courier;"&gt;pm_device_action_run(spi_dev, PM_DEVICE_ACTION_SUSPEND)&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;did not work at first and caused a BUS FAULT ERROR and my program crashed.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:courier new, courier;"&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;It worked when I used &lt;span style="font-family:courier new, courier;"&gt;PM_DEVICE_ACTION_SUSPEND&lt;/span&gt; together with the &lt;span style="font-family:courier new, courier;"&gt;spi node&lt;/span&gt; instead of the &lt;span style="font-family:courier new, courier;"&gt;spi device&lt;/span&gt; device everything worked fine. All I had to do after the suspension was to pull low the CS pins of my two peripherals and set them high again after resumed.&amp;nbsp; &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:courier new, courier;"&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;So in the end the code I use is:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:courier new, courier;"&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;CONFIG_PM_DEVICE=y in prj.conf&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:courier new, courier;"&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;Deinit SPI&lt;br /&gt;:&lt;/span&gt;const struct device *cons = DEVICE_DT_GET(DT_NODELABEL(spi1));&lt;br /&gt;pm_device_action_run(cons, PM_DEVICE_ACTION_SUSPEND);&lt;br /&gt;gpio_pin_set_dt(&amp;amp;pin_cs, 1); //CS is active high&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;reinit SPI&lt;/span&gt;:&lt;br /&gt;&lt;span style="font-family:courier new, courier;"&gt;gpio_pin_set_dt(&amp;amp;pin_cs, 0); //CS is active high&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new, courier;"&gt;const struct device *cons = DEVICE_DT_GET(DT_NODELABEL(spi1));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new, courier;"&gt;pm_device_action_run(cons, PM_DEVICE_ACTION_RESUME);&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Kind Regards Paul&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Deinitialize SPI</title><link>https://devzone.nordicsemi.com/thread/458534?ContentTypeID=1</link><pubDate>Fri, 01 Dec 2023 13:42:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:62e4e458-1e9b-4a0b-8f70-6b3785eb195e</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;I was thinking along the lines of if you use CONFIG_PM_DEVICE=y, then you have the option to call for instance pm_device_action_run(spi_dev, PM_DEVICE_ACTION_SUSPEND) and pm_device_action_run(spi_dev, PM_DEVICE_ACTION_RESUME) between transfers. When spi is suspended the pins should fall back to to the sleep state you have configured in dts or overlay file. I can however see now that you are possible having an external flash, which may complicate things but not sure, since I have not looked into it.&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Deinitialize SPI</title><link>https://devzone.nordicsemi.com/thread/458469?ContentTypeID=1</link><pubDate>Fri, 01 Dec 2023 09:40:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:12570aad-83a9-469f-ba04-bf778e714f07</guid><dc:creator>Paul123</dc:creator><description>&lt;p&gt;Thanks for the quick answer.&lt;/p&gt;
&lt;p&gt;I didin&amp;#39;t find the function to uninit and init the SPI. I only found&amp;nbsp; the function &lt;span style="font-family:courier new, courier;"&gt;device_is_ready(). &lt;span style="font-family:arial, helvetica, sans-serif;"&gt;Is there any function in zephyr to uninit the SPI? &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:courier new, courier;"&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;I am using the nrf Connect SDK&lt;/span&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:courier new, courier;"&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;in my prj.conf I set the following defines:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div style="background-color:#1f1f1f;color:#cccccc;font-family:Consolas, &amp;#39;Courier New&amp;#39;, monospace;font-size:14px;font-weight:normal;line-height:19px;white-space:pre;"&gt;
&lt;div&gt;&lt;span style="color:#569cd6;"&gt;CONFIG_SPI&lt;/span&gt;&lt;span style="color:#cccccc;"&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div style="background-color:#1f1f1f;color:#cccccc;font-family:Consolas, &amp;#39;Courier New&amp;#39;, monospace;font-size:14px;font-weight:normal;line-height:19px;white-space:pre;"&gt;
&lt;div style="background-color:#1f1f1f;color:#cccccc;font-family:Consolas, &amp;#39;Courier New&amp;#39;, monospace;font-size:14px;font-weight:normal;line-height:19px;white-space:pre;"&gt;
&lt;div&gt;&lt;span style="color:#569cd6;"&gt;CONFIG_FLASH_JESD216_API&lt;/span&gt;&lt;span style="color:#cccccc;"&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div style="background-color:#1f1f1f;color:#cccccc;font-family:Consolas, &amp;#39;Courier New&amp;#39;, monospace;font-size:14px;font-weight:normal;line-height:19px;white-space:pre;"&gt;
&lt;div&gt;&lt;span style="color:#569cd6;"&gt;CONFIG_SPI_NOR&lt;/span&gt;&lt;span style="color:#cccccc;"&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Deinitialize SPI</title><link>https://devzone.nordicsemi.com/thread/458341?ContentTypeID=1</link><pubDate>Thu, 30 Nov 2023 14:43:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a6c85e22-20b2-43a5-8990-fe5d1289e84a</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;It should not be problematic to uninit and init the the spi between transactions, e.g. by something like:&lt;/p&gt;
&lt;p&gt;//&amp;nbsp;power off sensor&lt;br /&gt;// unint spi + lower&amp;nbsp;cs + lower spi pins (e.g. clk, mosi)&lt;br /&gt;// wait&lt;br /&gt;// raise cs pin + init spi&lt;br /&gt;// power on sensor&lt;/p&gt;
&lt;p&gt;I guess how this can be done slightly depends on which sdk + driver api you are using.&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>