<?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 toggle the GPIO sense field?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/1114/how-to-toggle-the-gpio-sense-field</link><description>So now that I understand the problem with overlapping asserted events on the GPIO port, I can&amp;#39;t figure out the correct way to reset the sense field in the GPIOTE_IRQHandler correctly. 
 I have initialized a couple of input pins like so: 
 
NRF_GPIO</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 13 Dec 2013 08:17:45 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/1114/how-to-toggle-the-gpio-sense-field" /><item><title>RE: How to toggle the GPIO sense field?</title><link>https://devzone.nordicsemi.com/thread/5232?ContentTypeID=1</link><pubDate>Fri, 13 Dec 2013 08:17:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a92e633-4036-4aab-90f8-67528549319d</guid><dc:creator>Robert Blasutig</dc:creator><description>&lt;pre&gt;&lt;code&gt;volatile bool reed2asserted = false;
void GPIOTE_IRQHandler(void)
{
  if (NRF_GPIOTE-&amp;gt;EVENTS_PORT != 0)
  {
    NRF_GPIOTE-&amp;gt;EVENTS_PORT = 0;
	
    if (nrf_gpio_pin_read(PIN_GPIO_REED2) &amp;amp;&amp;amp; reed2asserted)
    {
      nrf_gpio_pin_toggle(LED1);
      reed2asserted = !reed2asserted;
      NRF_GPIO-&amp;gt;PIN_CNF[PIN_GPIO_REED2] = 
        (GPIO_PIN_CNF_SENSE_Low &amp;lt;&amp;lt; GPIO_PIN_CNF_SENSE_Pos)
        | (NRF_GPIO_PIN_PULLUP &amp;lt;&amp;lt; GPIO_PIN_CNF_PULL_Pos)
        | (GPIO_PIN_CNF_INPUT_Connect &amp;lt;&amp;lt; GPIO_PIN_CNF_INPUT_Pos)
        | (GPIO_PIN_CNF_DIR_Input &amp;lt;&amp;lt; GPIO_PIN_CNF_DIR_Pos);    
    }
    else if (!nrf_gpio_pin_read(PIN_GPIO_REED2) &amp;amp;&amp;amp; !reed2asserted)
    {
      nrf_gpio_pin_toggle(LED1);
      reed2asserted = !reed2asserted;
      NRF_GPIO-&amp;gt;PIN_CNF[PIN_GPIO_REED2] = 
        (GPIO_PIN_CNF_SENSE_High &amp;lt;&amp;lt; GPIO_PIN_CNF_SENSE_Pos)
        | (NRF_GPIO_PIN_PULLUP &amp;lt;&amp;lt; GPIO_PIN_CNF_PULL_Pos)
        | (GPIO_PIN_CNF_INPUT_Connect &amp;lt;&amp;lt; GPIO_PIN_CNF_INPUT_Pos)
        | (GPIO_PIN_CNF_DIR_Input &amp;lt;&amp;lt; GPIO_PIN_CNF_DIR_Pos);    
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to toggle the GPIO sense field?</title><link>https://devzone.nordicsemi.com/thread/5231?ContentTypeID=1</link><pubDate>Fri, 13 Dec 2013 08:02:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2303a46e-539c-4bde-b720-ff66be650a8b</guid><dc:creator>Robert Blasutig</dc:creator><description>&lt;p&gt;For those of us that don&amp;#39;t think the solution is immediately obvious, I&amp;#39;ll share some code that seems to get it to behave...&lt;/p&gt;
&lt;p&gt;This is for a single IO.  The app_gpiote code has more clever stuff that doesn&amp;#39;t really make clear what needs to be done... at least to me.  I guess an explanation is that overlapping GPIO port events cannot occur if the current pin level is the same as the current sense setting.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>