<?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: Discussion on the Wiring API and the new style Includes for libmaple</title>
		<link>http://forums.leaflabs.com/topic.php?id=2016</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:05:20 +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=2016" rel="self" type="application/rss+xml" />

		<item>
			<title>modkit on "Discussion on the Wiring API and the new style Includes for libmaple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2016&amp;page=3#post-21239</link>
			<pubDate>Fri, 23 Nov 2012 01:40:04 +0000</pubDate>
			<dc:creator>modkit</dc:creator>
			<guid isPermaLink="false">21239@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Thanks @siy, @gbulmer, and @mbolivar for a wonderful discussion!  Sorry we're coming to this late but we hope to continue this focus on &#34;pins as objects&#34; over &#60;a href=&#34;http://forums.leaflabs.com/topic.php?id=9685&#34;&#62;here&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Discussion on the Wiring API and the new style Includes for libmaple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2016&amp;page=3#post-12024</link>
			<pubDate>Thu, 26 Jul 2012 07:28:40 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">12024@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;mbolivar - (you were up late! I hope you're well.)&#60;/p&#62;
&#60;p&#62;Okay so this is validating the pin number:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;void digitalWrite(uint8 pin, uint8 val) {
    if (pin &#38;gt;= BOARD_NR_GPIO_PINS) {
        return;
    }

    gpio_write_bit(PIN_MAP[pin].gpio_device, PIN_MAP[pin].gpio_bit, val);
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;It silently does nothing when the pin number isn't valid.&#60;/p&#62;
&#60;p&#62;So, I think I understand that example, but I think the use case for my experimental class was different; I had hoped to eventually identify errors at compile time.&#60;/p&#62;
&#60;p&#62;My aim was to check validity of all Pin instances at construction.&#60;br /&#62;
The overriding goal of the experiments were to keep digitalWrite and digitalRead minimal so that inline would be comparable to a function call in size, and as quick as practical.&#60;/p&#62;
&#60;p&#62;Also, I was assuming that if there was a good template-based solution, the error would be raised at compile time.&#60;br /&#62;
The approach for this experimental class was weaker.&#60;/p&#62;
&#60;p&#62;So something like this (assuming the LeafLabs error handler which throbs led13 for assertion failure):&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;//...
#define GPIOA_VALID_PINS (0x0000E7FF)         // valid GPIOA pins for Maple
#define GPIOB_VALID_PINS (0x0000FFFB)         // valid GPIOB pins for Maple
#define GPIOC_VALID_PINS (0x0000E7FF)         // valid GPIOC pins for Maple
#define GPIOD_VALID_PINS (0x00000004)         // valid GPIOD pins for Maple
#define ASSERT_VALID_PIN(t) if (!(t)) pin_assert_failure(&#38;quot;Pin::Pin failure&#38;quot;, __LINE__)

// ...

class Pin {
public:
    volatile uint32_t* const bitbandaddress;
    Pin(volatile void* addr, uint8_t bit): bitbandaddress(bb_perip(addr, bit)) {
        if (addr == GPIOA) {
            ASSERT_VALID_PIN((0x1&#38;lt;&#38;lt;bit) &#38;amp; GPIOA_VALID_PINS);
        } else if (addr == GPIOB) {
            ASSERT_VALID_PIN((0x1&#38;lt;&#38;lt;bit) &#38;amp; GPIOB_VALID_PINS);
        } else if (addr == GPIOC) {
            ASSERT_VALID_PIN((0x1&#38;lt;&#38;lt;bit) &#38;amp; GPIOC_VALID_PINS);
        } else if (addr == GPIOD) {
            ASSERT_VALID_PIN((0x1&#38;lt;&#38;lt;bit) &#38;amp; GPIOC_VALID_PINS);
        } else {
            ASSERT_VALID_PIN(false);
        }
    }

private:
    Pin(): bitbandaddress((volatile uint32_t*)0xFFFFFFFF) {} // cheap and nasty: force an exception
};&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;In retrospect, a solution more like Maples digitalWrite might have been:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;inline volatile uint32_t* safebb(volatile void* addr, uint8_t bit) {
    if (addr == GPIOA &#38;amp;&#38;amp; ((0x1&#38;lt;&#38;lt;bit) &#38;amp; GPIOA_VALID_PINS)) {
        return bb_perip(addr, bit);
    } else if (addr == GPIOB &#38;amp;&#38;amp; ((0x1&#38;lt;&#38;lt;bit) &#38;amp; GPIOB_VALID_PINS)) {
        return bb_perip(addr, bit);
    } else if (addr == GPIOC &#38;amp;&#38;amp; ((0x1&#38;lt;&#38;lt;bit) &#38;amp; GPIOC_VALID_PINS)) {
        return bb_perip(addr, bit);
    } else if (addr == GPIOD &#38;amp;&#38;amp; ((0x1&#38;lt;&#38;lt;bit) &#38;amp; GPIOC_VALID_PINS)) {
        return bb_perip(addr, bit);
    }
    return bb_perip(GPIOD, 0);  // harmless pin
}
// ...
Pin(volatile void* addr, uint8_t bit): bitbandaddress(safebb(addr, bit)) {}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;So, at construction, the pin is either initialised correctly, or it is set to a harmless digital I/O address, e.g. &#60;code&#62;bb_perip(GPIOD, 0);&#60;/code&#62;. That bitband address would be whatever digital I/O address would work silently in my digitalWrite and digitalRead. That would give some of the behaviour of Maple's digitalWrite.&#60;br /&#62;
I prefer the 'proper' error in my old code :-)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mbolivar on "Discussion on the Wiring API and the new style Includes for libmaple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2016&amp;page=3#post-12015</link>
			<pubDate>Thu, 26 Jul 2012 00:32:11 +0000</pubDate>
			<dc:creator>mbolivar</dc:creator>
			<guid isPermaLink="false">12015@http://forums.leaflabs.com/</guid>
			<description>&#60;blockquote&#62;&#60;p&#62;
Why? I can imagine == and !=, but what's the example or use case for &#34;pin &#38;lt;= BOARD_NR_GPIO_PINS&#34;?
&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;well, here's &#60;code&#62;pin &#38;gt;= BOARD_NR_GPIO_PINS&#60;/code&#62;: &#60;a href=&#34;https://github.com/leaflabs/libmaple/blob/9a081c2d523252370ebcd100de1f3c57759ebcf5/wirish/wirish_digital.cpp#L49&#34; rel=&#34;nofollow&#34;&#62;https://github.com/leaflabs/libmaple/blob/9a081c2d523252370ebcd100de1f3c57759ebcf5/wirish/wirish_digital.cpp#L49&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Discussion on the Wiring API and the new style Includes for libmaple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2016&amp;page=3#post-12006</link>
			<pubDate>Wed, 25 Jul 2012 20:05:26 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">12006@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;mbolivar&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;One concern that you may have already considered: what happens when people try to treat a Pin as if it were a number?&#60;/p&#62;
&#60;/blockquote&#62;
&#60;p&#62;That seems quite exotic to me, but show me the example or use case where people do that now, and I might be able to propose a solution. &#60;/p&#62;
&#60;p&#62;I think I did have a function which mapped the bit band address to a pin number. It was used in pinMode instead of the for loop. But I thought it was muddying the simplicity of the approach, and this way pinMode is very simple and somewhat 'fail-safe'.&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;Sounds like to get that to work properly, we'd need to override the arithmetic operators to look up the pin's number via PIN_MAP and do the right thing with it&#60;/p&#62;
&#60;/blockquote&#62;
&#60;p&#62;That seems like a pile of work, and maybe premature optimisation.&#60;br /&#62;
Show the example and use cases, and we might come up with good proposals. My 'knee-jerk' reaction, without understanding enough about the actual use case, is to provide a way to map bitband addresses to useful numbers, and maybe an appropriate constant.&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;The same thing would apply to comparisons (I can see someone typing pin &#38;lt;= BOARD_NR_GPIO_PINS, e.g.).&#60;/p&#62;
&#60;/blockquote&#62;
&#60;p&#62;Why?  I can imagine &#60;code&#62;==&#60;/code&#62; and &#60;code&#62;!=&#60;/code&#62;, but what's the example or use case for &#34;pin &#38;lt;= BOARD_NR_GPIO_PINS&#34;?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mbolivar on "Discussion on the Wiring API and the new style Includes for libmaple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2016&amp;page=3#post-12005</link>
			<pubDate>Wed, 25 Jul 2012 19:58:10 +0000</pubDate>
			<dc:creator>mbolivar</dc:creator>
			<guid isPermaLink="false">12005@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Interesting.&#60;/p&#62;
&#60;p&#62;One concern that you may have already considered: what happens when people try to treat a Pin as if it were a number?&#60;/p&#62;
&#60;p&#62;Sounds like to get that to work properly, we'd need to override the arithmetic operators to look up the pin's number via PIN_MAP and do the right thing with it, with the attendant error message concerns. The same thing would apply to comparisons (I can see someone typing &#60;code&#62;pin &#38;lt;= BOARD_NR_GPIO_PINS&#60;/code&#62;, e.g.).
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Discussion on the Wiring API and the new style Includes for libmaple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2016&amp;page=3#post-12004</link>
			<pubDate>Wed, 25 Jul 2012 19:16:51 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">12004@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;mbolivar&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;Out of curiosity, did you also try separate inline and &#34;standard&#34; versions ...&#60;/p&#62;
&#60;/blockquote&#62;
&#60;p&#62;No. I was experimenting, and I wanted it simple and 'lite', so only one version.&#60;br /&#62;
Also, because my digitalRead and digitalWrite were intended to be simple and very compact, ideally smaller than a call of digitalRead and digitalWrite on &#60;code&#62;int&#60;/code&#62;, non-inline versions made no sense to me (IIRC compiling with debug and using GDB works properly)&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;... plus use of __builtin_constant_p() to determine which to use (as tried by Arduino)?&#60;/p&#62;
&#60;/blockquote&#62;
&#60;p&#62;Definitely not.&#60;br /&#62;
IMHO part of the attraction of the Arduino library is most of it is readable. That looks unnecessarily complex.&#60;/p&#62;
&#60;p&#62;A lot of beginners just declare things like &#60;code&#62;int led = 13;&#60;/code&#62; which I think fails the &#60;code&#62;__builtin_constant_p()&#60;/code&#62; test.&#60;br /&#62;
So the extra complexity only helps a more experienced developer, but a newbie would have to wade through quite subtle and sophisticated code to understand how it works.&#60;br /&#62;
I'd rather encourage folks to look at the MCU reference manual (e.g. RM0008) than the C++ specification :-)&#60;/p&#62;
&#60;p&#62;My plan was to have a new type which would easily discriminate between the two variations of digitalRead/digitalWrite/pinMode.&#60;br /&#62;
It was also intended to be simpler and more efficient anyway, so faffing around with integer pin numbers was minimised. &#60;/p&#62;
&#60;p&#62;Here's a rough cut early version which I've reconstituted; it didn't even use templates. &#60;/p&#62;
&#60;p&#62;I think digitalRead/digitalWrite are faster and smaller than the standard digitalRead/digitalWrite, but less safe in this version.&#60;br /&#62;
One objective was to make the type no bigger than the default &#60;code&#62;int&#60;/code&#62; pin number, so indiscriminate use of Pin is no worse than int.&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;inline volatile uint32_t* pin_to_bitband(int pin_numb) {  // luxury?
    // should validate pin number
    return bb_perip(PIN_MAP[pin_numb].gpio_device, PIN_MAP[pin_numb].gpio_bit);
}

class Pin {
public:
    volatile uint32_t* const bitbandaddress;
    // Construct pin from port address and bit number
    Pin(volatile void* addr, uint8_t bit): bitbandaddress(bb_perip(addr, bit)) {}
private:
    Pin(): bitbandaddress((volatile uint32_t*)0xFFFFFFFF) {} // cheap and nasty: force an exception
};

inline void digitalWrite(Pin p, uint32_t value) { *(p.bitbandaddress) = value; }
inline uint32_t digitalRead(Pin p) { return *(p.bitbandaddress+MAGIC_CONSTANT); }

void pinMode(Pin p, WiringPinMode mode) {
    /* quick and dirty: find pin in PIN_MAP, then call pinMode(int,...) */
    for (int i=0; i&#38;lt;BOARD_NR_GPIO_PINS; i++) {
        if (p.bitbandaddress == pin_to_bitband(i)) {
            pinMode(i, mode);
            break;
        }
    }
    /* proper: use the bitband address to derive control register addresses */
}

const Pin D0(GPIOA, 3);
// ...
const Pin D5(GPIOB, 6);
// ...
const Pin D13(GPIOA, 5);

// -- blink --

Pin led = D13;

void setup() {
    pinMode(led, OUTPUT);
}

void loop() {
    digitalWrite(led, HIGH);
    delay(1000);
    digitalWrite(led, LOW);
    delay(1000);
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;It doesn't do pinMode 'properly'.&#60;br /&#62;
It searches for a matching bitband address in PIN_MAP, and used the existing pinMode.&#60;br /&#62;
It should calculate the control registers from the bit band address, and hence be more direct, and not dependant on PIN_MAP.&#60;/p&#62;
&#60;p&#62;Edit {&#60;br /&#62;
I think an inline Pin digitalWrite or digitalRead could be the same number of instructions as the &#60;strong&#62;call&#60;/strong&#62; of the standard int digitalWrite or digitalRead, and hence always smaller because the body of a 'standard' digitalWrite and digitalRead isn't needed. I also think a sequence of inline-calls might be fewer instructions than a sequence of standard &#60;strong&#62;calls&#60;/strong&#62; because the compiler could optimise better. &#60;/p&#62;
&#60;p&#62;Hopefully we can agree that:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;inline void digitalWrite(Pin p, uint32_t value) { *(p.bitbandaddress) = value; }
inline uint32_t digitalRead(Pin p) { return *(p.bitbandaddress+MAGIC_CONSTANT); }&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;isn't too sophisticated C/C++ ?&#60;br /&#62;
So someone trying to understand this is best directed to ARM Cortex-M3 documentation, and the MCU Reference Manual :-)&#60;br /&#62;
} End-Edit&#60;/p&#62;
&#60;p&#62;The next step was to use templating so that the Pin instances were proper compile time constants. &#60;/p&#62;
&#60;p&#62;That might have made the inline digitalRead and digitalWrite smaller and quicker by removing the load-bitband-address-from-RAM, because the bitband address would be a comple-time constant. &#60;/p&#62;
&#60;p&#62;I didn't complete that templated variation because, at the time, some of the error messages I accidentally triggered were so opaque I felt people would be left flummoxed; the error messages mentioned templates, which I felt was too off-putting for non-C++ programmers. Maybe I should have tried more variations to try to make the errors easier?&#60;/p&#62;
&#60;p&#62;Edit:&#60;br /&#62;
Trimmed the Pin class to bare essentials; I hope it's clearer.&#60;br /&#62;
Also, I realise e.g.&#60;br /&#62;
&#60;code&#62;inline void digitalWrite(Pin p, uint32_t value) ...&#60;/code&#62; etc. could be&#60;br /&#62;
&#60;code&#62;inline void digitalWrite(Pin&#38;amp; p, uint32_t value)&#60;/code&#62;, but I didn't do that experiment.&#60;br /&#62;
I don't think C programmers would normally use references, so this way is a useful test.&#60;/p&#62;
&#60;p&#62;(WARNING: I may have made errors reconstituting this)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mbolivar on "Discussion on the Wiring API and the new style Includes for libmaple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2016&amp;page=2#post-12003</link>
			<pubDate>Wed, 25 Jul 2012 16:06:59 +0000</pubDate>
			<dc:creator>mbolivar</dc:creator>
			<guid isPermaLink="false">12003@http://forums.leaflabs.com/</guid>
			<description>&#60;blockquote&#62;&#60;p&#62;
IIRC, I only added new versions of digitalRead, digitalWrite and pinMode, and a few constructors. It used a class to differentiate existing calls (which take a pin number) from the calls of the new functions (which take a Pin). All the pins were pre-declared, e.g. D13.&#60;/p&#62;
&#60;p&#62;My main goal was to make digitalRead/digitalWrite fast with minimal change to the API.&#60;/p&#62;
&#60;/blockquote&#62;
&#60;p&#62;Out of curiosity, did you also try separate inline and &#34;standard&#34; versions plus use of &#60;code&#62;__builtin_constant_p()&#60;/code&#62; to determine which to use (&#60;a href=&#34;http://arduino.cc/pipermail/developers_arduino.cc/2011-February/004340.html&#34;&#62;as tried by Arduino&#60;/a&#62;)? If so, what turned you off about it?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>siy on "Discussion on the Wiring API and the new style Includes for libmaple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2016&amp;page=2#post-11994</link>
			<pubDate>Wed, 25 Jul 2012 09:02:08 +0000</pubDate>
			<dc:creator>siy</dc:creator>
			<guid isPermaLink="false">11994@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;@gbulmer, I completely agree, that at the time when C++ started gaining popularity, everyone tried to put every 'pet' idea into language. And definitely not every idea was simple enough to implement. But things like 'finally' clause were very easy to implement and would save a lot of time and efforts for users. Yes, I know about RAI and destructors, but while working with low level OS resources such as handles or OS-allocated memory regions 'pure' approach results to countless tiny classes which do nothing (beside making code harder to read). In contract 'pure' dynamic_cast&#38;lt;&#38;gt; was included into standard, despite significant efforts necessary to implement RTTI and its doubtful usability in real life.&#60;br /&#62;
Must admit that I'm assessing C++ as a system programming language while standard is targeted toward application programming, hence different 'weights' for different features and their usefulness in real life.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Discussion on the Wiring API and the new style Includes for libmaple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2016&amp;page=2#post-11989</link>
			<pubDate>Wed, 25 Jul 2012 07:45:14 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">11989@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;mbolivar - The experiment I'm describing was very simple. &#60;/p&#62;
&#60;p&#62;IIRC, I only added new versions of digitalRead, digitalWrite and pinMode, and a few constructors. It used a class to differentiate existing calls (which take a pin number) from the calls of the new functions (which take a Pin). All the pins were pre-declared, e.g. &#60;code&#62;D13&#60;/code&#62;.&#60;/p&#62;
&#60;p&#62;My main goal was to make digitalRead/digitalWrite fast with minimal change to the API.&#60;/p&#62;
&#60;p&#62;BTW - I have also spoken to Bjarne Stroustrup. A chum, Mark, who taught friends and myself C++, probably had the first C++ compiler in Europe, and Bjarne cut him the tape. He was the UK representative to ISO for C++ for several years. I tried to help him by reading and discussing some of the proposed changes to C++. After reading them, I would have been obsessed with trying to keep the language coherent and 'pure' too. People complain about C++ complexity, but IMHO it could have been much, much more complicated if some of the proposals were accepted (NB: complex != complicated). &#60;/p&#62;
&#60;p&#62;At that time, people were trying to put every 'pet' idea they had into a programming language. I am looking back to before Java, SmallTalk was one of the important Object Orientated (OO) programming languages, and OO was the 'next big thing'. &#60;/p&#62;
&#60;p&#62;C++ clearly had support, industry attention and momentum, so it was likely to be used. Hence C++ standardisation became a 'magnet' for those people with 'pet' ideas for OO, and a target vehicle for implementing everything, including 'the kitchen sink':-)&#60;/p&#62;
&#60;p&#62;Stroustrup was probably bombarded with proposals and criticisms of C++ every waking hour for years. He likely heard most ideas, in some variation, several times each week. Further, he was one of the implementers, so the proposals weren't just intellectually interesting; he would likely end up having to implement them. I know that changes the way I listen to ideas.&#60;/p&#62;
&#60;p&#62;When designing any large, complex, software system, the hard part is not gathering 'wants', that is easy, everyone contributes those. The hard part is weeding out from the enormous volume of 'wants' the very few critical requirements, and focusing on the right ones well enough to build them adequately. Every new independent idea has a combinatorial impact on complexity, so we want to keep the core of systems simple and coherent (to keep it buildable, testable and flexible enough to evolve). As a more recent example, have a look at the volume of Java ideas, or look at VPRI's fonc mailing list.&#60;/p&#62;
&#60;p&#62;IMHO, Stroustrup did well to focus on a few key areas, move forward, and keep moving forward.&#60;/p&#62;
&#60;p&#62;I think it may be helpful for people to view conversations with him from this perspective.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mbolivar on "Discussion on the Wiring API and the new style Includes for libmaple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2016&amp;page=2#post-11949</link>
			<pubDate>Mon, 23 Jul 2012 17:50:09 +0000</pubDate>
			<dc:creator>mbolivar</dc:creator>
			<guid isPermaLink="false">11949@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;siy:&#60;/p&#62;
&#60;p&#62;I think you're probably right that many people avoid C++ for the &#34;sharp tool&#34; reason. I don't think I'm one of them, but I'm also not interested in having a fight about C versus C++.&#60;/p&#62;
&#60;p&#62;These two things are true: libmaple proper is in C, and the Wiring layer is in C++. Neither of those facts is going to change any time in the foreseeable future.&#60;/p&#62;
&#60;p&#62;I'm a bad C++ programmer, so there's good reason for me to avoid using C++ features in the code I write. However, as I've said, if you can make a good argument for using a particular C++ feature in the Wiring layer that's not currently in use, I'm happy to listen. It looks like you and gbulmer are off to a good start; I look forward to seeing what you come up with.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>siy on "Discussion on the Wiring API and the new style Includes for libmaple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2016&amp;page=2#post-11947</link>
			<pubDate>Mon, 23 Jul 2012 17:25:59 +0000</pubDate>
			<dc:creator>siy</dc:creator>
			<guid isPermaLink="false">11947@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;@mbolivar, I think that many peoples trying to avoid C++ just because it really a &#34;sharp tool&#34; and any mistake may lead to not just &#34;shot itself in the foot&#34; but also &#34;amputate legs, hands and head in the same time&#34;. To use it effectively one need to have very good understanding how every line of code will be handled by compiler. And C++ in many cases unnecessarily makes things complex even in cases which are very simple by nature but do not fit into &#34;academic style&#34; proposed by Stroustrup. Many years ago I had discussion with him in regard to some aspects of the C++ which were related to &#34;real world&#34; low level and system programming, but during that discussion I quickly realized that the main goal is &#34;purity&#34; rather than practical usability.&#60;br /&#62;
At present choice of languages usable for embedded programming is quite limited, so we ought to use tools we have. With some reasonable restrictions and careful use C++ is way better than pure C (although still far from perfect). Since embedded programming by its nature (limited resources, lack of full-featured underlying OS and so forth) requires careful use of programming language and establishes some restrictions, difference between C and C++ in this regard is not so big. But, as I've mentioned above, C++ is way better and more powerful language. So, I see no reasons to limit itself and avoid C++.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mbolivar on "Discussion on the Wiring API and the new style Includes for libmaple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2016&amp;page=2#post-11943</link>
			<pubDate>Mon, 23 Jul 2012 14:33:54 +0000</pubDate>
			<dc:creator>mbolivar</dc:creator>
			<guid isPermaLink="false">11943@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Wow, this discussion is really going somewhere. Great.&#60;/p&#62;
&#60;p&#62;Regarding the pros and cons of a template-based pin approach, I'm not qualified to comment, as I generally avoid using C++ features not available in C as much as I can. I remain very receptive to specific proposals with the kind of concrete analysis that gbulmer and siy have begun performing. Because of my inexperience, I will say right away that proposals which don't come with patches are not likely to be adopted, as I don't feel capable of coming up with a good implementation myself.&#60;/p&#62;
&#60;p&#62;I really don't like doing API design in isolation, and I totally agree that anything LeafLabs comes up with unilaterally is all but certain to have serious shortcomings that user feedback can easily correct. Case in point:&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;
A small comment; I think device, peripheral or registers are more memorable than c_dev&#60;/p&#62;
&#60;/blockquote&#62;
&#60;p&#62;Yes, I'm uncomfortable with the name as well, which is why I've been keeping this feature a little quiet. I chose c_dev to try to evoke intuition from c_str, but it does have all the flaws you've outlined. Thankfully, these have never been part of a release, so there's still time to come up with something better.&#60;/p&#62;
&#60;p&#62;I like &#34;device&#34; best of the names you've suggested; it makes it easier to point to documentation about libmaple's device model.&#60;/p&#62;
&#60;p&#62;We could additionally add a &#34;registers&#34; method, that did nothing more than return &#60;code&#62;this-&#38;gt;device()-&#38;gt;regs&#60;/code&#62;. That would provide the standard escape hatch without any additional stuff wrapped around it which you desire.&#60;/p&#62;
&#60;p&#62;Thoughts?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>feurig on "Discussion on the Wiring API and the new style Includes for libmaple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2016&amp;page=2#post-11923</link>
			<pubDate>Sun, 22 Jul 2012 21:54:46 +0000</pubDate>
			<dc:creator>feurig</dc:creator>
			<guid isPermaLink="false">11923@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Well said.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Discussion on the Wiring API and the new style Includes for libmaple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2016&amp;page=2#post-11922</link>
			<pubDate>Sun, 22 Jul 2012 21:52:17 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">11922@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;feurig - I did my experiments (using template classes) for a couple of reasons:&#60;br /&#62;
1. When I have dipped under the Arduino digitalRead/digitalWrite API (to get reasonable performance on a couple of projects), changes to the Arduino library broke my code,&#60;br /&#62;
2. the performance of some library calls, e.g. digitalWrite &#38;amp; digitalRead, on Maple are so poor, compared to the underlying hardware, that it is frustrating; problems that I feel I should be able to solve easily require special solutions. I've ended up coding ARM-specific solutions, which I later felt should have been portable.&#60;/p&#62;
&#60;p&#62;Edit: so I have wanted a 'standard' &#34;escape hatch&#34;, to get at the hardware, and have NOT wanted much else wrapped around it.&#60;/p&#62;
&#60;p&#62;So, I don't completely agree that it isn't broken. It might not be broken for a lot of uses, but we do get quite a regular stream of people moving to Maple, and posting on the forum because they want a lot more performance than Arduino. So I feel more folks than me would appreciate performance improvements.&#60;/p&#62;
&#60;p&#62;A solution I was experimenting with was intended to be almost invisible. Things like digitalWrite(13, HIGH), worked the same as always, but digitalWrite(D13, HIGH) had much better performace. The easiest way to get that effect (that I can think of) is using classes for pins. Some folks assume the 'right way' is to drag in all the syntax of classes just because they have encapsulated something in a class. I don't feel that is essential, or even desirable in some cases.&#60;/p&#62;
&#60;p&#62;I do agree with the sentiment there is no benefit in moving to a new API which is either so complex it is unusable by the majority of folks (and I include error messages as part of this complexity), or users feel it is so opaque that it becomes magic, because that has defeated the purpose of improving it for me. (My base-reference for improvements is Wiring and not libmaple or Wirish.)&#60;/p&#62;
&#60;p&#62;I think it is extremely hard to get things right, and the Wiring/Arduino API is remarkably good. I do think the best way to get something better is to try it with real problems, with real people, and not expect to get it right first time, no matter how 'smart' we think we are. &#60;/p&#62;
&#60;p&#62;I think (but maybe wrong) that an evolutionary approach implies the improved interface needs to appear to be close to the old API.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>feurig on "Discussion on the Wiring API and the new style Includes for libmaple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=2016&amp;page=2#post-11920</link>
			<pubDate>Sun, 22 Jul 2012 21:02:18 +0000</pubDate>
			<dc:creator>feurig</dc:creator>
			<guid isPermaLink="false">11920@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;One of the joys of libmaple/wiring is that the details are kept out of the way, but you are allowed to just bypass them when when it makes sense. Most of what is proposed here (outside of pinMode(42, INPUT_PULLUP) which is just common sense) is way too complicated. As mbolivar and gbulmer already said. Keep it simple, keep it approachable. These things are not just for beginners. As an experienced programmer I don't want to pay attention to more detail than I have to; which is why I have started with wiring for most of my professional projects and why I am working with libmaple instead of the multitude of other stm code bases.&#60;/p&#62;
&#60;p&#62;I think you are WAY over-thinking this. .  Classing pins is just freaking out there.  Feel free to write me off as an stdio loving, c programming geezer . Problem is that even if it isn't elegant or technically interesting it ain't broken. .&#60;/p&#62;
&#60;p&#62;tl;dr&#60;br /&#62;
omg @_@ NOOOOOOOO!!!!!!!!!
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
