Created
January 9, 2014 21:36
-
-
Save technobly/8342518 to your computer and use it in GitHub Desktop.
Intro to Inline Assembly on the Spark Core #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//-------------------------------------------------- | |
// Intro to Inline Assembly on the Spark Core (WIP) | |
//================================================== | |
// Copy this into a new application at: | |
// https://www.spark.io/build and go nuts! | |
//-------------------------------------------------- | |
// Technobly / BDub - Jan 2014 | |
//================================================== | |
uint16_t pin = D0; | |
void setup() { | |
pinMode(pin,OUTPUT); | |
} | |
void loop() { | |
// Bit-Bang Digital Output D7 at 18MHz = System Clock 72MHz / 4 | |
// HIGH time = 27.7ns | |
// LOW time = 27.7ns | |
PIN_MAP[pin].gpio_peripheral->BSRR = PIN_MAP[pin].gpio_pin; // HIGH | |
asm volatile( | |
"nop" "\n\t" | |
"nop" "\n\t" | |
"nop" "\n\t" | |
); | |
PIN_MAP[pin].gpio_peripheral->BRR = PIN_MAP[pin].gpio_pin; // LOW | |
asm volatile( | |
"nop" "\n\t" | |
"nop" "\n\t" | |
"nop" "\n\t" | |
); | |
PIN_MAP[pin].gpio_peripheral->BSRR = PIN_MAP[pin].gpio_pin; // HIGH | |
asm volatile( | |
"nop" "\n\t" | |
"nop" "\n\t" | |
); | |
PIN_MAP[pin].gpio_peripheral->BRR = PIN_MAP[pin].gpio_pin; // LOW | |
asm volatile( | |
"nop" "\n\t" | |
"nop" "\n\t" | |
); | |
PIN_MAP[pin].gpio_peripheral->BSRR = PIN_MAP[pin].gpio_pin; // HIGH | |
asm volatile("nop\n\t"); | |
PIN_MAP[pin].gpio_peripheral->BRR = PIN_MAP[pin].gpio_pin; // LOW | |
asm volatile("nop\n\t"); | |
PIN_MAP[pin].gpio_peripheral->BSRR = PIN_MAP[pin].gpio_pin; // HIGH | |
asm volatile("nop\n\t"); | |
PIN_MAP[pin].gpio_peripheral->BRR = PIN_MAP[pin].gpio_pin; // LOW | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment