we blink the LED on the board with a new twist in the that
authorDarron Broad <darron@kewl.org>
Thu, 19 Mar 2015 16:41:38 +0000
changeset 4 7eb933f8df19
parent 3 abd53450bed2
child 5 3331ea365003
we blink the LED on the board with a new twist in the that
in the illuminated phase of the cycle we bit-bang it as
fast as possible to inspect on a frequency counter.
miniblink.c
mk/Makefile.rules
--- a/miniblink.c	Thu Mar 19 16:12:35 2015 +0000
+++ b/miniblink.c	Thu Mar 19 16:41:38 2015 +0000
@@ -32,17 +32,24 @@
 		      GPIO_CNF_OUTPUT_PUSHPULL, GPIO13);
 }
 
+#define PC13 (1 << 13)
+
 int main(void)
 {
-	int i;
-
 	gpio_setup();
 
 	/* Blink the LED (PC13) on the board. */
 	while (1) {
-		gpio_toggle(GPIOC, GPIO13);	/* LED on/off */
-		for (i = 0; i < 0x200000; i++)	/* Wait a bit. */
-			__asm__("nop");
+		uint16_t c = 0;
+
+		for (int i = 0; i < 0x800000; ++i) {
+			GPIOC_ODR = c;
+			c = PC13 - c;
+		}
+		for (int i = 0; i < 0x800000; ++i) {
+			GPIOC_ODR = PC13;
+			c = PC13 - c;
+		}
 	}
 
 	return 0;
--- a/mk/Makefile.rules	Thu Mar 19 16:12:35 2015 +0000
+++ b/mk/Makefile.rules	Thu Mar 19 16:41:38 2015 +0000
@@ -78,7 +78,7 @@
 ###############################################################################
 # C flags
 
-CFLAGS		+= -Os -g
+CFLAGS		+= -Os -g -std=gnu99
 CFLAGS		+= -Wextra -Wshadow -Wimplicit-function-declaration
 CFLAGS		+= -Wredundant-decls -Wmissing-prototypes -Wstrict-prototypes
 CFLAGS		+= -fno-common -ffunction-sections -fdata-sections