mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2024-12-22 23:22:25 +02:00
Basic framework for CNTR firmware.
- atrf/fw/common/regs.h: forward to regs-f326.h - cntr/: added basic framework for CNTR firmware
This commit is contained in:
parent
c2dd23840c
commit
5109e0bd44
1
atrf/fw/common/regs.h
Normal file
1
atrf/fw/common/regs.h
Normal file
@ -0,0 +1 @@
|
||||
#include "regs-f326.h"
|
36
cntr/fw/Makefile
Normal file
36
cntr/fw/Makefile
Normal file
@ -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
|
22
cntr/fw/boot/Makefile
Normal file
22
cntr/fw/boot/Makefile
Normal file
@ -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)
|
32
cntr/fw/cntr/Makefile
Normal file
32
cntr/fw/cntr/Makefile
Normal file
@ -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
|
59
cntr/fw/cntr/cntr.c
Normal file
59
cntr/fw/cntr/cntr.c
Normal file
@ -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();
|
||||
}
|
||||
}
|
53
cntr/fw/common/Makefile
Normal file
53
cntr/fw/common/Makefile
Normal file
@ -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
|
44
cntr/fw/common/config.h
Normal file
44
cntr/fw/common/config.h
Normal file
@ -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 */
|
31
cntr/fw/common/io.h
Normal file
31
cntr/fw/common/io.h
Normal file
@ -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 */
|
1
cntr/fw/common/regs.h
Normal file
1
cntr/fw/common/regs.h
Normal file
@ -0,0 +1 @@
|
||||
#include "regs-f320.h"
|
Loading…
Reference in New Issue
Block a user