[mv] blink source into example/blink
authorFabien Le Mentec <texane@gmail.com>
Sun, 16 Oct 2011 06:28:57 +0000 (01:28 -0500)
committerFabien Le Mentec <texane@gmail.com>
Sun, 16 Oct 2011 06:28:57 +0000 (01:28 -0500)
12 files changed:
doc/tutorial/tutorial.pdf
doc/tutorial/tutorial.tex
example/Makefile [deleted file]
example/blink/Makefile [new file with mode: 0644]
example/blink/default_bootloader.bin [new file with mode: 0755]
example/blink/disasm.sh [new file with mode: 0755]
example/blink/main.c [new file with mode: 0644]
example/blink/o.bin [new file with mode: 0755]
example/default_bootloader.bin [deleted file]
example/disasm.sh [deleted file]
example/main.c [deleted file]
example/o.bin [deleted file]

index bcc9065f0b1a9f8371cf98442e4dae353b3f0c31..622e60f966b993df3fadce47a4aa98c758c480e3 100644 (file)
Binary files a/doc/tutorial/tutorial.pdf and b/doc/tutorial/tutorial.pdf differ
index 21bd13a570abf0553a919a42366df03d86a5c50f..53a220dec3d612ce7d1e73505afbb43fe46835b6 100644 (file)
@@ -88,7 +88,7 @@ $> make ;
 A simple LED blinking example is provided in the example directory. It is built using:\\
 \begin{small}
 \begin{lstlisting}[frame=tb]
-cd stlink.git/example ;
+cd stlink.git/example/blink ;
 PATH=$TOOLCHAIN_PATH/bin:$PATH make ;
 \end{lstlisting}
 \end{small}
diff --git a/example/Makefile b/example/Makefile
deleted file mode 100644 (file)
index 1b310b1..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-EXECUTABLE=blink.elf
-BIN_IMAGE=blink.bin
-
-CC=arm-none-eabi-gcc
-OBJCOPY=arm-none-eabi-objcopy
-
-CFLAGS=-O2 -mlittle-endian -mthumb
-CFLAGS+=-mcpu=cortex-m3 -ffreestanding -nostdlib -nostdinc
-
-# to run from SRAM
-CFLAGS+=-Wl,-Ttext,0x20000000 -Wl,-e,0x20000000
-
-# to write to flash then run
-# CFLAGS+=-Wl,-Ttext,0x08000000 -Wl,-e,0x08000000
-
-all: $(BIN_IMAGE)
-
-$(BIN_IMAGE): $(EXECUTABLE)
-       $(OBJCOPY) -O binary $^ $@
-
-$(EXECUTABLE): main.c
-       $(CC) $(CFLAGS) $^ -o $@
-
-clean:
-       rm -rf $(EXECUTABLE)
-       rm -rf $(BIN_IMAGE)
-
-.PHONY: all clean
diff --git a/example/blink/Makefile b/example/blink/Makefile
new file mode 100644 (file)
index 0000000..1b310b1
--- /dev/null
@@ -0,0 +1,28 @@
+EXECUTABLE=blink.elf
+BIN_IMAGE=blink.bin
+
+CC=arm-none-eabi-gcc
+OBJCOPY=arm-none-eabi-objcopy
+
+CFLAGS=-O2 -mlittle-endian -mthumb
+CFLAGS+=-mcpu=cortex-m3 -ffreestanding -nostdlib -nostdinc
+
+# to run from SRAM
+CFLAGS+=-Wl,-Ttext,0x20000000 -Wl,-e,0x20000000
+
+# to write to flash then run
+# CFLAGS+=-Wl,-Ttext,0x08000000 -Wl,-e,0x08000000
+
+all: $(BIN_IMAGE)
+
+$(BIN_IMAGE): $(EXECUTABLE)
+       $(OBJCOPY) -O binary $^ $@
+
+$(EXECUTABLE): main.c
+       $(CC) $(CFLAGS) $^ -o $@
+
+clean:
+       rm -rf $(EXECUTABLE)
+       rm -rf $(BIN_IMAGE)
+
+.PHONY: all clean
diff --git a/example/blink/default_bootloader.bin b/example/blink/default_bootloader.bin
new file mode 100755 (executable)
index 0000000..0e31371
Binary files /dev/null and b/example/blink/default_bootloader.bin differ
diff --git a/example/blink/disasm.sh b/example/blink/disasm.sh
new file mode 100755 (executable)
index 0000000..b3b46da
--- /dev/null
@@ -0,0 +1,3 @@
+#!/usr/bin/env sh
+#/home/texane/sat/bin/arm-none-eabi-objdump -marm -Mforce-thumb -EL -b binary -D /tmp/barfoo
+/home/texane/sat/bin/arm-none-eabi-objdump -marm -EL -b binary -D /tmp/barfoo
diff --git a/example/blink/main.c b/example/blink/main.c
new file mode 100644 (file)
index 0000000..91c7040
--- /dev/null
@@ -0,0 +1,88 @@
+/* missing type */
+
+typedef unsigned int uint32_t;
+
+
+/* boot mode configuration */
+
+#define CONFIG_BOOT_SRAM 1
+#define CONFIG_BOOT_FLASH 0
+
+
+/* hardware configuration */
+
+#define CONFIG_STM32L_DISCOVERY 1
+#define CONFIG_STM32VL_DISCOVERY 0
+
+
+#if CONFIG_STM32VL_DISCOVERY
+
+# define GPIOC 0x40011000 /* port C */
+# define GPIOC_CRH (GPIOC + 0x04) /* port configuration register high */
+# define GPIOC_ODR (GPIOC + 0x0c) /* port output data register */
+
+# define LED_BLUE (1 << 8) /* port C, pin 8 */
+# define LED_GREEN (1 << 9) /* port C, pin 9 */
+
+static inline void setup_leds(void)
+{
+  *(volatile uint32_t*)GPIOC_CRH = 0x44444411;
+}
+
+static inline void switch_leds_on(void)
+{
+  *(volatile uint32_t*)GPIOC_ODR = LED_BLUE | LED_GREEN;
+}
+
+static inline void switch_leds_off(void)
+{
+  *(volatile uint32_t*)GPIOC_ODR = 0;
+}
+
+#elif CONFIG_STM32L_DISCOVERY
+
+# define GPIOB 0x40020400 /* port B */
+# define GPIOB_MODER (GPIOB + 0x00) /* port mode register */
+# define GPIOB_ODR (GPIOB + 0x14) /* port output data register */
+
+# define LED_BLUE (1 << 6) /* port B, pin 6 */
+# define LED_GREEN (1 << 7) /* port B, pin 7 */
+
+static inline void setup_leds(void)
+{
+  /* configure port 6 and 7 as output */
+  *(volatile uint32_t*)GPIOB_MODER |= (1 << (7 * 2)) | (1 << (6 * 2));
+}
+
+static inline void switch_leds_on(void)
+{
+  *(volatile uint32_t*)GPIOB_ODR = LED_BLUE | LED_GREEN;
+}
+
+static inline void switch_leds_off(void)
+{
+  *(volatile uint32_t*)GPIOB_ODR = 0;
+}
+
+#endif /* otherwise, error */
+
+
+#define delay()                                                \
+do {                                                   \
+  register unsigned int i;                             \
+  for (i = 0; i < 1000000; ++i)                                \
+    __asm__ __volatile__ ("nop\n\t":::"memory");       \
+} while (0)
+
+static void __attribute__((naked)) __attribute__((used)) main(void)
+{
+  setup_leds();
+
+  while (1)
+  {
+    switch_leds_on();
+    delay();
+    switch_leds_off();
+    delay();
+  }
+}
diff --git a/example/blink/o.bin b/example/blink/o.bin
new file mode 100755 (executable)
index 0000000..76324f7
Binary files /dev/null and b/example/blink/o.bin differ
diff --git a/example/default_bootloader.bin b/example/default_bootloader.bin
deleted file mode 100755 (executable)
index 0e31371..0000000
Binary files a/example/default_bootloader.bin and /dev/null differ
diff --git a/example/disasm.sh b/example/disasm.sh
deleted file mode 100755 (executable)
index b3b46da..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/env sh
-#/home/texane/sat/bin/arm-none-eabi-objdump -marm -Mforce-thumb -EL -b binary -D /tmp/barfoo
-/home/texane/sat/bin/arm-none-eabi-objdump -marm -EL -b binary -D /tmp/barfoo
diff --git a/example/main.c b/example/main.c
deleted file mode 100644 (file)
index 929e3b9..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/* missing type */
-
-typedef unsigned int uint32_t;
-
-
-/* hardware configuration */
-
-#define CONFIG_STM32L_DISCOVERY 1
-#define CONFIG_STM32VL_DISCOVERY 0
-
-
-#if CONFIG_STM32VL_DISCOVERY
-
-# define GPIOC 0x40011000 /* port C */
-# define GPIOC_CRH (GPIOC + 0x04) /* port configuration register high */
-# define GPIOC_ODR (GPIOC + 0x0c) /* port output data register */
-
-# define LED_BLUE (1 << 8) /* port C, pin 8 */
-# define LED_GREEN (1 << 9) /* port C, pin 9 */
-
-static inline void setup_leds(void)
-{
-  *(volatile uint32_t*)GPIOC_CRH = 0x44444411;
-}
-
-static inline void switch_leds_on(void)
-{
-  *(volatile uint32_t*)GPIOC_ODR = LED_BLUE | LED_GREEN;
-}
-
-static inline void switch_leds_off(void)
-{
-  *(volatile uint32_t*)GPIOC_ODR = 0;
-}
-
-#elif CONFIG_STM32L_DISCOVERY
-
-# define GPIOB 0x40020400 /* port B */
-# define GPIOB_MODER (GPIOB + 0x00) /* port mode register */
-# define GPIOB_ODR (GPIOB + 0x14) /* port output data register */
-
-# define LED_BLUE (1 << 6) /* port B, pin 6 */
-# define LED_GREEN (1 << 7) /* port B, pin 7 */
-
-static inline void setup_leds(void)
-{
-  /* configure port 6 and 7 as output */
-  *(volatile uint32_t*)GPIOB_MODER |= (1 << (7 * 2)) | (1 << (6 * 2));
-}
-
-static inline void switch_leds_on(void)
-{
-  *(volatile uint32_t*)GPIOB_ODR = LED_BLUE | LED_GREEN;
-}
-
-static inline void switch_leds_off(void)
-{
-  *(volatile uint32_t*)GPIOB_ODR = 0;
-}
-
-#endif /* otherwise, error */
-
-
-#define delay()                                                \
-do {                                                   \
-  register unsigned int i;                             \
-  for (i = 0; i < 1000000; ++i)                                \
-    __asm__ __volatile__ ("nop\n\t":::"memory");       \
-} while (0)
-
-static void __attribute__((naked)) __attribute__((used)) main(void)
-{
-  setup_leds();
-
-  while (1)
-  {
-    switch_leds_on();
-    delay();
-    switch_leds_off();
-    delay();
-  }
-}
diff --git a/example/o.bin b/example/o.bin
deleted file mode 100755 (executable)
index 76324f7..0000000
Binary files a/example/o.bin and /dev/null differ