<?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 set two interrupts for one pin?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/23093/how-to-set-two-interrupts-for-one-pin</link><description>On nRF52 interrupts for GPIOTE, I need to perform one event when a button is pushed, and perform another different event when the button is released. 
 I&amp;#39;ve checked these links already, buy they are quit old. 
 devzone.nordicsemi.com/.../ 
 devzone</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 28 Jun 2017 11:13:46 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/23093/how-to-set-two-interrupts-for-one-pin" /><item><title>RE: How to set two interrupts for one pin?</title><link>https://devzone.nordicsemi.com/thread/90881?ContentTypeID=1</link><pubDate>Wed, 28 Jun 2017 11:13:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4a54c0e2-0676-4114-860e-85bbdf777959</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The driver does not allow you to configure one pin for multiple actions, this will only result in an error.&lt;/p&gt;
&lt;p&gt;If you set PIN_IN to sense TOGGLE, you will get one event when the button is pressed and another event when the button is released. You can use a variable to keep track of the state:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uint8_t button_pressed = 0;

void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
    if(button_pressed == 0)
    {
        NRF_LOG_INFO(&amp;quot;Button pressed!\r\n&amp;quot;);
        button_pressed = 1;
    }
    else
    {
        NRF_LOG_INFO(&amp;quot;Button released!\r\n&amp;quot;);
        button_pressed = 0;
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>