Date:2010-08-23 19:32:50 (9 years 29 days ago)
Author:Werner Almesberger
Commit:5109e0bd44a870009975cc1f3cdf6edcce8da5cb
Message:Basic framework for CNTR firmware.

- atrf/fw/common/regs.h: forward to regs-f326.h
- cntr/: added basic framework for CNTR firmware
Files: atrf/fw/common/regs.h (1 diff)
cntr/fw/Makefile (1 diff)
cntr/fw/boot/Makefile (1 diff)
cntr/fw/cntr/Makefile (1 diff)
cntr/fw/cntr/cntr.c (1 diff)
cntr/fw/common/Makefile (1 diff)
cntr/fw/common/config.h (1 diff)
cntr/fw/common/io.h (1 diff)
cntr/fw/common/regs.h (1 diff)

Change Details

atrf/fw/common/regs.h
1#include "regs-f326.h"
cntr/fw/Makefile
1#
2# fw/Makefile - CNTR firmware build
3#
4# Written 2008-2010 by Werner Almesberger
5# Copyright 2008-2010 Werner Almesberger
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
11#
12
13
14DIRS=common boot cntr
15
16
17.PHONY: all depend install uninstall clean spotless
18
19all:
20        for d in $(DIRS); do make -C $$d all || exit 1; done
21
22depend:
23        for d in $(DIRS); do make -C $$d depend || exit 1; done
24
25# Top-level Makefile recurses for "install" and "uninstall", which have no use
26# here. Just ignore them.
27
28install:
29
30uninstall:
31
32clean:
33        for d in $(DIRS); do make -C $$d clean || exit 1; done
34
35spotless:
36        for d in $(DIRS); do make -C $$d spotless || exit 1; done
cntr/fw/boot/Makefile
1#
2# boot/Makefile - Makefile for DFU-capable boot loader for CNTR
3#
4# Written 2008, 2010 by Werner Almesberger
5# Copyright 2008, 2010 Werner Almesberger
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
11#
12
13MAIN=boot
14OBJS=$(MAIN) usb dfu version
15
16F32XBASE = ../../../../f32xbase
17
18include $(F32XBASE)/fw/common/Makefile.system
19include $(F32XBASE)/fw/common/Makefile.common
20
21CFLAGS += -I../common -I../include
22LDFLAGS += --code-size $(PAYLOAD_START)
cntr/fw/cntr/Makefile
1#
2# cntr/Makefile - Makefile for USB to SPI translator (for AT86RF230)
3#
4# Written 2010 by Werner Almesberger
5# Copyright 2010 Werner Almesberger
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
11#
12
13
14MAIN = cntr
15OBJS = $(MAIN) # usb descr version ep0
16
17F32XBASE = ../../../../f32xbase
18
19include $(F32XBASE)/fw/common/Makefile.system
20include $(F32XBASE)/fw/common/Makefile.common
21
22CFLAGS += -I../common -I../include
23LDFLAGS += --code-size $(PAYLOAD_SIZE) --code-loc $(PAYLOAD_START)
24
25USB_ID = $(shell \
26  ( echo '\#include "config.h"'; echo USB_VENDOR:USB_PRODUCT; ) | \
27  cpp -I../common -I../include | sed '/^ *$$/d;/^\#/d' )
28
29.PHONY: dfu
30
31dfu:
32        dfu-util -d $(USB_ID) -D $(MAIN).bin
cntr/fw/cntr/cntr.c
1/*
2 * cntr/cntr.c - CNTR initialization and main loop
3 *
4 * Written 2008-2010 by Werner Almesberger
5 * Copyright 2008-2010 Werner Almesberger
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */
12
13
14#include "regs.h"
15#include "io.h"
16#include "usb.h"
17#include "cntr/ep0.h"
18#include "version.h"
19
20
21static void init_io(void)
22{
23    /*
24     * Signal Mode Value
25     *
26     * PROBE_T0 open drain 1 (input)
27     * PROBE_ECI open drain 1 (input)
28     * PROBE_INT0 open drain 1 (input)
29     *
30     * PROBE_TERM open drain 0
31     *
32     * LED push-pull 0 (set up by boot loader)
33     *
34     * all unused open drain 0
35     */
36
37    P0 = 1 << PROBE_INT0_BIT;
38    P1 = (1 << PROBE_T0_BIT) | (1 << PROBE_ECI_BIT);
39    P2 = 0;
40    P3 = 0;
41
42    /*
43     * Disable pull-ups
44     */
45    XBR1 |= WEAKPUD;
46}
47
48
49void main(void)
50{
51    init_io();
52
53// usb_init();
54// ep0_init();
55
56    while (1) {
57// usb_poll();
58    }
59}
cntr/fw/common/Makefile
1#
2# common/Makefile - Makefile for shared items
3#
4# Written 2008, 2010 by Werner Almesberger
5# Copyright 2008, 2010 Werner Almesberger
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
11#
12
13
14GEN_quiet = @echo " GENERATE " $@ &&
15
16ifeq ($(V),1)
17    GEN =
18else
19    GEN = $(GEN_quiet)
20endif
21
22
23.PHONY: all depend clean spotless
24
25all: io-parts.h
26
27io-parts.h: io.h Makefile
28        $(GEN) $(CPP) -dD $< | \
29          sed '1,/IO_H/d' | \
30          awk \
31          'BEGIN { print "/* MACHINE-GENERATED. DO NOT EDIT ! */"; \
32            print "#ifndef IO_PARTS_H"; \
33            print "#define IO_PARTS_H"; } \
34           /#define/ && $$3 != "" { \
35            split($$3, a, "_"); \
36            print $$1, $$2 "_PORT", a[1]; \
37            print $$1, $$2 "_MODE", a[1] "MDOUT"; \
38            print $$1, $$2 "_BIT", a[2]; } \
39           END { print "#endif" }' >$@ || \
40                { rm -f $@; exit 1; }
41
42
43#
44# When we do a global "make depend", we'll come here first. So we create
45# io-parts.h so that "make depend" in the other directories can pick it up.
46#
47
48depend: io-parts.h
49
50clean:
51        rm -f io-parts.h
52
53spotless: clean
cntr/fw/common/config.h
1/*
2 * common/config.h - Configuration data for boot loader and application
3 *
4 * Written 2010 by Werner Almesberger
5 * Copyright 2010 Werner Almesberger
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */
12
13#ifndef CONFIG_H
14#define CONFIG_H
15
16#include "io.h"
17#include "io-parts.h"
18#include "cntr/usb-ids.h"
19
20
21/* ----- Boot loader configuration ----------------------------------------- */
22
23/*
24 * Make LED output push-pull so that we can output a high voltage.
25 * This turns on the LED, to indicate that we're in the boot loader.
26 */
27
28#define PLATFORM_SETUP \
29    LED_MODE |= 1 << LED_BIT;
30
31
32/*
33 * Turn off the LED when we exit the boot loader.
34 */
35
36#define PLATFORM_EXIT \
37    LED = 0
38
39
40/* ----- Application configuration ----------------------------------------- */
41
42#define HW_TYPE 0
43
44#endif /* !CONFIG_H */
cntr/fw/common/io.h
1/*
2 * common/io.h - I/O pin assignment
3 *
4 * Written 2010 by Werner Almesberger
5 * Copyright 2010 Werner Almesberger
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */
12
13
14#ifndef IO_H
15#define IO_H
16
17/* Diagnostic LED */
18
19#define LED P1_3
20
21/* Probe input */
22
23#define PROBE_T0 P1_0
24#define PROBE_ECI P1_1
25#define PROBE_INT0 P0_7
26
27/* Probe termination */
28
29#define PROBE_TERM P1_2
30
31#endif /* !IO_H */
cntr/fw/common/regs.h
1#include "regs-f320.h"

Archive Download the corresponding diff file



interactive