LD=$(ARCH)-ld
OBJCOPY=$(ARCH)-objcopy
-CFLAGS=-mcpu=cortex-m4 -nostdinc -I $(STELLARISWARE)/inc
+CFLAGS=-ggdb -std=gnu99 -mcpu=cortex-m4 -nostdinc -I $(STELLARISWARE)/inc
LDFLAGS=-Tstellaris.t
STELLARISWARE=/home/mmullins/projects/stellaris/StellarisWare
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $^
-led_blink: isr_table.o
+led_blink: isr_table.o led_blink.o
$(LD) $(LDFLAGS) -o $@ $^
led_blink.bin: led_blink
+#include "led_blink.h"
+
static void infinite_loop_isr();
__attribute__((section(".reset")))
void (*reset_vectors[])() = {
(void(*)()) 0x20007000,
- infinite_loop_isr,
+ main_isr,
infinite_loop_isr,
infinite_loop_isr,
infinite_loop_isr,
--- /dev/null
+#include "led_blink.h"
+#include <lm4f120h5qr.h>
+
+__attribute__((isr))
+void main_isr() {
+ // Enable Port F
+ SYSCTL_RCGCGPIO_R = 0x20;
+
+ // Wait for a few clocks to let GPIO module stabilize
+ for (int i = 0; i < 10; ++i) {
+ }
+
+ // RGB pins (PF1, 2, 3) as outputs
+ GPIO_PORTF_DIR_R = 0xE;
+
+ // deliver 2mA of current
+ GPIO_PORTF_DR2R_R = 0xE;
+
+ // set to digital mode
+ GPIO_PORTF_DEN_R = 0xE;
+
+ // Set RGB pins to 1
+ *(GPIO_PORTF_DATA_BITS_R + 0xE) = 0x2;
+
+ // infinite loop
+ for (;;) {
+ *(GPIO_PORTF_DATA_BITS_R + 0xC) ^= 0xC;
+
+ for (int j = 0; j < 1000000; ++j) {
+ }
+ }
+}