Last active
January 23, 2020 12:04
-
-
Save denizzzka/1e31d3cf275403ae50768eca613fb1c6 to your computer and use it in GitHub Desktop.
Bare metal Dlang ARM
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
| // https://github.com/ldc-developers/ldc/issues/3290 | |
| import ldc.attributes; | |
| @llvmAttr("nounwind"): | |
| import ldc.llvmasm; | |
| #include <libopencm3/stm32/rcc.h> | |
| #include <libopencm3/stm32/gpio.h> | |
| static void gpio_setup() | |
| { | |
| rcc_periph_clock_enable(RCC_GPIOB); | |
| gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO1); | |
| } | |
| import ldc.attributes; | |
| extern(C) void main() | |
| { | |
| int i; | |
| gpio_setup(); | |
| while (1) { | |
| gpio_toggle(GPIOB, GPIO1); /* LED on/off */ | |
| for (i = 0; i < 800000; i++) /* Wait a bit. */ | |
| __asm("nop", ""); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to build:
Build libopencm3
Build dpp
Save previous snippet as
test.dppThen: