From 3bddb71d56d5d556a41779f04b4fefa135f319cd Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Sun, 29 Mar 2015 22:08:57 +0200 Subject: Blink LED. --- .gdbinit | 22 ++++++++++++++++++++++ .gitignore | 5 +++++ .gitmodules | 3 +++ SConstruct | 11 +++++++++++ laks | 1 + main.cpp | 22 ++++++++++++++++++++++ 6 files changed, 64 insertions(+) create mode 100644 .gdbinit create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 SConstruct create mode 160000 laks create mode 100644 main.cpp diff --git a/.gdbinit b/.gdbinit new file mode 100644 index 0000000..99eae86 --- /dev/null +++ b/.gdbinit @@ -0,0 +1,22 @@ +define flash +file demo.elf +load +end + +define restart +run +end + +define attach_swd +mon swdp_scan +attach 1 +end + +define attach_jtag +mon jtag_scan +attach 1 +end + +file demo.elf + +set mem inaccessible-by-default off diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b137a4a --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*.o +*.a +*.elf +*.swp +.sconsign.dblite diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..cd4f3c2 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "laks"] + path = laks + url = git://git.jvnv.net/laks.git diff --git a/SConstruct b/SConstruct new file mode 100644 index 0000000..aaeea43 --- /dev/null +++ b/SConstruct @@ -0,0 +1,11 @@ +import os + +env = Environment( + ENV = os.environ, +) + +SConscript('laks/build_rules') + +env.SelectMCU('stm32f051r8') + +env.Firmware('demo.elf', Glob('*.cpp')) diff --git a/laks b/laks new file mode 160000 index 0000000..16cc0f1 --- /dev/null +++ b/laks @@ -0,0 +1 @@ +Subproject commit 16cc0f1414c33772dd6daa6c19d2be9dcaca2e64 diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..57b1ed0 --- /dev/null +++ b/main.cpp @@ -0,0 +1,22 @@ +#include +#include +#include + +Pin led_green = GPIOC[8]; +Pin led_blue = GPIOC[9]; + +int main() { + // Initialize system timer. + STK.LOAD = 8000000 / 8 / 1000; // 1000 Hz. + STK.CTRL = 0x03; + + RCC.enable(RCC.GPIOC); + + led_green.set_mode(Pin::Output); + + while(1) { + Time::sleep(500); + + led_green.toggle(); + } +} -- cgit v1.2.3