<?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>How to determine if peripheral has been initialized</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/23998/how-to-determine-if-peripheral-has-been-initialized</link><description>Hello, 
 I&amp;#39;m working on an application in which I have to dynamically switch between a TWI master peripheral and SPI master peripheral that use the same peripheral ID (our application requires this, since we need the extra buses). Is there a way to check</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 03 Aug 2017 16:24:37 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/23998/how-to-determine-if-peripheral-has-been-initialized" /><item><title>RE: How to determine if peripheral has been initialized</title><link>https://devzone.nordicsemi.com/thread/94474?ContentTypeID=1</link><pubDate>Thu, 03 Aug 2017 16:24:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:199b9104-6bfd-47ee-9c5e-7cdc5b3774e3</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Also make sure that you have &lt;code&gt;PERIPHERAL_RESOURCE_SHARING_ENABLED&lt;/code&gt;, see &lt;a href="https://devzone.nordicsemi.com/question/98648/twi0-and-spi0-time-multiplex/"&gt;this post&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to determine if peripheral has been initialized</title><link>https://devzone.nordicsemi.com/thread/94473?ContentTypeID=1</link><pubDate>Thu, 03 Aug 2017 15:37:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2439ba1b-8841-43d6-b6e0-84c473d6dba9</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The easiest solution would probably be to just read the &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/spim.html?cp=2_1_0_30_5_3#register.ENABLE"&gt;ENABLE register&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;It will return 0 when disabled, and 7 when enabled(initialized)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;NRF_LOG_INFO(&amp;quot;NRF_SPIM0-&amp;gt;ENABLE: %d &amp;quot;, NRF_SPIM0-&amp;gt;ENABLE);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The SPI/TWI drivers have a control block that holds all the driver instance local data, where the e.g. the state is kept track of. So another option could be to add a function in nrf_drv_spi.c that returns the state value, e.g. something like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ret_code_t nrf_drv_spi_is_instance_initialized(nrf_drv_spi_t     const * const p_instance)
{
    spi_control_block_t * p_cb  = &amp;amp;m_cb[p_instance-&amp;gt;drv_inst_idx];
    
    if(p_cb-&amp;gt;state != NRF_DRV_STATE_UNINITIALIZED)
    {
        return true;
    }
    else
        return false;
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>