<?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>GPIO interrupt for DRDY pin in NCS 2.5.2</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/111087/gpio-interrupt-for-drdy-pin-in-ncs-2-5-2</link><description>I wrote a code for GPIO interrupt when DRDY pin goes high to low(Data ready) interrupt should occur and call a function but it is not working Below is a code: 
 intDRDY = false; 
 #define GPIO_DRDY 8 
 #define GPIO1 DT_NODELABEL(gpio1) 
 const struct</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 15 May 2024 07:14:03 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/111087/gpio-interrupt-for-drdy-pin-in-ncs-2-5-2" /><item><title>RE: GPIO interrupt for DRDY pin in NCS 2.5.2</title><link>https://devzone.nordicsemi.com/thread/483398?ContentTypeID=1</link><pubDate>Wed, 15 May 2024 07:14:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a22643de-0cd2-496a-95ba-a6f6820ff766</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Happy to help out. Hope you have a great day!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO interrupt for DRDY pin in NCS 2.5.2</title><link>https://devzone.nordicsemi.com/thread/483380?ContentTypeID=1</link><pubDate>Wed, 15 May 2024 05:32:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c0a2d0e3-176f-4361-956e-f7ed7fe9b35b</guid><dc:creator>Madhu Mohan Reddy</dc:creator><description>&lt;p&gt;Thank you&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO interrupt for DRDY pin in NCS 2.5.2</title><link>https://devzone.nordicsemi.com/thread/483098?ContentTypeID=1</link><pubDate>Mon, 13 May 2024 14:42:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b0f11903-15fc-4efa-ba79-8d71ec49a475</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You have to declare intDRDY as volatile.&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s a setup that worked on my side (added a pull-down for simplicity):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/*
 * Copyright (c) 2016 Intel Corporation
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;zephyr/kernel.h&amp;gt;
#include &amp;lt;zephyr/drivers/gpio.h&amp;gt;
#include &amp;lt;hal/nrf_gpio.h&amp;gt;

volatile bool intDRDY = false;
#define GPIO_DRDY 8
#define GPIO1 DT_NODELABEL(gpio1)
const struct device *gpio1_dev = DEVICE_DT_GET(GPIO1);
static struct gpio_callback gpio_cb;

/*call back function */

static void gpio_handler(const struct device *dev,
                         struct gpio_callback *cb,
                         uint32_t pins)

{
     intDRDY = true;	 
}


int main(void) 
{
	if (!device_is_ready(gpio1_dev)) {
		printk(&amp;quot;Device not ready\n&amp;quot;);
	}
	int ret = gpio_pin_configure(gpio1_dev, GPIO_DRDY, GPIO_INPUT | GPIO_PULL_DOWN);
	printk(&amp;quot;Ret %d\n&amp;quot;, ret);
	ret = gpio_pin_interrupt_configure(gpio1_dev, GPIO_DRDY, GPIO_INT_EDGE_FALLING);
	printk(&amp;quot;Ret %d\n&amp;quot;, ret);
	gpio_init_callback(&amp;amp;gpio_cb, gpio_handler, BIT(GPIO_DRDY));
	printk(&amp;quot;Ret %d\n&amp;quot;, ret);
	ret = gpio_add_callback(gpio1_dev, &amp;amp;gpio_cb);
	printk(&amp;quot;Ret %d\n&amp;quot;, ret);
	nrf_gpio_cfg_output(13);
	while(1)
	{
		if(intDRDY)
		{
			intDRDY = false;
			nrf_gpio_pin_toggle(13);
		}
	}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>