diff --git a/atrf/fw/common/regs.h b/atrf/fw/common/regs.h new file mode 100644 index 0000000..3fb441c --- /dev/null +++ b/atrf/fw/common/regs.h @@ -0,0 +1 @@ +#include "regs-f326.h" diff --git a/cntr/fw/Makefile b/cntr/fw/Makefile new file mode 100644 index 0000000..ba64955 --- /dev/null +++ b/cntr/fw/Makefile @@ -0,0 +1,36 @@ +# +# fw/Makefile - CNTR firmware build +# +# Written 2008-2010 by Werner Almesberger +# Copyright 2008-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. +# + + +DIRS=common boot cntr + + +.PHONY: all depend install uninstall clean spotless + +all: + 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 + +# Top-level Makefile recurses for "install" and "uninstall", which have no use +# here. Just ignore them. + +install: + +uninstall: + +clean: + 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 diff --git a/cntr/fw/boot/Makefile b/cntr/fw/boot/Makefile new file mode 100644 index 0000000..c5225f7 --- /dev/null +++ b/cntr/fw/boot/Makefile @@ -0,0 +1,22 @@ +# +# boot/Makefile - Makefile for DFU-capable boot loader for CNTR +# +# Written 2008, 2010 by Werner Almesberger +# Copyright 2008, 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. +# + +MAIN=boot +OBJS=$(MAIN) usb dfu version + +F32XBASE = ../../../../f32xbase + +include $(F32XBASE)/fw/common/Makefile.system +include $(F32XBASE)/fw/common/Makefile.common + +CFLAGS += -I../common -I../include +LDFLAGS += --code-size $(PAYLOAD_START) diff --git a/cntr/fw/cntr/Makefile b/cntr/fw/cntr/Makefile new file mode 100644 index 0000000..1ad1b53 --- /dev/null +++ b/cntr/fw/cntr/Makefile @@ -0,0 +1,32 @@ +# +# cntr/Makefile - Makefile for USB to SPI translator (for AT86RF230) +# +# 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. +# + + +MAIN = cntr +OBJS = $(MAIN) # usb descr version ep0 + +F32XBASE = ../../../../f32xbase + +include $(F32XBASE)/fw/common/Makefile.system +include $(F32XBASE)/fw/common/Makefile.common + +CFLAGS += -I../common -I../include +LDFLAGS += --code-size $(PAYLOAD_SIZE) --code-loc $(PAYLOAD_START) + +USB_ID = $(shell \ + ( echo '\#include "config.h"'; echo USB_VENDOR:USB_PRODUCT; ) | \ + cpp -I../common -I../include | sed '/^ *$$/d;/^\#/d' ) + +.PHONY: dfu + +dfu: + dfu-util -d $(USB_ID) -D $(MAIN).bin diff --git a/cntr/fw/cntr/cntr.c b/cntr/fw/cntr/cntr.c new file mode 100644 index 0000000..bbbe529 --- /dev/null +++ b/cntr/fw/cntr/cntr.c @@ -0,0 +1,59 @@ +/* + * cntr/cntr.c - CNTR initialization and main loop + * + * Written 2008-2010 by Werner Almesberger + * Copyright 2008-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. + */ + + +#include "regs.h" +#include "io.h" +#include "usb.h" +#include "cntr/ep0.h" +#include "version.h" + + +static void init_io(void) +{ + /* + * Signal Mode Value + * + * PROBE_T0 open drain 1 (input) + * PROBE_ECI open drain 1 (input) + * PROBE_INT0 open drain 1 (input) + * + * PROBE_TERM open drain 0 + * + * LED push-pull 0 (set up by boot loader) + * + * all unused open drain 0 + */ + + P0 = 1 << PROBE_INT0_BIT; + P1 = (1 << PROBE_T0_BIT) | (1 << PROBE_ECI_BIT); + P2 = 0; + P3 = 0; + + /* + * Disable pull-ups + */ + XBR1 |= WEAKPUD; +} + + +void main(void) +{ + init_io(); + +// usb_init(); +// ep0_init(); + + while (1) { +// usb_poll(); + } +} diff --git a/cntr/fw/common/Makefile b/cntr/fw/common/Makefile new file mode 100644 index 0000000..85cf3ac --- /dev/null +++ b/cntr/fw/common/Makefile @@ -0,0 +1,53 @@ +# +# common/Makefile - Makefile for shared items +# +# Written 2008, 2010 by Werner Almesberger +# Copyright 2008, 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. +# + + +GEN_quiet = @echo " GENERATE " $@ && + +ifeq ($(V),1) + GEN = +else + GEN = $(GEN_quiet) +endif + + +.PHONY: all depend clean spotless + +all: io-parts.h + +io-parts.h: io.h Makefile + $(GEN) $(CPP) -dD $< | \ + sed '1,/IO_H/d' | \ + awk \ + 'BEGIN { print "/* MACHINE-GENERATED. DO NOT EDIT ! */"; \ + print "#ifndef IO_PARTS_H"; \ + print "#define IO_PARTS_H"; } \ + /#define/ && $$3 != "" { \ + split($$3, a, "_"); \ + print $$1, $$2 "_PORT", a[1]; \ + print $$1, $$2 "_MODE", a[1] "MDOUT"; \ + print $$1, $$2 "_BIT", a[2]; } \ + END { print "#endif" }' >$@ || \ + { rm -f $@; exit 1; } + + +# +# When we do a global "make depend", we'll come here first. So we create +# io-parts.h so that "make depend" in the other directories can pick it up. +# + +depend: io-parts.h + +clean: + rm -f io-parts.h + +spotless: clean diff --git a/cntr/fw/common/config.h b/cntr/fw/common/config.h new file mode 100644 index 0000000..4e3c280 --- /dev/null +++ b/cntr/fw/common/config.h @@ -0,0 +1,44 @@ +/* + * common/config.h - Configuration data for boot loader and application + * + * 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. + */ + +#ifndef CONFIG_H +#define CONFIG_H + +#include "io.h" +#include "io-parts.h" +#include "cntr/usb-ids.h" + + +/* ----- Boot loader configuration ----------------------------------------- */ + +/* + * Make LED output push-pull so that we can output a high voltage. + * This turns on the LED, to indicate that we're in the boot loader. + */ + +#define PLATFORM_SETUP \ + LED_MODE |= 1 << LED_BIT; + + +/* + * Turn off the LED when we exit the boot loader. + */ + +#define PLATFORM_EXIT \ + LED = 0 + + +/* ----- Application configuration ----------------------------------------- */ + +#define HW_TYPE 0 + +#endif /* !CONFIG_H */ diff --git a/cntr/fw/common/io.h b/cntr/fw/common/io.h new file mode 100644 index 0000000..33b5382 --- /dev/null +++ b/cntr/fw/common/io.h @@ -0,0 +1,31 @@ +/* + * common/io.h - I/O pin assignment + * + * 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. + */ + + +#ifndef IO_H +#define IO_H + +/* Diagnostic LED */ + +#define LED P1_3 + +/* Probe input */ + +#define PROBE_T0 P1_0 +#define PROBE_ECI P1_1 +#define PROBE_INT0 P0_7 + +/* Probe termination */ + +#define PROBE_TERM P1_2 + +#endif /* !IO_H */ diff --git a/cntr/fw/common/regs.h b/cntr/fw/common/regs.h new file mode 100644 index 0000000..b64092b --- /dev/null +++ b/cntr/fw/common/regs.h @@ -0,0 +1 @@ +#include "regs-f320.h"