<?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>Use P1.04 as interruption in nrf5340</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/91224/use-p1-04-as-interruption-in-nrf5340</link><description>hello everyone, recently I entered the world of nordic, 
 and I have been testing some of the functionalities, of one of the devices, 
 specifically the nrf5304 dk model, I am trying to make a connection between a sensor and this model 
 using gpio P1</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 22 Aug 2022 22:11:22 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/91224/use-p1-04-as-interruption-in-nrf5340" /><item><title>RE: Use P1.04 as interruption in nrf5340</title><link>https://devzone.nordicsemi.com/thread/382768?ContentTypeID=1</link><pubDate>Mon, 22 Aug 2022 22:11:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5e5fccda-79a6-4688-9942-94f6fdf8688a</guid><dc:creator>sshenoy105</dc:creator><description>&lt;p&gt;P1.04 is oin 4 in GPIO1 port/peripheral.. This is generally what you could ... you may need to tweak it to compile/work for you&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;const struct device *gpio_1_dev; //device struct for GPIO1
static struct gpio_callback my_cb; //callback handle
gpio_1_dev = device_get_binding(&amp;quot;GPIO_1&amp;quot;);

if (!gpio_1_dev) {
printk(&amp;quot;\n!!!!!!!! Cannot get GPIO_1 device\n&amp;quot;);
return;
} else {
printk(&amp;quot;\nGPIO_1 device binding SUCCESS\n&amp;quot;);
}

//ocnfigure your pin for interrupt

gpio_pin_configure(gpio_1_dev, 4, GPIO_INPUT);

int ret = gpio_pin_interrupt_configure(gpio_1_dev, 4, GPIO_INT_EDGE_FALLING); // edge falling is just an example.. you should set it what you need it to be
if (ret != 0) {
printk(&amp;quot;Error %d: failed to configure interrupt pin %d\n&amp;quot;, ret, 4);
return;
}

//set up call backs )(what to do once you get an interrupt)
gpio_init_callback(&amp;amp;my_cb, my_intr_process, BIT(4));
gpio_add_callback(gpio_1_dev, &amp;amp;my_cb);



// and define your actual call back function which does whatever you need to do when interrupt does show up.. hint.. don;t do too many things here
void my_intr_process(const struct device *dev, struct gpio_callback *cb, uint32_t pins) {
printk(&amp;quot;\n\n my intr happened\n\n&amp;quot;);

//give semaphore or set a voltaile flag etc.
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>