<?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: is there a board specific constant defined?</title>
		<link>http://forums.leaflabs.com/topic.php?id=10467</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:07:45 +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=10467" rel="self" type="application/rss+xml" />

		<item>
			<title>tlgosser on "is there a board specific constant defined?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=10467#post-25689</link>
			<pubDate>Fri, 03 May 2013 11:23:20 +0000</pubDate>
			<dc:creator>tlgosser</dc:creator>
			<guid isPermaLink="false">25689@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;In other words it only compiles what's needed for the specific target.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>tlgosser on "is there a board specific constant defined?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=10467#post-25688</link>
			<pubDate>Fri, 03 May 2013 10:57:01 +0000</pubDate>
			<dc:creator>tlgosser</dc:creator>
			<guid isPermaLink="false">25688@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;If you don't want to waste a few cycles you can make your choice precompiler with an #if directive.  These are all just workflow choices and I tend to be very lazy.  &#60;/p&#62;
&#60;p&#62;If you can figure out how to use those option bytes please post how you did it.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>tdc218 on "is there a board specific constant defined?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=10467#post-25680</link>
			<pubDate>Thu, 02 May 2013 21:48:48 +0000</pubDate>
			<dc:creator>tdc218</dc:creator>
			<guid isPermaLink="false">25680@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;tlgosser - Hiding a board definition value somewhere in flash would probably work fine for a small project but I don't think it would scale well for a larger program as this is a significant trade off of a one time decision during compilation versus many bazillions of run time decisions.  Also the program would have to carry all of the code for all of the boards it might need to run on, whereas the former only compiles what's needed for the specific target.&#60;/p&#62;
&#60;p&#62;gbulmer - thank you for the info on the option bytes - definitely an interesting tidbit.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>tlgosser on "is there a board specific constant defined?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=10467#post-25582</link>
			<pubDate>Tue, 30 Apr 2013 22:46:07 +0000</pubDate>
			<dc:creator>tlgosser</dc:creator>
			<guid isPermaLink="false">25582@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Interesting.  That looks like something to try on a rainy day.&#60;/p&#62;
&#60;p&#62;Of course the lazy thing to do is just tie an extra pin to ground or something as an identifier and I often go that route!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "is there a board specific constant defined?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=10467#post-25579</link>
			<pubDate>Tue, 30 Apr 2013 10:12:39 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">25579@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;tlgosser - &#60;em&#62;&#34;So the option bytes are here... 0x1FFF F800 -0x1FFF F80F.&#34;&#60;/em&#62;&#60;/p&#62;
&#60;p&#62;Yes, the &#34;Option Bytes&#34; are 16 bytes in the &#34;Information block&#34;.&#60;/p&#62;
&#60;p&#62;They are described in PM0075 &#34;Programming manual&#34;, &#34;STM32F10xxx Flash memory microcontrollers&#34;:&#60;br /&#62;
&#60;a href=&#34;http://www.st.com/web/en/resource/technical/document/programming_manual/CD00283419.pdf&#34; rel=&#34;nofollow&#34;&#62;http://www.st.com/web/en/resource/technical/document/programming_manual/CD00283419.pdf&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;The option bytes are described in Table 9. &#34;Description of the option bytes&#34; on page 20.&#60;/p&#62;
&#60;p&#62;They are rather obscure. Using them is mentioned in RM0008 (search for &#34;option bytes&#34;) but I don't think that explains what they are, or how to program them. For example, they are mentioned as containing nRST_STDBY and nRST_STOP. The most helpful statement is &#34;For further information on the User Option Bytes, refer to the STM32F10xxx Flash programming manual.&#34;&#60;/p&#62;
&#60;p&#62;&#60;em&#62;&#34;Is it just those 2 bytes that are available for user data?&#34;&#60;/em&#62;&#60;br /&#62;
Yes, AFAIK. Other bytes control write protection of Flash memory, configure the watchdog timer, and how stop and standby work.&#60;/p&#62;
&#60;p&#62;&#60;em&#62;&#34;How would you write to just those two bytes?&#34;&#60;/em&#62;&#60;br /&#62;
Section 2.3.5 &#34;Option byte programming&#34; describes the process, which is basically the same as programming Flash memory, except their is an extra bit (OPTPG bit in the FLASH_CR) which must be set.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>tlgosser on "is there a board specific constant defined?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=10467#post-25556</link>
			<pubDate>Tue, 30 Apr 2013 00:27:07 +0000</pubDate>
			<dc:creator>tlgosser</dc:creator>
			<guid isPermaLink="false">25556@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I've never heard of this.  So the option bytes are here... 0x1FFF F800 -0x1FFF F80F.&#60;/p&#62;
&#60;p&#62;EEPROM.h makes us erase and program an entire flash page in order to write data.  Although we can read words anywhere.&#60;/p&#62;
&#60;p&#62;Is it just those 2 bytes that are available for user data?  &#60;/p&#62;
&#60;p&#62;How would you write to just those two bytes?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "is there a board specific constant defined?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=10467#post-25534</link>
			<pubDate>Mon, 29 Apr 2013 17:37:30 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">25534@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I believe there are two 'option bytes' for user data at 0x1FFFF804 which would keep that magic-number out of Flash, which might make things simpler.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>tlgosser on "is there a board specific constant defined?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=10467#post-25428</link>
			<pubDate>Sat, 27 Apr 2013 18:58:27 +0000</pubDate>
			<dc:creator>tlgosser</dc:creator>
			<guid isPermaLink="false">25428@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;//To read your board's 'label':&#60;/p&#62;
&#60;p&#62;#include &#38;lt;EEPROM.h&#38;gt;&#60;/p&#62;
&#60;p&#62;uint16 AddressWrite = 0x10;&#60;br /&#62;
uint16 DataRead = 0;&#60;/p&#62;
&#60;p&#62;void setup(void){&#60;br /&#62;
  EEPROM.read(AddressWrite, &#38;amp;DataRead);&#60;br /&#62;
  }&#60;/p&#62;
&#60;p&#62;void loop(void){&#60;br /&#62;
  delay(3000);//let the serial monitor wake up&#60;br /&#62;
  SerialUSB.print(&#34;Confirmed.  Board No.: &#34;);&#60;br /&#62;
  SerialUSB.println(DataRead, HEX);&#60;br /&#62;
  }
&#60;/p&#62;</description>
		</item>
		<item>
			<title>tlgosser on "is there a board specific constant defined?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=10467#post-25427</link>
			<pubDate>Sat, 27 Apr 2013 18:57:08 +0000</pubDate>
			<dc:creator>tlgosser</dc:creator>
			<guid isPermaLink="false">25427@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;/*&#60;br /&#62;
It is also possible to write a permanent identifier to flash memory for each board - a number that stays in memory even when you load a new program.  This way you can write code for ALL of your boards in one program!  But only run one set of instructions.  I find this makes things dramatically simpler.  &#60;/p&#62;
&#60;p&#62;To write an identifier you will need to put this eeprom lib in your 'libraries' folder:&#60;br /&#62;
&#60;a href=&#34;http://akb77.com/g/stm32/maple-eeprom-emulation-library/&#34; rel=&#34;nofollow&#34;&#62;http://akb77.com/g/stm32/maple-eeprom-emulation-library/&#60;/a&#62;&#60;br /&#62;
*/&#60;/p&#62;
&#60;p&#62;//Program to write a permanent 'label' on your board:&#60;/p&#62;
&#60;p&#62;#include &#38;lt;EEPROM.h&#38;gt;&#60;/p&#62;
&#60;p&#62;uint16 DataWrite = 9;//lets just say this is board no. 9&#60;br /&#62;
uint16 AddressWrite = 0x10;&#60;br /&#62;
void setup(void){&#60;br /&#62;
  EEPROM.write(AddressWrite, DataWrite);&#60;br /&#62;
  }&#60;/p&#62;
&#60;p&#62;void loop(void){}
&#60;/p&#62;</description>
		</item>
		<item>
			<title>tlgosser on "is there a board specific constant defined?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=10467#post-25426</link>
			<pubDate>Sat, 27 Apr 2013 18:24:59 +0000</pubDate>
			<dc:creator>tlgosser</dc:creator>
			<guid isPermaLink="false">25426@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Maple's predefined values can be helpful since they are portable:  BOARD_LED_PIN,  BOARD_BUTTON_PIN, and the SPI and serial USART serial pins.  &#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://leaflabs.com/docs/lang/api/board-values.html&#34; rel=&#34;nofollow&#34;&#62;http://leaflabs.com/docs/lang/api/board-values.html&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>tdc218 on "is there a board specific constant defined?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=10467#post-24507</link>
			<pubDate>Sun, 14 Apr 2013 12:19:57 +0000</pubDate>
			<dc:creator>tdc218</dc:creator>
			<guid isPermaLink="false">24507@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;@ala42 - thanks very much, this appears to work.&#60;/p&#62;
&#60;p&#62;@iainism - the point is to be able to compile the same project for different boards without having to change anything other that the make command line (or the BOARD environment variable).  I had been doing something similar to what you suggest, but this required me to change two things every time I switch boards.  I can't tell you how many times I'd forget to change the pin defs and got some seriously weird (and time consuming to troubleshoot) symptoms as a result.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>ala42 on "is there a board specific constant defined?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=10467#post-24361</link>
			<pubDate>Wed, 10 Apr 2013 17:43:20 +0000</pubDate>
			<dc:creator>ala42</dc:creator>
			<guid isPermaLink="false">24361@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;In the libmaple boards.h file you find&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;#ifdef BOARD_maple
	#include &#38;quot;maple.h&#38;quot;
#elif defined(BOARD_maple_native)
	#include &#38;quot;maple_native.h&#38;quot;
#elif defined(BOARD_maple_mini)
	#include &#38;quot;maple_mini.h&#38;quot;
#elif defined(BOARD_maple_RET6)&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Check if these defines also work in your main code.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>iainism on "is there a board specific constant defined?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=10467#post-24353</link>
			<pubDate>Wed, 10 Apr 2013 07:40:01 +0000</pubDate>
			<dc:creator>iainism</dc:creator>
			<guid isPermaLink="false">24353@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I may be missing the point here, but can't you 'just' create a header file for each hardware configuration? i.e.&#60;/p&#62;
&#60;p&#62;/pathTo/RET6/hwSpecific.h&#60;br /&#62;
-----------------&#60;br /&#62;
#define MyPin 3&#60;br /&#62;
#define otherRet6Stuff&#60;br /&#62;
/eof&#60;/p&#62;
&#60;p&#62;/pathTo/mini/hwSpecific.h&#60;br /&#62;
-----------------&#60;br /&#62;
#define MyPin 5&#60;br /&#62;
#define otherMiniStuff&#60;br /&#62;
/eof&#60;/p&#62;
&#60;p&#62;main.c then has &#34;#include &#38;lt;hwSpecific.h&#38;gt;&#34; with the include path being varied between /pathTo/mini/ and /pathTo/RET6/ as required by setting up the makefile (or command line, but seriously, use a makefile) appropriately.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>tdc218 on "is there a board specific constant defined?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=10467#post-24311</link>
			<pubDate>Sun, 07 Apr 2013 19:48:20 +0000</pubDate>
			<dc:creator>tdc218</dc:creator>
			<guid isPermaLink="false">24311@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Is there a value defined that I can use to determine what board I'm compiling for?&#60;/p&#62;
&#60;p&#62;Eg something like:&#60;/p&#62;
&#60;p&#62;#ifdef BOARD_RET6&#60;br /&#62;
#define MyPin 3&#60;br /&#62;
#endif&#60;br /&#62;
#ifdef BOARD_Mini&#60;br /&#62;
#define MyPin 5&#60;br /&#62;
#endif&#60;/p&#62;
&#60;p&#62;I'm using the Unix command line tool chain if it make any difference.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
