<?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>Configure GPIO Interrupt on nRF9160</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/68042/configure-gpio-interrupt-on-nrf9160</link><description>Hi all, 
 I am interfacing with a CAN Controller (MCP25625) that sets an Interrupt pin when data is ready (active low). That pin is then connected to a GPIO on the nRF9160. I want to configure an interrupt on the nRF9160 that calls a SPI read function</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 09 Nov 2020 18:45:33 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/68042/configure-gpio-interrupt-on-nrf9160" /><item><title>RE: Configure GPIO Interrupt on nRF9160</title><link>https://devzone.nordicsemi.com/thread/279099?ContentTypeID=1</link><pubDate>Mon, 09 Nov 2020 18:45:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1deba4d7-4b00-4266-896a-cd40bffa5fa9</guid><dc:creator>kgarland789</dc:creator><description>&lt;p&gt;Thanks for the response Jay, greatly appreciate it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Configure GPIO Interrupt on nRF9160</title><link>https://devzone.nordicsemi.com/thread/278882?ContentTypeID=1</link><pubDate>Sat, 07 Nov 2020 13:20:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e07c8bdd-d806-4ea0-83c0-eca5e0fe742f</guid><dc:creator>Jan Rychter</dc:creator><description>&lt;p&gt;Since I&amp;#39;ve just had to go through the same discovery process, here is what works for me:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;  static struct gpio_callback button_callback;

  gpio_pin_configure(gpio0, BUTTON, GPIO_INPUT | GPIO_ACTIVE_LOW);
  gpio_init_callback(&amp;amp;button_callback, button_callback_handler, BIT(BUTTON));
  gpio_add_callback(gpio0, &amp;amp;button_callback);
  gpio_pin_interrupt_configure(gpio0, BUTTON, GPIO_INT_EDGE_BOTH);
  
  &lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And to get your gpio0:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define GPIO_PORT DT_LABEL(DT_NODELABEL(gpio0))
const struct device *gpio0;
gpio0 = device_get_binding(GPIO_PORT);
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Be careful with the last parameter to gpio_init_callback(), it does not take the pin number, but a bit mask. That&amp;#39;s one hour of my life I&amp;#39;m not getting back.&lt;/p&gt;
&lt;p&gt;I am still unclear what context the callback executes in, but I suspect it&amp;#39;s the interrupt context, because trying to sleep there promptly hangs my system. I wish this was documented.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>