<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Control GPIO using libgpiod API in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/Control-GPIO-using-libgpiod-API/m-p/2088391#M236765</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/151788"&gt;@Zhiming_Liu&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; I'm trying to read GPIO line values in &lt;STRONG&gt;imx91&amp;nbsp;&lt;/STRONG&gt; using &lt;STRONG&gt;libgpiod&lt;/STRONG&gt; by c application. But showing &lt;STRONG&gt;gpiod.h&lt;/STRONG&gt; is not found. I installed libgpiod-tools and able to see gpiod.h in /usr/include/. But when I compile recipe it is showing error undefined reference to API used. It is linking error is there any way to read value of GPIO using C application.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Mon, 28 Apr 2025 12:12:15 GMT</pubDate>
    <dc:creator>Robbi</dc:creator>
    <dc:date>2025-04-28T12:12:15Z</dc:date>
    <item>
      <title>Control GPIO using libgpiod API</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Control-GPIO-using-libgpiod-API/m-p/1988460#M230547</link>
      <description>&lt;PRE&gt;Hello,

I'm using IMX8ULP EVK9 board &lt;SPAN class=""&gt;and&lt;/SPAN&gt; i have onboard LED. I'm able &lt;SPAN class=""&gt;to&lt;/SPAN&gt; control LED using &lt;SPAN class=""&gt;"gpioset -c /dev/gpiochip4 20=1"&lt;/SPAN&gt; command. Now I'm trying &lt;SPAN class=""&gt;to&lt;/SPAN&gt; control LED using C code but on that time i'm getting &lt;SPAN class=""&gt;"Request lines failed: Invalid argument"&lt;/SPAN&gt; error.

I'm using libgpiod &lt;SPAN class=""&gt;2.0&lt;/SPAN&gt;.

Following is my C code

    const &lt;SPAN class=""&gt;char&lt;/SPAN&gt; *chipname = &lt;SPAN class=""&gt;"/dev/gpiochip4"&lt;/SPAN&gt;;
    unsigned &lt;SPAN class=""&gt;int&lt;/SPAN&gt; line_num = &lt;SPAN class=""&gt;20&lt;/SPAN&gt;;
    &lt;SPAN class=""&gt;struct&lt;/SPAN&gt; gpiod_chip *chip;
    &lt;SPAN class=""&gt;struct&lt;/SPAN&gt; gpiod_request_config *req_cfg;
    &lt;SPAN class=""&gt;struct&lt;/SPAN&gt; gpiod_line_config *line_cfg;
    &lt;SPAN class=""&gt;struct&lt;/SPAN&gt; gpiod_line_request *request;

    &lt;SPAN class=""&gt;// Open the GPIO chip&lt;/SPAN&gt;
    chip = gpiod&lt;SPAN class=""&gt;_chip_open(&lt;SPAN class=""&gt;chipname&lt;/SPAN&gt;)&lt;/SPAN&gt;;
    &lt;SPAN class=""&gt;if&lt;/SPAN&gt; (!chip) {
        perror(&lt;SPAN class=""&gt;"Open chip failed"&lt;/SPAN&gt;);
        return &lt;SPAN class=""&gt;1&lt;/SPAN&gt;;
    }

    &lt;SPAN class=""&gt;// Allocate and configure the request config&lt;/SPAN&gt;
    req_cfg = gpiod&lt;SPAN class=""&gt;_request_config_new()&lt;/SPAN&gt;;
    gpiod&lt;SPAN class=""&gt;_request_config_set_consumer(&lt;SPAN class=""&gt;req_cfg&lt;/SPAN&gt;, &lt;SPAN class=""&gt;"led_control"&lt;/SPAN&gt;)&lt;/SPAN&gt;;

    &lt;SPAN class=""&gt;// Allocate line config&lt;/SPAN&gt;
    line_cfg = gpiod&lt;SPAN class=""&gt;_line_config_new()&lt;/SPAN&gt;;

    &lt;SPAN class=""&gt;// Request the line&lt;/SPAN&gt;
    unsigned &lt;SPAN class=""&gt;int&lt;/SPAN&gt; offsets&lt;SPAN class=""&gt;[]&lt;/SPAN&gt; = {line_num};
    request = gpiod&lt;SPAN class=""&gt;_chip_request_lines(&lt;SPAN class=""&gt;chip&lt;/SPAN&gt;, &lt;SPAN class=""&gt;req_cfg&lt;/SPAN&gt;, &lt;SPAN class=""&gt;line_cfg&lt;/SPAN&gt;)&lt;/SPAN&gt;;
    &lt;SPAN class=""&gt;if&lt;/SPAN&gt; (!request) {
        perror(&lt;SPAN class=""&gt;"Request lines failed"&lt;/SPAN&gt;);
        gpiod&lt;SPAN class=""&gt;_chip_close(&lt;SPAN class=""&gt;chip&lt;/SPAN&gt;)&lt;/SPAN&gt;;
        return &lt;SPAN class=""&gt;1&lt;/SPAN&gt;;
    }

    &lt;SPAN class=""&gt;// Blink the LED&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;for&lt;/SPAN&gt; (&lt;SPAN class=""&gt;int&lt;/SPAN&gt; i = &lt;SPAN class=""&gt;0&lt;/SPAN&gt;; i &amp;lt; &lt;SPAN class=""&gt;10&lt;/SPAN&gt;; i++) {
        gpiod&lt;SPAN class=""&gt;_line_request_set_value(&lt;SPAN class=""&gt;request&lt;/SPAN&gt;, &lt;SPAN class=""&gt;line_num&lt;/SPAN&gt;, GPIOD_LINE_VALUE_ACTIVE)&lt;/SPAN&gt;; &lt;SPAN class=""&gt;// Turn on LED&lt;/SPAN&gt;
        sleep(&lt;SPAN class=""&gt;1&lt;/SPAN&gt;);
        gpiod&lt;SPAN class=""&gt;_line_request_set_value(&lt;SPAN class=""&gt;request&lt;/SPAN&gt;, &lt;SPAN class=""&gt;line_num&lt;/SPAN&gt;, GPIOD_LINE_VALUE_INACTIVE)&lt;/SPAN&gt;; &lt;SPAN class=""&gt;// Turn off LED&lt;/SPAN&gt;
        sleep(&lt;SPAN class=""&gt;1&lt;/SPAN&gt;);
    }

    &lt;SPAN class=""&gt;// Clean up&lt;/SPAN&gt;
    gpiod&lt;SPAN class=""&gt;_line_request_release(&lt;SPAN class=""&gt;request&lt;/SPAN&gt;)&lt;/SPAN&gt;;
    gpiod&lt;SPAN class=""&gt;_request_config_free(&lt;SPAN class=""&gt;req_cfg&lt;/SPAN&gt;)&lt;/SPAN&gt;;
    gpiod&lt;SPAN class=""&gt;_line_config_free(&lt;SPAN class=""&gt;line_cfg&lt;/SPAN&gt;)&lt;/SPAN&gt;; &lt;SPAN class=""&gt;// Free line_cfg&lt;/SPAN&gt;
    gpiod&lt;SPAN class=""&gt;_chip_close(&lt;SPAN class=""&gt;chip&lt;/SPAN&gt;)&lt;/SPAN&gt;;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Nov 2024 05:07:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Control-GPIO-using-libgpiod-API/m-p/1988460#M230547</guid>
      <dc:creator>dhruvinrajpura</dc:creator>
      <dc:date>2024-11-06T05:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: Control GPIO using libgpiod API</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Control-GPIO-using-libgpiod-API/m-p/1989659#M230594</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;Please refer&amp;nbsp;libgpiod 2.0 examples to modify your code.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/brgl/libgpiod/tree/v2.2.x/examples" target="_blank"&gt;https://github.com/brgl/libgpiod/tree/v2.2.x/examples&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Best Regards,&lt;BR /&gt;Zhiming&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2024 02:17:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Control-GPIO-using-libgpiod-API/m-p/1989659#M230594</guid>
      <dc:creator>Zhiming_Liu</dc:creator>
      <dc:date>2024-11-07T02:17:35Z</dc:date>
    </item>
    <item>
      <title>Re: Control GPIO using libgpiod API</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Control-GPIO-using-libgpiod-API/m-p/2088391#M236765</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/151788"&gt;@Zhiming_Liu&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; I'm trying to read GPIO line values in &lt;STRONG&gt;imx91&amp;nbsp;&lt;/STRONG&gt; using &lt;STRONG&gt;libgpiod&lt;/STRONG&gt; by c application. But showing &lt;STRONG&gt;gpiod.h&lt;/STRONG&gt; is not found. I installed libgpiod-tools and able to see gpiod.h in /usr/include/. But when I compile recipe it is showing error undefined reference to API used. It is linking error is there any way to read value of GPIO using C application.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 28 Apr 2025 12:12:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Control-GPIO-using-libgpiod-API/m-p/2088391#M236765</guid>
      <dc:creator>Robbi</dc:creator>
      <dc:date>2025-04-28T12:12:15Z</dc:date>
    </item>
  </channel>
</rss>

