/*
Blink - substitution for digitalWrite using BSRR and array table.
Works for all io pins on the Leaf Maple. Approx 3x faster than digitalWrite.
You must manually specify GPIOA,GPIOB,or GPIOC (listed as 0,1,or 2 in last column for convenience).
*/
#include <gpio.h>
const int digtalWriteFast[44][3] = {
{0b00000000000010000000000000000000,0b0000000000001000,0},
{0b00000000000001000000000000000000,0b0000000000000100,0},
{0b00000000000000010000000000000000,0b0000000000000001,0},
{0b00000000000000100000000000000000,0b0000000000000010,0},
{0b00000000001000000000000000000000,0b0000000000100000,1},
{0b00000000010000000000000000000000,0b0000000001000000,1},
{0b00000001000000000000000000000000,0b0000000100000000,0},
{0b00000010000000000000000000000000,0b0000001000000000,0},
{0b00000100000000000000000000000000,0b0000010000000000,0},
{0b00000000100000000000000000000000,0b0000000010000000,1},
{0b00000000000100000000000000000000,0b0000000000010000,0},
{0b00000000100000000000000000000000,0b0000000010000000,0},
{0b00000000010000000000000000000000,0b0000000001000000,0},
{0b00000000001000000000000000000000,0b0000000000100000,0},
{0b00000001000000000000000000000000,0b0000000100000000,1},
{0b00000000000000010000000000000000,0b0000000000000001,2},
{0b00000000000000100000000000000000,0b0000000000000010,2},
{0b00000000000001000000000000000000,0b0000000000000100,2},
{0b00000000000010000000000000000000,0b0000000000001000,2},
{0b00000000000100000000000000000000,0b0000000000010000,2},
{0b00000000001000000000000000000000,0b0000000000100000,2},
{0b00100000000000000000000000000000,0b0010000000000000,2},
{0b01000000000000000000000000000000,0b0100000000000000,2},
{0b10000000000000000000000000000000,0b1000000000000000,2},
{-1,-1,-1},
{-1,-1,-1},
{0b00000100000000000000000000000000,0b0000010000000000,2},
{0b00000000000000010000000000000000,0b0000000000000001,1},
{0b00000000000000100000000000000000,0b0000000000000010,1},
{0b00000100000000000000000000000000,0b0000010000000000,1},
{0b00001000000000000000000000000000,0b0000100000000000,1},
{0b00010000000000000000000000000000,0b0001000000000000,1},
{0b00100000000000000000000000000000,0b0010000000000000,1},
{0b01000000000000000000000000000000,0b0100000000000000,1},
{0b10000000000000000000000000000000,0b1000000000000000,1},
{0b00000000010000000000000000000000,0b0000000001000000,2},
{0b00000000100000000000000000000000,0b0000000010000000,2},
{0b00000001000000000000000000000000,0b0000000100000000,2},
{0b00000010000000000000000000000000,0b0000001000000000,2},
{-1,-1,-1},
{0b01000000000000000000000000000000,0b0100000000000000,0},
{0b10000000000000000000000000000000,0b1000000000000000,0},
{0b00000000000010000000000000000000,0b0000000000001000,1},
{0b00000000000100000000000000000000,0b0000000000010000,1}
};
void setup() {
// Set up the built-in LED pin as an output:
pinMode(13, OUTPUT);
}
void loop() {
(GPIOA_BASE)->BSRR = digtalWriteFast[13][1]; // sets pin 13, and ignores the other bits in the port
delay(1000); // Wait for 1 second (1000 milliseconds)
(GPIOA_BASE)->BSRR = digtalWriteFast[13][0]; // clears pin 13, and ignores the other bits in the port
delay(1000); // Wait for 1 second (1000 milliseconds)
}