<?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 configuration code</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/19075/gpio-configuration-code</link><description>Sir, 
 We want to know about sample code of how to configure GPIO pins as output, and let we know how to include them for led toggling.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 25 Nov 2019 08:44:35 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/19075/gpio-configuration-code" /><item><title>RE: GPIO configuration code</title><link>https://devzone.nordicsemi.com/thread/221761?ContentTypeID=1</link><pubDate>Mon, 25 Nov 2019 08:44:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b7468186-d9cf-4462-86be-cfd2f0254f93</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Use &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/group__nrf__gpio__hal.html#ga0d66f2aaf7771ca4424237174032bf6a"&gt;NRF_GPIO_PIN_MAP&lt;/a&gt;&lt;span&gt;(port, pin)&lt;/span&gt;&lt;span&gt;&amp;nbsp;macro to define the pin, or simply add 32 to the pin number for port 1, i.e., 33 in your example (P1.01).&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO configuration code</title><link>https://devzone.nordicsemi.com/thread/221507?ContentTypeID=1</link><pubDate>Fri, 22 Nov 2019 09:47:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:169a5509-0016-49e6-bd93-4b4db6c85dba</guid><dc:creator>Luke Galea</dc:creator><description>&lt;p&gt;How would you go about using the nrf_gpio_cfg_output to configure pin 1.01 for example on the nRF52840?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO configuration code</title><link>https://devzone.nordicsemi.com/thread/73773?ContentTypeID=1</link><pubDate>Wed, 18 Jan 2017 10:08:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e5dd42f0-4f4a-421e-85f3-57714f287faf</guid><dc:creator>Sadasivam</dc:creator><description>&lt;p&gt;Thank you sir. And thanks for your valuable answer&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO configuration code</title><link>https://devzone.nordicsemi.com/thread/73771?ContentTypeID=1</link><pubDate>Wed, 18 Jan 2017 10:07:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1fa3c274-8703-4598-9498-0abb0764c5b5</guid><dc:creator>Sadasivam</dc:creator><description>&lt;p&gt;Thank you sir for your valuable answer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO configuration code</title><link>https://devzone.nordicsemi.com/thread/73772?ContentTypeID=1</link><pubDate>Wed, 18 Jan 2017 10:02:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:64c1fc5e-4f5c-4aa7-aea1-e0324491a7bf</guid><dc:creator>Roger Clark</dc:creator><description>&lt;p&gt;To configure a pin as output you just need to use
(Assuming your LED is on pin 29)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define LED_PIN 29

nrf_gpio_cfg_output(LED_PIN);// Set LED PIN pin as output

To set the pin to High , use

nrf_gpio_pin_set(LED_PIN);

to set the pin to low, use

nrf_gpio_pin_clear(LED_PIN);

to toggle the pin use

nrf_gpio_pin_toggle(LED_PIN);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note. You need to include &amp;quot;nrf_gpio.h&amp;quot;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO configuration code</title><link>https://devzone.nordicsemi.com/thread/73770?ContentTypeID=1</link><pubDate>Wed, 18 Jan 2017 09:57:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8723961a-c192-4aa8-81f6-fb39d383ac02</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You can configure and control GPIOs using the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v12.2.0/group__nrf__gpio.html?cp=4_0_1_6_6_7"&gt;GPIO abstraction API&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Below is an example of how to toggle LED1 on the nRF52 DK every 1 second:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#include &amp;quot;nrf.h&amp;quot;
#include &amp;quot;nrf_gpio.h&amp;quot;
#include &amp;quot;nrf_delay.h&amp;quot;

#define LED1_PIN 17

int main (void)
{
   nrf_gpio_cfg_output(LED1_PIN);
   nrf_gpio_pin_clear(LED1_PIN);
   while(1)
   {
       nrf_gpio_pin_toggle(LED1_PIN);
       nrf_delay_ms(1000);
   }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can also have a look at &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v12.2.0/group__nrf__gpiote.html?cp=4_0_1_6_6_4"&gt;GPIOTE&lt;/a&gt;, for more advanced GPIO controlling.&lt;/p&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>