From ad2c72fa7f4f373716016dd0777f44b85c365209 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Fri, 17 Dec 2010 23:01:31 -0300 Subject: [PATCH] atusb: firmware update for the 2010-12-16 board series - fw/Makefile: replaced "make" with $(MAKE) (just for style) - common/Makefile.common: Makefile settings shared within project. For now, this contains only the board version, which defaults to 2010-12-16. - fw/common/Makefile, fw/boot/Makefile, fw/atusb/Makefile: include common/Makefile.common - fw/common/Makefile, fw/boot/Makefile, fw/atusb/Makefile: pass board version to cpp and gcc - fw/atusb/atusb.c (init_io): individually set IRQ_RF to one, LED and TST to zero - fw/atusb/atusb.c (init_io): added macros to set all unused pins to zero in a way that doesn't need updating if a signal moves from one pin to another - include/atusb/ep0.h: added hardware type 1 (2010-12-16 design) - common/config.h: set hardware type depending on board version - common/io.h: assign pins depending on board version --- atusb/fw/Makefile | 8 +++---- atusb/fw/atusb/Makefile | 3 ++- atusb/fw/atusb/atusb.c | 38 +++++++++++++++++++++++++++++++-- atusb/fw/boot/Makefile | 3 ++- atusb/fw/common/Makefile | 4 +++- atusb/fw/common/Makefile.common | 14 ++++++++++++ atusb/fw/common/config.h | 6 ++++++ atusb/fw/common/io.h | 31 +++++++++++++++++++++++++++ atusb/fw/include/atusb/ep0.h | 3 ++- 9 files changed, 100 insertions(+), 10 deletions(-) create mode 100644 atusb/fw/common/Makefile.common diff --git a/atusb/fw/Makefile b/atusb/fw/Makefile index 7bd445a..50c53f0 100644 --- a/atusb/fw/Makefile +++ b/atusb/fw/Makefile @@ -17,10 +17,10 @@ DIRS=common boot atusb .PHONY: all depend install uninstall clean spotless all: - for d in $(DIRS); do make -C $$d all || exit 1; done + for d in $(DIRS); do $(MAKE) -C $$d all || exit 1; done depend: - for d in $(DIRS); do make -C $$d depend || exit 1; done + for d in $(DIRS); do $(MAKE) -C $$d depend || exit 1; done # Top-level Makefile recurses for "install" and "uninstall", which have no use # here. Just ignore them. @@ -30,7 +30,7 @@ install: uninstall: clean: - for d in $(DIRS); do make -C $$d clean || exit 1; done + for d in $(DIRS); do $(MAKE) -C $$d clean || exit 1; done spotless: - for d in $(DIRS); do make -C $$d spotless || exit 1; done + for d in $(DIRS); do $(MAKE) -C $$d spotless || exit 1; done diff --git a/atusb/fw/atusb/Makefile b/atusb/fw/atusb/Makefile index 975051b..595ab52 100644 --- a/atusb/fw/atusb/Makefile +++ b/atusb/fw/atusb/Makefile @@ -18,8 +18,9 @@ F32XBASE = ../../../../f32xbase include $(F32XBASE)/fw/common/Makefile.system include $(F32XBASE)/fw/common/Makefile.common +include ../common/Makefile.common -CFLAGS += -I../common -I../include +CFLAGS += -I../common -I../include -D$(BOARD) LDFLAGS += --code-size $(PAYLOAD_SIZE) --code-loc $(PAYLOAD_START) USB_ID = $(shell \ diff --git a/atusb/fw/atusb/atusb.c b/atusb/fw/atusb/atusb.c index 1a6496c..21e2b01 100644 --- a/atusb/fw/atusb/atusb.c +++ b/atusb/fw/atusb/atusb.c @@ -59,6 +59,35 @@ void test_mode(void) } +/* + * The following macros set all unused pins on a given port to zero. This is + * more elaborate than just setting the ports directly, but it has the + * advantage of hiding the pin to port relation. + */ + +#define PORT_NUM_P0 0 +#define PORT_NUM_P2 2 +#define PORT_NUM_P3 3 + +#define __PORT_NUM(mode) PORT_NUM_##mode +#define PORT_NUM(mode) __PORT_NUM(mode) + +#define USED(port, net) (PORT_NUM(net##_PORT) == port ? 1 << net##_BIT : 0) + +#define ZERO_UNUSED(port) \ + P##port &= \ + USED(port, LED) | \ + USED(port, ID) | \ + USED(port, MOSI) | \ + USED(port, MISO) | \ + USED(port, SCLK) | \ + USED(port, nSS) | \ + USED(port, nRST_RF) | \ + USED(port, IRQ_RF) | \ + USED(port, SLP_TR) | \ + USED(port, TST) + + static void init_io(void) { /* @@ -91,8 +120,13 @@ static void init_io(void) SLP_TR = 0; SLP_TR_MODE |= 1 << SLP_TR_BIT; - P0 = 1; /* IRQ_RF = 1; LED = 0; TST = Z; the rest is unused */ - P3 = 0; + IRQ_RF = 1; + LED = 0; + TST = 0; + + ZERO_UNUSED(0); + ZERO_UNUSED(2); + ZERO_UNUSED(3); #if 0 /* diff --git a/atusb/fw/boot/Makefile b/atusb/fw/boot/Makefile index 1baf3c2..3872afb 100644 --- a/atusb/fw/boot/Makefile +++ b/atusb/fw/boot/Makefile @@ -17,6 +17,7 @@ F32XBASE = ../../../../f32xbase include $(F32XBASE)/fw/common/Makefile.system include $(F32XBASE)/fw/common/Makefile.common +include ../common/Makefile.common -CFLAGS += -I../common -I../include +CFLAGS += -I../common -I../include -D$(BOARD) LDFLAGS += --code-size $(PAYLOAD_START) diff --git a/atusb/fw/common/Makefile b/atusb/fw/common/Makefile index 85cf3ac..dec1b7d 100644 --- a/atusb/fw/common/Makefile +++ b/atusb/fw/common/Makefile @@ -10,6 +10,8 @@ # (at your option) any later version. # +include Makefile.common + GEN_quiet = @echo " GENERATE " $@ && @@ -25,7 +27,7 @@ endif all: io-parts.h io-parts.h: io.h Makefile - $(GEN) $(CPP) -dD $< | \ + $(GEN) $(CPP) -D$(BOARD) -dD $< | \ sed '1,/IO_H/d' | \ awk \ 'BEGIN { print "/* MACHINE-GENERATED. DO NOT EDIT ! */"; \ diff --git a/atusb/fw/common/Makefile.common b/atusb/fw/common/Makefile.common new file mode 100644 index 0000000..1952214 --- /dev/null +++ b/atusb/fw/common/Makefile.common @@ -0,0 +1,14 @@ +# +# common/Makefile.common - Makefile settings shared within project +# +# Written 2010 by Werner Almesberger +# Copyright 2010 Werner Almesberger +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# + +#BOARD=BOARD_100813 +BOARD=BOARD_101216 diff --git a/atusb/fw/common/config.h b/atusb/fw/common/config.h index 19ed150..1db0de1 100644 --- a/atusb/fw/common/config.h +++ b/atusb/fw/common/config.h @@ -39,6 +39,12 @@ /* ----- Application configuration ----------------------------------------- */ +#if defined(BOARD_1008xx) #define HW_TYPE HW_TYPE_100813 +#elif defined(BOARD_1012xx) +#define HW_TYPE HW_TYPE_101216 +#else +#error must define BOARD_1008xx or BOARD_1012xx +#endif #endif /* !CONFIG_H */ diff --git a/atusb/fw/common/io.h b/atusb/fw/common/io.h index eac4355..2832c3f 100644 --- a/atusb/fw/common/io.h +++ b/atusb/fw/common/io.h @@ -18,6 +18,17 @@ #define LED P0_1 +/* ID pin */ + +/* + * 100813 open + * 101216 GND + */ + +#define ID P0_2 + +#if defined(BOARD_100813) + /* SPI */ #define MOSI P2_2 @@ -32,4 +43,24 @@ #define SLP_TR P2_1 #define TST P0_7 +#elif defined(BOARD_101216) + +/* SPI */ + +#define MOSI P2_1 +#define MISO P2_0 +#define SCLK P0_7 +#define nSS P2_4 + +/* Miscellaneous RF signals */ + +#define nRST_RF P0_6 +#define IRQ_RF P0_0 +#define SLP_TR P0_5 +#define TST P0_4 + +#else +#error must define BOARD_1008xx or BOARD1012xx +#endif /* !BOARD_101216 */ + #endif /* !IO_H */ diff --git a/atusb/fw/include/atusb/ep0.h b/atusb/fw/include/atusb/ep0.h index ef8d325..cb6acd1 100644 --- a/atusb/fw/include/atusb/ep0.h +++ b/atusb/fw/include/atusb/ep0.h @@ -43,7 +43,8 @@ #define EP0ATUSB_MAJOR 0 /* EP0 protocol, major revision */ #define EP0ATUSB_MINOR 1 /* EP0 protocol, minor revision */ -#define HW_TYPE_100813 0 /* 100813 */ +#define HW_TYPE_100813 0 /* 2010-08-13 */ +#define HW_TYPE_101216 1 /* 2010-12-16 */ /*