From fcfaec399ae725ebc0fc9cb0449585fae70a1bf4 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Thu, 19 Aug 2010 00:34:19 -0300 Subject: [PATCH] Move platform-specific boot loader configuration into macros. - fw/boot/boot.c (boot_loader): moved GTA-specific pull-up disable and I2C_SDA_PULL enable into macro PLATFORM_SETUP - fw/boot/boot.c (run_payload): moved GTA-specific pull-up enable and I2C_SDA_PULL disable into macro PLATFORM_EXIT - fw/boot/boot.c (boot_loader): moved GTA-specific I2C_SDA probe into macro PLATFORM_TEST - fw/common/Makefile.common: removed all references to dependencies on .target. The caller is now responsible for these. - fw/boot/dfu.c: don't include idbg/usb-ids.h; USB_VENDOR and USB_PRODUCT are now passed via macros --- fw/boot/boot.c | 52 ++++++++++++++++++++++++++------------- fw/boot/dfu.c | 1 - fw/common/Makefile.common | 7 +----- 3 files changed, 36 insertions(+), 24 deletions(-) diff --git a/fw/boot/boot.c b/fw/boot/boot.c index f161b59..f4b090c 100644 --- a/fw/boot/boot.c +++ b/fw/boot/boot.c @@ -27,22 +27,44 @@ #include "dfu.h" +/* + * GTA example: + * + +#define PLATFORM_SETUP \ + GPIOCN |= WEAKPUD; \ + I2C_SDA_PULL = 0; \ + delay(); + +// Re-enable pull-ups +// Don't waste power in pull-down +#define PLATFORM_EXIT \ + GPIOCN &= ~WEAKPUD; \ + I2C_SDA_PULL = 1; + +#define PLATFORM_TEST \ + (!I2C_SDA || dfu.state != dfuIDLE) + */ + +#ifndef PLATFORM_SETUP +#define PLATFORM_SETUP +#endif + +#ifndef PLATFORM_EXIT +#define PLATFORM_EXIT +#endif + + void run_payload(void) { + PLAYFORM_EXIT; + /* No interrupts while jumping between worlds */ EA = 0; /* Restart USB */ USB0XCN = 0; - /* Re-enable pull-ups */ - GPIOCN &= ~WEAKPUD; - -#ifdef GTA - /* Don't waste power in pull-down */ - I2C_SDA_PULL = 1; -#endif - debug("launching payload\n"); __asm @@ -182,21 +204,17 @@ static void boot_loader(void) * the GTA01/02, once the system is powered up, IDBG exits this loop. */ - GPIOCN |= WEAKPUD; -#ifdef GTA - I2C_SDA_PULL = 0; -#endif - delay(); + BOOT_SETUP; dfu_init(); usb_init(); -#ifdef GTA +#ifdef PLATFORM_TEST - while (!I2C_SDA || dfu.state != dfuIDLE) + while (PLATFORM_TEST) usb_poll(); -#else /* GTA */ +#else /* PLATFORM_TEST */ #define MS_TO_LOOPS(ms) ((uint32_t) (ms)*190) @@ -211,7 +229,7 @@ static void boot_loader(void) loop = 0; } } -#endif /* !GTA */ +#endif /* !PLATFORM_TEST */ } diff --git a/fw/boot/dfu.c b/fw/boot/dfu.c index de9ef56..ad7ab9d 100644 --- a/fw/boot/dfu.c +++ b/fw/boot/dfu.c @@ -31,7 +31,6 @@ #include "uart.h" #include "usb.h" #include "dfu.h" -#include "idbg/usb-ids.h" #ifndef NULL diff --git a/fw/common/Makefile.common b/fw/common/Makefile.common index dbc38b0..3bf1164 100644 --- a/fw/common/Makefile.common +++ b/fw/common/Makefile.common @@ -13,8 +13,7 @@ CC=sdcc CFLAGS=--std-c99 -I. -I../common \ - -DPAYLOAD_START=$(PAYLOAD_START) -DPAYLOAD_SIZE=$(PAYLOAD_SIZE) \ - -D`cat ../.target` + -DPAYLOAD_START=$(PAYLOAD_START) -DPAYLOAD_SIZE=$(PAYLOAD_SIZE) LDFLAGS=--xram-size 1024 @@ -68,8 +67,6 @@ $(MAIN).ihx: $(OBJS:%=%.rel) .c.rel: $(CC) $(CFLAGS) -c $< -$(OBJS:%=%.rel): ../.target - # below, set dummy UART speed to make dependencies build without error depend .depend: @@ -81,8 +78,6 @@ depend .depend: { rm -f .depend; exit 1; }; \ done -.depend: ../.target - ifeq (.depend,$(wildcard .depend)) include .depend endif