<?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>WFI internals</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/7264/wfi-internals</link><description>Hello :)
For the code below, why are we defining the _wfi while in the code we only use _WFI() for addressing the function? Also once we use _asm volatile (&amp;quot;wfi); isnt the syntax still in C ? I presumed that using _asm we need to write the rest of the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 26 May 2015 09:10:00 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/7264/wfi-internals" /><item><title>RE: WFI internals</title><link>https://devzone.nordicsemi.com/thread/25681?ContentTypeID=1</link><pubDate>Tue, 26 May 2015 09:10:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:53214e64-6c5d-4993-9612-cf41b24ca64f</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I will change the title to suit this question better, i hope it is ok to you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: WFI internals</title><link>https://devzone.nordicsemi.com/thread/25680?ContentTypeID=1</link><pubDate>Tue, 26 May 2015 09:07:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:05241606-3ef2-4a7d-a395-59dd088ba65b</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;pre&gt;&lt;code&gt;__attribute__((always_inline)) __STATIC_INLINE void __WFI(void)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;INLINE does not guarantee that compiler will in all cases inline the function, hence adding &lt;code&gt;__attribute__((always_inline))&lt;/code&gt; forces the compiler to inline this function and the only exception is if the its a recursive inlined function which will exhaust the whole memory.
Read &lt;a href="http://www.keil.com/support/man/docs/armccref/armccref_CIAJGAIH.htm"&gt;this&lt;/a&gt; for more information on always_inline attribute&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;__ASM volatile (&amp;quot;wfi&amp;quot;);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;wfi&lt;/code&gt; is assembly instruction, but we can use it inside C code by giving __ASM keyword, this __ASM keyword tells the compiler to skip compiler stage and hand over this line directly to the assembler. I am not sure what volatile will do here as this is a single instruction.&lt;/p&gt;
&lt;p&gt;you do not need to write the rest of the code in assembly, as the above code is accepted by C compiler. There are tons of examples you find if you google &amp;quot;inline assembly in C&amp;quot;. Below is one good example I found that might be of your interest.
&lt;a href="http://www.codeproject.com/Articles/15971/Using-Inline-Assembly-in-C-C"&gt;www.codeproject.com/.../Using-Inline-Assembly-in-C-C&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>