<?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>Using the same GPIO for interrupt input and for executing functions (setting it as output after entering the interrupt)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/96842/using-the-same-gpio-for-interrupt-input-and-for-executing-functions-setting-it-as-output-after-entering-the-interrupt</link><description>Hello. I am trying to set up some code for an interrupt on the NRF52840 DK. I am using the pin_change_int example code as a starting point. In the example code, one GPIO is used as interrupt input, and another GPIO is set as output and is toggled in the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 23 Feb 2023 08:56:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/96842/using-the-same-gpio-for-interrupt-input-and-for-executing-functions-setting-it-as-output-after-entering-the-interrupt" /><item><title>RE: Using the same GPIO for interrupt input and for executing functions (setting it as output after entering the interrupt)</title><link>https://devzone.nordicsemi.com/thread/411560?ContentTypeID=1</link><pubDate>Thu, 23 Feb 2023 08:56:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1d617b34-8a38-4ae2-97e3-29680d64317b</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Maybe the driver description here might be of help:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/hardware_driver_gpiote.html"&gt;https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/hardware_driver_gpiote.html&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using the same GPIO for interrupt input and for executing functions (setting it as output after entering the interrupt)</title><link>https://devzone.nordicsemi.com/thread/411489?ContentTypeID=1</link><pubDate>Wed, 22 Feb 2023 20:45:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5f5098a0-2003-416a-b956-598385b0770a</guid><dc:creator>nicsam1992</dc:creator><description>&lt;p&gt;Thanks! And then I also have to re-initialize it as input after I&amp;#39;m done&amp;nbsp;I suppose.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Is there anywhere I can read up on these things? It&amp;#39;s not very straight forward how to do these things.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using the same GPIO for interrupt input and for executing functions (setting it as output after entering the interrupt)</title><link>https://devzone.nordicsemi.com/thread/411352?ContentTypeID=1</link><pubDate>Wed, 22 Feb 2023 12:16:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1fc1b1e7-0c16-4b63-a4b5-274e82e77822</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Yes,&lt;/p&gt;
&lt;p&gt;Something like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define MY_PIN 3

nrf_drv_gpiote_out_config_t out_config = GPIOTE_CONFIG_OUT_SIMPLE(false);

void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
    nrf_drv_gpiote_in_uninit(MY_PIN);

    ret_code_t err_code;
    err_code = nrf_drv_gpiote_out_init(MY_PIN, &amp;amp;out_config);
    APP_ERROR_CHECK(err_code);

}
/**
 * @brief Function for configuring: PIN_IN pin for input, PIN_OUT pin for output,
 * and configures GPIOTE to give an interrupt on pin change.
 */
static void gpio_init(void)
{
    ret_code_t err_code;

    err_code = nrf_drv_gpiote_init();
    APP_ERROR_CHECK(err_code);


    nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);
    in_config.pull = NRF_GPIO_PIN_PULLUP;

    err_code = nrf_drv_gpiote_in_init(MY_PIN, &amp;amp;in_config, in_pin_handler);
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_in_event_enable(MY_PIN, true);
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using the same GPIO for interrupt input and for executing functions (setting it as output after entering the interrupt)</title><link>https://devzone.nordicsemi.com/thread/411194?ContentTypeID=1</link><pubDate>Tue, 21 Feb 2023 18:22:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e0033813-5cab-4436-a881-0cf4cd828f4d</guid><dc:creator>nicsam1992</dc:creator><description>&lt;p&gt;Ok, thank you for the reply.&lt;/p&gt;
&lt;p&gt;The following code is from the example. Are you saying I need to do a similar setup as in&amp;nbsp;gpio_init(void) inside of&amp;nbsp; the interrupt? Maybe using the line &amp;quot;err_code = nrf_drv_gpiote_out_init(PIN_IN, &amp;amp;out_config);&amp;quot;?&lt;/p&gt;
&lt;p&gt;I need a little bit more guidance if it&amp;#39;s possible. Thank you!&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
    
   nrf_drv_gpiote_out_toggle(PIN_IN);

}
/**
 * @brief Function for configuring: PIN_IN pin for input, PIN_OUT pin for output,
 * and configures GPIOTE to give an interrupt on pin change.
 */
static void gpio_init(void)
{
    ret_code_t err_code;

    err_code = nrf_drv_gpiote_init();
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_out_config_t out_config = GPIOTE_CONFIG_OUT_SIMPLE(false);

    err_code = nrf_drv_gpiote_out_init(PIN_OUT, &amp;amp;out_config);
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);
    in_config.pull = NRF_GPIO_PIN_PULLUP;

    err_code = nrf_drv_gpiote_in_init(PIN_IN, &amp;amp;in_config, in_pin_handler);
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_in_event_enable(PIN_IN, true);
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using the same GPIO for interrupt input and for executing functions (setting it as output after entering the interrupt)</title><link>https://devzone.nordicsemi.com/thread/410903?ContentTypeID=1</link><pubDate>Mon, 20 Feb 2023 13:27:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ef1c774-5c00-43e1-a32e-f93665baf34b</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Yes, you can reconfigure the pin, and switch between being a input and a output pin at run-time.&amp;nbsp;Use the GPIO API for that.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>