<?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: Port Registers on Maple</title>
		<link>http://forums.leaflabs.com/topic.php?id=737</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:08:47 +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=737" rel="self" type="application/rss+xml" />

		<item>
			<title>gbulmer on "Port Registers on Maple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=737&amp;page=3#post-25535</link>
			<pubDate>Mon, 29 Apr 2013 17:45:56 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">25535@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;stephanschulz - I think the thing that gives the high performance are the LED strips which handle PWM themselves.&#60;/p&#62;
&#60;p&#62;For example, have a look at &#60;a href=&#34;http://www.adafruit.com/products/306&#34; rel=&#34;nofollow&#34;&#62;http://www.adafruit.com/products/306&#60;/a&#62;&#60;br /&#62;
which have Arduino libraries for driving the LED strip.&#60;/p&#62;
&#60;p&#62;Maple has two SPI peripherals, so it could drive two sets of strips with very low overhead.&#60;/p&#62;
&#60;p&#62;Edit:  The performance of the mbed they use is pretty close to Maple, i.e. it is the same Cortex-M3 processor, running a bit faster. Hence I think pushing the problem of controlling brightness into the smart LED strips has a much more dramatic effect on the performance of the overall system. Once set, the smart strips will handle PWM for themselves until the brightness needs to change.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>tlgosser on "Port Registers on Maple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=737&amp;page=3#post-25423</link>
			<pubDate>Sat, 27 Apr 2013 14:30:55 +0000</pubDate>
			<dc:creator>tlgosser</dc:creator>
			<guid isPermaLink="false">25423@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I see, you engineer for Rafael Lozano-Hemmer.  I used to to do similar work in the 90's.  I worked for Bob Bielecki - he's the guy who engineered (and, ahem, often proposed) Laurie Anderson's technology art.  And I was Roxy Paine's engineer for a while. It was all PIC programming and parallel port back then, writing c++ with djgpp with Allegro.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>tlgosser on "Port Registers on Maple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=737&amp;page=3#post-25421</link>
			<pubDate>Sat, 27 Apr 2013 13:04:06 +0000</pubDate>
			<dc:creator>tlgosser</dc:creator>
			<guid isPermaLink="false">25421@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Are you working for this artist?  Or do you mean that you are working on something similar?&#60;/p&#62;
&#60;p&#62;That looks like it could be a great out-of-box solution and it would eliminate any 'malfunction anxiety'.  If something goes wrong you'd just toss it in the garbage and plug in another one.  &#60;/p&#62;
&#60;p&#62;Would this interface with your DMX?  Their description is confusing.  Sounds... unique.&#60;/p&#62;
&#60;p&#62;Thanks for tip about the avatar.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>stephanschulz on "Port Registers on Maple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=737&amp;page=3#post-25408</link>
			<pubDate>Fri, 26 Apr 2013 20:44:13 +0000</pubDate>
			<dc:creator>stephanschulz</dc:creator>
			<guid isPermaLink="false">25408@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;the profile image just showed up, because i registered with &#60;a href=&#34;http://www.gravatar.com&#34; rel=&#34;nofollow&#34;&#62;http://www.gravatar.com&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;the leds are for this piece: &#60;a href=&#34;http://lozano-hemmer.com/voice_array.php&#34; rel=&#34;nofollow&#34;&#62;http://lozano-hemmer.com/voice_array.php&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;i just saw this, which makes me rethink my use of the maple for this project: &#60;a href=&#34;http://www.heroicrobotics.com&#34; rel=&#34;nofollow&#34;&#62;http://www.heroicrobotics.com&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>tlgosser on "Port Registers on Maple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=737&amp;page=2#post-25407</link>
			<pubDate>Fri, 26 Apr 2013 20:00:42 +0000</pubDate>
			<dc:creator>tlgosser</dc:creator>
			<guid isPermaLink="false">25407@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Of course.  That is why you are participating in the port registers forum.  That's a lot of LEDs.  Are you making a monitor?&#60;br /&#62;
With LEDs it's all about the refresh rate in your eyeballs somehow.&#60;/p&#62;
&#60;p&#62;Btw how did you change your icon?  I don't mean to sound insecure but my icon was assigned to me randomly and I assumed it would be simple to change.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>stephanschulz on "Port Registers on Maple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=737&amp;page=2#post-25396</link>
			<pubDate>Fri, 26 Apr 2013 19:00:17 +0000</pubDate>
			<dc:creator>stephanschulz</dc:creator>
			<guid isPermaLink="false">25396@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;thanks for the reply.&#60;/p&#62;
&#60;p&#62;i figured out my problem. i was trying to access an array element that did not exist.&#60;/p&#62;
&#60;p&#62;about the dimming. i am just doing it linear, but your idea of some sort of curve is interesting. i did notice that the leds dim more noticeably in the lower numbers.&#60;br /&#62;
but i am also concerned that the dimming of my 16 leds takes up too much time and in turn messes up the dmx receiving. i have 16 channels per maple mini and a chain of 30 boards.&#60;/p&#62;
&#60;p&#62;all works well at this point though.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>tlgosser on "Port Registers on Maple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=737&amp;page=2#post-25384</link>
			<pubDate>Fri, 26 Apr 2013 16:09:39 +0000</pubDate>
			<dc:creator>tlgosser</dc:creator>
			<guid isPermaLink="false">25384@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I'm looking at this on my phone so it's difficult to read.&#60;br /&#62;
Is the dmx dimming data already 'curved' or are you generating&#60;br /&#62;
linear gradients here ++?&#60;/p&#62;
&#60;p&#62;The maple is fast enough to run the arduino spline library effectively&#60;br /&#62;
if you want to interpolate  splines on board.&#60;br /&#62;
&#60;a href=&#34;https://github.com/kerinin/arduino-splines&#34; rel=&#34;nofollow&#34;&#62;https://github.com/kerinin/arduino-splines&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;I think you only have to replace Arduino.h with WProgram.h
&#60;/p&#62;</description>
		</item>
		<item>
			<title>stephanschulz on "Port Registers on Maple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=737&amp;page=2#post-25372</link>
			<pubDate>Fri, 26 Apr 2013 10:42:42 +0000</pubDate>
			<dc:creator>stephanschulz</dc:creator>
			<guid isPermaLink="false">25372@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;now it works. i had some other problem that were not apparent when using gpio_write_bit and only showed up when using digitalwrite. works great this library.&#60;br /&#62;
thanks.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>stephanschulz on "Port Registers on Maple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=737&amp;page=2#post-25371</link>
			<pubDate>Fri, 26 Apr 2013 09:10:27 +0000</pubDate>
			<dc:creator>stephanschulz</dc:creator>
			<guid isPermaLink="false">25371@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;this looks very interesting.&#60;/p&#62;
&#60;p&#62;i tried to integrate it in to my project which also receives dmx data. &#60;/p&#62;
&#60;p&#62;digitalWriteFaster works fine before running my dmx setup routine. could it be that some of my dmx pins are being effect by the digitalWriteFaster.h library?&#60;/p&#62;
&#60;p&#62;i am using pin 25 to receive dmx data&#60;/p&#62;
&#60;p&#62;-------------dmx code-----------------&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;enum
{
  DMX_IDLE,
  DMX_BREAK,
  DMX_START,
  DMX_RUN
};

// We need to read the data register in order to avoid overrun errors,
// but we don&#38;#39;t do anything with the value. This attribute silences an
// unused variable warning from GCC.
#define __unused __attribute__((unused))

volatile unsigned char dmx_state;

// this is the start address for the dmx frame
//const unsigned int dmx_start_addr = 0;
unsigned int dmx_start_addr = 0;

// this is the current address of the dmx frame
volatile unsigned int dmx_addr;

//// this is used to keep track of the channels
volatile unsigned int chan_cnt;

extern &#38;quot;C&#38;quot; {
  void __irq_usart1(void) {
    unsigned char status = USART1_BASE-&#38;gt;SR;
    data = USART1_BASE-&#38;gt;DR;

    switch (dmx_state)
    {
    case DMX_IDLE:
      if (status &#38;amp; 1&#38;lt;&#38;lt;USART_SR_FE_BIT)
      {
        dmx_addr = 0;
        dmx_state = DMX_BREAK;
        update = 1;
        //delayMicroseconds(8);
      }
      break;

    case DMX_BREAK:
      if (data == 0)
      {
        dmx_state = DMX_START;
      }
      else
      {
        dmx_state = DMX_IDLE;
      }
      break;

    case DMX_START:
      dmx_addr++;

      if (dmx_addr == dmx_start_addr)
      {
        chan_cnt = 0;
        dmx_data[chan_cnt++] = data; //constrain(data,0,maxDMXvalue); //data;
        dmx_state = DMX_RUN;
      }
      break;

    case DMX_RUN:
      //for (int wasteTime =0; wasteTime &#38;lt;2; wasteTime++) {}
      dmx_data[chan_cnt++] = data; //constrain(data,0,maxDMXvalue); //data;
      if (chan_cnt &#38;gt;= DMX_NUM_CHANNELS)
      {
       // printTestStage = 2;
        dmx_state = DMX_IDLE;
      }
      break;

    default:
      dmx_state = DMX_IDLE;
      break;
    }
  }
}

void setup_dmx(){
  update = 0;

  // set default DMX state
  dmx_state = DMX_IDLE;
dmx_start_addr = myGroupID * 16 + 1;
  Serial1.begin(250000);

  // Set USART1 to 2 stop bits
  USART1_BASE-&#38;gt;CR2 = 2;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;---------------------and this is my dimming code------------------------&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;void setup_dimming(){
  for(int i=0; i&#38;lt;DMX_NUM_CHANNELS; i++){
    pinMode(ledPin[i],OUTPUT_OPEN_DRAIN);
    // dimValue[i] = counterLimit/DMX_NUM_CHANNELS * i;
  }

  Timer3.setPrescaleFactor(1);
  Timer3.setOverflow(255); //2000); //500); //1079);
  Timer3.attachCompare1Interrupt(timer3_dimming_handler);
}

void timer3_dimming_handler(void) {
  for(int i=0; i&#38;lt;DMX_NUM_CHANNELS; i++){

    if(dmx_data[i] &#38;gt; counter){
      dimStates[i] = true;
    }
    else{
      dimStates[i] = false;
    }
    digitalWriteFaster(ledPin[i],dimStates[i]);

    //if(LED_PORTref_ARRAY[i] == 0) gpio_write_bit(GPIOA, LED_BIT_ARRAY[i],dimStates[i]);
    //if(LED_PORTref_ARRAY[i] == 1) gpio_write_bit(GPIOB, LED_BIT_ARRAY[i],dimStates[i]);
    //digitalWrite(ledPin[i],dimStates[i]);

  }

  counter++;
  if(counter &#38;gt; counterLimit) counter = 0;
}&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>tlgosser on "Port Registers on Maple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=737&amp;page=2#post-25153</link>
			<pubDate>Wed, 24 Apr 2013 11:57:03 +0000</pubDate>
			<dc:creator>tlgosser</dc:creator>
			<guid isPermaLink="false">25153@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;And you will probably have to restart your editor for the library to show up.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>tlgosser on "Port Registers on Maple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=737&amp;page=2#post-25152</link>
			<pubDate>Wed, 24 Apr 2013 11:52:15 +0000</pubDate>
			<dc:creator>tlgosser</dc:creator>
			<guid isPermaLink="false">25152@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;/* digitalWriteFaster example as per gbulmer's code above */&#60;/p&#62;
&#60;p&#62;#include &#38;lt;gpio.h&#38;gt;&#60;br /&#62;
#include &#38;lt;digitalWriteFaster.h&#38;gt;&#60;/p&#62;
&#60;p&#62;void setup() {&#60;br /&#62;
    // Set up the built-in LED pin as an output:&#60;br /&#62;
    pinMode(13, OUTPUT);&#60;br /&#62;
    pinMode(9, INPUT);&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;void loop() {&#60;br /&#62;
    int val = digitalReadFaster(9);&#60;br /&#62;
    digitalWriteFaster(13, HIGH);&#60;br /&#62;
    delay(250);&#60;br /&#62;
    digitalWriteFaster(13, LOW);&#60;br /&#62;
    delay(250);&#60;br /&#62;
}
&#60;/p&#62;</description>
		</item>
		<item>
			<title>tlgosser on "Port Registers on Maple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=737&amp;page=2#post-25151</link>
			<pubDate>Wed, 24 Apr 2013 11:41:19 +0000</pubDate>
			<dc:creator>tlgosser</dc:creator>
			<guid isPermaLink="false">25151@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;/******************************************************************************&#60;br /&#62;
*                            digitalWriteFaster.h&#60;br /&#62;
*&#60;br /&#62;
*  An ultra-fast hardware specific replacement for both&#60;br /&#62;
*  digitalWrite and digitalRead.&#60;br /&#62;
*&#60;br /&#62;
*  Works for Maple, Maple-Mini, Maple Native, and Maple Ret6.&#60;br /&#62;
*&#60;br /&#62;
*  To use, create a folder named 'digitalWriteFaster' inside your 'libraries' folder.&#60;br /&#62;
*  Create a text file named 'digitalWriteFaster.h' and cut&#38;amp;paste this code.&#60;br /&#62;
*&#60;br /&#62;
*  Use 'digitalWriteFaster' and 'digitalReadFaster' in the original manner.&#60;br /&#62;
*&#60;br /&#62;
*  Based on code written by moderator 'gbulmer' and member 'manitou'.&#60;br /&#62;
*  Re-packaged by member tlgosser 4/24/2013.&#60;br /&#62;
*  &#60;a href=&#34;http://forums.leaflabs.com/topic.php?id=737&#34; rel=&#34;nofollow&#34;&#62;http://forums.leaflabs.com/topic.php?id=737&#60;/a&#62;&#60;br /&#62;
*&#60;br /&#62;
*****************************************************************************/&#60;/p&#62;
&#60;p&#62;typedef unsigned int uint32_t;&#60;/p&#62;
&#60;p&#62;#define ODR (0x0C&#38;gt;&#38;gt;2)  // offset of output register within port&#60;br /&#62;
#define IDR (0x08&#38;gt;&#38;gt;2)  // offset of input register within port&#60;/p&#62;
&#60;p&#62;// Address of output data register for each GPIO peripheral&#60;br /&#62;
#define GPIOA_ODR ((uint32_t*) GPIOA_BASE+ODR)&#60;br /&#62;
#define GPIOB_ODR ((uint32_t*) GPIOB_BASE+ODR)&#60;br /&#62;
#define GPIOC_ODR ((uint32_t*) GPIOC_BASE+ODR)&#60;br /&#62;
#define GPIOD_ODR ((uint32_t*) GPIOD_BASE+ODR)&#60;br /&#62;
#define GPIOE_ODR ((uint32_t*) GPIOE_BASE+ODR)&#60;br /&#62;
#define GPIOF_ODR ((uint32_t*) GPIOF_BASE+ODR)&#60;br /&#62;
#define GPIOG_ODR ((uint32_t*) GPIOG_BASE+ODR)&#60;/p&#62;
&#60;p&#62;#define GPIOA_IDR ((uint32_t*) GPIOA_BASE+IDR)&#60;br /&#62;
#define GPIOB_IDR ((uint32_t*) GPIOB_BASE+IDR)&#60;br /&#62;
#define GPIOC_IDR ((uint32_t*) GPIOC_BASE+IDR)&#60;br /&#62;
#define GPIOD_IDR ((uint32_t*) GPIOD_BASE+IDR)&#60;br /&#62;
#define GPIOE_IDR ((uint32_t*) GPIOE_BASE+IDR)&#60;br /&#62;
#define GPIOF_IDR ((uint32_t*) GPIOF_BASE+IDR)&#60;br /&#62;
#define GPIOG_IDR ((uint32_t*) GPIOG_BASE+IDR)&#60;/p&#62;
&#60;p&#62;// Formula converts peripheral address to bit band peripheral address&#60;br /&#62;
// See ARMs Cortex™-M3 Technical Reference Manual for details&#60;br /&#62;
// Must all be calculated at compile time&#60;br /&#62;
#define BB_PERIPHERAL(peripheral_address, bit) ((volatile uint32_t*)  (0x42000000 \&#60;br /&#62;
        + ((uint32_t)peripheral_address - 0x40000000) * 32 + bit * 4))&#60;/p&#62;
&#60;p&#62;#ifdef BOARD_maple_mini&#60;br /&#62;
    // uses &#60;a href=&#34;http://leaflabs.com/docs/hardware/maple-mini.html#gpio-port-pin-map&#34; rel=&#34;nofollow&#34;&#62;http://leaflabs.com/docs/hardware/maple-mini.html#gpio-port-pin-map&#60;/a&#62;&#60;br /&#62;
    // to map Maple mini pins back to STM32F103CB&#60;br /&#62;
    // Each entry is the bit-band address of one GPIO output pin&#60;br /&#62;
  volatile uint32_t* const bb_port_ODR_bit_address[] = {&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_ODR, 11),          // D0&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_ODR, 10),          // D1&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_ODR,  2),          // D2&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_ODR,  0),          // D3&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_ODR,  7),          // D4&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_ODR,  6),          // D5&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_ODR,  5),          // D6&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_ODR,  4),          // D7&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_ODR,  3),          // D8&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_ODR,  2),          // D9&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_ODR,  1),          // D10&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_ODR,  0),          // D11&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_ODR, 15),          // D12&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_ODR, 14),          // D13&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_ODR, 13),          // D14&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_ODR,  7),           //D15&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_ODR,  6),           //D16&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_ODR,  5),           //D17&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_ODR,  4),           //D18&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_ODR,  3),           //D19&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_ODR,  15),          //D20&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_ODR,  14),          //D21&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_ODR,  13),          //D22&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_ODR,  12),          //D23&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_ODR,  11),          //D24&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_ODR,  10),          //D25&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_ODR,  9),           //D26&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_ODR,  8),           //D27&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_ODR,  15),          //D28&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_ODR,  14),          //D29&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_ODR,  13),          //D30&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_ODR,  12)           //D31&#60;br /&#62;
    };&#60;/p&#62;
&#60;p&#62;    // Each entry is the bit-band address of one GPIO input pin&#60;br /&#62;
    volatile uint32_t* const bb_port_IDR_bit_address[] = {&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_IDR, 11),          // D0&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_IDR, 10),          // D1&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_IDR,  2),          // D2&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_IDR,  0),          // D3&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_IDR,  7),          // D4&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_IDR,  6),          // D5&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_IDR,  5),          // D6&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_IDR,  4),          // D7&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_IDR,  3),          // D8&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_IDR,  2),          // D9&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_IDR,  1),          // D10&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_IDR,  0),          // D11&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_IDR, 15),          // D12&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_IDR, 14),          // D13&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_IDR, 13),          // D14&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_IDR,  7),          // D15&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_IDR,  6),          // D16&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_IDR,  5),          // D17&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_IDR,  4),          // D18&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_IDR,  3),          // D19&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_IDR,  15),         // D20&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_IDR,  14),         // D21&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_IDR,  13),         // D22&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_IDR,  12),         // D23&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_IDR,  11),         // D24&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_IDR,  10),         // D25&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_IDR,  9),          // D26&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_IDR,  8),          // D27&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_IDR,  15),         // D28&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_IDR,  14),         // D29&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_IDR,  13),         // D30&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_IDR,  12)          // D31&#60;br /&#62;
    };&#60;/p&#62;
&#60;p&#62;#elif defined  BOARD_maple_native&#60;br /&#62;
    // uses &#60;a href=&#34;http://leaflabs.com/docs/hardware/maple-native-beta.html#gpio-port-pin-map&#34; rel=&#34;nofollow&#34;&#62;http://leaflabs.com/docs/hardware/maple-native-beta.html#gpio-port-pin-map&#60;/a&#62;&#60;br /&#62;
    volatile uint32_t* const bb_port_ODR_bit_address[] = {&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_ODR,  10),          // D0&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_ODR,  11),          // D1&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_ODR,  12),          // D2&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_ODR,  13),          // D3&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_ODR,  14),          // D4&#60;br /&#62;
        BB_PERIPHERAL(-1,  -1),                 // D5&#60;br /&#62;
        BB_PERIPHERAL(-1,  -1),                 // D6 button pin&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_ODR,  0),           // D7&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_ODR,  1),           // D8&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_ODR,  2),           // D9&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_ODR,  3),           // D10&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_ODR,  4),           // D11&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_ODR,  5),           // D12&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_ODR,  6),           // D13&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_ODR,  7),           // D14&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_ODR,  8),           // D15&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_ODR,  9),           // D16&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_ODR,  10),          // D17&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_ODR,  11),          // D18&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_ODR,  12),          // D19&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_ODR,  13),          // D20&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_ODR,  14),          // D21&#60;br /&#62;
        BB_PERIPHERAL(-1,  -1),                 // D22&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_ODR,  8),           // D23&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_ODR,  9),           // D24&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_ODR,  10),          // D25&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_ODR,  9),           // D26&#60;br /&#62;
        BB_PERIPHERAL(GPIOD_ODR,  2),           // D27&#60;br /&#62;
        BB_PERIPHERAL(GPIOD_ODR,  3),           // D28&#60;br /&#62;
        BB_PERIPHERAL(GPIOD_ODR,  6),           // D29&#60;br /&#62;
        BB_PERIPHERAL(GPIOG_ODR,  11),          // D30&#60;br /&#62;
        BB_PERIPHERAL(GPIOG_ODR,  12),          // D31&#60;br /&#62;
        BB_PERIPHERAL(GPIOG_ODR,  13),          // D32&#60;br /&#62;
        BB_PERIPHERAL(GPIOG_ODR,  14)           // D33&#60;br /&#62;
        BB_PERIPHERAL(GPIOG_ODR,  8),           // D34&#60;br /&#62;
        BB_PERIPHERAL(GPIOG_ODR,  7),           // D35&#60;br /&#62;
        BB_PERIPHERAL(GPIOG_ODR,  6),           // D36&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_ODR,  5),           // D37&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_ODR,  6),           // D38&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_ODR,  7),           // D39&#60;br /&#62;
        BB_PERIPHERAL(GPIOF_ODR,  11),          // D40&#60;br /&#62;
        BB_PERIPHERAL(GPIOF_ODR,  6),           // D41&#60;br /&#62;
        BB_PERIPHERAL(GPIOF_ODR,  7),           // D42&#60;br /&#62;
        BB_PERIPHERAL(GPIOF_ODR,  8),           // D43&#60;br /&#62;
        BB_PERIPHERAL(GPIOF_ODR,  9),           // D44&#60;br /&#62;
        BB_PERIPHERAL(GPIOF_ODR,  10),          // D45&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_ODR,  1),           // D46&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_ODR,  0),           // D47&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_ODR,  0),           // D48&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_ODR,  1),           // D49&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_ODR,  2),           // D50&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_ODR,  3),           // D51&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_ODR,  4),           // D52&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_ODR,  5),           // D53&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_ODR,  6),           // D54&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_ODR,  7),           // D55&#60;br /&#62;
        BB_PERIPHERAL(GPIOF_ODR,  0),           // D56&#60;br /&#62;
        BB_PERIPHERAL(GPIOD_ODR,  11),          // D57&#60;br /&#62;
        BB_PERIPHERAL(GPIOD_ODR,  14),          // D58&#60;br /&#62;
        BB_PERIPHERAL(GPIOF_ODR,  1),           // D59&#60;br /&#62;
        BB_PERIPHERAL(GPIOD_ODR,  12),          // D60&#60;br /&#62;
        BB_PERIPHERAL(-1,  -1),                 // D61&#60;br /&#62;
        BB_PERIPHERAL(GPIOF_ODR,  2),           // D62&#60;br /&#62;
        BB_PERIPHERAL(GPIOD_ODR,  13),          // D63&#60;br /&#62;
        BB_PERIPHERAL(GPIOD_ODR,  0),           // D64&#60;br /&#62;
        BB_PERIPHERAL(GPIOF_ODR,  3),           // D65&#60;br /&#62;
        BB_PERIPHERAL(GPIOE_ODR,  3),           // D66&#60;br /&#62;
        BB_PERIPHERAL(GPIOD_ODR,  1),           // D67&#60;br /&#62;
        BB_PERIPHERAL(GPIOF_ODR,  4),           // D68&#60;br /&#62;
        BB_PERIPHERAL(GPIOE_ODR,  4),           // D69&#60;br /&#62;
        BB_PERIPHERAL(GPIOE_ODR,  7),           // D70&#60;br /&#62;
        BB_PERIPHERAL(GPIOF_ODR,  5),           // D71&#60;br /&#62;
        BB_PERIPHERAL(GPIOE_ODR,  5),           // D72&#60;br /&#62;
        BB_PERIPHERAL(GPIOE_ODR,  8),           // D73&#60;br /&#62;
        BB_PERIPHERAL(GPIOF_ODR,  12),          // D74&#60;br /&#62;
        BB_PERIPHERAL(GPIOE_ODR,  6),           // D75&#60;br /&#62;
        BB_PERIPHERAL(GPIOE_ODR,  9),           // D76&#60;br /&#62;
        BB_PERIPHERAL(GPIOF_ODR,  13),          // D77&#60;br /&#62;
        BB_PERIPHERAL(GPIOE_ODR,  10),          // D78&#60;br /&#62;
        BB_PERIPHERAL(GPIOF_ODR,  14),          // D79&#60;br /&#62;
        BB_PERIPHERAL(GPIOG_ODR,  9),           // D80&#60;br /&#62;
        BB_PERIPHERAL(GPIOE_ODR,  11),          // D81&#60;br /&#62;
        BB_PERIPHERAL(-1,  -1),                 // D82&#60;br /&#62;
        BB_PERIPHERAL(GPIOG_ODR,  10),          // D83&#60;br /&#62;
        BB_PERIPHERAL(GPIOE_ODR,  12),          // D84&#60;br /&#62;
        BB_PERIPHERAL(GPIOG_ODR,  0),           // D85&#60;br /&#62;
        BB_PERIPHERAL(GPIOD_ODR,  5),           // D86&#60;br /&#62;
        BB_PERIPHERAL(GPIOE_ODR,  13),          // D87&#60;br /&#62;
        BB_PERIPHERAL(GPIOG_ODR,  1),           // D88&#60;br /&#62;
        BB_PERIPHERAL(GPIOD_ODR,  4),           // D89&#60;br /&#62;
        BB_PERIPHERAL(GPIOE_ODR,  14),          // D90&#60;br /&#62;
        BB_PERIPHERAL(GPIOG_ODR,  2),           // D91&#60;br /&#62;
        BB_PERIPHERAL(GPIOE_ODR,  1),           // D92&#60;br /&#62;
        BB_PERIPHERAL(-1,  -1),                 // D93&#60;br /&#62;
        BB_PERIPHERAL(GPIOG_ODR,  3),           // D94&#60;br /&#62;
        BB_PERIPHERAL(GPIOE_ODR,  0),           // D95&#60;br /&#62;
        BB_PERIPHERAL(GPIOD_ODR,  8),           // D96&#60;br /&#62;
        BB_PERIPHERAL(GPIOG_ODR,  4),           // D97&#60;br /&#62;
        BB_PERIPHERAL(GPIOD_ODR,  9),           // D98&#60;br /&#62;
        BB_PERIPHERAL(GPIOG_ODR,  5),           // D99&#60;br /&#62;
        BB_PERIPHERAL(GPIOD_ODR,  10),          // D100&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_ODR,  13),          // D101&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_ODR,  14),          // D102&#60;br /&#62;
        BB_PERIPHERAL(-1,  -1),                 // D103&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_ODR,  3),           // D104&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_ODR,  4)            // D105&#60;br /&#62;
    };&#60;/p&#62;
&#60;p&#62;    // Each entry is the bit-band address of one GPIO input pin&#60;br /&#62;
    volatile uint32_t* const bb_port_IDR_bit_address[] = {&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_IDR,  10),          // D0&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_IDR,  11),          // D1&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_IDR,  12),          // D2&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_IDR,  13),          // D3&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_IDR,  14),          // D4&#60;br /&#62;
        BB_PERIPHERAL(-1,  -1),                 // D5&#60;br /&#62;
        BB_PERIPHERAL(-1,  -1),                 // D6 button pin&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_IDR,  0),           // D7&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_IDR,  1),           // D8&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_IDR,  2),           // D9&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_IDR,  3),           // D10&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_IDR,  4),           // D11&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_IDR,  5),           // D12&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_IDR,  6),           // D13&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_IDR,  7),           // D14&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_IDR,  8),           // D15&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_IDR,  9),           // D16&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_IDR,  10),          // D17&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_IDR,  11),          // D18&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_IDR,  12),          // D19&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_IDR,  13),          // D20&#60;br /&#62;
        BB_PERIPHERAL(GPIOC_IDR,  14),          // D21&#60;br /&#62;
        BB_PERIPHERAL(-1,  -1),                 // D22&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_IDR,  8),           // D23&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_IDR,  9),           // D24&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_IDR,  10),          // D25&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_IDR,  9),           // D26&#60;br /&#62;
        BB_PERIPHERAL(GPIOD_IDR,  2),           // D27&#60;br /&#62;
        BB_PERIPHERAL(GPIOD_IDR,  3),           // D28&#60;br /&#62;
        BB_PERIPHERAL(GPIOD_IDR,  6),           // D29&#60;br /&#62;
        BB_PERIPHERAL(GPIOG_IDR,  11),          // D30&#60;br /&#62;
        BB_PERIPHERAL(GPIOG_IDR,  12),          // D31&#60;br /&#62;
        BB_PERIPHERAL(GPIOG_IDR,  13),          // D32&#60;br /&#62;
        BB_PERIPHERAL(GPIOG_IDR,  14)           // D33&#60;br /&#62;
        BB_PERIPHERAL(GPIOG_IDR,  8),           // D34&#60;br /&#62;
        BB_PERIPHERAL(GPIOG_IDR,  7),           // D35&#60;br /&#62;
        BB_PERIPHERAL(GPIOG_IDR,  6),           // D36&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_IDR,  5),           // D37&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_IDR,  6),           // D38&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_IDR,  7),           // D39&#60;br /&#62;
        BB_PERIPHERAL(GPIOF_IDR,  11),          // D40&#60;br /&#62;
        BB_PERIPHERAL(GPIOF_IDR,  6),           // D41&#60;br /&#62;
        BB_PERIPHERAL(GPIOF_IDR,  7),           // D42&#60;br /&#62;
        BB_PERIPHERAL(GPIOF_IDR,  8),           // D43&#60;br /&#62;
        BB_PERIPHERAL(GPIOF_IDR,  9),           // D44&#60;br /&#62;
        BB_PERIPHERAL(GPIOF_IDR,  10),          // D45&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_IDR,  1),           // D46&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_IDR,  0),           // D47&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_IDR,  0),           // D48&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_IDR,  1),           // D49&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_IDR,  2),           // D50&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_IDR,  3),           // D51&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_IDR,  4),           // D52&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_IDR,  5),           // D53&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_IDR,  6),           // D54&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_IDR,  7),           // D55&#60;br /&#62;
        BB_PERIPHERAL(GPIOF_IDR,  0),           // D56&#60;br /&#62;
        BB_PERIPHERAL(GPIOD_IDR,  11),          // D57&#60;br /&#62;
        BB_PERIPHERAL(GPIOD_IDR,  14),          // D58&#60;br /&#62;
        BB_PERIPHERAL(GPIOF_IDR,  1),           // D59&#60;br /&#62;
        BB_PERIPHERAL(GPIOD_IDR,  12),          // D60&#60;br /&#62;
        BB_PERIPHERAL(-1,  -1),                 // D61&#60;br /&#62;
        BB_PERIPHERAL(GPIOF_IDR,  2),           // D62&#60;br /&#62;
        BB_PERIPHERAL(GPIOD_IDR,  13),          // D63&#60;br /&#62;
        BB_PERIPHERAL(GPIOD_IDR,  0),           // D64&#60;br /&#62;
        BB_PERIPHERAL(GPIOF_IDR,  3),           // D65&#60;br /&#62;
        BB_PERIPHERAL(GPIOE_IDR,  3),           // D66&#60;br /&#62;
        BB_PERIPHERAL(GPIOD_IDR,  1),           // D67&#60;br /&#62;
        BB_PERIPHERAL(GPIOF_IDR,  4),           // D68&#60;br /&#62;
        BB_PERIPHERAL(GPIOE_IDR,  4),           // D69&#60;br /&#62;
        BB_PERIPHERAL(GPIOE_IDR,  7),           // D70&#60;br /&#62;
        BB_PERIPHERAL(GPIOF_IDR,  5),           // D71&#60;br /&#62;
        BB_PERIPHERAL(GPIOE_IDR,  5),           // D72&#60;br /&#62;
        BB_PERIPHERAL(GPIOE_IDR,  8),           // D73&#60;br /&#62;
        BB_PERIPHERAL(GPIOF_IDR,  12),          // D74&#60;br /&#62;
        BB_PERIPHERAL(GPIOE_IDR,  6),           // D75&#60;br /&#62;
        BB_PERIPHERAL(GPIOE_IDR,  9),           // D76&#60;br /&#62;
        BB_PERIPHERAL(GPIOF_IDR,  13),          // D77&#60;br /&#62;
        BB_PERIPHERAL(GPIOE_IDR,  10),          // D78&#60;br /&#62;
        BB_PERIPHERAL(GPIOF_IDR,  14),          // D79&#60;br /&#62;
        BB_PERIPHERAL(GPIOG_IDR,  9),           // D80&#60;br /&#62;
        BB_PERIPHERAL(GPIOE_IDR,  11),          // D81&#60;br /&#62;
        BB_PERIPHERAL(-1,  -1),                 // D82&#60;br /&#62;
        BB_PERIPHERAL(GPIOG_IDR,  10),          // D83&#60;br /&#62;
        BB_PERIPHERAL(GPIOE_IDR,  12),          // D84&#60;br /&#62;
        BB_PERIPHERAL(GPIOG_IDR,  0),           // D85&#60;br /&#62;
        BB_PERIPHERAL(GPIOD_IDR,  5),           // D86&#60;br /&#62;
        BB_PERIPHERAL(GPIOE_IDR,  13),          // D87&#60;br /&#62;
        BB_PERIPHERAL(GPIOG_IDR,  1),           // D88&#60;br /&#62;
        BB_PERIPHERAL(GPIOD_IDR,  4),           // D89&#60;br /&#62;
        BB_PERIPHERAL(GPIOE_IDR,  14),          // D90&#60;br /&#62;
        BB_PERIPHERAL(GPIOG_IDR,  2),           // D91&#60;br /&#62;
        BB_PERIPHERAL(GPIOE_IDR,  1),           // D92&#60;br /&#62;
        BB_PERIPHERAL(-1,  -1),                 // D93&#60;br /&#62;
        BB_PERIPHERAL(GPIOG_IDR,  3),           // D94&#60;br /&#62;
        BB_PERIPHERAL(GPIOE_IDR,  0),           // D95&#60;br /&#62;
        BB_PERIPHERAL(GPIOD_IDR,  8),           // D96&#60;br /&#62;
        BB_PERIPHERAL(GPIOG_IDR,  4),           // D97&#60;br /&#62;
        BB_PERIPHERAL(GPIOD_IDR,  9),           // D98&#60;br /&#62;
        BB_PERIPHERAL(GPIOG_IDR,  5),           // D99&#60;br /&#62;
        BB_PERIPHERAL(GPIOD_IDR,  10),          // D100&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_IDR,  13),          // D101&#60;br /&#62;
        BB_PERIPHERAL(GPIOA_IDR,  14),          // D102&#60;br /&#62;
        BB_PERIPHERAL(-1,  -1),                 // D103&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_IDR,  3),           // D104&#60;br /&#62;
        BB_PERIPHERAL(GPIOB_IDR,  4)            // D105&#60;br /&#62;
    };&#60;/p&#62;
&#60;p&#62;#elif defined (BOARD_maple_RET6) &#124;&#124; defined(BOARD_maple)&#60;br /&#62;
  // uses &#60;a href=&#34;http://leaflabs.com/docs/hardware/maple.html#gpio-port-pin-map&#34; rel=&#34;nofollow&#34;&#62;http://leaflabs.com/docs/hardware/maple.html#gpio-port-pin-map&#60;/a&#62;&#60;br /&#62;
  volatile uint32_t* const bb_port_ODR_bit_address[] = {&#60;br /&#62;
    BB_PERIPHERAL(GPIOA_ODR,  3),          //  D0&#60;br /&#62;
    BB_PERIPHERAL(GPIOA_ODR,  2),          //  D1&#60;br /&#62;
    BB_PERIPHERAL(GPIOA_ODR,  0),          //  D2&#60;br /&#62;
    BB_PERIPHERAL(GPIOA_ODR,  1),          //  D3&#60;br /&#62;
    BB_PERIPHERAL(GPIOB_ODR,  5),          //  D4&#60;br /&#62;
    BB_PERIPHERAL(GPIOB_ODR,  6),          //  D5&#60;br /&#62;
    BB_PERIPHERAL(GPIOA_ODR,  8),          //  D6&#60;br /&#62;
    BB_PERIPHERAL(GPIOA_ODR,  9),          //  D7&#60;br /&#62;
    BB_PERIPHERAL(GPIOA_ODR,  10),         //  D8&#60;br /&#62;
    BB_PERIPHERAL(GPIOB_ODR,  7),          //  D9&#60;br /&#62;
    BB_PERIPHERAL(GPIOA_ODR,  4),          //  D10&#60;br /&#62;
    BB_PERIPHERAL(GPIOA_ODR,  7),          //  D11&#60;br /&#62;
    BB_PERIPHERAL(GPIOA_ODR,  6),          //  D12&#60;br /&#62;
    BB_PERIPHERAL(GPIOA_ODR,  5),          //  D13&#60;br /&#62;
    BB_PERIPHERAL(GPIOB_ODR,  8),          //  D14&#60;br /&#62;
    BB_PERIPHERAL(GPIOC_ODR,  0),          //  D15&#60;br /&#62;
    BB_PERIPHERAL(GPIOC_ODR,  1),          //  D16&#60;br /&#62;
    BB_PERIPHERAL(GPIOC_ODR,  2),          //  D17&#60;br /&#62;
    BB_PERIPHERAL(GPIOC_ODR,  3),          //  D18&#60;br /&#62;
    BB_PERIPHERAL(GPIOC_ODR,  4),          //  D19&#60;br /&#62;
    BB_PERIPHERAL(GPIOC_ODR,  5),          //  D20&#60;br /&#62;
    BB_PERIPHERAL(GPIOC_ODR,  13),         //  D21&#60;br /&#62;
    BB_PERIPHERAL(GPIOC_ODR,  14),         //  D22&#60;br /&#62;
    BB_PERIPHERAL(GPIOC_ODR,  15),         //  D23&#60;br /&#62;
    BB_PERIPHERAL(GPIOB_ODR,  9),          //  D24&#60;br /&#62;
    BB_PERIPHERAL(GPIOD_ODR,  2), // D25 - changed by gbulmer 2014/6/16&#60;br /&#62;
    BB_PERIPHERAL(GPIOC_ODR,  10),         //  D26&#60;br /&#62;
    BB_PERIPHERAL(GPIOB_ODR,  0),          //  D27&#60;br /&#62;
    BB_PERIPHERAL(GPIOB_ODR,  1),          //  D28&#60;br /&#62;
    BB_PERIPHERAL(GPIOB_ODR,  10),         //  D29&#60;br /&#62;
    BB_PERIPHERAL(GPIOB_ODR,  11),         //  D30&#60;br /&#62;
    BB_PERIPHERAL(GPIOB_ODR,  12),         //  D31&#60;br /&#62;
    BB_PERIPHERAL(GPIOB_ODR,  13),         //  D32&#60;br /&#62;
    BB_PERIPHERAL(GPIOB_ODR,  14),         //  D33&#60;br /&#62;
    BB_PERIPHERAL(GPIOB_ODR,  15),         //  D34&#60;br /&#62;
    BB_PERIPHERAL(GPIOC_ODR,  6),          //  D35&#60;br /&#62;
    BB_PERIPHERAL(GPIOC_ODR,  7),          //  D36&#60;br /&#62;
    BB_PERIPHERAL(GPIOC_ODR,  8),          //  D37&#60;br /&#62;
    BB_PERIPHERAL(GPIOC_ODR,  9),          //  D38&#60;br /&#62;
    BB_PERIPHERAL(GPIOA_ODR,  13),         //  D39&#60;br /&#62;
    BB_PERIPHERAL(GPIOA_ODR,  14),         //  D40&#60;br /&#62;
    BB_PERIPHERAL(GPIOA_ODR,  15),         //  D41&#60;br /&#62;
    BB_PERIPHERAL(GPIOB_ODR,  3),          //  D42&#60;br /&#62;
    BB_PERIPHERAL(GPIOB_ODR,  4)           //  D43&#60;/p&#62;
&#60;p&#62;  };&#60;br /&#62;
  volatile uint32_t* const bb_port_IDR_bit_address[] = {&#60;br /&#62;
    BB_PERIPHERAL(GPIOA_IDR,  3),          //  D0&#60;br /&#62;
    BB_PERIPHERAL(GPIOA_IDR,  2),          //  D1&#60;br /&#62;
    BB_PERIPHERAL(GPIOA_IDR,  0),          //  D2&#60;br /&#62;
    BB_PERIPHERAL(GPIOA_IDR,  1),          //  D3&#60;br /&#62;
    BB_PERIPHERAL(GPIOB_IDR,  5),          //  D4&#60;br /&#62;
    BB_PERIPHERAL(GPIOB_IDR,  6),          //  D5&#60;br /&#62;
    BB_PERIPHERAL(GPIOA_IDR,  8),          //  D6&#60;br /&#62;
    BB_PERIPHERAL(GPIOA_IDR,  9),          //  D7&#60;br /&#62;
    BB_PERIPHERAL(GPIOA_IDR,  10),         //  D8&#60;br /&#62;
    BB_PERIPHERAL(GPIOB_IDR,  7),          //  D9&#60;br /&#62;
    BB_PERIPHERAL(GPIOA_IDR,  4),          //  D10&#60;br /&#62;
    BB_PERIPHERAL(GPIOA_IDR,  7),          //  D11&#60;br /&#62;
    BB_PERIPHERAL(GPIOA_IDR,  6),          //  D12&#60;br /&#62;
    BB_PERIPHERAL(GPIOA_IDR,  5),          //  D13&#60;br /&#62;
    BB_PERIPHERAL(GPIOB_IDR,  8),          //  D14&#60;br /&#62;
    BB_PERIPHERAL(GPIOC_IDR,  0),          //  D15&#60;br /&#62;
    BB_PERIPHERAL(GPIOC_IDR,  1),          //  D16&#60;br /&#62;
    BB_PERIPHERAL(GPIOC_IDR,  2),          //  D17&#60;br /&#62;
    BB_PERIPHERAL(GPIOC_IDR,  3),          //  D18&#60;br /&#62;
    BB_PERIPHERAL(GPIOC_IDR,  4),          //  D19&#60;br /&#62;
    BB_PERIPHERAL(GPIOC_IDR,  5),          //  D20&#60;br /&#62;
    BB_PERIPHERAL(GPIOC_IDR,  13),         //  D21&#60;br /&#62;
    BB_PERIPHERAL(GPIOC_IDR,  14),         //  D22&#60;br /&#62;
    BB_PERIPHERAL(GPIOC_IDR,  15),         //  D23&#60;br /&#62;
    BB_PERIPHERAL(GPIOB_IDR,  9),          //  D24&#60;br /&#62;
    BB_PERIPHERAL(GPIOD_IDR,  2), // D25 - changed by gbulmer 2014/6/16&#60;br /&#62;
    BB_PERIPHERAL(GPIOC_IDR,  10),         //  D26&#60;br /&#62;
    BB_PERIPHERAL(GPIOB_IDR,  0),          //  D27&#60;br /&#62;
    BB_PERIPHERAL(GPIOB_IDR,  1),          //  D28&#60;br /&#62;
    BB_PERIPHERAL(GPIOB_IDR,  10),         //  D29&#60;br /&#62;
    BB_PERIPHERAL(GPIOB_IDR,  11),         //  D30&#60;br /&#62;
    BB_PERIPHERAL(GPIOB_IDR,  12),         //  D31&#60;br /&#62;
    BB_PERIPHERAL(GPIOB_IDR,  13),         //  D32&#60;br /&#62;
    BB_PERIPHERAL(GPIOB_IDR,  14),         //  D33&#60;br /&#62;
    BB_PERIPHERAL(GPIOB_IDR,  15),         //  D34&#60;br /&#62;
    BB_PERIPHERAL(GPIOC_IDR,  6),          //  D35&#60;br /&#62;
    BB_PERIPHERAL(GPIOC_IDR,  7),          //  D36&#60;br /&#62;
    BB_PERIPHERAL(GPIOC_IDR,  8),          //  D37&#60;br /&#62;
    BB_PERIPHERAL(GPIOC_IDR,  9),          //  D38&#60;br /&#62;
    BB_PERIPHERAL(GPIOA_IDR,  13),         //  D39&#60;br /&#62;
    BB_PERIPHERAL(GPIOA_IDR,  14),         //  D40&#60;br /&#62;
    BB_PERIPHERAL(GPIOA_IDR,  15),         //  D41&#60;br /&#62;
    BB_PERIPHERAL(GPIOB_IDR,  3),          //  D42&#60;br /&#62;
    BB_PERIPHERAL(GPIOB_IDR,  4)           //  D43&#60;/p&#62;
&#60;p&#62;  };&#60;br /&#62;
#else&#60;br /&#62;
#error &#34;digitalWriteFaster only works on the Maple, Maple-Mini, Native, and Ret6.&#34;&#60;br /&#62;
#endif&#60;/p&#62;
&#60;p&#62;#define digitalWriteFaster(pin, value) (*bb_port_ODR_bit_address[pin] = value)&#60;/p&#62;
&#60;p&#62;#define digitalReadFaster(pin) (*bb_port_IDR_bit_address[pin])&#60;/p&#62;
&#60;p&#62;// Edit: &#60;em&#62;There may be some entries for Maple Native which are uninitialised&#60;br /&#62;
// They contain &#60;code&#62;BB_PERIPHERAL(-1, -1),&#60;/code&#62; instead of the correct value.&#60;br /&#62;
// Please check the appropriate Maple Native pin table.&#60;/em&#62; gbulmer
&#60;/p&#62;</description>
		</item>
		<item>
			<title>tlgosser on "Port Registers on Maple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=737&amp;page=2#post-25150</link>
			<pubDate>Wed, 24 Apr 2013 11:36:56 +0000</pubDate>
			<dc:creator>tlgosser</dc:creator>
			<guid isPermaLink="false">25150@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;digitalWriteFaster is here!&#60;/p&#62;
&#60;p&#62;I re-packaged this code into a permanent header file for our libraries &#34;digitalWriteFaster.h&#34;.&#60;/p&#62;
&#60;p&#62;I've been using this library for a couple of weeks and I have to say that this code you guys wrote is so much better than digitalWrite and digitalRead that I think it should just be part of the standard distribution.  &#60;/p&#62;
&#60;p&#62;Thanks again to member 'manitou' and moderator 'gbulmer'.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Port Registers on Maple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=737&amp;page=2#post-22939</link>
			<pubDate>Wed, 13 Mar 2013 18:35:12 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">22939@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;This looks a bit better on my Mac, but still not checked on Maple (sorry folks it's a bit long):&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;// base address of each GPIO peripheral port
#define GPIOA_BASE ((uint32_t) 0x40010800)
#define GPIOB_BASE ((uint32_t) 0x40010C00)
#define GPIOC_BASE ((uint32_t) 0x40011000)
#define GPIOD_BASE ((uint32_t) 0x40011400)
#define GPIOE_BASE ((uint32_t) 0x40011800)
#define GPIOF_BASE ((uint32_t) 0x40011C00)
#define GPIOG_BASE ((uint32_t) 0x40012000)

// GPIO Register byte offsets
#define ODR (0x0C)  // *BYTE* address offset of output register within port
#define IDR (0x08)  // *BYTE* address offset of input register within port

// Formula converts peripheral address to bit band peripheral address
// See ARMs Cortex™-M3 Technical Reference Manual fpr details
// Must all be calculatable at compile time
#define BB_PERIPHERAL(peripheral_address, bit) ((volatile uint32_t*)(0x42000000 \
        + ((((const uint32_t)(peripheral_address)) - 0x40000000)*32) \
            + ((const uint32_t)(bit)*4)))

// uses &#60;a href=&#34;http://leaflabs.com/docs/hardware/maple-mini.html#gpio-port-pin-map&#34; rel=&#34;nofollow&#34;&#62;http://leaflabs.com/docs/hardware/maple-mini.html#gpio-port-pin-map&#60;/a&#62;
// to map Maple mini pins back to STM32F103CB
// Each entry is the bit-band address of one GPIO output pin
volatile uint32_t* const bb_port_ODR_bit_address[] = {
BB_PERIPHERAL(GPIOB_BASE+ODR, 11),          // D0
BB_PERIPHERAL(GPIOB_BASE+ODR, 10),          // D1
BB_PERIPHERAL(GPIOB_BASE+ODR,  2),          // D2
BB_PERIPHERAL(GPIOB_BASE+ODR,  0),          // D3

BB_PERIPHERAL(GPIOA_BASE+ODR,  7),          // D4
BB_PERIPHERAL(GPIOA_BASE+ODR,  6),          // D5
BB_PERIPHERAL(GPIOA_BASE+ODR,  5),          // D6
BB_PERIPHERAL(GPIOA_BASE+ODR,  4),          // D7
BB_PERIPHERAL(GPIOA_BASE+ODR,  3),          // D8
BB_PERIPHERAL(GPIOA_BASE+ODR,  2),          // D9
BB_PERIPHERAL(GPIOA_BASE+ODR,  1),          // D10
BB_PERIPHERAL(GPIOA_BASE+ODR,  0),          // D11

BB_PERIPHERAL(GPIOC_BASE+ODR, 15),          // D12
BB_PERIPHERAL(GPIOC_BASE+ODR, 14),          // D13
BB_PERIPHERAL(GPIOC_BASE+ODR, 13),          // D14

// etc ...
};

// Each entry is the bit-band address of one GPIO input pin
volatile uint32_t* const bb_port_IDR_bit_address[] = {
BB_PERIPHERAL(GPIOB_BASE+IDR, 11),          // D0
BB_PERIPHERAL(GPIOB_BASE+IDR, 10),          // D1
BB_PERIPHERAL(GPIOB_BASE+IDR,  2),          // D2
BB_PERIPHERAL(GPIOB_BASE+IDR,  0),          // D3

BB_PERIPHERAL(GPIOA_BASE+IDR,  7),          // D4
BB_PERIPHERAL(GPIOA_BASE+IDR,  6),          // D5
BB_PERIPHERAL(GPIOA_BASE+IDR,  5),          // D6
BB_PERIPHERAL(GPIOA_BASE+IDR,  4),          // D7
BB_PERIPHERAL(GPIOA_BASE+IDR,  3),          // D8
BB_PERIPHERAL(GPIOA_BASE+IDR,  2),          // D9
BB_PERIPHERAL(GPIOA_BASE+IDR,  1),          // D10
BB_PERIPHERAL(GPIOA_BASE+IDR,  0),          // D11

BB_PERIPHERAL(GPIOC_BASE+IDR, 15),          // D12
BB_PERIPHERAL(GPIOC_BASE+IDR, 14),          // D13
BB_PERIPHERAL(GPIOC_BASE+IDR, 13),          // D14

// etc ...
};

#define fast_digitalWrite(pin, value) (*bb_port_ODR_bit_address[pin] = value)
#define fast_digitalRead(pin) (*bb_port_IDR_bit_address[pin])

void setup() {
    // Set up the built-in LED pin as an output:
    pinMode(13, OUTPUT);
    pinMode(9, INPUT);
}

void loop() {
    int val = fast_digitalRead(9);
    fast_digitalWrite(13, HIGH);
    delay(1000); // Wait for 1 second (1000 milliseconds)
    fast_digitalWrite(13, LOW);
    delay(1000); // Wait for 1 second (1000 milliseconds)
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;I tried using the &#60;code&#62;typedef struct gpio_reg_map&#60;/code&#62; declaration in gpio.h, but got a 'not constant' error when multiplying by 32, even though the pointer (e.g. &#60;code&#62;&#38;amp;GPIOB_BASE-&#38;gt;ODR&#60;/code&#62;) was cast to &#60;code&#62;uint32_t&#60;/code&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Port Registers on Maple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=737&amp;page=2#post-22935</link>
			<pubDate>Wed, 13 Mar 2013 13:23:52 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">22935@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;manitou - sorry about that. The only part that cares about the value being a &#60;code&#62;(volatile uint32_t*)&#60;/code&#62; is &#60;code&#62;BB_PERIPHERAL&#60;/code&#62;&#60;br /&#62;
Everything else could be simple integers, i.e. &#60;code&#62;uint32_t&#60;/code&#62;, and don't need to be pointers. I'll try to fix that, and repost.&#60;/p&#62;
&#60;p&#62;AFAICT &#60;code&#62;pulseIn&#60;/code&#62; will lose accuracy when other interrupts happen; the value of &#60;code&#62;width&#60;/code&#62; will be too small.&#60;/p&#62;
&#60;p&#62;A more robust approach would be to use the value of micros() which uses the hardware systick timer, which won't drift with interrupts.&#60;/p&#62;
&#60;p&#62;The code in wirish_time.h shows how micros works. Or you could get at the systick timer in your code (though it'll look similar to micros). AFAIK the systick timer is counting at 72MHz (which is likely more precision than is needed).&#60;/p&#62;
&#60;p&#62;NB: There was a bug in the Maple IDE wirish_time.h micros(); it should read:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;// corrected:
    do {
        ms = millis();
        cycle_cnt = systick_get_count();
    } while (ms != millis());&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;and not&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;// bug:
    do {
        cycle_cnt = systick_get_count();
        ms = millis();
    } while (ms != millis());&#60;/code&#62;&#60;/pre&#62;</description>
		</item>

	</channel>
</rss>
