<?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: Porting libmaple to STM32L1 -- mystery hex values in register maps?</title>
		<link>http://forums.leaflabs.com/topic.php?id=1227</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:21:33 +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=1227" rel="self" type="application/rss+xml" />

		<item>
			<title>gbulmer on "Porting libmaple to STM32L1 -- mystery hex values in register maps?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1227#post-7431</link>
			<pubDate>Sat, 24 Dec 2011 10:28:58 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">7431@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;jbaker - I'm glad to help.&#60;/p&#62;
&#60;p&#62;I did look at the RM0008, and I think I would change:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;#define ADC_CR2_JEXTSEL (0x7000)
#define ADC_CR2_EXTSEL (0xE0000)&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;to&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;#define ADC_CR2_JEXTSEL_OFFSET (12)
#define ADC_CR2_JEXTSEL (0b111 &#38;lt;&#38;lt; ADC_CR2_JEXTSEL_OFFSET)
#define ADC_CR2_EXTSEL_OFFSET (17)
#define ADC_CR2_EXTSEL (0b111 &#38;lt;&#38;lt; ADC_CR2_EXTSEL_OFFSET)&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;because there are a bunch of values which will need to be extracted, and so the ADC_CR2_..._OFFSET values will likely be useful.&#60;br /&#62;
I'd probably use 0x7 rather than 0b111  if I were unsure which C compiler might be used.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>jbaker on "Porting libmaple to STM32L1 -- mystery hex values in register maps?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1227#post-7425</link>
			<pubDate>Fri, 23 Dec 2011 01:38:14 +0000</pubDate>
			<dc:creator>jbaker</dc:creator>
			<guid isPermaLink="false">7425@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;You got it -- I've never seen the values hardcoded in a macro like that, so when I saw it alongside the other definitions using shifts I figured it was something weirder going on than just different styles within the same file, thanks.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Porting libmaple to STM32L1 -- mystery hex values in register maps?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1227#post-7418</link>
			<pubDate>Wed, 21 Dec 2011 22:34:56 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">7418@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;jbaker - I'm not sure what you are asking. Would you try to explain the issue a bit more?&#60;/p&#62;
&#60;p&#62;BIT(7) is the same as (01 &#38;lt;&#38;lt; 7)&#60;br /&#62;
0x7000 is the same as (0x7 &#38;lt;&#38;lt; 12)&#60;br /&#62;
I think it is partly personal preference on how it is done&#60;/p&#62;
&#60;p&#62;I might do:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;#define ADC_SMPR1_SMP17 (0b111 &#38;lt;&#38;lt; 7*3)
#define ADC_SMPR1_SMP16 (0b111 &#38;lt;&#38;lt; 6*3)
#define ADC_SMPR1_SMP15 (0b111 &#38;lt;&#38;lt; 5*3)
#define ADC_SMPR1_SMP14 (0b111 &#38;lt;&#38;lt; 4*3)
#define ADC_SMPR1_SMP13 (0b111 &#38;lt;&#38;lt; 3*3)
#define ADC_SMPR1_SMP12 (0b111 &#38;lt;&#38;lt; 2*3)
#define ADC_SMPR1_SMP11 (0b111 &#38;lt;&#38;lt; 1*3)
#define ADC_SMPR1_SMP10 (0b111 &#38;lt;&#38;lt; 0*3)&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;or something similar, to show that the register/word looks like an array of 3 bit values.&#60;/p&#62;
&#60;p&#62;But I might use either (0x7 &#38;lt;&#38;lt; 12) or (0x7000) or even (0b111000000000000) for a specific field in a complex set of register fields.&#60;br /&#62;
Which I use would likely be influenced by the way the documentation describes the fields.&#60;/p&#62;
&#60;p&#62;The layout of peripheral register fields are all described in RM0008:&#60;br /&#62;
&#60;a href=&#34;http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/REFERENCE_MANUAL/CD00171190.pdf&#34; rel=&#34;nofollow&#34;&#62;http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/REFERENCE_MANUAL/CD00171190.pdf&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;Sorry I can't be more help.&#60;/p&#62;
&#60;p&#62;(Full disclosure: I am not a member of LeafLabs staff.)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>jbaker on "Porting libmaple to STM32L1 -- mystery hex values in register maps?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1227#post-7412</link>
			<pubDate>Wed, 21 Dec 2011 03:38:06 +0000</pubDate>
			<dc:creator>jbaker</dc:creator>
			<guid isPermaLink="false">7412@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I'm working on a port of libmaple for the STM32L1 for a dev board I'm working on, and I'm running into some mystery hex values in the header files that I can't make heads or tails of. For example, the definitions for Configuration Register 2 in adc.h:&#60;/p&#62;
&#60;p&#62;&#60;code&#62;&#60;br /&#62;
#define ADC_CR2_ADON                    BIT(ADC_CR2_ADON_BIT)&#60;br /&#62;
#define ADC_CR2_CONT                    BIT(ADC_CR2_CONT_BIT)&#60;br /&#62;
#define ADC_CR2_CAL                     BIT(ADC_CR2_CAL_BIT)&#60;br /&#62;
#define ADC_CR2_RSTCAL                  BIT(ADC_CR2_RSTCAL_BIT)&#60;br /&#62;
#define ADC_CR2_DMA                     BIT(ADC_CR2_DMA_BIT)&#60;br /&#62;
#define ADC_CR2_ALIGN                   BIT(ADC_CR2_ALIGN_BIT)&#60;br /&#62;
#define ADC_CR2_JEXTSEL                 (0x7000)&#60;br /&#62;
#define ADC_CR2_JEXTTRIG                BIT(ADC_CR2_JEXTTRIG_BIT)&#60;br /&#62;
#define ADC_CR2_EXTSEL                  (0xE0000)&#60;br /&#62;
#define ADC_CR2_EXTTRIG                 BIT(ADC_CR2_EXTTRIG_BIT)&#60;br /&#62;
#define ADC_CR2_JSWSTART                BIT(ADC_CR2_JSWSTART_BIT)&#60;br /&#62;
#define ADC_CR2_SWSTART                 BIT(ADC_CR2_SWSTART_BIT)&#60;br /&#62;
#define ADC_CR2_TSEREFE                 BIT(ADC_CR2_TSEREFE_BIT)&#60;br /&#62;
&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;EXTSEL and JEXTSEL are multi-bit settings so I understand why it wouldn't be a single bitshift, but where are those values coming from? In this case, they're both 3-bit values. The sample time registers are all 3-bit values as well, but they're all defined like this (which does make sense):&#60;/p&#62;
&#60;p&#62;&#60;code&#62;&#60;br /&#62;
#define ADC_SMPR1_SMP17                 (0x7 &#38;lt;&#38;lt; 21)&#60;br /&#62;
#define ADC_SMPR1_SMP16                 (0x7 &#38;lt;&#38;lt; 18)&#60;br /&#62;
#define ADC_SMPR1_SMP15                 (0x7 &#38;lt;&#38;lt; 15)&#60;br /&#62;
#define ADC_SMPR1_SMP14                 (0x7 &#38;lt;&#38;lt; 12)&#60;br /&#62;
#define ADC_SMPR1_SMP13                 (0x7 &#38;lt;&#38;lt; 9)&#60;br /&#62;
#define ADC_SMPR1_SMP12                 (0x7 &#38;lt;&#38;lt; 6)&#60;br /&#62;
#define ADC_SMPR1_SMP11                 (0x7 &#38;lt;&#38;lt; 3)&#60;br /&#62;
#define ADC_SMPR1_SMP10                 0x7&#60;br /&#62;
&#60;/code&#62;
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
