<?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>MQX Software SolutionsのトピックRe: Using LWGPIO_STRUCT  in lwgpio</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/Using-LWGPIO-STRUCT-in-lwgpio/m-p/160537#M1178</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes it translates the LWGPIO macros for port and pin into the physical registers depending on the specific hardware and will modify those. That is why the helper functions that do not require a LWGPIO_STRUCT work - they initialize a LWGPIO struct each time then access the hardware while the other functions that require a LWGPIO_STRUCT instance are able to access the hardware directly (since the LWGPIO_STRUCT was already populated with the pointers to the hardware registers).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As far as when LWGIO system accesses the hardware - it only does so through the API functions, so whether the LWGIO_STRUCT exists after it has completed its work doesn't mater. That also means modifying values in the LWGPIO_STRUCT instance (that are not the pointers to the hardware registers) will not modify the hardware state.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 01 Nov 2012 15:19:49 GMT</pubDate>
    <dc:creator>BryGuyH</dc:creator>
    <dc:date>2012-11-01T15:19:49Z</dc:date>
    <item>
      <title>Using LWGPIO_STRUCT  in lwgpio</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Using-LWGPIO-STRUCT-in-lwgpio/m-p/160534#M1175</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to understand how to properly use the lwgpio functionality.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I scanned the forums and spotted this snippet:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;void _bsp_io_defaults(void)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;{&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LWGPIO_STRUCT pin_struct;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lwgpio_init(&amp;amp;pin_struct, BSP_SPI_FLASH_WP_N,&amp;nbsp;&amp;nbsp;&amp;nbsp; LWGPIO_DIR_OUTPUT, LWGPIO_VALUE_LOW);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lwgpio_init(&amp;amp;pin_struct, BSP_SPI_FLASH_HOLD_N,&amp;nbsp; LWGPIO_DIR_OUTPUT, LWGPIO_VALUE_LOW);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lwgpio_init(&amp;amp;pin_struct, BSP_ANALOG_PULLUP_1,&amp;nbsp;&amp;nbsp; LWGPIO_DIR_OUTPUT, LWGPIO_VALUE_LOW);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lwgpio_init(&amp;amp;pin_struct, BSP_ANALOG_PULLUP_2,&amp;nbsp;&amp;nbsp; LWGPIO_DIR_OUTPUT, LWGPIO_VALUE_LOW);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lwgpio_init(&amp;amp;pin_struct, BSP_ANALOG_PULLUP_3,&amp;nbsp;&amp;nbsp; LWGPIO_DIR_OUTPUT, LWGPIO_VALUE_LOW);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;/*etc until all pins have the correct defaults set */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In that snippet, and some other mqx code examples,&amp;nbsp; the various &lt;STRONG style="font-family: courier new,courier;"&gt;LWGPIO_STRUCT&lt;/STRONG&gt; instances are NOT global. If so, I guess I don't understand how one accesses a pin (say &lt;STRONG style="font-family: courier new,courier;"&gt;BSP_SPI_FLASH_WP_N&lt;/STRONG&gt;) from elsewhere in the code.&amp;nbsp; In other words, the struct(s) used above are gone once &lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;_bsp_io_defaults()&lt;/STRONG&gt;&lt;/SPAN&gt; returns , so if I want to change a pin's value from time to time, to what struct do I talk (e.g., using &lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;lwgpio_set_value&lt;/STRONG&gt;&lt;/SPAN&gt;)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can/should I, when I need it, just declare another local struct, initialize it to the pin I want to control using &lt;STRONG style="font-family: courier new,courier;"&gt;lwgpio_init&lt;/STRONG&gt;, and then call &lt;STRONG&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;lwgpio&lt;/SPAN&gt;_&lt;SPAN style="font-family: courier new,courier;"&gt;set_value&lt;/SPAN&gt;&lt;/STRONG&gt; ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or do I instead declare a struct for each applicable IO pin globally and talk to that struct when I need to?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that's clear.&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Oct 2012 15:35:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Using-LWGPIO-STRUCT-in-lwgpio/m-p/160534#M1175</guid>
      <dc:creator>mike65535</dc:creator>
      <dc:date>2012-10-31T15:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: Using LWGPIO_STRUCT  in lwgpio</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Using-LWGPIO-STRUCT-in-lwgpio/m-p/160535#M1176</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;lwgpio functions act on an instance of the LWGPIO_STRUCT so always need a pointer to one that has been previously initialized with the init function... However there are 3 helper functions that do not require a previously initialized LWGPIO_STRUCT:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;lwgpio_set_pin_output&lt;/LI&gt;&lt;LI&gt;lwgpio_toggle_pin_output&lt;/LI&gt;&lt;LI&gt;lwgpio_get_pin_input&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your case you could:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;lwgpio_set_pin_output(BSP_SPI_FLASH_WP_N, LWGPIO_VALUE_HIGH);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However I would say if you're referencing a pin frequently just initialize it with a global LWGPIO_STRUCT and use the functions that require a pointer to it so you don't go through the reinitialization when you change io state.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also if you configure an input for use with an interrupt you have to make sure the LWGPIO_STRUCT instance isn't going to become invalid sometime before the interrupt is disabled.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Oct 2012 23:28:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Using-LWGPIO-STRUCT-in-lwgpio/m-p/160535#M1176</guid>
      <dc:creator>BryGuyH</dc:creator>
      <dc:date>2012-10-31T23:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: Using LWGPIO_STRUCT  in lwgpio</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Using-LWGPIO-STRUCT-in-lwgpio/m-p/160536#M1177</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For example, if I initialize a pin using an instance of LWGPIO_STRUCT&amp;nbsp; locally in a function (say as an "output", and "high") and I exit that function (and so, that "instance" disappears) how does the pin "stay" an output/high? Is there an explanation of how this "engine" operates?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm guessing the mqx engine somehow sees that I created a LWGPIO_STRUCT specific to a certain pin, dutifully loads the low-level hardware registers with the values seen in that struct, and as I change those values, keeps the registers updated, but if that struct "disappears" it leaves the registers alone?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Nov 2012 14:18:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Using-LWGPIO-STRUCT-in-lwgpio/m-p/160536#M1177</guid>
      <dc:creator>mike65535</dc:creator>
      <dc:date>2012-11-01T14:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: Using LWGPIO_STRUCT  in lwgpio</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Using-LWGPIO-STRUCT-in-lwgpio/m-p/160537#M1178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes it translates the LWGPIO macros for port and pin into the physical registers depending on the specific hardware and will modify those. That is why the helper functions that do not require a LWGPIO_STRUCT work - they initialize a LWGPIO struct each time then access the hardware while the other functions that require a LWGPIO_STRUCT instance are able to access the hardware directly (since the LWGPIO_STRUCT was already populated with the pointers to the hardware registers).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As far as when LWGIO system accesses the hardware - it only does so through the API functions, so whether the LWGIO_STRUCT exists after it has completed its work doesn't mater. That also means modifying values in the LWGPIO_STRUCT instance (that are not the pointers to the hardware registers) will not modify the hardware state.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Nov 2012 15:19:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Using-LWGPIO-STRUCT-in-lwgpio/m-p/160537#M1178</guid>
      <dc:creator>BryGuyH</dc:creator>
      <dc:date>2012-11-01T15:19:49Z</dc:date>
    </item>
  </channel>
</rss>

