From bbd9404fa54dc7ec5c783e65feea2f95bee54bf2 Mon Sep 17 00:00:00 2001
From: NIIBE Yutaka <gniibe@fsij.org>
Date: Thu, 6 Jun 2013 15:16:11 +0900
Subject: fix sys.c

---
 example-cdc/sys.c | 14 +++++++++-----
 example-cdc/sys.h |  2 +-
 2 files changed, 10 insertions(+), 6 deletions(-)

(limited to 'example-cdc')

diff --git a/example-cdc/sys.c b/example-cdc/sys.c
index 59d826b..8bb9ae0 100644
--- a/example-cdc/sys.c
+++ b/example-cdc/sys.c
@@ -540,11 +540,14 @@ nvic_system_reset (void)
 {
   SCB->AIRCR = (0x05FA0000 | (SCB->AIRCR & 0x70) | SYSRESETREQ);
   asm volatile ("dsb");
+  for (;;);
 }
 
 static void __attribute__ ((naked))
 reset (void)
 {
+  extern const unsigned long *FT0, *FT1, *FT2;
+
   asm volatile ("cpsid	i\n\t"		/* Mask all interrupts. */
 		"mov.w	r0, #0xed00\n\t" /* r0 = SCR */
 		"movt	r0, #0xe000\n\t"
@@ -559,13 +562,16 @@ reset (void)
 		"ldr	r0, [r1]\n\t"	/* Reset handler.                  */
 		"bx	r0\n"
 		: /* no output */ : /* no input */ : "memory");
+
+  /* Never reach here. */
+  /* Artificial entry to refer FT0, FT1, and FT2.  */
+  asm volatile (""
+		: : "r" (&FT0), "r" (&FT1), "r" (&FT2));
 }
 
 typedef void (*handler)(void);
 extern uint8_t __ram_end__;
 
-extern const unsigned long *FT0, *FT1, *FT2;
-
 handler vector[] __attribute__ ((section(".vectors"))) = {
   (handler)&__ram_end__,
   reset,
@@ -582,9 +588,7 @@ handler vector[] __attribute__ ((section(".vectors"))) = {
   nvic_system_reset,
   clock_init,
   gpio_init,
-  (handler)&FT0,
-  (handler)&FT1,
-  (handler)&FT2,
+  NULL,
 };
 
 const uint8_t sys_version[8] __attribute__((section(".sys.version"))) = {
diff --git a/example-cdc/sys.h b/example-cdc/sys.h
index ce0eb1d..25d33f1 100644
--- a/example-cdc/sys.h
+++ b/example-cdc/sys.h
@@ -1,7 +1,7 @@
 extern const uint8_t sys_version[8];
 
 typedef void (*handler)(void);
-extern handler vector[18];
+extern handler vector[16];
 
 static inline const uint8_t *
 unique_device_id (void)
-- 
cgit v1.2.3