From 75c0f46433f3e7f730b3d8bf991647080ebacd7d Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Wed, 7 Mar 2018 15:55:54 -0800 Subject: [PATCH] blue-pill: more draugr cleanups --- blue-pill/blinky/Makefile | 4 ++-- blue-pill/draugr/Makefile | 2 +- blue-pill/draugr/blink.cc | 22 ++++++++++++---------- blue-pill/draugr/startup.s | 3 ++- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/blue-pill/blinky/Makefile b/blue-pill/blinky/Makefile index d7a7cc6..dd1ce1d 100644 --- a/blue-pill/blinky/Makefile +++ b/blue-pill/blinky/Makefile @@ -31,12 +31,12 @@ all: $(BIN) $(ELF): $(OBJS) $(ARMCC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS) - $(ARMSIZE) -A $@ + $(ARMSIZE) $@ .PHONY: strip strip: $(ELF) $(ARMTC)-strip $(ELF) - $(ARMSIZE) -A $(ELF) + $(ARMSIZE) $(ELF) $(BIN): $(ELF) $(OBJCOPY) -O binary $< $@ diff --git a/blue-pill/draugr/Makefile b/blue-pill/draugr/Makefile index 15f29b6..34fefa9 100644 --- a/blue-pill/draugr/Makefile +++ b/blue-pill/draugr/Makefile @@ -33,7 +33,7 @@ all: $(BIN) $(ELF): $(OBJS) $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS) - $(ARMSIZE) -A $@ + $(ARMSIZE) $@ $(BIN): $(ELF) $(OBJCOPY) -O binary $< $@ diff --git a/blue-pill/draugr/blink.cc b/blue-pill/draugr/blink.cc index 952e9a0..7de7ceb 100644 --- a/blue-pill/draugr/blink.cc +++ b/blue-pill/draugr/blink.cc @@ -1,22 +1,24 @@ #include "bluepill.h" -#define LED_PIN 13 +constexpr uint32_t LED = 13; +constexpr unsigned long SDELAY = 100000; +constexpr unsigned long LDELAY = (SDELAY * 10) - (3 * SDELAY); // void __attribute__ ((weak, naked)) reset_handler(void) { int main() { GPIO_C->enable_clock(); - GPIO_C->pin_mode(LED_PIN, true, OUTPUT_GPP, OUTPUT_MAX_2MHZ); + GPIO_C->pin_mode(LED, true, OUTPUT_GPP, OUTPUT_MAX_2MHZ); while(1) { - GPIO_C->pin_clear(LED_PIN); - delay(1000000); - GPIO_C->pin_set(LED_PIN); - delay(100000); - GPIO_C->pin_clear(LED_PIN); - delay(100000); - GPIO_C->pin_set(LED_PIN); - delay(100000); + GPIO_C->pin_clear(LED); + delay(LDELAY); + GPIO_C->pin_set(LED); + delay(SDELAY); + GPIO_C->pin_clear(LED); + delay(SDELAY); + GPIO_C->pin_set(LED); + delay(SDELAY); } } diff --git a/blue-pill/draugr/startup.s b/blue-pill/draugr/startup.s index ac22465..fca5a0b 100644 --- a/blue-pill/draugr/startup.s +++ b/blue-pill/draugr/startup.s @@ -6,6 +6,7 @@ */ .globl vectors +vectors: .align 2 .long 0x100 /* best guess at stack pointer */ .long reset_handler /* reset handler */ @@ -20,7 +21,7 @@ .skip 4 /* reserved */ .long 0 /* pendsv handler */ .long 0 /* systick handler */ -.skip 0x110 /* remaining / IRQ vectors */ +.skip 0xf4 /* remaining / IRQ vectors */ .globl reset_handler reset_handler: