<?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 close the spi interface</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/1420/how-to-close-the-spi-interface</link><description>hi,
now ,i have save the power,so need to close the spi interface at some time.
but when i call follow function (hal_spi_disable).
it see not close the spi interface, 
 if any issue about this? 
 
uint32_t hal_spi_disable(SPIModuleNumber module_number</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 24 Jan 2014 11:00:49 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/1420/how-to-close-the-spi-interface" /><item><title>RE: how to close the spi interface</title><link>https://devzone.nordicsemi.com/thread/6368?ContentTypeID=1</link><pubDate>Fri, 24 Jan 2014 11:00:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8b0dddca-1db8-426e-a2c7-fad3e4c7d28f</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;In your initial post, you mention that you disable SPI to save power.
Is the issue that you still have high power consumption?
Or is it that the GPIOs are not released from the peripheral?&lt;/p&gt;
&lt;p&gt;Best regards
Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to close the spi interface</title><link>https://devzone.nordicsemi.com/thread/6367?ContentTypeID=1</link><pubDate>Fri, 24 Jan 2014 03:14:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0d411573-563d-46d0-89ca-0cc218ec0f46</guid><dc:creator>steven</dc:creator><description>&lt;p&gt;hi,&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;when i disable the spi interface , i have reconfigure the GPIO.
i will check my system .&lt;/p&gt;
&lt;ol start="2"&gt;
&lt;li&gt;follow  hal_spi.c file , so it will be not reconfigure i/o when disable the spi interface.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;// Disable SPI when it&amp;#39;s not in use
spi_base-&amp;gt;ENABLE = (SPI_ENABLE_ENABLE_Disabled &amp;lt;&amp;lt; SPI_ENABLE_ENABLE_Pos);&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
bool hal_spi_tx_rx(uint32_t *spi_base_address, uint16_t transfer_size, const uint8_t *tx_data, uint8_t *rx_data)
{
    uint32_t counter = 0;
    uint16_t number_of_txd_bytes = 0;
    uint32_t SEL_SS_PINOUT;

    NRF_SPI_Type *spi_base = (NRF_SPI_Type *)spi_base_address;

    SEL_SS_PINOUT = spi_base == NRF_SPI0 ? spi0_pins.ss_pin : spi1_pins.ss_pin;
    
    // Enable SPI
    spi_base-&amp;gt;ENABLE = (SPI_ENABLE_ENABLE_Enabled &amp;lt;&amp;lt; SPI_ENABLE_ENABLE_Pos);

    /* enable slave (slave select active low) */
    nrf_gpio_pin_clear(SEL_SS_PINOUT);

    while(number_of_txd_bytes &amp;lt; transfer_size)
    {
        spi_base-&amp;gt;TXD = (uint32_t)(tx_data[number_of_txd_bytes]);

        /* Wait for the transaction complete or timeout (about 10ms - 20 ms) */
        while ((spi_base-&amp;gt;EVENTS_READY == 0U) &amp;amp;&amp;amp; (counter &amp;lt; TIMEOUT_COUNTER))
        {
            counter++;
        }

        if (counter == TIMEOUT_COUNTER)
        {
            /* timed out, disable slave (slave select active low) and return with error */
            nrf_gpio_pin_set(SEL_SS_PINOUT);
            spi_base-&amp;gt;ENABLE = (SPI_ENABLE_ENABLE_Disabled &amp;lt;&amp;lt; SPI_ENABLE_ENABLE_Pos);
            return false;
        }
        else
        {   /* clear the event to be ready to receive next messages */
            spi_base-&amp;gt;EVENTS_READY = 0U;
        }

        rx_data[number_of_txd_bytes] = (uint8_t)spi_base-&amp;gt;RXD;
        number_of_txd_bytes++;
    };

    /* disable slave (slave select active low) */
    nrf_gpio_pin_set(SEL_SS_PINOUT);

    // Disable SPI when it&amp;#39;s not in use
    spi_base-&amp;gt;ENABLE = (SPI_ENABLE_ENABLE_Disabled &amp;lt;&amp;lt; SPI_ENABLE_ENABLE_Pos);
    
    return true;
}


&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to close the spi interface</title><link>https://devzone.nordicsemi.com/thread/6366?ContentTypeID=1</link><pubDate>Thu, 23 Jan 2014 14:49:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:21a5841e-1225-44aa-a376-7f26741e7269</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi Steven,&lt;/p&gt;
&lt;p&gt;Setting NRF_SPIx-&amp;gt;ENABLE = (SPI_ENABLE_ENABLE_Disabled &amp;lt;&amp;lt; SPI_ENABLE_ENABLE_Pos); will disable the peripheral, and then free up the GPIOs.
Are you not able to re-configure the GPIOs afterwards?
Can you please provide a bit more detailed information about the issue you are seeing?&lt;/p&gt;
&lt;p&gt;Best regards
Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>