<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>LeafLabs Garden &#187; Topic: ARM equivalent of ATOMIC_BLOCK(ATOMIC_RESTORE_STATE){ } ?</title>
		<link>http://forums.leaflabs.com/topic.php?id=2566</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:18:41 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://forums.leaflabs.com/search.php</link>
		</textInput>
		<atom:link href="http://forums.leaflabs.com/rss.php?topic=2566" rel="self" type="application/rss+xml" />

		<item>
			<title>asterix on "ARM equivalent of ATOMIC_BLOCK(ATOMIC_RESTORE_STATE){ } ?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2566#post-13024</link>
			<pubDate>Fri, 31 Aug 2012 03:09:01 +0000</pubDate>
			<dc:creator>asterix</dc:creator>
			<guid isPermaLink="false">13024@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;nointerrupts()
&#60;/p&#62;</description>
		</item>
		<item>
			<title>pico on "ARM equivalent of ATOMIC_BLOCK(ATOMIC_RESTORE_STATE){ } ?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2566#post-13023</link>
			<pubDate>Fri, 31 Aug 2012 02:01:07 +0000</pubDate>
			<dc:creator>pico</dc:creator>
			<guid isPermaLink="false">13023@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Just started testing a port of the AVR &#34;atomic.h&#34; macros to the Maple5, in case anyone else is interested. So far so good... preliminary testing showing eveything as expected.&#60;/p&#62;
&#60;p&#62;One advantage (for me) of going to the additional trouble of porting the higher level macros instead of just the primitives is that it makes portability between AVR &#38;lt;-&#38;gt; ARM just that bit cleaner.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>pico on "ARM equivalent of ATOMIC_BLOCK(ATOMIC_RESTORE_STATE){ } ?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2566#post-12919</link>
			<pubDate>Mon, 27 Aug 2012 04:15:44 +0000</pubDate>
			<dc:creator>pico</dc:creator>
			<guid isPermaLink="false">12919@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;please correct closing  to make above more readable (I found the mistake too late to edit myself).
&#60;/p&#62;</description>
		</item>
		<item>
			<title>pico on "ARM equivalent of ATOMIC_BLOCK(ATOMIC_RESTORE_STATE){ } ?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2566#post-12896</link>
			<pubDate>Sun, 26 Aug 2012 22:05:36 +0000</pubDate>
			<dc:creator>pico</dc:creator>
			<guid isPermaLink="false">12896@http://forums.leaflabs.com/</guid>
			<description>&#60;blockquote&#62;&#60;p&#62;
I assume you are referring to &#60;a href=&#34;http://www.nongnu.org/avr-libc/user-manual/group__util__atomic.html&#34; rel=&#34;nofollow&#34;&#62;http://www.nongnu.org/avr-libc/user-manual/group__util__atomic.html&#60;/a&#62;&#60;/p&#62;
&#60;/blockquote&#62;
&#60;p&#62;Yes, that's correct.&#60;/p&#62;
&#60;p&#62;I am porting some Arduino/AVR code over to a Maple 5, and since the ATOMIC_BLOCK macro wasn't defined in the Maple ARM compiler environment, I did a bit digging to see what the equivalent was, but couldn't find anything definitive. It did make me appreciate that the ARM interrupt architecture is far more complex than the much simpler AVR model, though. &#60;/p&#62;
&#60;p&#62;The macro basically turns off external interrupts while the code block executes, in case there is some undesirable effect an interrupt at that point might cause. The ATOMIC_RESTORE_STATE option is just fancy wrapping for (pseudocode)&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;original_state = int_enabled_register_bit&#38;lt;br /&#38;gt;
cli()
&#38;lt;non interrupt code block here&#38;gt;
if (original_state == enabled) sei()&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;I use it from time to time in a variety of situations, typically doing things like assigning values to a set of variables that would be inconsistent if an external interrupt service routine were to find them in a state where some variables had been changed but not the others -- stuff like that. Just anywhere that I have identified a critical section that I want to lock out any interrupts until complete.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "ARM equivalent of ATOMIC_BLOCK(ATOMIC_RESTORE_STATE){ } ?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2566#post-12888</link>
			<pubDate>Sun, 26 Aug 2012 09:29:46 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">12888@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;pico - you'll have to give us a bit more information about what you are trying to do so we have enough to go on to give a meaningful answer. Are you trying to protect access to a variable, or something more complex?&#60;/p&#62;
&#60;p&#62;I assume you are referring to &#60;a href=&#34;http://www.nongnu.org/avr-libc/user-manual/group__util__atomic.html&#34; rel=&#34;nofollow&#34;&#62;http://www.nongnu.org/avr-libc/user-manual/group__util__atomic.html&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>pico on "ARM equivalent of ATOMIC_BLOCK(ATOMIC_RESTORE_STATE){ } ?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2566#post-12883</link>
			<pubDate>Sun, 26 Aug 2012 03:02:13 +0000</pubDate>
			<dc:creator>pico</dc:creator>
			<guid isPermaLink="false">12883@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Is there an ARM equivalent of ATOMIC_BLOCK(ATOMIC_RESTORE_STATE){ } ? Or does the different architecture and more involved interrupt capabilities mean that you need to think about things a bit differently?&#60;/p&#62;
&#60;p&#62;Sorry if this is somewhere in a FAQ list I have overlooked -- I did search, and was surprised I didn't turn anything up.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
