diff --git a/cpu/z80/Makefile.z80 b/cpu/z80/Makefile.z80 deleted file mode 100644 index 47a705b47..000000000 --- a/cpu/z80/Makefile.z80 +++ /dev/null @@ -1,83 +0,0 @@ -# -# Makefile for z80/SDCC -# @author Takahide Matsutsuka -# -# $Id: Makefile.z80,v 1.15 2009/12/16 06:47:17 matsutsuka Exp $ -# - -### Compiler definitions -CC = sdcc -LD = link-z80 -AS = as-z80 -AR = sdcclib -OBJCOPY = objcopy -STRIP = strip - -### Custom rules -CUSTOM_RULE_C_TO_OBJECTDIR_O=1 -CUSTOM_RULE_ALLOBJS_TO_TARGETLIB=1 -CUSTOM_RULE_LINK=1 - -### Default flags -CFLAGS += --std-c99 -mz80 --opt-code-size -CFLAGS += --peep-file $(CONTIKI_CPU)/z80peephole.def --fverbose-asm -ASFLAGS += -LDFLAGS += -mz80 --out-fmt-ihx --no-std-crt0 -AROPTS = -a - -ifdef CONTIKI_PROJECT - CFLAGS += -DAUTOSTART_ENABLE=1 - CONTIKI_SOURCEFILES += $(CONTIKI_PROJECT).c -endif - -### CPU-dependent cleanup files -CLEAN += *.ihx *.lnk *.sym contiki-$(TARGET).lib *.$(TARGET) - -### CPU-dependent directories -CONTIKI_CPU_DIRS = . dev lib loader - -### CPU-dependent source files -CONTIKI_SOURCEFILES += strcasecmp.c mtarch.c uip_arch.c \ - libconio_z80.c log-conio.c rs232.c - -CONTIKI_ASMFILES += uip_arch-asm.S crt0.S - -CONTIKI_ASMOBJECTFILES = ${addprefix $(OBJECTDIR)/,$(CONTIKI_ASMFILES:.S=.o)} - -CONTIKI_CASMOBJECTFILES = ${addprefix $(OBJECTDIR)/,$(CONTIKI_CASMFILES:.cS=.o)} - -CONTIKI_PLATFORM_DIRS = $(PLATFORM_APPDIRS) \ - ${addprefix $(CONTIKI)/platform/$(TARGET)/, $(CONTIKI_TARGET_DIRS)} - -#".cS" suffix means assembler file with #include directive -#so that a developer can use definitions of C-style include file -#in assembler file. Make sure the header file contains only compiler -#directives. (i.e. #define, etc.) -vpath %.cS $(CONTIKI_PLATFORM_DIRS) - -#option -MMD doesn't work well on SDCC as of 2.9.0 -$(OBJECTDIR)/%.o: %.c | $(OBJECTDIR) - $(CC) $(CFLAGS) -c $< -o $@ - -ifndef CUSTOM_RULE_CS_TO_OBJECTDIR_O -$(OBJECTDIR)/%.o: %.cS | $(OBJECTDIR) - cp $< $(OBJECTDIR)/$*.c - $(CC) $(CFLAGS) -E $(OBJECTDIR)/$*.c > $(OBJECTDIR)/tmp - perl -pe "s/^#(.*)/;$$1/" $(OBJECTDIR)/tmp > $(OBJECTDIR)/$*.S - $(AS) $(ASFLAGS) -o $@ $(OBJECTDIR)/$*.S - rm -f $(OBJECTDIR)/tmp -endif - -#CUSTOM_RULE_ALLOBJS_TO_TARGETLIB -contiki-$(TARGET).lib: $(CONTIKI_OBJECTFILES) $(PROJECT_OBJECTFILES) $(CONTIKI_ASMOBJECTFILES) $(CONTIKI_CASMOBJECTFILES) - rm -f $@ - for target in $^; do echo $$target >> $@; done - -#CUSTOM_RULE_LINK (workaround for compiling examples) -$(CONTIKI_PROJECT): $(CONTIKI_PROJECT).ihx - mv $(CONTIKI_PROJECT).ihx $(CONTIKI_PROJECT).$(TARGET) - -#CUSTOM_RULE_LINK -%.ihx: contiki-$(TARGET).lib - $(CC) $(LDFLAGS) -o $@ $(OBJECTDIR)/crt0.o -lcontiki-$(TARGET).lib - $(LD) -nf $* diff --git a/cpu/z80/crt0.S b/cpu/z80/crt0.S deleted file mode 100644 index 6c3a18b4b..000000000 --- a/cpu/z80/crt0.S +++ /dev/null @@ -1,55 +0,0 @@ -;;; -;;; -;;; ctt0.S -;;; -;;; \file -;;; C runtime startup routine -;;; -;;; \author -;;; Takahide Matsutsuka -;;; -;;; $Id: crt0.S,v 1.3 2008/07/02 07:13:22 matsutsuka Exp $ -;;; - .module crt0 - .globl _main - - ;; Ordering of segments for the linker. - .area _HOME - .area _CODE - .area _GSINIT - .area _GSFINAL - .area _DATA - .area _DATAFINAL - .area _BSS - .area _HEAP - - .area _CODE -init:: - ;; Clear global variables - ld hl, #_datastart - ld bc, #_dataend -_clear_loop: - ld a, h - sub b - jr nz, _clear_next - ld a, l - sub c - jr z, _clear_exit -_clear_next: - ld (hl), #0 - inc hl - jr _clear_loop -_clear_exit: - ;; Initialize global variables - call gsinit - jp _main - - .area _GSINIT -gsinit:: - - .area _GSFINAL - ret - .area _DATA -_datastart:: - .area _DATAFINAL -_dataend:: diff --git a/cpu/z80/dev/rs232.c b/cpu/z80/dev/rs232.c deleted file mode 100644 index 630069bb8..000000000 --- a/cpu/z80/dev/rs232.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2007, Takahide Matsutsuka. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - */ -/* - * \file - * This is RS-232C process based on polling. - * Note that rs232.c and rs232-slip.c cannot be used at the same time. - * \author - * Takahide Matsutsuka - */ - -#include "contiki.h" -#include "dev/slip.h" -#include "dev/serial-line.h" -#include "dev/rs232.h" - -PROCESS(rs232_process, "RS-232C polling process"); -/*---------------------------------------------------------------------------*/ -PROCESS_THREAD(rs232_process, ev, data) -{ - static struct etimer timer; - char ch; - unsigned char i, stat; - PROCESS_BEGIN(); - - rs232_arch_init(RS232_BAUD_RATE); - etimer_set(&timer, CLOCK_SECOND / 16); - - while(1) { - PROCESS_WAIT_EVENT(); - - if (etimer_expired(&timer)) { - for (i = 0; i < RS232_BUFSIZE; i++) { - ch = rs232_arch_poll(&stat); - if (stat == 0) { - break; - } - /* We have an input data */ - RS232_CALLBACK(ch); - } - etimer_reset(&timer); - } - } - - PROCESS_END(); -} -/*---------------------------------------------------------------------------*/ diff --git a/cpu/z80/dev/rs232.h b/cpu/z80/dev/rs232.h deleted file mode 100644 index 15eec0480..000000000 --- a/cpu/z80/dev/rs232.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2007, Takahide Matsutsuka. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - */ -/* - * \file - * This is RS-232C process based on polling. - * \author - * Takahide Matsutsuka - */ - -#ifndef __RS232_H__ -#define __RS232_H__ - -/* - * Implement the following methods for each platform. - */ - -/* - * An architecture-depend implementation of RS-232C initialization. - */ -void rs232_arch_init(unsigned long ubr); - -/* - * An architecture-depend implementation of RS-232C polling. - * @return character, stat == zero if no input. - */ -unsigned char rs232_arch_poll(unsigned char* stat); - -/* - * An architecture-depend implementation of RS-232C writing a byte. - */ -void rs232_arch_writeb(unsigned char ch); - -PROCESS_NAME(rs232_process); - -/* - * if you want to use simple serial communication, - * define RS232_CONF_CALLBACK as serial_input_byte. - * The default is SLIP. - */ -#ifdef RS232_CONF_CALLBACK -#define RS232_CALLBACK RS232_CONF_CALLBACK -#else /* RS232_CONF_CALLBACK */ -#define RS232_CALLBACK slip_input_byte -#endif /* RS232_CONF_CALLBACK */ - -#ifdef RS232_CONF_BUFISZE -#define RS232_BUFSIZE RS232_CONF_BUFISZE -#else /* RS232_CONF_BUFISZE */ -#define RS232_BUFSIZE 64 -#endif /* RS232_CONF_BUFISZE */ - -#ifdef RS232_CONF_BAUD_RATE -#define RS232_BAUD_RATE RS232_CONF_BAUD_RATE -#else /* RS232_CONF_BAUD_RATE */ -#define RS232_BAUD_RATE 9600 -#endif /* RS232_CONF_BAUD_RATE */ - -#endif /* __RS232_H__ */ diff --git a/cpu/z80/lib/libconio_z80.c b/cpu/z80/lib/libconio_z80.c deleted file mode 100644 index a54c1cbc7..000000000 --- a/cpu/z80/lib/libconio_z80.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2007, Takahide Matsutsuka. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - */ - /* - * \file - * Arcitecture-depend libconio module, which supposes - * the machine has character VRAM and optional attribute VRAM - * on the main memory. - * \author - * Takahide Matsutsuka - */ - -#include "contiki.h" -#include "sys/log.h" -#include "libconio.h" -#include "libconio_z80.h" - -/*---------------------------------------------------------------------------*/ -static void scroll() { - unsigned char y; - uint16_t src, dst; - for (y = 0; y < LIBCONIO_CONF_SCREEN_HEIGHT - 1; y++) { - dst = LIBCONIO_VRAM_OFFSET(0, y); - src = LIBCONIO_VRAM_OFFSET(0, y + 1); - memcpy(LIBCONIO_VRAM_CHAR + dst, - LIBCONIO_VRAM_CHAR + src, - LIBCONIO_CONF_SCREEN_WIDTH); -#ifdef LIBCONIO_CONF_ATTRIBUTES_ENABLED - memcpy(LIBCONIO_VRAM_ATTR + dst, - LIBCONIO_VRAM_ATTR + src, - LIBCONIO_CONF_SCREEN_WIDTH); -#endif /* LIBCONIO_CONF_ATTRIBUTES_ENABLED */ - } - dst = LIBCONIO_VRAM_OFFSET(0, LIBCONIO_CONF_SCREEN_HEIGHT - 1); - memset(LIBCONIO_VRAM_CHAR + dst, ' ', - LIBCONIO_CONF_SCREEN_WIDTH); -#ifdef LIBCONIO_CONF_ATTRIBUTES_ENABLED - memset(LIBCONIO_VRAM_ATTR + dst, LIBCONIO_COLOR_NORMAL, - LIBCONIO_CONF_SCREEN_WIDTH); -#endif /* LIBCONIO_CONF_ATTRIBUTES_ENABLED */ - - gotoxy(0, LIBCONIO_CONF_SCREEN_HEIGHT - 1); -} -/*---------------------------------------------------------------------------*/ -/* make sure that the position is inside screen */ -static void adjust(unsigned char *x, unsigned char *y) { - if (*x > LIBCONIO_CONF_SCREEN_WIDTH) { - *y += *x / LIBCONIO_CONF_SCREEN_WIDTH; - *x = *x % LIBCONIO_CONF_SCREEN_WIDTH; - gotoxy(*x, *y); - } -} -/*---------------------------------------------------------------------------*/ -void ctk_arch_draw_char(char c, - unsigned char xpos, - unsigned char ypos, - unsigned char reversed, - unsigned char color) { - uint16_t off; - adjust(&xpos, &ypos); - - off = LIBCONIO_VRAM_OFFSET(xpos, ypos); - if (off >= LIBCONIO_VRAM_OFFSET_MAX) { - scroll(); - off = LIBCONIO_VRAM_OFFSET(0, LIBCONIO_CONF_SCREEN_HEIGHT - 1); - } - *(char *)(LIBCONIO_VRAM_CHAR + off) = c; -#ifdef LIBCONIO_CONF_ATTRIBUTES_ENABLED - *(char *)(LIBCONIO_VRAM_ATTR + off) = reversed ? - LIBCONIO_COLOR_REVERSED : LIBCONIO_COLOR_NORMAL; -#endif /* LIBCONIO_CONF_ATTRIBUTES_ENABLED */ -} -/*---------------------------------------------------------------------------*/ diff --git a/cpu/z80/lib/libconio_z80.h b/cpu/z80/lib/libconio_z80.h deleted file mode 100644 index a3198f27e..000000000 --- a/cpu/z80/lib/libconio_z80.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2007, Takahide Matsutsuka. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - */ - /* - * \file - * Arcitecture-depend libconio module, which supposes - * the machine has character VRAM and optional attribute VRAM - * on the main memory. - * \author - * Takahide Matsutsuka - */ - -#ifndef __LIBCONIO_ARCH_H__ -#define __LIBCONIO_ARCH_H__ - -#ifndef LIBCONIO_VRAM_CHAR -#error "must specify vram address for characters!" -#endif /* LIBCONIO_VRAM_CHAR */ - -#ifdef LIBCONIO_CONF_ATTRIBUTES_ENABLED -#ifndef LIBCONIO_VRAM_ATTR -#error "must specify vram address for attributes!" -#endif /* LIBCONIO_VRAM_ATTR */ -#endif /* LIBCONIO_CONF_ATTRIBUTES_ENABLED */ - -#ifndef LIBCONIO_CONF_SCREEN_WIDTH -#define LIBCONIO_CONF_SCREEN_WIDTH 32 -#endif /* LIBCONIO_CONF_SCREEN_WIDTH */ - -#ifndef LIBCONIO_CONF_SCREEN_HEIGHT -#define LIBCONIO_CONF_SCREEN_HEIGHT 16 -#endif /* LIBCONIO_CONF_SCREEN_HEIGHT */ - -#ifndef LIBCONIO_COLOR_REVERSED -#define LIBCONIO_COLOR_REVERSED 0x21 -#endif /* LIBCONIO_COLOR_REVERSED */ - -#ifndef LIBCONIO_COLOR_NORMAL -#define LIBCONIO_COLOR_NORMAL 0x20 -#endif /* LIBCONIO_COLOR_NORMAL */ - -/* - * An offset caluclation logic. - * The default supposes the VRAM is sequential - */ -#ifndef LIBCONIO_VRAM_OFFSET -#define LIBCONIO_VRAM_OFFSET(x, y) (y) * LIBCONIO_CONF_SCREEN_WIDTH + (x) -#endif /* VRAM_OFFSET */ - -/* - * A maximum offset + 1. - * If offset is equal or more than this maximum, the screen will scroll. - */ -#ifndef LIBCONIO_VRAM_OFFSET_MAX -#define LIBCONIO_VRAM_OFFSET_MAX \ - (LIBCONIO_CONF_SCREEN_HEIGHT * LIBCONIO_CONF_SCREEN_WIDTH) -#endif /* VRAM_MAX */ - -#endif /* __LIBCONIO_ARCH_H__ */ diff --git a/cpu/z80/lib/log-conio.c b/cpu/z80/lib/log-conio.c deleted file mode 100644 index 7f404afea..000000000 --- a/cpu/z80/lib/log-conio.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2007, Takahide Matsutsuka. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - */ - /* - * \file - * A default implmentation of logging for conio - * \author - * Takahide Matsutsuka - */ - -#include "contiki.h" -#include "libconio.h" -#include "log.h" - -#if LOG_CONF_ENABLED -void -log_message(const char *part1, const char *part2) -{ - cputs(part1); - /* line feed */ - gotoxy(0, wherey() + 1); -} -#endif /* LOG_CONF_ENABLED */ diff --git a/cpu/z80/lib/strcasecmp.c b/cpu/z80/lib/strcasecmp.c deleted file mode 100644 index dc0e844b3..000000000 --- a/cpu/z80/lib/strcasecmp.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2007, Takahide Matsutsuka. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - */ - /* - * \file - * This complements standard C library of sdcc. - * \author - * Takahide Matsutsuka - */ - -#include -#include "strcasecmp.h" - -int strcasecmp(const char *str1, const char *str2) -{ - while (*str1 != '\0' && tolower(*str1) == tolower(*str2)) { - str1++; - str2++; - } - return tolower(*(unsigned char *)str1) - tolower(*(unsigned char *)str2); -} diff --git a/cpu/z80/lib/strcasecmp.h b/cpu/z80/lib/strcasecmp.h deleted file mode 100644 index 833151b45..000000000 --- a/cpu/z80/lib/strcasecmp.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2007, Takahide Matsutsuka. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - */ - /* - * \file - * This complements standard C library of sdcc. - * \author - * Takahide Matsutsuka - */ - -#ifndef __STRCASECMP_H__ -#define __STRCASECMP_H__ - -int strcasecmp(const char *str1, const char *str2); - -#endif /*__STRCASECMP_H__*/ diff --git a/cpu/z80/loader/mef.c b/cpu/z80/loader/mef.c deleted file mode 100644 index 2bde4c45f..000000000 --- a/cpu/z80/loader/mef.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2007, Takahide Matsutsuka. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - */ - -/* - * \file - * mef.c - * The Micro Executable Format - * \author - * Takahide Matsutsuka - */ - -#ifdef WITH_LOADER_ARCH -#include "contiki.h" -#include "loader/mef.h" - -struct Area areas[MEF_AREA_MAX]; - -void -mef_load(unsigned char* offset) -{ - unsigned char* start = offset; - unsigned char areasize = load_byte(); - uint16_t relocsize; - unsigned int i, j; - uint16_t checksum = 0; - unsigned char* buf; - struct Relocation reloc; - - for (i = 0; i < areasize; i++) { - buf = (unsigned char *) &areas[i]; - for (j = 0; j < sizeof(struct Area); j++) { - *buf++ = load_byte(); - } - } - - for (i = 0; i < areasize; i++) { - for (j = 0; j < areas[i].size; j++) { - *offset = load_byte(); - checksum += *offset; - offset++; - } - if (areas[i].checksum != checksum) { - // Checksum error! - } - } - - // relocation information - relocsize = load_byte(); - relocsize = (load_byte() << 8) + relocsize; - for (i = 0; i < relocsize; i++) { - buf = (unsigned char *) &reloc; - for (j = 0; j < sizeof(struct Relocation); j++) { - *buf++ = load_byte(); - } - mef_reloc(start, &reloc); - } -} - -void -mef_reloc(unsigned char* offset, struct Relocation *reloc) -{ - if (reloc->mode & MEF_RELOC_ABSOLUTE) { - return; - } - offset += reloc->address; - if (reloc->mode & MEF_RELOC_MSB_BYTE) { - *offset = (unsigned char) ((reloc->data + (uint16_t) offset) >> 8); - } else if (reloc->mode & MEF_RELOC_LSB_BYTE) { - *offset = (unsigned char) ((reloc->data + (uint16_t) offset) & 0xff); - } else { /* word */ - *offset++ = (unsigned char) ((reloc->data + (uint16_t) offset) & 0xff); - *offset = (unsigned char) ((reloc->data + (uint16_t) offset) >> 8); - } -} - - -#endif /* WITH_LOADER_ARCH */ diff --git a/cpu/z80/loader/mef.h b/cpu/z80/loader/mef.h deleted file mode 100644 index 1a5866de4..000000000 --- a/cpu/z80/loader/mef.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2007, Takahide Matsutsuka. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - */ - -/* - * \file - * mef.h - * The Micro Executable Format - * \author - * Takahide Matsutsuka - */ -/* - * MEF file format: - * [AreaDecls] - * BYTE nAreas (0-15) - * struct AreaSize[nAreas] - * [Data] - * binary* - * [Relocation] - * WORD nRelocs - * struct Relocation[nRelocs] - */ - -#ifndef __MEF_H__ -#define __MEF_H__ - - -/* - * mode - * bit 7: read/write (1) / read only (0) - * bit 3-0: Area index - * checksum - * just a sum of all data of the area - */ -#define MEF_AREA_RW 0x80 -#define MEF_AREA_MAX 0x10 - -struct Area { - unsigned char mode; - uint16_t size; - uint16_t checksum; -}; - -/* - * mode - * bit 7: Absolute (1) / Relative (0) - * bit 6: MSB (1) / LSB (0) (in byte mode) - * bit 5: Byte mode (1) / Word mode (0) - */ -#define MEF_RELOC_ABSOLUTE 0x80 -#define MEF_RELOC_MSB_BYTE 0x60 -#define MEF_RELOC_LSB_BYTE 0x20 - -struct Relocation { - unsigned char mode; - uint16_t address; - uint16_t data; -}; - -unsigned char load_byte(); - -void mef_load(unsigned char* offset); -unsigned char load_byte(); -void mef_reloc(unsigned char* offset, struct Relocation* reloc); - -#endif /* __MEF_H__ */ diff --git a/cpu/z80/mtarch.c b/cpu/z80/mtarch.c deleted file mode 100644 index 50f9959dc..000000000 --- a/cpu/z80/mtarch.c +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright (c) 2007, Takahide Matsutsuka. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - /* - * \file - * Z80 machine-specific implementation for supporting multithread. - * \author - * Takahide Matsutsuka - */ -#include "sys/mt.h" -#include "mtarch.h" - -/*--------------------------------------------------------------------------*/ -void -mtarch_init(void) -{ -} -/*--------------------------------------------------------------------------*/ -void -mtarch_start(struct mtarch_thread *t, - void (*function)(void *), void *data) -{ - uint16_t i; - - for(i = 0; i < MTARCH_STACKSIZE; i++) { - t->stack[i] = i; - } - - t->sp = &t->stack[MTARCH_STACKSIZE - 1]; - - - /* A parameter for method for thread function. */ - *t->sp = (uint16_t)data; - --t->sp; - - /* This will be a return address of thread function. */ - *t->sp = (uint16_t)mt_exit; - --t->sp; - - /* The thread function, is used as a return address of mtarch_switch. */ - *t->sp = (uint16_t)function; - --t->sp; - - /* - * Space for registers. - * af, bc, de, hl, ix, iy, af', bc', de', hl' - */ - /* - * Z80 stack basis: - * push stores the data AFTER decrementing sp. - * pop reads the data BEFORE incrementing sp. - */ - - t->sp = t->sp - 9; -} -/*--------------------------------------------------------------------------*/ -static struct mtarch_thread *running_thread; -static uint16_t *sptmp; -static void -mtarch_switch() -{ - __asm - di ; disable interrupt - ; normal registers - push af - push bc - push de - push hl - push ix - push iy - - ; back registers - ex af,af' - push af - exx - push bc - push de - push hl - - ; swap between running_thread->sp and SP reg - ; _running_thread in asembler below points running_thread->sp - ; sptmp = sp; - ld (_sptmp),sp - - ; sp = *(running_thread->sp); - ld ix,(_running_thread) - ld l,0(ix) - ld h,1(ix) - ld sp,hl - - ; running_thread->sp = sptmp; - ld hl,(_sptmp) - ld 0(ix),l - ld 1(ix),h - - ; back registers - pop hl - pop de - pop bc - exx - pop af - ex af,af' - - ; normal registers - pop iy - pop ix - pop hl - pop de - pop bc - pop af - ei ; enable interrupt - __endasm; - // here sp indicates the address that point the function -} -/*--------------------------------------------------------------------------*/ -void -mtarch_exec(struct mtarch_thread *t) -{ - running_thread = t; - mtarch_switch(); - running_thread = NULL; -} -/*--------------------------------------------------------------------------*/ -void -mtarch_remove() -{ -} -/*--------------------------------------------------------------------------*/ -void -mtarch_yield() -{ - if (running_thread == NULL) { - /* ERROR! we have no runnning thread. */ - return; - } - mtarch_switch(); -} -/*--------------------------------------------------------------------------*/ -void mtarch_stop(struct mtarch_thread *thread) -{ -} -/*--------------------------------------------------------------------------*/ -void -mtarch_pstop() -{ -} -/*--------------------------------------------------------------------------*/ -void -mtarch_pstart() -{ -} -/*--------------------------------------------------------------------------*/ -int -mtarch_stack_usage(struct mtarch_thread *t) -{ - uint16_t i; - for (i = 0; i < MTARCH_STACKSIZE; i++) { - if (t->stack[i] != i) { - return MTARCH_STACKSIZE - i; - } - } - - return 0; -} -/*--------------------------------------------------------------------------*/ diff --git a/cpu/z80/mtarch.h b/cpu/z80/mtarch.h deleted file mode 100644 index f5d2b80b2..000000000 --- a/cpu/z80/mtarch.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2007, Takahide Matsutsuka. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - /* - * \file - * Z80 machine-specific difinitions for supporting multithread. - * - * \author - * Takahide Matsutsuka - */ -#ifndef __MTARCH_H__ -#define __MTARCH_H__ - -/* Unit of the stack is 2byte wide. */ -#ifndef MTARCH_STACKSIZE -#define MTARCH_STACKSIZE 128 -#endif /* MTARCH_STACKSIZE */ - -struct mtarch_thread { - /* - * On top of the mtarch_thread must be the address for the stack pointer. - * See details at mtarch_switch in mtarch.c - */ - uint16_t *sp; - /* - * Stack is 2-byte wide, so please note that you need 2 * MTARCH_STACKSIZE - * bytes for the stack area for each thread. - */ - uint16_t stack[MTARCH_STACKSIZE]; -}; - -/* - * A function for debugging purpose, placed here by following other implementations. - */ -int mtarch_stack_usage(struct mtarch_thread *t); - -#endif /* __MTARCH_H__ */ - diff --git a/cpu/z80/uip_arch-asm.S b/cpu/z80/uip_arch-asm.S deleted file mode 100644 index e64ddf45a..000000000 --- a/cpu/z80/uip_arch-asm.S +++ /dev/null @@ -1,221 +0,0 @@ -;;; -;;; -;;; uip_arch-asm.S -;;; -;;; \file -;;; Z80 architecture-depend uip module -;;; for calculating checksums -;;; -;;; \author -;;; Takahide Matsutsuka -;;; - .module uip_arch-asm - - ;; export symbols - .globl _uip_add32 - .globl _uip_arch_chksum - .globl _uip_chksum - - ;; import symbols - .globl _uip_acc32 - .globl _uip_buf - - .area _DATA - - .area _GSINIT - - .area _CODE - - ;; --------------------------------- - ;; void uip_add32(uint8_t *op32, uint16_t op16); - ;; Stack; retl reth op32l op32h op16l op16h - ;; ABCDEHL____ - ;; return void - ;; _uip_acc32 = op32 + op16 - ;; --------------------------------- -_uip_add32_start:: -_uip_add32: - ;; HL = #_op32l - ld hl, #2 - add hl, sp - - ;; DE = #(_op32) - ld e, (hl) - inc hl - ld d, (hl) - inc hl - - ;; BC = op16 - ld c, (hl) - inc hl - ld b, (hl) - - ;; HL = #(_op32) + 3 - ld hl, #3 - add hl, de - - ;; DE = #_uip_acc32 + 3 - ld de, #_uip_acc32 + 3 - - ;; uip_acc32[3] = op32[3] + op16l; - ld a, (hl) - add a, c - ld (de), a - - ;; uip_acc32[2] = op32[2] + op16h + carry; - dec hl - dec de - ld a, (hl) - adc a, b - ld (de), a - jr nc, _uip_add32_nocarry1 - - ;; uip_acc32[1] - dec hl - dec de - ld a, (hl) - inc a - ld (de), a - jr nz, _uip_add32_nocarry0 - - ;; uip_acc32[0] - dec hl - dec de - ld a, (hl) - inc a - ld (de), a - ret -_uip_add32_nocarry1: - ;; uip_acc32[1] - dec hl - dec de - ld a, (hl) - ld (de), a - -_uip_add32_nocarry0: - ;; uip_acc32[0] - dec hl - dec de - ld a, (hl) - ld (de), a - ret -_uip_add32_end:: - - ;; --------------------------------- - ;; static uint16_t chksum(uint16_t sum, const uint8_t *data, uint16_t len) - ;; Stack; retl reth suml sumh datal datah lenl lenh - ;; ABCDEHL____ - ;; return HL - ;; --------------------------------- -_uip_arch_chksum_start:: -_uip_arch_chksum: - push ix - ;; IX = #_suml - ld ix, #4 - add ix, sp - ;; BC = sum - ld c, 0(ix) - ld b, 1(ix) - ;; DE = #data - ld e, 2(ix) - ld d, 3(ix) - - ;; (lenl, lenh) <- dataptr + len - 1 (last address) - ;; (len) + DE - 1 -> (len) - ld l, 4(ix) - ld h, 5(ix) - add hl, de - dec hl - ld 4(ix), l - ld 5(ix), h - -_uip_arch_chksum_loop: - ;; compare HL(last address) and DE(dataptr) - ;; HL - DE - ;; if (HL < DE) C,NZ else if (HL = DE) NC,Z=1 otherwise NC,NZ - ;; HL = last address, DE = current pointer - ld l, 4(ix) - ld h, 5(ix) - - ld a, h - sub d - jr nz, _uip_arch_chksum_compared - ld a, l - sub e - ;; if (last address == dataptr) _uip_arch_chksum_loop_exit_add_trailing - jr z, _uip_arch_chksum_loop_exit_add_trailing -_uip_arch_chksum_compared: - ;; if (last address > dataptr) _uip_arch_chksum_loop_exit - jr c, _uip_arch_chksum_loop_exit - ;; bc = dataptr[0],dataptr[1] + bc - ld a, (de) - ld h, a - inc de - ld a, (de) - ld l, a - push hl - add hl, bc - inc de - ld b, h - ld c, l - ;; HL = t - pop hl - ;; BC - HL - ;; if (sumBC < tHL) sum++ - ld a, b - sub h - jr nz, _uip_arch_chksum_compared_t - ld a, c - sub l -_uip_arch_chksum_compared_t: - jr nc, _uip_arch_chksum_nocarry_t - inc bc -_uip_arch_chksum_nocarry_t: - jr _uip_arch_chksum_loop -_uip_arch_chksum_loop_exit_add_trailing: - ;; HL = last address - ;; bc = bc + (last address)<<8 - ld a, b - add a, (hl) - ld b, a - jr nc, _uip_arch_chksum_loop_exit - inc bc -_uip_arch_chksum_loop_exit: - ld l, c - ld h, b - pop ix - ret -_uip_arch_chksum_end:: - - ;; --------------------------------- - ;; uint16_t uip_chksum(void); - ;; Stack; retl reth datal datah lenl lenh - ;; ABCDEHL____ - ;; return HL - ;; return htons(chksum(0, (uint8_t *)data, len)); - ;; --------------------------------- -_uip_chksum_start:: -_uip_chksum: - ld hl, #5 - add hl, sp - ;; HL indicates #_lenh - ld b, #2 -_uip_chksum_loop: - ld d, (hl) - dec hl - ld e, (hl) - dec hl - push de - djnz _uip_chksum_loop - ld bc, #0 - push bc - call _uip_arch_chksum - pop af - pop af - pop af - ;; convert to BIG ENDIAN (htons) - ld a, l - ld l, h - ld h, a - ret -_uip_chksum_end:: diff --git a/cpu/z80/uip_arch.c b/cpu/z80/uip_arch.c deleted file mode 100644 index 31388242c..000000000 --- a/cpu/z80/uip_arch.c +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Copyright (c) 2007, Takahide Matsutsuka. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - */ - /* - * \file - * Z80 architecture-depend uip module - * for calculating checksums - * \author - * Takahide Matsutsuka - */ - -#include -#include "uip_arch.h" - -static const uint16_t sizeof_uip_ipaddr_t = sizeof(uip_ipaddr_t); -static const uint16_t offset_tcpip_hdr_len = offsetof(struct uip_tcpip_hdr, len); -static const uint16_t offset_tcpip_hdr_srcipaddr = offsetof(struct uip_tcpip_hdr, srcipaddr); - -/*--------------------------------------------------------------------------*/ -static void upper_layer_chksum() { -__asm - ;; --------------------------------- - ;; static uint16_t upper_layer_chksum(uint8_t proto); - ;; Stack; retl reth - ;; @param C proto - ;; ABCDEHL____ - ;; --------------------------------- - ;; HL = BUF = &uip_buf[UIP_LLH_LEN] - ld hl, #_uip_buf - ld de, #UIP_LLH_LEN - add hl, de - push hl - - ;; HL = BUF->len[0] - push ix - ld ix, #_offset_tcpip_hdr_len - ld e, 0(ix) - ld d, 1(ix) - add hl, de - pop ix - - ;; DE = upper layer length - ld d, (hl) - inc hl - ld e, (hl) -#if UIP_CONF_IPV6 -#else - ld a, e - sub a, #UIP_IPH_LEN - ld e, a - jr nc, _upper_layer_chksum_setlen2 - dec d -_upper_layer_chksum_setlen2: -#endif - ;; bc = upper_leyer_len + proto - ld b, d - ld a, e - add a, c - ld c, a - jr nc, _upper_layer_chksum_setlen3 - inc b -_upper_layer_chksum_setlen3: - pop hl ; BUF - push de - push ix - ld ix, #_offset_tcpip_hdr_srcipaddr - ld e, 0(ix) - ld d, 1(ix) - add hl, de - ld e, l - ld d, h - ld ix, #_sizeof_uip_ipaddr_t - ld l, 0(ix) - ld h, 1(ix) - pop ix - sla l - rl h - push hl - push de - push bc - call _uip_arch_chksum ; hl = sum - pop af - pop af - pop af - ;; de is still stacked - - ld b, h - ld c, l - ld hl, #_uip_buf - ld de, #UIP_IPH_LEN - add hl, de -_upper_layer_chksum_call: - ld de, #UIP_LLH_LEN - add hl, de - push hl - push bc - call _uip_arch_chksum - pop af - pop af - pop af - - ld a, h - or a, l - jr nz, _upper_layer_uip_htons - ld hl, #0xffff - jr _upper_layer_ret -_upper_layer_uip_htons: - ld a, l - ld l, h - ld h, a -_upper_layer_ret: -__endasm; -} - -/*--------------------------------------------------------------------------*/ -uint16_t -uip_ipchksum(void) -{ -__asm - ;; --------------------------------- - ;; uint16_t uip_ipchksum(void); - ;; Stack; retl reth - ;; ABCDEHL____ - ;; return HL - ;; --------------------------------- - ld hl, #UIP_IPH_LEN - push hl - ;; HL = BUF = &uip_buf[UIP_LLH_LEN] - ld hl, #_uip_buf - ;; BC = sum = 0 - ld bc, #0 - jp _upper_layer_chksum_call -__endasm; -} - -/*--------------------------------------------------------------------------*/ -#if UIP_CONF_IPV6 -uint16_t -uip_icmp6chksum(void) -{ -__asm - ;; --------------------------------- - ;; uint16_t uip_icmp6chksum(void); - ;; Stack; retl reth - ;; ABCDEHL____ - ;; return HL - ;; --------------------------------- - ld c, #UIP_PROTO_ICMP6 - jp _upper_layer_chksum -__endasm; -} -#endif /* UIP_CONF_IPV6 */ - -/*--------------------------------------------------------------------------*/ -uint16_t -uip_tcpchksum(void) -{ -__asm - ;; --------------------------------- - ;; uint16_t uip_tcpchksum(void); - ;; Stack; retl reth - ;; ABCDEHL____ - ;; return HL - ;; --------------------------------- - ld c, #UIP_PROTO_TCP - jp _upper_layer_chksum -__endasm; -} - -/*--------------------------------------------------------------------------*/ -#if UIP_UDP_CHKSUMS -uint16_t -uip_udpchksum(void) -{ -__asm - ;; --------------------------------- - ;; uint16_t uip_udpchksum(void); - ;; Stack; retl reth - ;; ABCDEHL____ - ;; return HL - ;; --------------------------------- - ld c, #UIP_PROTO_UDP - jp _upper_layer_chksum -__endasm; -} -#endif /* UIP_UDP_CHKSUMS */ -/*--------------------------------------------------------------------------*/ diff --git a/cpu/z80/z80def.h b/cpu/z80/z80def.h deleted file mode 100644 index d39857f93..000000000 --- a/cpu/z80/z80def.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2007, Takahide Matsutsuka. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - */ - -/* - * \file - * This file contains a set of configuration for using SDCC as a compiler. - * - * \author - * Takahide Matsutsuka - */ - -#ifndef __Z80_DEF_H__ -#define __Z80_DEF_H__ - -#define CC_CONF_FUNCTION_POINTER_ARGS 1 -#define CC_CONF_FASTCALL -#define CC_CONF_VA_ARGS 0 -#define CC_CONF_UNSIGNED_CHAR_BUGS 0 -#define CC_CONF_REGISTER_ARGS 0 - - -/* Generic types. */ -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef signed short int16_t; -typedef unsigned short uint16_t; -typedef unsigned long uint32_t; -typedef unsigned char u8_t; /* 8 bit type */ -typedef unsigned short u16_t; /* 16 bit type */ -typedef unsigned long u32_t; /* 32 bit type */ -typedef signed long s32_t; /* 32 bit type */ -typedef unsigned short uip_stats_t; -typedef signed long int32_t; /* 32 bit type */ -#ifndef _SIZE_T_DEFINED -#define _SIZE_T_DEFINED -typedef unsigned int size_t; -#endif - -/* Compiler configurations */ -#define CCIF -#define CLIF -#define CC_CONF_CONST_FUNCTION_BUG - -/* - * Enable architecture-depend checksum calculation - * for uIP configuration. - * @see uip_arch.h - * @see uip_arch-asm.S - */ -#define UIP_ARCH_ADD32 1 -#define UIP_ARCH_CHKSUM 1 -#define UIP_ARCH_IPCHKSUM - -#define CC_CONF_ASSIGN_AGGREGATE(dest, src) \ - memcpy(dest, src, sizeof(*dest)) - -#define uip_ipaddr_copy(dest, src) \ - memcpy(dest, src, sizeof(*dest)) - -#define snprintf(a...) - -#endif /* __Z80_DEF_H__ */ diff --git a/cpu/z80/z80peephole.def b/cpu/z80/z80peephole.def deleted file mode 100644 index 8b4ee06e9..000000000 --- a/cpu/z80/z80peephole.def +++ /dev/null @@ -1,183 +0,0 @@ -# -# Customized peep-hole optimizer for z80/SDCC -# @author Takahide Matsutsuka -# -# $Id: z80peephole.def,v 1.1 2009/12/11 14:59:32 matsutsuka Exp $ -# - -replace { - ld hl, %1 - ld (hl), #0x%2 - inc hl - ld (hl), #0x%3 -} by { - ;; (peep) 1 short store - ld hl, #0x%3%2 - ld (%1), hl -} - -replace { - ld hl, %1 + 0 - ld (hl), %2 - ld hl, %1 + 1 - ld (hl), %3 -} by { - ;; (peep) 2 short store - ld hl, %1 - ld (hl), %2 - inc hl - ld (hl), %3 -} - -replace { - sub a, #0x01 - jr Z, %1 -} by { - ;; (peep) 3 decrement optimization - dec a - jr z, %1 -} -replace { - sub a, #0x01 - jr NZ, %1 -} by { - ;; (peep) 4 decrement optimization - dec a - jr nz, %1 -} -replace { - sub a, #0x01 - jp Z, %1 -} by { - ;; (peep) 5 decrement optimization - dec a - jp z, %1 -} -replace { - sub a, #0x01 - jp NZ, %1 -} by { - ;; (peep) 6 decrement optimization - dec a - jp nz, %1 -} - -replace { - push %1 - pop iy - ld a, (iy) - or a, a -} by { - ;; (peep) 7 or optimization - ld a, (%1) - or a, a -} - -replace { - ld iy, %1 - ld a, 0 (iy) -} by { - ;; (peep) 8 iy optimization - ld a, (%1) -} - -replace { - ld iy, %1 - ld 0 (iy), a -} by { - ;; (peep) 9 iy optimization - ld (%1), a -} - -replace { - push %1 - pop iy - ld (iy), %2 -} by { - ;; (peep) 10 iy optimization - ld a, %2 - ld (%1), a -} - -replace { - ld iy, %1 - ld %2,0 (iy) - ld iy, %1 - ld %3,1 (iy) - ld iy, %1 - ld %4,2 (iy) - ld iy, %1 - ld %5,3 (iy) -} by { - ;; (peep) 11 iy optimization - ld iy, %1 - ld %2,0 (iy) - ld %3,1 (iy) - ld %4,2 (iy) - ld %5,3 (iy) -} - -replace { - ld iy, %1 - ld %2,0 (iy) - ld iy, %1 - ld %3,1 (iy) -} by { - ;; (peep) 12 iy optimization - ld iy, %1 - ld %2,0 (iy) - ld %3,1 (iy) -} - -replace { - ld iy, %1 - ld 0 (iy), %2 - ld iy, %1 - ld 1 (iy), %3 - ld iy, %1 - ld 2 (iy), %4 - ld iy, %1 - ld 3 (iy), %5 -} by { - ;; (peep) 13 iy optimization - ld iy, %1 - ld 0 (iy), %2 - ld 1 (iy), %3 - ld 2 (iy), %4 - ld 3 (iy), %5 -} - -replace { - ld iy, %1 - ld 0 (iy), %2 - ld iy, %1 - ld 1 (iy), %3 -} by { - ;; (peep) 14 iy optimization - ld iy, %1 - ld 0 (iy), %2 - ld 1 (iy), %3 -} - -replace { - jp %1 -%2: -} by { - ;; (peep) 15 short jump optimization - jr %1 -%2: -} if labelInRange - -replace { - ld c,%3 (ix) - ld b,%4 (ix) - push bc - pop iy - ld 0 (iy), #0x%6 - ld 1 (iy), #0x%5 -} by { - ;; (peep) 16 store value - ld l, %3 (ix) - ld h, %4 (ix) - ld (hl), #0x%5%6 -} diff --git a/platform/esb/Makefile.esb b/platform/esb/Makefile.esb deleted file mode 100644 index 7ec4d4444..000000000 --- a/platform/esb/Makefile.esb +++ /dev/null @@ -1,87 +0,0 @@ -# $Id: Makefile.esb,v 1.15 2010/03/02 22:40:39 nifi Exp $ - -SENSORS = sensors.c irq.c button-sensor.c pir-sensor.c vib-sensor.c \ - sound-sensor.c radio-sensor.c ctsrts-sensor.c battery-sensor.c \ - temperature-sensor.c -ESB = ir.c beep.c ds1629.c tr1001-gcr.c gcr.c \ - esb-sensors.c node-id.c eeprom.c \ - uip-driver.c uip-ipchksum.c -CFS_EEPROM = cfs-eeprom.c -CFS_COFFEE = cfs-coffee.c cfs-coffee-arch.c - -CONTIKI_TARGET_DIRS = . dev apps net loader -ifndef CONTIKI_TARGET_MAIN - CONTIKI_TARGET_MAIN = contiki-esb-main.c -endif - -CONTIKI_TARGET_SOURCEFILES += $(SENSORS) $(ESB) \ - contiki-esb-default-init-lowlevel.c \ - contiki-esb-default-init-apps.c \ - rs232.c rs232-putchar.c fader.c - -ifdef WITH_CODEPROP - CONTIKI_TARGET_DIRS += ../../apps/codeprop - CONTIKI_TARGET_SOURCEFILES += codeprop-tmp.c - WITH_UIP=1 -endif - -ifdef GCC -CFLAGS+=-Os -g -endif - -ifdef IAR -CFLAGS += -D__MSP430F149__=1 -e --vla -Ohz --multiplier=16s --core=430 --double=32 -CFLAGSNO = --dlib_config "$(IAR_PATH)/LIB/DLIB/dl430fn.h" $(CFLAGSWERROR) -endif - - -ifdef WITH_UIP - ifndef WITH_SLIP - WITH_SLIP=1 - endif - CFLAGS += -DWITH_UIP=1 -DWITH_SLIP=${WITH_SLIP} -endif - -ifeq ($(CFS),coffee) - CONTIKI_TARGET_SOURCEFILES += $(CFS_COFFEE) -else - CONTIKI_TARGET_SOURCEFILES += $(CFS_EEPROM) -endif - -include $(CONTIKI)/platform/$(TARGET)/apps/Makefile.apps - -MCU=msp430f149 -include $(CONTIKI)/cpu/msp430/Makefile.msp430 - -ifdef IAR -LDFLAGSNO += -xm "$(IAR_PATH)/lib/dlib/dl430fn.r43" -f "$(IAR_PATH)/config/lnk430f149.xcl" -LDFLAGS += $(LDFLAGSNO) -Felf -yn -endif # IAR - -contiki-$(TARGET).a: ${addprefix $(OBJECTDIR)/,symbols.o} -# $(AR) rcf $@ $^ - -ifndef BASE_IP -BASE_IP := 172.16.1.1 -endif - -send: $(CONTIKI)/tools/codeprop.c - cc -Wall $^ -o send - -%.send: %.cm send - send $(BASE_IP) $< - -### System dependent Makefile - -ifeq ($(HOST_OS),FreeBSD) - # settings for FreeBSD - -include $(CONTIKI)/platform/$(TARGET)/buildscripts/Makefile.freebsd -else - ifeq ($(HOST_OS),Windows) - # settings for Windows - -include $(CONTIKI)/platform/$(TARGET)/buildscripts/Makefile.win - else - # settings for an arbitary unix-like platform - -include $(CONTIKI)/platform/$(TARGET)/buildscripts/Makefile.unix - endif -endif diff --git a/platform/esb/apps/Makefile.apps b/platform/esb/apps/Makefile.apps deleted file mode 100644 index 83e02193a..000000000 --- a/platform/esb/apps/Makefile.apps +++ /dev/null @@ -1,4 +0,0 @@ -burn-nodeid: burn-nodeid.c -helloworld: helloworld.c -radio-test: radio-test.c -radio-sniffer: radio-sniffer.c diff --git a/platform/esb/apps/beeper.c b/platform/esb/apps/beeper.c deleted file mode 100644 index c0e7b9927..000000000 --- a/platform/esb/apps/beeper.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ -#include "contiki-esb.h" - -PROCESS(beeper_process, "Beeper"); - -AUTOSTART_PROCESSES(&beeper_process); - -static struct etimer etimer; - -static struct pt beeper_pt; - -static -PT_THREAD(beeper_thread(struct pt *pt)) -{ - PT_BEGIN(pt); - - while(1) { - PT_WAIT_UNTIL(pt, etimer_expired(&etimer)); - etimer_reset(&etimer); - leds_invert(LEDS_RED); - beep(); - - PT_WAIT_UNTIL(pt, etimer_expired(&etimer)); - etimer_reset(&etimer); - leds_invert(LEDS_RED); - } - - PT_END(pt); -} - -PROCESS_THREAD(beeper_process, ev, data) -{ - PROCESS_BEGIN(); - - etimer_set(&etimer, CLOCK_SECOND / 2); - PT_INIT(&beeper_pt); - - button_sensor.configure(SENSORS_ACTIVE, 1); - - while(1) { - - beeper_thread(&beeper_pt); - - PROCESS_WAIT_EVENT(); - - if(ev == PROCESS_EVENT_EXIT) { - break; - } else if(ev == sensors_event && - data == &button_sensor) { - leds_invert(LEDS_YELLOW); - } - - } - PROCESS_END(); -} diff --git a/platform/esb/apps/burn-nodeid.c b/platform/esb/apps/burn-nodeid.c deleted file mode 100644 index a157baebd..000000000 --- a/platform/esb/apps/burn-nodeid.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2006, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * \file - * A brief description of what this file is. - * \author - * Adam Dunkels - */ - -#include "sys/node-id.h" -#include "contiki.h" -#include "dev/esb-sensors.h" -#include "dev/rs232.h" - -#include - -PROCESS(burn_process, "Burn node id"); -AUTOSTART_PROCESSES(&burn_process); -/*---------------------------------------------------------------------------*/ -PROCESS_THREAD(burn_process, ev, data) -{ - PROCESS_BEGIN(); -#if NODEID - printf("Burning node id %d\n", NODEID); - node_id_burn(NODEID); - node_id_restore(); - printf("Restored node id %d\n", node_id); -#else -#error "burn-nodeid must be compiled with nodeid=" - node_id_restore(); - printf("Restored node id %d\n", node_id); -#endif - while(1) { - PROCESS_WAIT_EVENT(); - } - PROCESS_END(); -} -/*---------------------------------------------------------------------------*/ -void init_net(void) {} -void init_lowlevel(void) {esb_sensors_init(); esb_sensors_on(); rs232_init();} diff --git a/platform/esb/apps/fader.c b/platform/esb/apps/fader.c deleted file mode 100644 index 78e471e9b..000000000 --- a/platform/esb/apps/fader.c +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - * Author: Adam Dunkels - * - */ - -#include "contiki-esb.h" - -PROCESS(fader_process, "LED fader"); -AUTOSTART_PROCESSES(&fader_process); - -#define ON 1 -#define OFF 0 - -static unsigned char onoroff; -static struct etimer etimer; -static struct pt fade_pt, fade_in_pt, fade_out_pt; -/*---------------------------------------------------------------------------*/ -static -PT_THREAD(fade_in(struct pt *pt)) -{ - static int delay; - - PT_BEGIN(pt); - - for(delay = 3980; delay > 20; delay -= 20) { - leds_on(LEDS_ALL); - clock_delay(4000 - delay); - leds_off(LEDS_ALL); - clock_delay(delay); - PT_YIELD(pt); - } - - PT_END(pt); -} -/*---------------------------------------------------------------------------*/ -static -PT_THREAD(fade_out(struct pt *pt)) -{ - static int delay; - - PT_BEGIN(pt); - - for(delay = 20; delay < 3980; delay += 20) { - leds_on(LEDS_ALL); - clock_delay(4000 - delay); - leds_off(LEDS_ALL); - clock_delay(delay); - PT_YIELD(pt); - } - - PT_END(pt); -} -/*---------------------------------------------------------------------------*/ -static -PT_THREAD(fade(struct pt *pt)) -{ - PT_BEGIN(pt); - - PT_SPAWN(pt, &fade_in_pt, fade_in(&fade_in_pt)); - PT_SPAWN(pt, &fade_out_pt, fade_out(&fade_out_pt)); - - etimer_set(&etimer, CLOCK_SECOND * 10); - PT_WAIT_UNTIL(pt, etimer_expired(&etimer)); - - PT_END(pt); -} -/*---------------------------------------------------------------------------*/ -PROCESS_THREAD(fader_process, ev, data) -{ - PROCESS_BEGIN(); - - PT_INIT(&fade_pt); - PT_INIT(&fade_in_pt); - PT_INIT(&fade_out_pt); - onoroff = ON; - etimer_set(&etimer, CLOCK_SECOND * 32); - - while(1) { - PROCESS_WAIT_EVENT(); - - if(ev == PROCESS_EVENT_TIMER) { - etimer_reset(&etimer); - PT_INIT(&fade_pt); - process_poll(&fader_process); - } - - if(onoroff == ON && - PT_SCHEDULE(fade(&fade_pt))) { - process_poll(&fader_process); - } - } - PROCESS_END(); -} -/*---------------------------------------------------------------------------*/ -void -fader_on(void) -{ - onoroff = ON; - process_poll(&fader_process); -} -/*---------------------------------------------------------------------------*/ -void -fader_off(void) -{ - onoroff = OFF; -} -/*---------------------------------------------------------------------------*/ diff --git a/platform/esb/apps/fader.h b/platform/esb/apps/fader.h deleted file mode 100644 index 95c82dde2..000000000 --- a/platform/esb/apps/fader.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - * Author: Adam Dunkels - * - */ -#ifndef __FADER_H__ -#define __FADER_H__ - -#include "contiki.h" - -PROCESS_NAME(fader_process); - -void fader_on(void); -void fader_off(void); - -#endif /* __FADER_H__ */ diff --git a/platform/esb/apps/helloworld.c b/platform/esb/apps/helloworld.c deleted file mode 100644 index ffc18a87f..000000000 --- a/platform/esb/apps/helloworld.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2006, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Configurable Sensor Network Application - * Architecture for sensor nodes running the Contiki operating system. - * - * - * ----------------------------------------------------------------- - * - * Author : Adam Dunkels, Joakim Eriksson, Niclas Finne - * Created : 2006-03-07 - * Updated : $Date: 2006/06/18 07:48:48 $ - * $Revision: 1.1 $ - */ - -#include "contiki-esb.h" -#include - -PROCESS(helloworld_process, "Helloworld"); - -AUTOSTART_PROCESSES(&helloworld_process); - -static struct etimer timer; - -/*---------------------------------------------------------------------*/ -PROCESS_THREAD(helloworld_process, ev, data) -{ - PROCESS_BEGIN(); - - etimer_set(&timer, CLOCK_SECOND * 2); - - while(1) { - PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_TIMER); - - etimer_reset(&timer); - leds_invert(LEDS_YELLOW); - printf("Hello world!\n"); - } - PROCESS_END(); -} -/*---------------------------------------------------------------------*/ diff --git a/platform/esb/apps/pinger.c b/platform/esb/apps/pinger.c deleted file mode 100644 index 4e6a807d1..000000000 --- a/platform/esb/apps/pinger.c +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -#include "contiki-esb.h" - -#include - -PROCESS(pinger, "Pinger"); - -static struct uip_udp_conn *conn; - -struct data { - uint8_t dummy_data[20]; - uint16_t id; - uint16_t seqno; - uint8_t pingpong; -#define PING 0 -#define PONG 1 -}; - -static unsigned char pingeron; -static struct etimer etimer; - -static unsigned short sent_seqno, last_seqno; - -#define PORT 9145 - -static int place_id = 0, packet_count = 0; - - -/*---------------------------------------------------------------------------*/ -static void -quit(void) -{ - process_exit(&pinger); - LOADER_UNLOAD(); -} -/*---------------------------------------------------------------------------*/ -static void -udp_appcall(void *arg) -{ - struct data *d; - /* char buf[50];*/ - d = (struct data *)uip_appdata; - - if(uip_newdata()) { - leds_toggle(LEDS_YELLOW); - /* beep();*/ - - /* if(uip_htons(d->seqno) != last_seqno + 1) { - leds_toggle(LEDS_RED); - beep_quick(2); - }*/ - /* last_seqno = uip_htons(d->seqno);*/ - /* uip_udp_send(sizeof(struct data));*/ - /* snprintf(buf, sizeof(buf), "Packet received id %d signal %u\n", - d->id, tr1001_sstrength()); - - rs232_print(buf);*/ - /* if(d->pingpong == PING) { - d->pingpong = PONG; - } else { - d->pingpong = PING; - d->seqno = uip_htons(uip_htons(d->seqno) + 1); - }*/ - /* uip_udp_send(sizeof(struct data)); - timer_restart(&timer);*/ - } else if(uip_poll()) { - if(pingeron && etimer_expired(&etimer) && packet_count > 0) { - --packet_count; - d->id = place_id; - d->pingpong = PING; - d->seqno = uip_htons(sent_seqno); - ++sent_seqno; - uip_udp_send(sizeof(struct data)); - etimer_reset(&etimer); - leds_toggle(LEDS_GREEN); - } - - if(packet_count == 0) { - pingeron = 0; - } - } -} -/*---------------------------------------------------------------------------*/ -static -PT_THREAD(config_thread(struct pt *pt, process_event_t ev, process_data_t data)) -{ - static struct etimer pushtimer; - static int counter; - - PT_BEGIN(pt); - - - while(1) { - - PT_WAIT_UNTIL(pt, ev == sensors_event && data == &button_sensor); - - beep(); - - leds_on(LEDS_YELLOW); - - etimer_set(&pushtimer, CLOCK_SECOND); - for(counter = 0; !etimer_expired(&pushtimer); ++counter) { - etimer_restart(&pushtimer); - PT_YIELD_UNTIL(pt, (ev == sensors_event && data == &button_sensor) || - etimer_expired(&pushtimer)); - } - - place_id = counter; - - beep_quick(place_id); - - pingeron = 1; - - packet_count = 20; - - etimer_set(&etimer, CLOCK_SECOND / 2); - - leds_off(LEDS_YELLOW); - - leds_on(LEDS_RED); - PT_WAIT_UNTIL(pt, packet_count == 0); - - pingeron = 0; - leds_off(LEDS_RED); - } - - PT_END(pt); -} -/*---------------------------------------------------------------------------*/ -PROCESS_THREAD(pinger, ev, data) -{ - static struct pt config_pt; - - PROCESS_BEGIN(); - - pingeron = 0; - - conn = udp_broadcast_new(UIP_HTONS(PORT), NULL); - - PT_INIT(&config_pt); - - button_sensor.configure(SENSORS_ACTIVE, 1); - - - while(1) { - - config_thread(&config_pt, ev, data); - - PROCESS_WAIT_EVENT(); - - printf("Event %d\n", ev); - - beep(); - - if(ev == tcpip_event) { - udp_appcall(data); - } - - if(ev == PROCESS_EVENT_TIMER && etimer_expired(&etimer)) { - tcpip_poll_udp(conn); - } - - } - - PROCESS_END(); -} -/*---------------------------------------------------------------------------*/ diff --git a/platform/esb/apps/pinger.h b/platform/esb/apps/pinger.h deleted file mode 100644 index 7af1b7440..000000000 --- a/platform/esb/apps/pinger.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ -#ifndef __PINGER_H__ -#define __PINGER_H__ - -#include "contiki.h" - -PROCESS_NAME(pinger); - -#endif /* __PINGER_H__ */ diff --git a/platform/esb/apps/radio-sniffer.c b/platform/esb/apps/radio-sniffer.c deleted file mode 100644 index 8bd4b93d1..000000000 --- a/platform/esb/apps/radio-sniffer.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2006, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * \file - * A brief description of what this file is. - * \author - * Adam Dunkels - */ - -#include "radio-sniffer.h" -#include "contiki-net.h" -#include "contiki-esb.h" -#include "net/hc.h" -#include "net/tcpdump.h" - -#include -/*---------------------------------------------------------------------------*/ -PROCESS(radio_sniffer_process, "Radio sniffer"); -AUTOSTART_PROCESSES(&radio_sniffer_process); -/*---------------------------------------------------------------------------*/ -static void -sniffer_callback(const struct radio_driver *driver) -{ - static char buf[40]; - static uint8_t packet[UIP_BUFSIZE]; - static int len; - len = driver->read(packet, sizeof(packet)); - if(len > 0) { - leds_blink(); - len = hc_inflate(packet, len); - tcpdump_format(packet, len, buf, sizeof(buf)); - printf("radio-sniffer %d: packet length %d, %s\n", node_id, len, buf); - } -} -/*---------------------------------------------------------------------------*/ -PROCESS_THREAD(radio_sniffer_process, ev, data) -{ - PROCESS_BEGIN(); - - tr1001_init(); - tr1001_driver.set_receive_function(sniffer_callback); - - printf("Radio sniffer started.\n"); - - while(1) { - PROCESS_WAIT_EVENT(); - } - PROCESS_END(); -} -/*---------------------------------------------------------------------------*/ -void -init_net(void) -{ -} -/*---------------------------------------------------------------------------*/ diff --git a/platform/esb/apps/radio-sniffer.h b/platform/esb/apps/radio-sniffer.h deleted file mode 100644 index 93d9adc66..000000000 --- a/platform/esb/apps/radio-sniffer.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2006, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * \file - * A brief description of what this file is. - * \author - * Adam Dunkels - */ - -#ifndef __RADIO_SNIFFER_H__ -#define __RADIO_SNIFFER_H__ - -#include "contiki.h" -PROCESS_NAME(radio_sniffer_process); - -#endif /* __RADIO_SNIFFER_H__ */ diff --git a/platform/esb/apps/radio-test.c b/platform/esb/apps/radio-test.c deleted file mode 100644 index ae03e1bdc..000000000 --- a/platform/esb/apps/radio-test.c +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) 2006, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * - * ----------------------------------------------------------------- - * - * Author : Adam Dunkels, Joakim Eriksson, Niclas Finne - * Created : 2006-03-07 - * Updated : $Date: 2010/10/19 18:29:05 $ - * $Revision: 1.3 $ - * - * Simple application to indicate connectivity between two nodes: - * - * - Red led indicates a packet sent via radio (one packet sent each second) - * - Yellow led indicates that this node can hear the other node but not - * necessary vice versa (unidirectional communication). - * - Green led indicates that both nodes can communicate with each - * other (bidirectional communication) - */ - -#include "contiki-esb.h" -#include - -PROCESS(radio_test_process, "Radio test"); -AUTOSTART_PROCESSES(&radio_test_process); - -#define ON 1 -#define OFF 0 - -#define HEADER "RTST" -#define PACKET_SIZE 20 -#define PORT 2345 - -struct indicator { - int onoff; - int led; - clock_time_t interval; - struct etimer timer; -}; - -/*---------------------------------------------------------------------*/ -static void -set(struct indicator *indicator, int onoff) { - if(indicator->onoff ^ onoff) { - indicator->onoff = onoff; - if(onoff) { - leds_on(indicator->led); - } else { - leds_off(indicator->led); - } - } - if(onoff) { - etimer_set(&indicator->timer, indicator->interval); - } -} -/*---------------------------------------------------------------------*/ -PROCESS_THREAD(radio_test_process, ev, data) -{ - static struct etimer send_timer; - static struct uip_udp_conn *conn; - static struct indicator recv, other, flash; - - PROCESS_BEGIN(); - - /* Initialize the indicators */ - recv.onoff = other.onoff = flash.onoff = OFF; - recv.interval = other.interval = CLOCK_SECOND; - flash.interval = 1; - recv.led = LEDS_YELLOW; - other.led = LEDS_GREEN; - flash.led = LEDS_RED; - - conn = udp_broadcast_new(UIP_HTONS(PORT), NULL); - etimer_set(&send_timer, CLOCK_SECOND); - - while(1) { - PROCESS_WAIT_EVENT(); - - if(ev == PROCESS_EVENT_TIMER) { - if(data == &send_timer) { - etimer_reset(&send_timer); - tcpip_poll_udp(conn); - - } else if(data == &other.timer) { - set(&other, OFF); - - } else if(data == &recv.timer) { - set(&recv, OFF); - - } else if(data == &flash.timer) { - set(&flash, OFF); - } - - } else if(ev == tcpip_event) { - - if(uip_poll()) { - /* send packet */ - memcpy(uip_appdata, HEADER, sizeof(HEADER)); - ((char *)uip_appdata)[sizeof(HEADER)] = recv.onoff; - /* send arbitrary data to fill the packet size */ - uip_send(uip_appdata, PACKET_SIZE); - - set(&flash, ON); - } - - if(uip_newdata()) { - /* packet received */ - if(uip_datalen() < PACKET_SIZE - || strncmp((char *)uip_appdata, HEADER, sizeof(HEADER))) { - /* invalid message */ - leds_blink(); - - } else { - set(&recv, ON); - set(&other, ((char *)uip_appdata)[sizeof(HEADER)] ? ON : OFF); - - /* synchronize the sending to keep the nodes from sending - simultaneously */ - etimer_set(&send_timer, CLOCK_SECOND); - etimer_adjust(&send_timer, - (int) (CLOCK_SECOND >> 1)); - - beep(); - } - } - } - } - PROCESS_END(); -} -/*---------------------------------------------------------------------*/ diff --git a/platform/esb/apps/sensor-output.c b/platform/esb/apps/sensor-output.c deleted file mode 100644 index 632b604b3..000000000 --- a/platform/esb/apps/sensor-output.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ -#include "contiki-esb.h" - -#include - -PROCESS(sensor_output_process, "Sensor output"); - -AUTOSTART_PROCESSES(&sensor_output_process); - -/*---------------------------------------------------------------------------*/ -PROCESS_THREAD(sensor_output_process, ev, data) -{ - struct sensors_sensor *s; - - PROCESS_BEGIN(); - - /* Activate some sensors to get sensor events */ - button_sensor.configure(SENSORS_ACTIVE, 1); - pir_sensor.configure(SENSORS_ACTIVE, 1); - vib_sensor.configure(SENSORS_ACTIVE, 1); - - while(1) { - PROCESS_WAIT_EVENT_UNTIL(ev == sensors_event); - - s = (struct sensors_sensor *)data; - printf("%s %d\n", s->type, s->value(0)); - - if (data == &button_sensor) leds_invert(LEDS_YELLOW); - if (data == &pir_sensor) leds_invert(LEDS_GREEN); - if (data == &vib_sensor) leds_invert(LEDS_RED); - } - - PROCESS_END(); -} -/*---------------------------------------------------------------------------*/ diff --git a/platform/esb/apps/sensor-output.h b/platform/esb/apps/sensor-output.h deleted file mode 100644 index 5c31d2d62..000000000 --- a/platform/esb/apps/sensor-output.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ -#ifndef __SENSOR_OUTPUT_H__ -#define __SENSOR_OUTPUT_H__ - -#include "contiki.h" - -PROCESS_NAME(sensor_output_process); - -#endif /* __SENSOR_OUTPUT_H__ */ diff --git a/platform/esb/apps/test-receiver.c b/platform/esb/apps/test-receiver.c deleted file mode 100644 index 5f315a715..000000000 --- a/platform/esb/apps/test-receiver.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2006, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * - * ----------------------------------------------------------------- - * - * Author : Adam Dunkels, Joakim Eriksson, Niclas Finne - * Created : 2006-03-07 - * Updated : $Date: 2010/10/19 18:29:05 $ - * $Revision: 1.2 $ - */ - -#include "contiki-esb.h" -#include - -PROCESS(test_receiver_process, "Test - Receiver"); -AUTOSTART_PROCESSES(&test_receiver_process); - -#define PORT 1234 - -PROCESS_THREAD(test_receiver_process, ev, data) -{ - static struct uip_udp_conn *conn; - - PROCESS_BEGIN(); - - conn = udp_broadcast_new(UIP_HTONS(PORT), NULL); - - while(1) { - PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event && uip_newdata()); - leds_invert(LEDS_YELLOW); - - /* Make sure the message is null terminated */ - ((char *) uip_appdata)[uip_datalen()] = 0; - printf("RECV: %s\n", (char *) uip_appdata); - - } - PROCESS_END(); -} -/*---------------------------------------------------------------------*/ diff --git a/platform/esb/apps/test-sender.c b/platform/esb/apps/test-sender.c deleted file mode 100644 index 7881c2704..000000000 --- a/platform/esb/apps/test-sender.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2006, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * - * ----------------------------------------------------------------- - * - * Author : Adam Dunkels, Joakim Eriksson, Niclas Finne - * Created : 2006-03-07 - * Updated : $Date: 2010/10/19 18:29:05 $ - * $Revision: 1.2 $ - */ - -#include "contiki-esb.h" - -PROCESS(test_sender_process, "Test - Sender"); -AUTOSTART_PROCESSES(&test_sender_process); - -#define PORT 1234 - -PROCESS_THREAD(test_sender_process, ev, data) -{ - static struct etimer timer; - static struct uip_udp_conn *conn; - - PROCESS_BEGIN(); - - conn = udp_broadcast_new(UIP_HTONS(PORT), NULL); - etimer_set(&timer, CLOCK_SECOND * 2); - - while(1) { - PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_TIMER); - etimer_reset(&timer); - - /* Send packet */ - tcpip_poll_udp(conn); - PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event && uip_poll()); - leds_invert(LEDS_YELLOW); - uip_send("Hello world", sizeof("Hello world")); - } - PROCESS_END(); -} -/*---------------------------------------------------------------------*/ diff --git a/platform/esb/buildscripts/Makefile.freebsd b/platform/esb/buildscripts/Makefile.freebsd deleted file mode 100644 index 489b4205b..000000000 --- a/platform/esb/buildscripts/Makefile.freebsd +++ /dev/null @@ -1,18 +0,0 @@ -ifndef JTAG - JTAG := $(CONTIKI)/platform/$(TARGET)/buildscripts/jtag/pyjtag/jtag.py -endif - -ifndef JTAG_PORT - JTAG_PORT = /dev/ppi0 -endif - -%.u: %.$(TARGET) - $(JTAG) -l $(JTAG_PORT) -e - $(JTAG) -l $(JTAG_PORT) -D -D -S -R 2048 -p $^ - $(JTAG) -l $(JTAG_PORT) -D -r - -r: - $(JTAG) -l $(JTAG_PORT) -r - -erase: - $(JTAG) -l $(JTAG_PORT) -e diff --git a/platform/esb/buildscripts/Makefile.unix b/platform/esb/buildscripts/Makefile.unix deleted file mode 100644 index 782b49500..000000000 --- a/platform/esb/buildscripts/Makefile.unix +++ /dev/null @@ -1,2 +0,0 @@ -%.u: %.ihex - msp430-jtag -eI $^ diff --git a/platform/esb/buildscripts/Makefile.win b/platform/esb/buildscripts/Makefile.win deleted file mode 100644 index 655a3d81e..000000000 --- a/platform/esb/buildscripts/Makefile.win +++ /dev/null @@ -1,11 +0,0 @@ -%.u: %.ihex -ifdef JTAG_PORT - msp430-jtag -l $(JTAG_PORT) -eI $^ -else - msp430-jtag -eI $^ -endif - -#CW=cw23 - -#%.u: %.ihex -# $(CW) -d f430p $^ diff --git a/platform/esb/buildscripts/jtag/pyjtag/_parjtag.so b/platform/esb/buildscripts/jtag/pyjtag/_parjtag.so deleted file mode 100755 index 76fe1ecba..000000000 Binary files a/platform/esb/buildscripts/jtag/pyjtag/_parjtag.so and /dev/null differ diff --git a/platform/esb/buildscripts/jtag/pyjtag/elf.py b/platform/esb/buildscripts/jtag/pyjtag/elf.py deleted file mode 100644 index 2ab16b1c2..000000000 --- a/platform/esb/buildscripts/jtag/pyjtag/elf.py +++ /dev/null @@ -1,318 +0,0 @@ -#!/usr/bin/env python -import struct - -# ELF object file reader -# (C) 2003 cliechti@gmx.net -# Python license - -# size alignment -# Elf32_Addr 4 4 Unsigned program address -# Elf32_Half 2 2 Unsigned medium integer -# Elf32_Off 4 4 Unsigned file offset -# Elf32_Sword 4 4 Signed large integer -# Elf32_Word 4 4 Unsigned large integer -# unsignedchar 1 1 Unsigned small integer - -#define EI_NIDENT 16 -#~ typedef struct{ - #~ unsigned char e_ident[EI_NIDENT]; - #~ Elf32_Half e_type; - #~ Elf32_Half e_machine; - #~ Elf32_Word e_version; - #~ Elf32_Addr e_entry; - #~ Elf32_Off e_phoff; - #~ Elf32_Off e_shoff; - #~ Elf32_Word e_flags; - #~ Elf32_Half e_ehsize; - #~ Elf32_Half e_phentsize; - #~ Elf32_Half e_phnum; - #~ Elf32_Half e_shentsize; - #~ Elf32_Half e_shnum; - #~ Elf32_Half e_shstrndx; -#~ } Elf32_Ehdr; - - -#Section Header -#~ typedef struct { - #~ Elf32_Word sh_name; - #~ Elf32_Word sh_type; - #~ Elf32_Word sh_flags; - #~ Elf32_Addr sh_addr; - #~ Elf32_Off sh_offset; - #~ Elf32_Word sh_size; - #~ Elf32_Word sh_link; - #~ Elf32_Word sh_info; - #~ Elf32_Word sh_addralign; - #~ Elf32_Word sh_entsize; -#~ } Elf32_Shdr; - -#~ typedef struct { - #~ Elf32_Word p_type; - #~ Elf32_Off p_offset; - #~ Elf32_Addr p_vaddr; - #~ Elf32_Addr p_paddr; - #~ Elf32_Word p_filesz; - #~ Elf32_Word p_memsz; - #~ Elf32_Word p_flags; - #~ Elf32_Word p_align; -#~ } Elf32_Phdr; - - -class ELFException(Exception): pass - -class ELFSection: - """read and store a section""" - Elf32_Shdr = "= section.sh_addr + section.sh_size) \ - and (not (section.sh_flags & ELFSection.SHF_ALLOC and section.sh_type != ELFSection.SHT_NOBITS) \ - or (p.p_offset <= section.sh_offset \ - and (p.p_offset + p.p_filesz >= section.sh_offset + section.sh_size)))): - return section.sh_addr + p.p_paddr - p.p_vaddr - return section.sh_addr - - def getSections(self): - """get sections relevant for the application""" - res = [] - for section in self.sections: - if section.sh_flags & ELFSection.SHF_ALLOC and section.sh_type != ELFSection.SHT_NOBITS: - res.append(section) - return res - - def __str__(self): - """pretty print for debug...""" - return "%s(self.e_type=%r, self.e_machine=%r, self.e_version=%r, sections=%r)" % ( - self.__class__.__name__, - self.e_type, self.e_machine, self.e_version, - [section.name for section in self.sections]) - - -if __name__ == '__main__': - print "This is only a module test!" - elf = ELFObject() - elf.fromFile(open("test.elf")) - if elf.e_type != ELFObject.ET_EXEC: - raise Exception("No executable") - print elf - - #~ print repr(elf.getSection('.text').data) - #~ print [(s.name, hex(s.sh_addr)) for s in elf.getSections()] - print "-"*20 - for p in elf.sections: print p - print "-"*20 - for p in elf.getSections(): print p - print "-"*20 - for p in elf.getProgrammableSections(): print p diff --git a/platform/esb/buildscripts/jtag/pyjtag/gen-ihex.py b/platform/esb/buildscripts/jtag/pyjtag/gen-ihex.py deleted file mode 100644 index c917ec975..000000000 --- a/platform/esb/buildscripts/jtag/pyjtag/gen-ihex.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env python -"""Test File generator. -This tool generates a hex file, of given size, ending on address -0xffff. - -USAGE: hen-ihex.py size_in_kilobyte - -The resulting Intel-hex file is output to stdout, use redirection -to save the data to a file. -""" - -#return a string with data in intel hex format -def makeihex(address, data): - out = [] - start = 0 - while start len(data): end = len(data) - out.append(_ihexline(address, [ord(x) for x in data[start:end]])) - start += 16 - address += 16 - out.append(_ihexline(address, [], end=1)) #append no data but an end line - return ''.join(out) - -def _ihexline(address, buffer, end=0): - out = [] - if end: - type = 1 - else: - type = 0 - out.append( ':%02X%04X%02X' % (len(buffer),address&0xffff,type) ) - sum = len(buffer) + ((address>>8)&255) + (address&255) - for b in buffer: - if b == None: b = 0 #substitute nonexistent values with zero - out.append('%02X' % (b&255) ) - sum += b&255 - out.append('%02X\n' %( (-sum)&255)) - return ''.join(out) - -if __name__ == '__main__': - import struct, sys - if len(sys.argv) != 2: - print __doc__ - sys.exit(1) - - size = int(sys.argv[1]) #in kilo - startadr = 0x10000 - 1024*size - data = ''.join([struct.pack(">H", x) for x in range(startadr, startadr+ 1024*size, 2)]) - print makeihex(startadr, data) diff --git a/platform/esb/buildscripts/jtag/pyjtag/install-pyjtag.nsi b/platform/esb/buildscripts/jtag/pyjtag/install-pyjtag.nsi deleted file mode 100644 index a2cb801b8..000000000 --- a/platform/esb/buildscripts/jtag/pyjtag/install-pyjtag.nsi +++ /dev/null @@ -1,108 +0,0 @@ -Name "install-pyjtag" -OutFile "install-pyjtag.exe" - -!define SF_SELECTED 1 -!define SF_SUBSEC 2 -!define SF_SUBSECEND 4 -!define SF_BOLD 8 -!define SF_RO 16 -!define SF_EXPAND 32 - -!define SECTION_OFF 0xFFFFFFFE - -LicenseText License -LicenseData license.txt - -SetOverwrite on -SetDateSave on - -; The default installation directory -InstallDir $PROGRAMFILES\mspgcc -; Registry key to check for directory (so if you install again, it will -; overwrite the old one automatically) -InstallDirRegKey HKLM SOFTWARE\mspgcc "rootdir" - -; The text to prompt the user to enter a directory -DirText "This will install the pyjtag executables. You can choose the same \ - directory as for the other mspgcc tools." - -; The text to prompt the user to enter a directory -ComponentText "Select which optional things you want installed." - -Section "msp430-jtag (required)" - SectionIn RO - SetOutPath $INSTDIR - - File /r bin - File /oname=license-pyjtag.txt license.txt - File /oname=readme-pyjtag.txt readme.txt - File /oname=bin\jtag.py jtag.py - - ; Write the installation path into the registry - WriteRegStr HKLM SOFTWARE\mspgcc "rootdir" "$INSTDIR" - ; Write the uninstall keys for Windows - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\mspgcc-pyjtag" "DisplayName" "mspgcc pyjtag (remove only)" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\mspgcc-pyjtag" "UninstallString" '"$INSTDIR\uninstall-pyjtag.exe"' - WriteUninstaller "uninstall-pyjtag.exe" -SectionEnd - -Section "giveio (needed on Win NT/2k/XP, but NOT on 9x/ME)" - SetOutPath $INSTDIR\bin - File ..\jtag\hardware_access\giveio\giveio.sys - File ..\jtag\hardware_access\giveio\loaddrv.exe - SetOutPath $INSTDIR - nsExec::ExecToLog '$INSTDIR\bin\loaddrv.exe install giveio $INSTDIR\bin\giveio.sys' - Pop $0 ;return value/error/timeout - IntCmp $0 2 ext_here ;assume its alredy installed - IntCmp $0 0 0 ext_err ext_err ;if not 0 -> error - nsExec::ExecToLog '$INSTDIR\bin\loaddrv.exe start giveio' - Pop $0 ;return value/error/timeout - IntCmp $0 0 0 ext_err ext_err ;if not 0 -> error - nsExec::ExecToLog '$INSTDIR\bin\loaddrv.exe starttype giveio auto' - Pop $0 ;return value/error/timeout - IntCmp $0 0 0 ext_err ext_err ;if not 0 -> error - WriteRegStr HKLM SOFTWARE\mspgcc "giveio" "started" - Goto ext_ok -ext_err: - DetailPrint "Error while installing and starting giveio" - MessageBox MB_OK|MB_ICONSTOP "Error while installing and starting giveio" - Goto ext_ok -ext_here: - DetailPrint "Installing giveio gave an error, assuming its already installed" -ext_ok: -SectionEnd - -; special uninstall section. -Section "Uninstall" - ; remove registry keys - DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\mspgcc-pyjtag" - DeleteRegKey HKLM SOFTWARE\NSIS_Example2 - ; remove files - Delete $INSTDIR\bin\msp430-jtag.exe - Delete $INSTDIR\bin\_parjtag.pyd - Delete $INSTDIR\bin\jtag.py - Delete $INSTDIR\bin\HIL.dll - Delete $INSTDIR\bin\MSP430mspgcc.dll - ;XXX python22.dll is left installed as it is used by pybsl and other tools - Delete $INSTDIR\license-pyjtag.txt - Delete $INSTDIR\readme-pyjtag.txt - ; giveio - ; if it was started by us, stop it - ReadRegStr $0 HKLM SOFTWARE\mspgcc "giveio" - StrCmp $0 '' no_giveio - nsExec::ExecToLog '$INSTDIR\bin\loaddrv.exe stop giveio' - Pop $0 ;return value/error/timeout - IntCmp $0 0 0 giveio_err giveio_err ;if not 0 -> error - nsExec::ExecToLog '$INSTDIR\bin\loaddrv.exe remove giveio' - Pop $0 ;return value/error/timeout - IntCmp $0 0 0 giveio_err giveio_err ;if not 0 -> error - Goto no_giveio -giveio_err: - DetailPrint "Error while uninstalling giveio service" - MessageBox MB_OK|MB_ICONSTOP "Error while uninstalling giveio service" -no_giveio: - Delete loaddrv.exe - Delete giveio.sys - ; MUST REMOVE UNINSTALLER, too - Delete $INSTDIR\uninstall-pyjtag.exe -SectionEnd diff --git a/platform/esb/buildscripts/jtag/pyjtag/jtag.py b/platform/esb/buildscripts/jtag/pyjtag/jtag.py deleted file mode 100644 index 0cb556a91..000000000 --- a/platform/esb/buildscripts/jtag/pyjtag/jtag.py +++ /dev/null @@ -1,604 +0,0 @@ -#!/usr/bin/env python -#Parallel JTAG programmer for the MSP430 embedded proccessor. -# -#(C) 2002 Chris Liechti -#this is distributed under a free software license, see license.txt -# -#Requires Python 2+ and the binary extension _parjtag. - -import sys -import _parjtag - -VERSION = "1.3" - -DEBUG = 0 #disable debug messages by default - - -#frame specific consts -ERASE_MASS = 2 -ERASE_MAIN = 1 -ERASE_SGMT = 0 - -#states -FREERUNNING = 0 -STOPPED = 1 - -#Configurations of the MSP430 driver -VERIFICATION_MODE = 0 #Verify data downloaded to FLASH memories. -RAMSIZE_OPTION = 1 #Change RAM used to download and program flash blocks -DEBUG_OPTION = 2 #Set debug level. Enables debug outputs. - -#enumeration of output formats for uploads -HEX = 0 -INTELHEX = 1 -BINARY = 2 - -#exceptions -class JTAGException(Exception): pass - -#for the use with memread -def hexdump( (adr, memstr) ): - """Print a hex dump of data collected with memread - arg1: tuple with adress, memory - return None""" - count = 0 - ascii = '' - for value in map(ord, memstr): - if not count: print "%04x: " % adr, - print "%02x" % value, - ascii += (32 <= value < 128) and chr(value) or '.' - count += 1 - adr += 1 - if count == 16: - count = 0 - print " ", ascii - ascii = '' - if count < 16: print " "*(16-count), " ", ascii - -def makeihex( (address, data) ): - """work though the data and output lines in inzel hex format. - and end tag is appended""" - start = 0 - while start len(data): end = len(data) - _ihexline(address, [ord(x) for x in data[start:end]]) - start += 16 - address += 16 - _ihexline(address, [], type=1) #append no data but an end line - -def _ihexline(address, buffer, type=0): - """encode one line, output with checksum""" - sys.stdout.write( ':%02X%04X%02X' % (len(buffer), address & 0xffff, type) ) - sum = len(buffer) + ((address >> 8) & 255) + (address & 255) - for b in buffer: - if b == None: b = 0 #substitute nonexistent values with zero - sys.stdout.write('%02X' % (b & 255)) - sum += b&255 - sys.stdout.write('%02X\n' %( (-sum) & 255)) - - -class Segment: - """store a string with memory contents along with its startaddress""" - def __init__(self, startaddress = 0, data=None): - if data is None: - self.data = '' - else: - self.data = data - self.startaddress = startaddress - - def __getitem__(self, index): - return self.data[index] - - def __len__(self): - return len(self.data) - - def __repr__(self): - return "Segment(startaddress = 0x%04x, data=%r)" % (self.startaddress, self.data) - -class Memory: - """represent memory contents. with functions to load files""" - def __init__(self, filename=None): - self.segments = [] - if filename: - self.filename = filename - self.loadFile(filename) - - def append(self, seg): - self.segments.append(seg) - - def __getitem__(self, index): - return self.segments[index] - - def __len__(self): - return len(self.segments) - - def loadIHex(self, file): - """load data from a (opened) file in Intel-HEX format""" - segmentdata = [] - currentAddr = 0 - startAddr = 0 - lines = file.readlines() - for l in lines: - if not l.strip(): continue #skip empty lines - if l[0] != ':': raise Exception("File Format Error\n") - l = l.strip() #fix CR-LF issues... - length = int(l[1:3],16) - address = int(l[3:7],16) - type = int(l[7:9],16) - check = int(l[-2:],16) - if type == 0x00: - if currentAddr != address: - if segmentdata: - self.segments.append( Segment(startAddr, ''.join(segmentdata)) ) - startAddr = currentAddr = address - segmentdata = [] - for i in range(length): - segmentdata.append( chr(int(l[9+2*i:11+2*i],16)) ) - currentAddr = length + currentAddr - elif type == 0x01: - pass - else: - sys.stderr.write("Ignored unknown field (type 0x%02x) in ihex file.\n" % type) - if segmentdata: - self.segments.append( Segment(startAddr, ''.join(segmentdata)) ) - - def loadTIText(self, file): - """load data from a (opened) file in TI-Text format""" - next = 1 - currentAddr = 0 - startAddr = 0 - segmentdata = [] - #Convert data for MSP430, TXT-File is parsed line by line - while next >= 1: - #Read one line - l = file.readline() - if not l: break #EOF - l = l.strip() - if l[0] == 'q': break - elif l[0] == '@': #if @ => new address => send frame and set new addr. - #create a new segment - if segmentdata: - self.segments.append( Segment(startAddr, ''.join(segmentdata)) ) - startAddr = currentAddr = int(l[1:],16) - segmentdata = [] - else: - for i in l.split(): - segmentdata.append(chr(int(i,16))) - if segmentdata: - self.segments.append( Segment(startAddr, ''.join(segmentdata)) ) - - def loadELF(self, file): - """load data from a (opened) file in ELF object format. - File must be seekable""" - import elf - obj = elf.ELFObject() - obj.fromFile(file) - if obj.e_type != elf.ELFObject.ET_EXEC: - raise Exception("No executable") - for section in obj.getSections(): - if DEBUG: - sys.stderr.write("ELF section %s at 0x%04x %d bytes\n" % (section.name, section.lma, len(section.data))) - if len(section.data): - self.segments.append( Segment(section.lma, section.data) ) - - def loadFile(self, filename): - """fill memory with the contents of a file. file type is determined from extension""" - #TODO: do a contents based detection - if filename[-4:].lower() == '.txt': - self.loadTIText(open(filename, "rb")) - elif filename[-4:].lower() in ('.a43', '.hex'): - self.loadIHex(open(filename, "rb")) - else: - self.loadELF(open(filename, "rb")) - - def getMemrange(self, fromadr, toadr): - """get a range of bytes from the memory. unavailable values are filled with 0xff.""" - res = '' - toadr = toadr + 1 #python indxes are excluding end, so include it - while fromadr < toadr: - for seg in self.segments: - segend = seg.startaddress + len(seg.data) - if seg.startaddress <= fromadr and fromadr < segend: - if toadr > segend: #not all data in segment - catchlength = segend-fromadr - else: - catchlength = toadr-fromadr - res = res + seg.data[fromadr-seg.startaddress : fromadr-seg.startaddress+catchlength] - fromadr = fromadr + catchlength #adjust start - if len(res) >= toadr-fromadr: - break #return res - else: #undefined memory is filled with 0xff - res = res + chr(255) - fromadr = fromadr + 1 #adjust start - return res - -class JTAG: - """wrap the _parjtag extension""" - - def __init__(self): - self.showprogess = 0 - - def connect(self, lpt=None): - """connect to specified or default port""" - if lpt is None: - _parjtag.connect() - else: - _parjtag.connect(lpt) - - def close(self): - """release JTAG""" - _parjtag.release() - - def uploadData(self, startaddress, size): - """upload a datablock""" - if DEBUG > 1: sys.stderr.write("* uploadData()\n") - return _parjtag.memread(startaddress, size) - - def actionMassErase(self): - """Erase the flash memory completely (with mass erase command)""" - sys.stderr.write("Mass Erase...\n") - _parjtag.memerase(ERASE_MASS) - - def actionMainErase(self): - """Erase the MAIN flash memory, leave the INFO mem""" - sys.stderr.write("Erase Main Flash...\n") - _parjtag.memerase(ERASE_MAIN, 0xfffe) - - def makeActionSegmentErase(self, address): - """Selective segment erase""" - class SegmentEraser: - def __init__(self, segaddr): - self.address = segaddr - def __call__(self): - sys.stderr.write("Erase Segment @ 0x%04x...\n" % self.address) - _parjtag.memerase(ERASE_SGMT, self.address) - return SegmentEraser(address) - - def actionEraseCheck(self): - """check the erasure of required flash cells.""" - sys.stderr.write("Erase Check by file ...\n") - if self.data is not None: - for seg in self.data: - data = _parjtag.memread(seg.startaddress, len(seg.data)) - if data != '\xff'*len(seg.data): raise JTAGException("Erase check failed") - else: - raise JTAGException("cannot do erase check against data with not knowing the actual data") - - def progess_update(self, count, total): - sys.stderr.write("\r%d%%" % (100*count/total)) - - def actionProgram(self): - """program data into flash memory.""" - if self.data is not None: - sys.stderr.write("Program ...\n") - if self.showprogess: - _parjtag.set_flash_callback(self.progess_update) - bytes = 0 - for seg in self.data: - _parjtag.memwrite(seg.startaddress, seg.data) - bytes += len(seg.data) - if self.showprogess: - sys.stderr.write("\r") - sys.stderr.write("%i bytes programmed.\n" % bytes) - else: - raise JTAGException("programming without data not possible") - - def actionVerify(self): - """Verify programmed data""" - if self.data is not None: - sys.stderr.write("Verify ...\n") - for seg in self.data: - data = _parjtag.memread(seg.startaddress, len(seg.data)) - if data != seg.data: raise JTAGException("Verify failed") - else: - raise JTAGException("verify without data not possible") - - def actionReset(self): - """perform a reset""" - sys.stderr.write("Reset device ...\n") - _parjtag.reset(0, 0) - - def actionRun(self, address): - """start program at specified address""" - raise NotImplementedError - #sys.stderr.write("Load PC with 0x%04x ...\n" % address) - - def funclet(self): - """download and start funclet""" - sys.stderr.write("Download and execute of funclet...\n") - if len(self.data) > 1: - raise JTAGException("don't know how to handle multiple segments in funclets") - _parjtag.funclet(self.data[0].data) - sys.stderr.write("Funclet OK.\n") - -def usage(): - """print some help message""" - sys.stderr.write(""" -USAGE: %s [options] [file] -Version: %s - -If "-" is specified as file the data is read from the stdinput. -A file ending with ".txt" is considered to be in TIText format all -other filenames are considered IntelHex. - -General options: - -h, --help Show this help screen. - -l, --lpt=name Specify an other parallel port. - (defaults to LPT1 (/dev/parport0 on unix) - -D, --debug Increase level of debug messages. This won't be - very useful for the average user... - -I, --intelhex Force fileformat to IntelHex - -T, --titext Force fileformat to be TIText - -f, --funclet The given file is a funclet (a small program to - be run in RAM) - -R, --ramsize Specify the amont of RAM to be used to program - flash (default 256). - -Program Flow Specifiers: - - -e, --masserase Mass Erase (clear all flash memory) - -m, --mainerase Erase main flash memory only - --eraseinfo Erase info flash memory only (0x1000-0x10ff) - --erase=address Selectively erase segment at the specified address - -E, --erasecheck Erase Check by file - -p, --program Program file - -v, --verify Verify by file - -The order of the above options matters! The table is ordered by normal -execution order. For the options "Epv" a file must be specified. -Program flow specifiers default to "p" if a file is given. -Don't forget to specify "e" or "eE" when programming flash! -"p" already verifies the programmed data, "v" adds an additional -verification though uploading the written data for a 1:1 compare. -No default action is taken if "p" and/or "v" is given, say specifying -only "v" does a check by file of a programmed device. - -Data retreiving: - -u, --upload=addr Upload a datablock (see also: -s). - -s, --size=num Size of the data block do upload. (Default is 2) - -x, --hex Show a hexadecimal display of the uploaded data. - (Default) - -b, --bin Get binary uploaded data. This can be used - to redirect the output into a file. - -i, --ihex Uploaded data is output in Intel HEX format. - This can be used to clone a device. - -Do before exit: - -g, --go=address Start programm execution at specified address. - This implies option "w" (wait) - -r, --reset Reset connected MSP430. Starts application. - This is a normal device reset and will start - the programm that is specified in the reset - interrupt vector. (see also -g) - -w, --wait Wait for before closing parallel port. -""" % (sys.argv[0], VERSION)) - -def main(): - global DEBUG - import getopt - filetype = None - filename = None - reset = 0 - wait = 0 - goaddr = None - jtag = JTAG() - toinit = [] - todo = [] - startaddr = None - size = 2 - outputformat= HEX - lpt = None - funclet = None - ramsize = None - - sys.stderr.write("MSP430 parallel JTAG programmer Version: %s\n" % VERSION) - try: - opts, args = getopt.getopt(sys.argv[1:], - "hl:weEmpvrg:Du:d:s:xbiITfR:S", - ["help", "lpt=", "wait" - "masserase", "erasecheck", "mainerase", "program", - "erase=", "eraseinfo", - "verify", "reset", "go=", "debug", - "upload=", "download=", "size=", "hex", "bin", "ihex", - "intelhex", "titext", "funclet", "ramsize=", "progress"] - ) - except getopt.GetoptError: - # print help information and exit: - usage() - sys.exit(2) - - for o, a in opts: - if o in ("-h", "--help"): - usage() - sys.exit() - elif o in ("-l", "--lpt"): - lpt = a - elif o in ("-w", "--wait"): - wait = 1 - elif o in ("-e", "--masserase"): - toinit.append(jtag.actionMassErase) #Erase Flash - elif o in ("-E", "--erasecheck"): - toinit.append(jtag.actionEraseCheck) #Erase Check (by file) - elif o in ("-m", "--mainerase"): - toinit.append(jtag.actionMainErase) #Erase main Flash - elif o == "--erase": - try: - seg = int(a, 0) - toinit.append(jtag.makeActionSegmentErase(seg)) - except ValueError: - sys.stderr.write("segment address must be a valid number in dec, hex or octal\n") - sys.exit(2) - elif o == "--eraseinfo": - toinit.append(jtag.makeActionSegmentErase(0x1000)) - toinit.append(jtag.makeActionSegmentErase(0x1080)) - elif o in ("-p", "--program"): - todo.append(jtag.actionProgram) #Program file - elif o in ("-v", "--verify"): - todo.append(jtag.actionVerify) #Verify file - elif o in ("-r", "--reset"): - reset = 1 - elif o in ("-g", "--go"): - try: - goaddr = int(a, 0) #try to convert decimal - except ValueError: - sys.stderr.write("upload address must be a valid number in dec, hex or octal\n") - sys.exit(2) - elif o in ("-D", "--debug"): - DEBUG = DEBUG + 1 - elif o in ("-u", "--upload"): - try: - startaddr = int(a, 0) #try to convert number of any base - except ValueError: - sys.stderr.write("upload address must be a valid number in dec, hex or octal\n") - sys.exit(2) - elif o in ("-s", "--size"): - try: - size = int(a, 0) - except ValueError: - sys.stderr.write("upload address must be a valid number in dec, hex or octal\n") - sys.exit(2) - #outut formats - elif o in ("-x", "--hex"): - outputformat = HEX - elif o in ("-b", "--bin"): - outputformat = BINARY - elif o in ("-i", "--ihex"): - outputformat = INTELHEX - #input formats - elif o in ("-I", "--intelhex"): - filetype = 0 - elif o in ("-T", "--titext"): - filetype = 1 - #others - elif o in ("-f", "--funclet"): - funclet = 1 - elif o in ("-R", "--ramsize"): - try: - ramsize = int(a, 0) - except ValueError: - sys.stderr.write("ramsize must be a valid number in dec, hex or octal\n") - sys.exit(2) - elif o in ("-S", "--progress"): - jtag.showprogess = 1 - - if len(args) == 0: - sys.stderr.write("Use -h for help\n") - elif len(args) == 1: #a filename is given - if not funclet: - if not todo: #if there are no actions yet - todo.extend([ #add some useful actions... - jtag.actionProgram, - ]) - filename = args[0] - else: #number of args is wrong - usage() - sys.exit(2) - - if DEBUG: #debug infos - sys.stderr.write("debug level set to %d\n" % DEBUG) - _parjtag.configure(DEBUG_OPTION, DEBUG) - sys.stderr.write("python version: %s\n" % sys.version) - - - #sanity check of options - if goaddr and reset: - sys.stderr.write("Warning: option --reset ignored as --go is specified!\n") - reset = 0 - - if startaddr and reset: - sys.stderr.write("Warning: option --reset ignored as --upload is specified!\n") - reset = 0 - - #prepare data to download - jtag.data = Memory() #prepare downloaded data - if filetype is not None: #if the filetype is given... - if filename is None: - raise ValueError("no filename but filetype specified") - if filename == '-': #get data from stdin - file = sys.stdin - else: - file = open(filename,"rb") #or from a file - if filetype == 0: #select load function - jtag.data.loadIHex(file) #intel hex - elif filetype == 1: - jtag.data.loadTIText(file) #TI's format - else: - raise ValueError("illegal filetype specified") - else: #no filetype given... - if filename == '-': #for stdin: - jtag.data.loadIHex(sys.stdin) #assume intel hex - elif filename: - jtag.data.loadFile(filename) #autodetect otherwise - - if DEBUG > 5: sys.stderr.write("File: %r\n" % filename) - - try: - jtag.connect(lpt) #try to open port - except IOError: - raise #do not handle here - else: #continue if open was successful - if ramsize is not None: - _parjtag.configure(RAMSIZE_OPTION, ramsize) - #initialization list - if toinit: #erase and erase check - if DEBUG: sys.stderr.write("Preparing device ...\n") - for f in toinit: f() - - #work list - if todo: - if DEBUG > 0: #debug - #show a nice list of sheduled actions - sys.stderr.write("TODO list:\n") - for f in todo: - try: - sys.stderr.write(" %s\n" % f.func_name) - except AttributeError: - sys.stderr.write(" %r\n" % f) - for f in todo: f() #work through todo list - - if reset: #reset device first if desired - jtag.actionReset() - - if funclet is not None: #download and start funclet - jtag.funclet() - - if goaddr is not None: #start user programm at specified address - jtag.actionRun(goaddr) #load PC and execute - - #upload datablock and output - if startaddr is not None: - if goaddr: #if a program was started... - raise NotImplementedError - #TODO: - #sys.stderr.write("Waiting to device for reconnect for upload: ") - data = jtag.uploadData(startaddr, size) #upload data - if outputformat == HEX: #depending on output format - hexdump( (startaddr, data) ) #print a hex display - elif outputformat == INTELHEX: - makeihex( (startaddr, data) ) #ouput a intel-hex file - else: - sys.stdout.write(data) #binary output w/o newline! - wait = 0 #wait makes no sense as after the upload the device is still stopped - - if wait: #wait at the end if desired - sys.stderr.write("Press ...\n") #display a prompt - raw_input() #wait for newline - - _parjtag.reset(1, 1) #reset and release target - #~ jtag.actionReset() - jtag.close() #Release communication port - -if __name__ == '__main__': - try: - main() - except SystemExit: - raise #let pass exit() calls - except KeyboardInterrupt: - if DEBUG: raise #show full trace in debug mode - sys.stderr.write("user abort.\n") #short messy in user mode - sys.exit(1) #set errorlevel for script usage - except Exception, msg: #every Exception is caught and displayed - if DEBUG: raise #show full trace in debug mode - sys.stderr.write("\nAn error occoured:\n%s\n" % msg) #short messy in user mode - sys.exit(1) #set errorlevel for script usage diff --git a/platform/esb/buildscripts/jtag/pyjtag/license.txt b/platform/esb/buildscripts/jtag/pyjtag/license.txt deleted file mode 100644 index 810a2d24c..000000000 --- a/platform/esb/buildscripts/jtag/pyjtag/license.txt +++ /dev/null @@ -1,62 +0,0 @@ -Copyright (c) 2001-2002 Chris Liechti - -All Rights Reserved. - -This is the Python license. In short, you can use this product in -commercial and non-commercial applications, modify it, redistribute it. -A notification to the author when you use and/or modify it is welcome. - -TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING THIS SOFTWARE -============================================ - -LICENSE AGREEMENT ------------------ - -1. This LICENSE AGREEMENT is between the copyright holder of this -product, and the Individual or Organization ("Licensee") accessing -and otherwise using this product in source or binary form and its -associated documentation. - -2. Subject to the terms and conditions of this License Agreement, -the copyright holder hereby grants Licensee a nonexclusive, -royalty-free, world-wide license to reproduce, analyze, test, -perform and/or display publicly, prepare derivative works, distribute, -and otherwise use this product alone or in any derivative version, -provided, however, that copyright holders License Agreement and -copyright holders notice of copyright are retained in this product -alone or in any derivative version prepared by Licensee. - -3. In the event Licensee prepares a derivative work that is based on -or incorporates this product or any part thereof, and wants to make -the derivative work available to others as provided herein, then -Licensee hereby agrees to include in any such work a brief summary of -the changes made to this product. - -4. The copyright holder is making this product available to Licensee -on an "AS IS" basis. THE COPYRIGHT HOLDER MAKES NO REPRESENTATIONS -OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE, BUT NOT -LIMITATION, THE COPYRIGHT HOLDER MAKES NO AND DISCLAIMS ANY -REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS FOR -ANY PARTICULAR PURPOSE OR THAT THE USE OF THIS PRODUCT WILL -NOT INFRINGE ANY THIRD PARTY RIGHTS. - -5. THE COPYRIGHT HOLDER SHALL NOT BE LIABLE TO LICENSEE OR ANY -OTHER USERS OF THIS PRODUCT FOR ANY INCIDENTAL, SPECIAL, OR -CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF MODIFYING, -DISTRIBUTING, OR OTHERWISE USING THIS PRODUCT, OR ANY -DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY -THEREOF. - -6. This License Agreement will automatically terminate upon a -material breach of its terms and conditions. - -7. Nothing in this License Agreement shall be deemed to create any -relationship of agency, partnership, or joint venture between the -copyright holder and Licensee. This License Agreement does not grant -permission to use trademarks or trade names from the copyright holder -in a trademark sense to endorse or promote products or services of -Licensee, or any third party. - -8. By copying, installing or otherwise using this product, Licensee -agrees to be bound by the terms and conditions of this License -Agreement. diff --git a/platform/esb/buildscripts/jtag/pyjtag/makefile b/platform/esb/buildscripts/jtag/pyjtag/makefile deleted file mode 100644 index 5482fa2f1..000000000 --- a/platform/esb/buildscripts/jtag/pyjtag/makefile +++ /dev/null @@ -1,33 +0,0 @@ - -.PHONY: all FORCE clean windist - -all: windist - -#wrap py to exe and build windows installer -windist: - python setup.py py2exe - rm -r bin - mv dist/jtag/jtag.exe dist/msp430-jtag.exe - mv dist/jtag/* dist/ - rmdir dist/jtag - mv dist bin - rm -r build - - -#generate test files -fill60k.a43: - python gen-ihex.py 60 >$@ -fill48k.a43: - python gen-ihex.py 48 >$@ -fill32k.a43: - python gen-ihex.py 32 >$@ -fill16k.a43: - python gen-ihex.py 16 >$@ -fill8k.a43: - python gen-ihex.py 8 >$@ -fill4k.a43: - python gen-ihex.py 4 >$@ - -#clean up the mess... -clean: - rm -r dist build bin \ No newline at end of file diff --git a/platform/esb/buildscripts/jtag/pyjtag/readme.txt b/platform/esb/buildscripts/jtag/pyjtag/readme.txt deleted file mode 100644 index bdd3da6c2..000000000 --- a/platform/esb/buildscripts/jtag/pyjtag/readme.txt +++ /dev/null @@ -1,182 +0,0 @@ -pyJTAG ------- - -Software to talk to the parallel port JTAG PCB as seen with the FET kits. -It is released under a free software license, -see license.txt for more details. - -(C) 2002-2003 Chris Liechti - -Features --------- - -- understands TI-Text and Intel-hex -- download to Flash and/or RAM, erase, verify -- reset device -- load addres into R0/PC and run -- upload a memory block MSP->PC (output as binary data or hex dump) -- written in Python, runs on Win32, Linux, BSD -- use per command line, or in a Python script - -Requirements ------------- -- Linux, BSD, Un*x or Windows PC -- Python 2.0 or newer, 2.2 recomeded -- Parallel JTAG hardware with an MSP430 device connected - -Installation ------------- -Python installations are available from www.python.org. On Windows simply -use the installer. The win32all package has an installer too. These -installations should run fine with the deafults. - -On Linux just Python is needed. On some distributions is Python 1.5.2 -installed per default. You may meed to change the first line in the script -from "python" to "python2". Maybe Python 2.x is in a separate package that -has to be installed. There are rpm and deb binary packages and a source -tarball available through the Python homepage. - -The pyjtag archive can simply be unpacked to a directory, Windows users -can use WinZip or WinRar among others to extract the gzipped tar file. -If you want to run it from everywhere the directory where the file jtag.py -is, should be added to the PATH. -Look at "~/.profile", "/etc/profile" on Linux, "autoexec.bat" on Win9x/ME, -System Properties/Environment in Win2000/NT/XP. - -_parjtag.so/dll from the jtag archive must be copied to the same directory as -jtag.py. On Windows also MSP430mspgcc.dll and HIL.dll must be located in the -same dir or somewhere in the PATH. - -Short introduction ------------------- -This software uses the JTAG hardware that comes with the FET kits. It is -connected to the parallel port. - -The program can be started by typing "python jtag.py" in a console. Often -it works also with just "jtag.py" or "./jtag.py". - -USAGE: jtag.py [options] [file] -If "-" is specified as file the data is read from the stdinput. -A file ending with ".txt" is considered to be in TIText format all -other filenames are considered IntelHex. - -General options: - -h, --help Show this help screen. - -l, --lpt=name Specify an other parallel port. - (defaults to LPT1 (/dev/parport0 on unix) - -D, --debug Increase level of debug messages. This won't be - very useful for the average user... - -I, --intelhex Force fileformat to IntelHex - -T, --titext Force fileformat to be TIText - -f, --funclet The given file is a funclet (a small program to - be run in RAM) - -R, --ramsize Specify the amont of RAM to be used to program - flash (default 256). - -Program Flow Specifiers: - - -e, --masserase Mass Erase (clear all flash memory) - -m, --mainerase Erase main flash memory only - --eraseinfo Erase info flash memory only (0x1000-0x10ff) - --erase=address Selectively erase segment at the specified address - -E, --erasecheck Erase Check by file - -p, --program Program file - -v, --verify Verify by file - -The order of the above options matters! The table is ordered by normal -execution order. For the options "Epv" a file must be specified. -Program flow specifiers default to "p" if a file is given. -Don't forget to specify "e" or "eE" when programming flash! -"p" already verifies the programmed data, "v" adds an additional -verification though uploading the written data for a 1:1 compare. -No default action is taken if "p" and/or "v" is given, say specifying -only "v" does a check by file of a programmed device. - -Data retreiving: - -u, --upload=addr Upload a datablock (see also: -s). - -s, --size=num Size of the data block do upload. (Default is 2) - -x, --hex Show a hexadecimal display of the uploaded data. - (Default) - -b, --bin Get binary uploaded data. This can be used - to redirect the output into a file. - -i, --ihex Uploaded data is output in Intel HEX format. - This can be used to clone a device. - -Do before exit: - -g, --go=address Start programm execution at specified address. - This implies option "w" (wait) - -r, --reset Reset connected MSP430. Starts application. - This is a normal device reset and will start - the programm that is specified in the reset - interrupt vector. (see also -g) - -w, --wait Wait for before closing parallel port. - - -Examples --------- -These examples assume that you have added the installation directory to -the PATH. Type the full path to jtag.py otherwise and maybe use -"python jtag.py". Depending on installation it may also appear under the -name "msp430-jtag". - -jtag.py -e - Only erase flash. - -jtag.py -eErw 6port.a43 - Erase flash, erase check, download an executable, run it (reset) - and wait. - -jtag.py -mS -R 2048 6port.a43 - Use ramsize option on a device with 2k RAM to speed up - download. Of course any value from 128B up to the maximum - a device has is allowed. - The progress and mainerase options are also activated. - Only erasing the main memory is useful to keep calibration - data in the information memory. - -jtag.py 6port.a43 - Download of an executable to en empty (new or erased) device. - (Note that in new devices some of the first bytes in the - information memory are random data. If data should be - downloaded there, specify -eE.) - -jtag.py --go=0x220 ramtest.a43 - Download a program into RAM and run it, may not work - with all devices. - -jtag.py -f blinking.a43 - Download a program into RAM and run it. It must be - a special format with "startadr", "entrypoint", - "exitpoint" as the first three words in the data - and it must end on "jmp $". See MSP430debug sources - for more info. - -jtag.py -u 0x0c00 -s 1024 - Get a memory dump in HEX, from the bootstrap loader. - or save the binary in a file: - "python jtag.py -u 0x0c00 -s 1024 -b >dump.bin" - or as an intel-hex file: - "python jtag.py -u 0x0c00 -s 1024 -i >dump.a43" - -jtag.py -r - Just start the user program (with a reset). - -cat 6port.a43|jtag.py -e - - Pipe the data from "cat" to jtag.py to erase and program the - flash. (un*x example, don't forget the dash at the end of the - line) - -History -------- -1.0 public release -1.1 fix of verify error -1.2 use the verification during programming -1.3 meinerase, progress options, ihex output - -References ----------- -- Python: http://www.python.org - -- Texas Instruments MSP430 Homepage, links to Datasheets and Application - Notes: http://www.ti.com/sc/msp430 - diff --git a/platform/esb/buildscripts/jtag/pyjtag/setup.py b/platform/esb/buildscripts/jtag/pyjtag/setup.py deleted file mode 100644 index 982b58340..000000000 --- a/platform/esb/buildscripts/jtag/pyjtag/setup.py +++ /dev/null @@ -1,9 +0,0 @@ -# setup.py -from distutils.core import setup -import glob -import py2exe - -setup( - name="msp430-jtag", - scripts=["jtag.py"], - ) \ No newline at end of file diff --git a/platform/esb/cfs-coffee-arch.c b/platform/esb/cfs-coffee-arch.c deleted file mode 100644 index 558f079db..000000000 --- a/platform/esb/cfs-coffee-arch.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2008, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * \file - * Coffee architecture-dependent functionality for the ESB platform. - * \author - * Nicolas Tsiftes - * Niclas Finne - */ - -#include "cfs-coffee-arch.h" - -static const unsigned char nullb[COFFEE_SECTOR_SIZE < 32 ? COFFEE_SECTOR_SIZE : 32] = {0}; - -void -cfs_coffee_arch_erase(uint16_t sector) -{ - unsigned int i; - for(i = 0; i <= COFFEE_SECTOR_SIZE - sizeof(nullb); i += sizeof(nullb)) { - eeprom_write(COFFEE_START + sector * COFFEE_SECTOR_SIZE + i, - (unsigned char *)nullb, sizeof(nullb)); - } - if(i < COFFEE_SECTOR_SIZE) { - eeprom_write(COFFEE_START + sector * COFFEE_SECTOR_SIZE + i, - (unsigned char *)nullb, COFFEE_SECTOR_SIZE - i); - - } -} diff --git a/platform/esb/cfs-coffee-arch.h b/platform/esb/cfs-coffee-arch.h deleted file mode 100644 index 7fd0ec604..000000000 --- a/platform/esb/cfs-coffee-arch.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2008, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * \file - * Coffee architecture-dependent header for the ESB platform. - * \author - * Nicolas Tsiftes - * Niclas Finne - */ - -#ifndef CFS_COFFEE_ARCH_H -#define CFS_COFFEE_ARCH_H - -#include "contiki-conf.h" -#include "dev/eeprom.h" - -#define COFFEE_SECTOR_SIZE 1024UL -#define COFFEE_PAGE_SIZE 64UL -#define COFFEE_START COFFEE_SECTOR_SIZE -#define COFFEE_SIZE (32 * 1024U - COFFEE_START) -#define COFFEE_NAME_LENGTH 16 -#define COFFEE_MAX_OPEN_FILES 2 -#define COFFEE_FD_SET_SIZE 2 -#define COFFEE_LOG_TABLE_LIMIT 16 -#define COFFEE_DYN_SIZE 1024 -#define COFFEE_LOG_SIZE 256 - -#define COFFEE_MICRO_LOGS 0 - -#if COFFEE_START < CFS_EEPROM_CONF_OFFSET -#error COFFEE_START must be at least as large as CFS_EEPROM_CONF_OFFSET -#error Change in cfs-coffee-arch.h -#endif /* COFFEE_START < CFS_EEPROM_CONF_OFFSET */ - -#define COFFEE_WRITE(buf, size, offset) \ - eeprom_write(COFFEE_START + (offset), (unsigned char *)(buf), (size)) - -#define COFFEE_READ(buf, size, offset) \ - eeprom_read(COFFEE_START + (offset), (unsigned char *)(buf), (size)) - -#define COFFEE_ERASE(sector) cfs_coffee_arch_erase(sector) - -void cfs_coffee_arch_erase(uint16_t sector); - -typedef int16_t coffee_page_t; - -#endif /* !COFFEE_ARCH_H */ diff --git a/platform/esb/contiki-conf.h b/platform/esb/contiki-conf.h deleted file mode 100644 index ad11e2142..000000000 --- a/platform/esb/contiki-conf.h +++ /dev/null @@ -1,124 +0,0 @@ -#ifndef __CONTIKI_CONF_H__ -#define __CONTIKI_CONF_H__ - -#define PLATFORM_HAS_LEDS 1 -#define PLATFORM_HAS_BUTTON 1 -#define PLATFORM_HAS_BATTERY 1 - -/* DCO speed resynchronization for more robust UART, etc. */ -#define DCOSYNCH_CONF_ENABLED 1 -#define DCOSYNCH_CONF_PERIOD 30 - -#define SERIAL_LINE_CONF_BUFSIZE 64 - -#define TIMESYNCH_CONF_ENABLED 0 -#define PROFILE_CONF_ON 0 -#define ENERGEST_CONF_ON 1 - -#define HAVE_STDINT_H -#include "msp430def.h" - - -#define PROCESS_CONF_NUMEVENTS 8 -#define PROCESS_CONF_STATS 0 - -/* CPU target speed in Hz */ -#define F_CPU 2457600uL - -/* Our clock resolution, this is the same as Unix HZ. Must be a power - of two (see clock.c for details). */ -#define CLOCK_CONF_SECOND 64UL - -#define NODE_ID_EEPROM_OFFSET 0x0010 /* - 0x0014 */ -#define CFS_EEPROM_CONF_OFFSET 0x0040 - -#define CC_CONF_REGISTER_ARGS 1 -#define CC_CONF_FUNCTION_POINTER_ARGS 1 - -#define CC_CONF_VA_ARGS 1 - -#define CCIF -#define CLIF - -typedef unsigned long clock_time_t; - -#define LOG_CONF_ENABLED 0 - -#define PACKETBUF_CONF_ATTRS_INLINE 1 -#define NETSTACK_CONF_RADIO tr1001_driver - -#if WITH_UIP -/* Network setup for IPv4 */ - -#define NETSTACK_CONF_NETWORK uip_driver -#define NETSTACK_CONF_MAC nullmac_driver -#define NETSTACK_CONF_RDC nullrdc_driver -#define NETSTACK_CONF_FRAMER framer_nullmac - -#define QUEUEBUF_CONF_NUM 0 -#define QUEUEBUF_CONF_REF_NUM 0 -#define ROUTE_CONF_ENTRIES 0 - -#else /* WITH_UIP */ - -/* Network setup for non-IPv4 (rime). */ - -#define NETSTACK_CONF_NETWORK rime_driver -#define NETSTACK_CONF_MAC nullmac_driver -#define NETSTACK_CONF_RDC nullrdc_driver -#define NETSTACK_CONF_FRAMER framer_nullmac - -#define QUEUEBUF_CONF_NUM 1 -#define QUEUEBUF_CONF_REF_NUM 1 -#define ROUTE_CONF_ENTRIES 4 - -#endif /* WITH_UIP */ - -/** - * The statistics data type. - * - * This datatype determines how high the statistics counters are able - * to count. - */ -typedef unsigned short uip_stats_t; - -#define UIP_CONF_ICMP_DEST_UNREACH 1 - -#define UIP_CONF_IP_FORWARD 1 -#define UIP_CONF_DHCP_LIGHT -#define UIP_CONF_LLH_LEN 0 -#define UIP_CONF_BUFFER_SIZE 110 -#define UIP_CONF_RECEIVE_WINDOW (UIP_CONF_BUFFER_SIZE - 40) -#define UIP_CONF_MAX_CONNECTIONS 4 -#define UIP_CONF_MAX_LISTENPORTS 4 -#define UIP_CONF_UDP_CONNS 3 -#define UIP_CONF_FWCACHE_SIZE 1 -#define UIP_CONF_BROADCAST 1 -#define UIP_ARCH_IPCHKSUM 1 -#define UIP_CONF_UDP_CHECKSUMS 1 -#define UIP_CONF_PINGADDRCONF 0 -#define UIP_CONF_LOGGING 0 -#define UIP_CONF_RESOLV_ENTRIES 1 - -#define UIP_CONF_TCP_SPLIT 0 - -#define LOADER_CONF_ARCH "loader/loader-arch.h" - -#define ELFLOADER_CONF_TEXT_IN_ROM 1 -#define ELFLOADER_CONF_DATAMEMORY_SIZE 100 -#define ELFLOADER_CONF_TEXTMEMORY_SIZE 0x1000 - -#define WEBSERVER_CONF_CGI_CONNS 1 - -/* LEDs ports. */ -#define LEDS_PxDIR P2DIR -#define LEDS_PxOUT P2OUT -#define LEDS_CONF_RED 0x01 -#define LEDS_CONF_GREEN 0x02 -#define LEDS_CONF_YELLOW 0x04 - -#ifdef PROJECT_CONF_H -#include PROJECT_CONF_H -#endif /* PROJECT_CONF_H */ - -#endif /* __CONTIKI_CONF_H__ */ diff --git a/platform/esb/contiki-esb-default-init-apps.c b/platform/esb/contiki-esb-default-init-apps.c deleted file mode 100644 index 94ac86ad4..000000000 --- a/platform/esb/contiki-esb-default-init-apps.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ -void -init_apps(void) -{ -} diff --git a/platform/esb/contiki-esb-default-init-lowlevel.c b/platform/esb/contiki-esb-default-init-lowlevel.c deleted file mode 100644 index 4a34e5439..000000000 --- a/platform/esb/contiki-esb-default-init-lowlevel.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ -#include "contiki-esb.h" -#include "dev/esb-sensors.h" - - -void -init_lowlevel(void) -{ - esb_sensors_init(); - esb_sensors_on(); - leds_init(); - rs232_init(); -} diff --git a/platform/esb/contiki-esb-main.c b/platform/esb/contiki-esb-main.c deleted file mode 100644 index 718b99c2a..000000000 --- a/platform/esb/contiki-esb-main.c +++ /dev/null @@ -1,319 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -#include -#include - -#include "contiki.h" -#include "contiki-esb.h" - -#include "dev/watchdog.h" -#include "sys/autostart.h" -#include "net/uip-driver.h" -#include "net/netstack.h" - -#if WITH_UIP - -static struct uip_fw_netif tr1001if = - {UIP_FW_NETIF(0,0,0,0, 0,0,0,0, uip_driver_send)}; - -#if WITH_SLIP -static struct uip_fw_netif slipif = - {UIP_FW_NETIF(172,16,0,0, 255,255,255,0, slip_send)}; -#endif /* WITH_SLIP */ - -#endif /* WITH_UIP */ - -#ifdef DCOSYNCH_CONF_PERIOD -#define DCOSYNCH_PERIOD DCOSYNCH_CONF_PERIOD -#else -#define DCOSYNCH_PERIOD 30 -#endif /* DCOSYNCH_CONF_PERIOD */ - -#ifdef DCOSYNCH_CONF_ENABLED -#define DCOSYNCH_ENABLED DCOSYNCH_CONF_ENABLED -#else -#define DCOSYNCH_ENABLED 0 -#endif /* DCOSYNCH_CONF_ENABLED */ - -#if DCOSYNCH_ENABLED -static struct timer dco_timer; -#endif /* DCOSYNCH_ENABLED */ - -SENSORS(&button_sensor, &sound_sensor, &vib_sensor, - &pir_sensor, &radio_sensor, &battery_sensor, &ctsrts_sensor, - &temperature_sensor); - -/*---------------------------------------------------------------------------*/ -static void -set_rime_addr(void) -{ - int i; - rimeaddr_t rimeaddr; - - rimeaddr.u8[0] = node_id & 0xff; - rimeaddr.u8[1] = node_id >> 8; - rimeaddr_set_node_addr(&rimeaddr); - - printf("Rime started with address "); - for(i = 0; i < sizeof(rimeaddr.u8) - 1; i++) { - printf("%u.", rimeaddr.u8[i]); - } - printf("%u\n", rimeaddr.u8[i]); -} -/*---------------------------------------------------------------------------*/ -#if WITH_UIP -static void -init_uip_net(void) -{ - uip_ipaddr_t hostaddr; - - uip_init(); - uip_fw_init(); - - process_start(&tcpip_process, NULL); -#if WITH_SLIP - process_start(&slip_process, NULL); - rs232_set_input(slip_input_byte); -#endif /* WITH_SLIP */ - process_start(&uip_fw_process, NULL); - - if (node_id > 0) { - /* node id is set, construct an ip address based on the node id */ - uip_ipaddr(&hostaddr, 172, 16, 1, node_id & 0xff); - uip_sethostaddr(&hostaddr); - } - -#if WITH_SLIP - uip_fw_register(&slipif); -#endif /* WITH_SLIP */ - - uip_fw_default(&tr1001if); -} -#endif /* WITH_UIP */ -/*---------------------------------------------------------------------------*/ -static void -print_processes(struct process * const processes[]) -{ - printf("Starting"); - while(*processes != NULL) { - printf(" '%s'", (*processes)->name); - processes++; - } - /* Needed to force link with putchar */ - putchar('\n'); -} -/*---------------------------------------------------------------------------*/ -static void init_ports_toberemoved() { - ////////// Port 1 //// - P1SEL = 0x00; - P1DIR = 0x81; // Outputs: P10=IRSend, P17=RS232RTS - // Inputs: P11=Light, P12=IRRec, P13=PIR, P14=Vibration, - // P15=Clockalarm, P16=RS232CTS - P1OUT = 0x00; - - ////////// Port 2 //// - P2SEL = 0x00; // No Sels - P2DIR = 0x7F; // Outpus: P20..P23=Leds+Beeper, P24..P26=Poti - // Inputs: P27=Taster - P2OUT = 0x77; - - ////////// Port 3 //// - P3SEL = 0xE0; // Sels for P34..P37 to activate UART, - P3DIR = 0x5F; // Inputs: P30..P33=CON4, P35/P37=RXD Transceiver/RS232 - // OutPuts: P36/P38=TXD Transceiver/RS232 - P3OUT = 0xE0; // Output a Zero on P34(TXD Transceiver) and turn SELECT off when receiving!!! - - ////////// Port 4 //// - P4SEL = 0x00; // CON5 Stecker - P4DIR = 0xFF; - P4OUT = 0x00; - - ////////// Port 5 //// - P5SEL = 0x00; // P50/P51= Clock SDA/SCL, P52/P53/P54=EEPROM SDA/SCL/WP - P5DIR = 0xDA; // P56/P57=Transceiver CNTRL0/1 - P5OUT = 0x0F; - - ////////// Port 6 //// - P6SEL = 0x00; // P60=Microphone, P61=PIR digital (same as P13), P62=PIR analog - P6DIR = 0x00; // P63=extern voltage, P64=battery voltage, P65=Receive power - P6OUT = 0x00; -} -/*---------------------------------------------------------------------------*/ -int -main(void) -{ - msp430_cpu_init(); - - init_ports_toberemoved(); - - init_lowlevel(); - - clock_init(); - - rtimer_init(); - - process_init(); - - random_init(0); - - node_id_restore(); - - process_start(&etimer_process, NULL); - process_start(&sensors_process, NULL); - - ctimer_init(); - - set_rime_addr(); - - printf(CONTIKI_VERSION_STRING " started. "); - if(node_id > 0) { - printf("Node id is set to %u.\n", node_id); - } else { - printf("Node id is not set.\n"); - } - - netstack_init(); - - printf("%s %s, channel check rate %lu Hz\n", - NETSTACK_MAC.name, NETSTACK_RDC.name, - CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1: - NETSTACK_RDC.channel_check_interval())); - - beep_spinup(); - leds_on(LEDS_RED); - clock_delay(100); - leds_off(LEDS_RED); - -#if !WITH_SLIP - rs232_set_input(serial_line_input_byte); - serial_line_init(); -#endif - -#if WITH_UIP - init_uip_net(); -#endif /* WITH_UIP */ - -#if PROFILE_CONF_ON - profile_init(); -#endif /* PROFILE_CONF_ON */ - -#if ENERGEST_CONF_ON - energest_init(); - ENERGEST_ON(ENERGEST_TYPE_CPU); -#endif /* ENERGEST_CONF_ON */ - - init_apps(); - print_processes(autostart_processes); - autostart_start(autostart_processes); - -#if DCOSYNCH_ENABLED - timer_set(&dco_timer, DCOSYNCH_PERIOD * CLOCK_SECOND); -#endif /* DCOSYNCH_ENABLED */ - - /* - * This is the scheduler loop. - */ - watchdog_start(); - while(1) { - int r; -#if PROFILE_CONF_ON - profile_episode_start(); -#endif /* PROFILE_CONF_ON */ - do { - /* Reset watchdog. */ - watchdog_periodic(); - r = process_run(); - } while(r > 0); -#if PROFILE_CONF_ON - profile_episode_end(); -#endif /* PROFILE_CONF_ON */ - - /* - * Idle processing. - */ - dint(); - if(process_nevents() != 0) { - eint(); - } else { -#if ENERGEST_CONF_ON - static unsigned long irq_energest = 0; -#endif /* ENERGEST_CONF_ON */ - -#if DCOSYNCH_CONF_ENABLED - /* before going down to sleep possibly do some management */ - if(timer_expired(&dco_timer)) { - timer_reset(&dco_timer); - msp430_sync_dco(); - } -#endif /* DCOSYNCH_CONF_ENABLED */ - -#if ENERGEST_CONF_ON - /* Re-enable interrupts and go to sleep atomically. */ - ENERGEST_OFF(ENERGEST_TYPE_CPU); - ENERGEST_ON(ENERGEST_TYPE_LPM); - - /* We only want to measure the processing done in IRQs when we - are asleep, so we discard the processing time done when we - were awake. */ - energest_type_set(ENERGEST_TYPE_IRQ, irq_energest); -#endif /* ENERGEST_CONF_ON */ - - watchdog_stop(); - _BIS_SR(GIE | SCG0 | CPUOFF); /* LPM1 sleep. */ - -#if ENERGEST_CONF_ON - /* We get the current processing time for interrupts that was - done during the LPM and store it for next time around. */ - dint(); - irq_energest = energest_type_time(ENERGEST_TYPE_IRQ); - eint(); - ENERGEST_OFF(ENERGEST_TYPE_LPM); - ENERGEST_ON(ENERGEST_TYPE_CPU); -#endif /* ENERGEST_CONF_ON */ - - watchdog_start(); - } - } -} -/*---------------------------------------------------------------------------*/ -/* char *arg_alloc(char size) {return NULL;} */ -/* void arg_init(void) {} */ -/* void arg_free(char *arg) {} */ -/*---------------------------------------------------------------------------*/ -#if UIP_LOGGING -void -uip_log(char *m) -{ - printf("uIP log: '%s'\n", m); -} -#endif /* UIP_LOGGING */ diff --git a/platform/esb/contiki-esb.h b/platform/esb/contiki-esb.h deleted file mode 100644 index 7f385867c..000000000 --- a/platform/esb/contiki-esb.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ -#ifndef __CONTIKI_ESB_H__ -#define __CONTIKI_ESB_H__ - -#include "contiki.h" -#include "contiki-net.h" -#include "contiki-lib.h" - -#include "lib/sensors.h" -#include "dev/hwconf.h" - -#include "dev/lpm.h" - -#include "dev/rs232.h" - -#include "dev/serial-line.h" -#include "dev/slip.h" - -#include "sys/node-id.h" - -#include "dev/vib-sensor.h" -#include "dev/pir-sensor.h" -#include "dev/button-sensor.h" -#include "dev/radio-sensor.h" -#include "dev/sound-sensor.h" -#include "dev/battery-sensor.h" -#include "dev/temperature-sensor.h" -#include "dev/ctsrts-sensor.h" - -#include "dev/beep.h" - -#include "dev/ir.h" - -#include "dev/leds.h" - -#include "sys/node-id.h" - -void msp430_cpu_init(void); -void init_lowlevel(void); -void init_apps(void); - -#endif /* __CONTIKI_ESB_H__ */ diff --git a/platform/esb/core.c b/platform/esb/core.c deleted file mode 100644 index 069edad02..000000000 --- a/platform/esb/core.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ -#include "contiki-esb.h" -#include "codeprop-tmp.h" -#include -#include - -AUTOSTART_PROCESSES(&codeprop_process); - -int core_dummy_4711(int len) { - char t[1]; - int l = snprintf(t, sizeof(t), "%d", len % 9); - printf("%d\n", l / 2); - return len / 4; -} diff --git a/platform/esb/dev/battery-sensor.c b/platform/esb/dev/battery-sensor.c deleted file mode 100644 index 3a807b98c..000000000 --- a/platform/esb/dev/battery-sensor.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2006, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * - * ----------------------------------------------------------------- - * - * Author : Adam Dunkels, Joakim Eriksson, Niclas Finne - * Created : 2005-11-01 - * Updated : $Date: 2010/02/08 00:00:45 $ - * $Revision: 1.6 $ - */ - -#include "contiki.h" -#include "dev/battery-sensor.h" -#include "dev/irq.h" - -const struct sensors_sensor battery_sensor; -static unsigned int battery_value; - -/*---------------------------------------------------------------------------*/ -static int -irq(void) -{ - battery_value = ADC12MEM6; - return 0; -} -/*---------------------------------------------------------------------------*/ -static int -value(int type) -{ - return ADC12MEM6/*battery_value*/; -} -/*---------------------------------------------------------------------------*/ -static int -configure(int type, int value) -{ - switch(type) { - case SENSORS_HW_INIT: - battery_value = 0; - return 1; - case SENSORS_ACTIVE: - if(value) { - if(!irq_adc12_active(6)) { - irq_adc12_activate(6, (INCH_4 + SREF_0), irq); - } - } else { - irq_adc12_deactivate(6); - } - return 1; - } - return 0; -} -/*---------------------------------------------------------------------------*/ -static int -status(int type) -{ - switch(type) { - case SENSORS_ACTIVE: - case SENSORS_READY: - return irq_adc12_active(6); - } - return 0; -} -/*---------------------------------------------------------------------------*/ -SENSORS_SENSOR(battery_sensor, BATTERY_SENSOR, - value, configure, status); diff --git a/platform/esb/dev/battery-sensor.h b/platform/esb/dev/battery-sensor.h deleted file mode 100644 index 12c8fdc84..000000000 --- a/platform/esb/dev/battery-sensor.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2006, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * - * ----------------------------------------------------------------- - * - * Author : Adam Dunkels, Joakim Eriksson, Niclas Finne - * Created : 2005-11-01 - * Updated : $Date: 2006/06/18 08:07:30 $ - * $Revision: 1.3 $ - */ - -#ifndef __BATTERY_SENSOR_H__ -#define __BATTERY_SENSOR_H__ - -#include "lib/sensors.h" - -extern const struct sensors_sensor battery_sensor; - -#define BATTERY_SENSOR "Battery" - -#endif /* __BATTERY_SENSOR_H__ */ diff --git a/platform/esb/dev/beep.c b/platform/esb/dev/beep.c deleted file mode 100644 index 80256cc9e..000000000 --- a/platform/esb/dev/beep.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -#include "contiki.h" -#include "contiki-esb.h" -#include "sys/clock.h" - -#define ON 1 -#define OFF 0 - -/* - * Flag to indicate if any of these functions should generate a sound - * or not. The function beep_off() is used to change this flag so none - * of the functions will generate sounds and beep_on() to turn sound - * back on. - */ -static char onoroff = ON; - -/* - * BEEPER_BIT is the bit in the io-register that is connected to the actual - * beeper, setting the bit high vill generate a high pitch tone. - */ -#define BEEPER_BIT 0x08 - -/*-----------------------------------------------------------------------------------*/ -void -beep_alarm(int alarmmode, int len) -{ - len = len / 200; - - while(len > 0) { - /* - * Check here if we should beep or not since if we do it outside the - * while loop the call to this function would take muck less time, i.e. - * beep_on()/beep_off() would have side effects that might not be - * predictable. - */ - if(onoroff == ON) { - if((alarmmode == BEEP_ALARM1) && ((len & 7) > 4)) { - P2OUT |= BEEPER_BIT; - } else if((alarmmode == BEEP_ALARM2) && ((len & 15) > 12)) { - P2OUT |= BEEPER_BIT; - } else { - P2OUT &= ~BEEPER_BIT; - } - } - clock_delay(200); - len--; - } - P2OUT &= ~BEEPER_BIT; -} -/*-----------------------------------------------------------------------------------*/ -void -beep_beep(int i) -{ - if(onoroff == ON) { - /* Beep. */ - P2OUT |= BEEPER_BIT; - clock_delay(i); - P2OUT &= ~BEEPER_BIT; - } -} -/*-----------------------------------------------------------------------------------*/ -void -beep(void) -{ - beep_beep(20); -} -/*-----------------------------------------------------------------------------------*/ -void -beep_down(int d) -{ - int i; - for(i = 8; i < d; i += i / 8) { - beep_beep(10); - clock_delay(i); - } -} -/*-----------------------------------------------------------------------------------*/ -void -beep_on(void) -{ - onoroff = ON; -} -/*-----------------------------------------------------------------------------------*/ -void -beep_off(void) -{ - onoroff = OFF; -} -/*-----------------------------------------------------------------------------------*/ -void -beep_spinup(void) -{ - unsigned int i; - - for(i = 10000; i > 80; i -= i / 20) { - beep_beep(2); - clock_delay(i); - } - - for(i = 4980; i > 2000; i -= 20) { - leds_on(LEDS_ALL); - clock_delay(5000 - i); - leds_off(LEDS_ALL); - clock_delay(i); - } - -} -/*-----------------------------------------------------------------------------------*/ -void -beep_quick(int n) -{ - int i; - for(i = 0; i < n; ++i) { - beep_beep(2000); - clock_delay(20000); - } -} -/*-----------------------------------------------------------------------------------*/ -void beep_long(clock_time_t len) { - /* - * Check if the beeper is turned on or off, i.e. if a call should generate - * a noise or not. - */ - if(onoroff == ON) { - /* Turn on the beeper. */ - P2OUT |= BEEPER_BIT; - } - - clock_wait(len); - - if(onoroff == ON) { - /* Turn the beeper off. */ - P2OUT &= ~BEEPER_BIT; - } -} -/*-----------------------------------------------------------------------------------*/ diff --git a/platform/esb/dev/beep.h b/platform/esb/dev/beep.h deleted file mode 100644 index 8f17a7f6c..000000000 --- a/platform/esb/dev/beep.h +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ -/** - * \addtogroup esb - * @{ - */ - -/** - * \defgroup beeper Beeper interface - * @{ - */ - -/** - * \file - * Interface to the beeper. - * \author Adam Dunkels - * - */ - -#ifndef __BEEP_H__ -#define __BEEP_H__ - -#define BEEP_ALARM1 1 -#define BEEP_ALARM2 2 - -#include "sys/clock.h" - -/** - * Beep for a specified time. - * - * This function causes the beeper to beep for the specified time. The - * time is measured in the same units as for the clock_delay() - * function. - * - * \note This function will hang the CPU during the beep. - * - * \note This function will stop any beep that was on previously when this - * function ends. - * - * \note If the beeper is turned off with beep_off() this call will still - * take the same time, though it will be silent. - * - * \param len The length of the beep. - * - */ -void beep_beep(int len); - -/** - * Beep an alarm for a specified time. - * - * This function causes the beeper to beep for the specified time. The - * time is measured in the same units as for the clock_delay() - * function. - * - * \note This function will hang the CPU during the beep. - * - * \note This function will stop any beep that was on previously when this - * function ends. - * - * \note If the beeper is turned off with beep_off() this call will still - * take the same time, though it will be silent. - * - * \param alarmmode The alarm mode (BEEP_ALARM1,BEEP_ALARM2) - * \param len The length of the beep. - * - */ -void beep_alarm(int alarmmode, int len); - -/** - * Produces a quick click-like beep. - * - * This function produces a short beep that sounds like a click. - * - */ -void beep(void); - -/** - * A beep with a pitch-bend down. - * - * This function produces a pitch-bend sound with deecreasing - * frequency. - * - * \param len The length of the pitch-bend. - * - */ -void beep_down(int len); - -/** - * Turn the beeper on. - * - * This function turns on the beeper. The beeper is turned off with - * the beep_off() function. - */ -void beep_on(void); - -/** - * Turn the beeper off. - * - * This function turns the beeper off after it has been turned on with - * beep_on(). - */ -void beep_off(void); - -/** - * Produce a sound similar to a hard-drive spinup. - * - * This function produces a sound that is intended to be similar to - * the sound a hard-drive makes when it starts. - * - */ -void beep_spinup(void); - -/** - * Beep for a long time (seconds) - * - * This function produces a beep with the specified length and will - * not return until the beep is complete. The length of the beep is - * specified using CLOCK_SECOND: a two second beep is CLOCK_SECOND * - * 2, and a quarter second beep is CLOCK_SECOND / 4. - * - * \note If the beeper is turned off with beep_off() this call will still - * take the same time, though it will be silent. - * - * \param len The length of the beep, measured in units of CLOCK_SECOND - */ -void beep_long(clock_time_t len); - -void beep_quick(int num); - -/** @} */ -/** @} */ - -#endif /* __BEEP_H__ */ diff --git a/platform/esb/dev/button-sensor.c b/platform/esb/dev/button-sensor.c deleted file mode 100644 index ccd62c21f..000000000 --- a/platform/esb/dev/button-sensor.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -#include "dev/button-sensor.h" -#include "dev/hwconf.h" -#include "isr_compat.h" - -const struct sensors_sensor button_sensor; - -static struct timer debouncetimer; - -HWCONF_PIN(BUTTON, 2, 7); -HWCONF_IRQ(BUTTON, 2, 7); - -/*---------------------------------------------------------------------------*/ -ISR(PORT2, irq_p2) -{ - ENERGEST_ON(ENERGEST_TYPE_IRQ); - - if(BUTTON_CHECK_IRQ()) { - if(timer_expired(&debouncetimer)) { - timer_set(&debouncetimer, CLOCK_SECOND / 4); - sensors_changed(&button_sensor); - LPM4_EXIT; - } - } - P2IFG = 0x00; - ENERGEST_OFF(ENERGEST_TYPE_IRQ); -} -/*---------------------------------------------------------------------------*/ -static int -value(int type) -{ - return BUTTON_READ() || !timer_expired(&debouncetimer); -} -/*---------------------------------------------------------------------------*/ -static int -configure(int type, int value) -{ - switch(type) { - case SENSORS_HW_INIT: - BUTTON_IRQ_EDGE_SELECTD(); - BUTTON_SELECT(); - BUTTON_MAKE_INPUT(); - return 1; - case SENSORS_ACTIVE: - if(value) { - if(!BUTTON_IRQ_ENABLED()) { - timer_set(&debouncetimer, 0); - BUTTON_ENABLE_IRQ(); - } - } else { - BUTTON_DISABLE_IRQ(); - } - return 1; - } - return 0; -} -/*---------------------------------------------------------------------------*/ -static int -status(int type) -{ - switch(type) { - case SENSORS_ACTIVE: - case SENSORS_READY: - return BUTTON_IRQ_ENABLED(); - } - return 0; -} -/*---------------------------------------------------------------------------*/ -SENSORS_SENSOR(button_sensor, BUTTON_SENSOR, - value, configure, status); diff --git a/platform/esb/dev/ctsrts-sensor.c b/platform/esb/dev/ctsrts-sensor.c deleted file mode 100644 index e01afe6e7..000000000 --- a/platform/esb/dev/ctsrts-sensor.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * RTS/CTS (Request to Send/Clear to Send) are the signals used for hardware - * flow control. By setting the RTS line to "ON" the host tells the connected - * device that it is ready to receive data. Hardware flow control is not - * implemented yet. This implementation is just so some application can use - * the pins, it would also be possible for rs232.c to use it for hardware - * handshake but as said, that is not implemented yet. - */ - -#include "dev/ctsrts-sensor.h" -#include "dev/irq.h" -#include "dev/hwconf.h" - -const struct sensors_sensor ctsrts_sensor; - -HWCONF_PIN(RS232RTS, 1, 7); - -#define RS232CTS_IRQ() 6 -HWCONF_PIN(RS232CTS, 1, RS232CTS_IRQ()); -HWCONF_IRQ(RS232CTS, 1, RS232CTS_IRQ()); - -/*---------------------------------------------------------------------------*/ -static int -irq(void) -{ - /* Change the flank triggering for the irq so we will detect next shift. */ - if(RS232CTS_READ()) { - RS232CTS_IRQ_EDGE_SELECTD(); - } else { - RS232CTS_IRQ_EDGE_SELECTU(); - } - sensors_changed(&ctsrts_sensor); - return 1; -} -/*---------------------------------------------------------------------------*/ -static int -value(int type) -{ - /* - * Invert the bit and return. - * This is strange, accordingly to the MSP430 manual section 9.2.1, Input - * Register PxIN the bit should be low when input is low. In RealTerm on - * the PC I set RTS which is coupled to the CTS on the esb and I read a 0. - * Maybe RTS is defined active LOW on the PC? //Kalle - */ - return RS232CTS_READ() ? 0 : 1; -} -/*---------------------------------------------------------------------------*/ -static int -configure(int type, int value) -{ - switch(type) { - case SENSORS_HW_INIT: - RS232RTS_SELECT(); - RS232RTS_MAKE_OUTPUT(); - RS232RTS_CLEAR(); - RS232CTS_SELECT(); - RS232CTS_MAKE_INPUT(); - return 1; - case SENSORS_ACTIVE: - if(value) { - if(!RS232CTS_IRQ_ENABLED()) { - - /* - * Check current status on the CTS pin and set IRQ flank so we - * will detect a shift. - */ - if(RS232CTS_READ()) { - RS232CTS_IRQ_EDGE_SELECTD(); - } else { - RS232CTS_IRQ_EDGE_SELECTU(); - } - - irq_port1_activate(RS232CTS_IRQ(), irq); - RS232CTS_ENABLE_IRQ(); - } - } else { - RS232CTS_DISABLE_IRQ(); - irq_port1_deactivate(RS232CTS_IRQ()); - } - return 1; - } - return 0; -} -/*---------------------------------------------------------------------------*/ -static int -status(int type) -{ - switch(type) { - case SENSORS_ACTIVE: - case SENSORS_READY: - return RS232CTS_IRQ_ENABLED(); - } - return 0; -} -/*---------------------------------------------------------------------------*/ -/** - * Indicate to host/client we are NOT ready to receive data. Sets the RTS pin - * to low. - */ -void ctsrts_rts_clear(void) { - RS232RTS_CLEAR(); -} -/*---------------------------------------------------------------------------*/ -/** - * Request host/client to send data. Sets the RTS pin to high. - */ -void ctsrts_rts_set(void) { - RS232RTS_SET(); -} -/*---------------------------------------------------------------------------*/ -SENSORS_SENSOR(ctsrts_sensor, CTSRTS_SENSOR, - value, configure, status); diff --git a/platform/esb/dev/ctsrts-sensor.h b/platform/esb/dev/ctsrts-sensor.h deleted file mode 100644 index 798d1a69f..000000000 --- a/platform/esb/dev/ctsrts-sensor.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * RTS/CTS (Request to Send/Clear to Send) are the signals used for hardware - * flow control. By setting the RTS line to "ON" the host tells the connected - * device that it is ready to receive data. Hardware flow control is not - * implemented yet. This implementation is just so some application can use - * the pins, it would also be possible for rs232.c to use it for hardware - * handshake but that is not implemented yet. - */ -#ifndef __CTSRTS_SENSOR_H__ -#define __CTSRTS_SENSOR_H__ - -#include "lib/sensors.h" - -extern const struct sensors_sensor ctsrts_sensor; - -#define CTSRTS_SENSOR "CTSRTS" - -/** - * Indicate to host/client we are NOT ready to receive data. Sets the RTS pin - * to low. - */ -void ctsrts_rts_clear(void); - -/** - * Request host/client to send data. Sets the RTS pin to high. - */ -void ctsrts_rts_set(void); - -#endif /* __CTSRTS_SENSOR_H__ */ diff --git a/platform/esb/dev/ds1629.c b/platform/esb/dev/ds1629.c deleted file mode 100644 index ce922ecc4..000000000 --- a/platform/esb/dev/ds1629.c +++ /dev/null @@ -1,228 +0,0 @@ -/* -Copyright 2005, Freie Universitaet Berlin. All rights reserved. - -These sources were developed at the Freie Universität Berlin, Computer -Systems and Telematics group. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - -- Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -- Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -- Neither the name of Freie Universitaet Berlin (FUB) nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -This software is provided by FUB and the contributors on an "as is" -basis, without any representations or warranties of any kind, express -or implied including, but not limited to, representations or -warranties of non-infringement, merchantability or fitness for a -particular purpose. In no event shall FUB or contributors be liable -for any direct, indirect, incidental, special, exemplary, or -consequential damages (including, but not limited to, procurement of -substitute goods or services; loss of use, data, or profits; or -business interruption) however caused and on any theory of liability, -whether in contract, strict liability, or tort (including negligence -or otherwise) arising in any way out of the use of this software, even -if advised of the possibility of such damage. - -This implementation was developed by the CST group at the FUB. - -For documentation and questions please use the web site -http://scatterweb.mi.fu-berlin.de and the mailinglist -scatterweb@lists.spline.inf.fu-berlin.de (subscription via the Website). -Berlin, 2005 -*/ - -/** - * Part of the source code from ScatterWeb 2.2 (ScatterWeb.{Data,System}.c) - * released by Freie Universitaet Berlin has been reworked and - * reformatted to fit the Contiki ESB port. - */ - -#include "contiki.h" -#include "dev/ds1629.h" - -#define SDA_HIGH (P5OUT |= 0x01) /* RTC data line high */ -#define SDA_LOW (P5OUT &= 0xFE) /* RTC data line low */ -#define SCL_HIGH (P5OUT |= 0x02) /* RTC clock line high */ -#define SCL_LOW (P5OUT &= 0xFD) /* RTC clock line low */ -#define BUS_READ 0x9F -#define BUS_WRITE 0x9E -#define ACC_CSR 0xAC /* Access Configuration/Control Register */ -#define ACC_CLOCK 0xC0 /* Access Clock Register */ -#define ACC_CLOCK_ALARM 0xC7 /* Access Clock Alarm Register */ -#define ACC_TH 0xA1 /* Access Thermostat Setpoint High */ -#define ACC_TL 0xA2 /* Access Thermostat Setpoint Low */ -#define ACC_CSRAM 0x17 /* Access Clock 32 byte SRAM */ -#define ACC_RT 0xAA /* Access Read Temperatur Register */ -#define CSR_OS1 (0x80) -#define CSR_OS0 (0x40) -#define CSR_A1 (0x20) -#define CSR_A0 (0x10) -#define CSR_CNV (0x04) -#define CSR_POL (0x02) -#define CSR_1SH (0x01) -#define CSR_DEFAULT (CSR_OS1 + CSR_OS0 + CSR_A1 + CSR_CNV + CSR_1SH + CSR_POL) - -/** - * Temperature type (built on a signed int). It's a signed (twos complement) - * fixed point value with 8 bits before comma and 7 bits after. So Bit 15 is - * sign, Bit14-7 is before comma and Bit 6-0 after comma. - * - * @since 2.0 - */ -typedef union { unsigned int u; signed int s; } temp_t; - -/*--------------------------------------------------------------------------*/ -/* Puts the start condition on bus. */ -static void -cl_start(void) -{ - P5DIR |= 0x03; /* ensure: P50(SDA), P51(SCL) output */ - SCL_LOW; _NOP(); _NOP(); - SDA_HIGH; _NOP(); _NOP(); - SCL_HIGH; _NOP(); _NOP(); - SDA_LOW; _NOP(); _NOP(); - SCL_LOW; _NOP(); _NOP(); -} -/*--------------------------------------------------------------------------*/ -/* Puts the stop condition on bus. */ -static void -cl_stop() -{ - SCL_LOW; _NOP(); _NOP(); - SDA_LOW; _NOP(); _NOP(); - SCL_HIGH; _NOP(); _NOP(); - SDA_HIGH; _NOP(); _NOP(); - SCL_LOW; _NOP(); _NOP(); - P5DIR &= ~0x03; -} -/*--------------------------------------------------------------------------*/ -/* Writes a byte on the bus, returns the acknowledge bit. */ -static uint16_t -cl_writeOnBus(uint8_t byte) -{ - uint16_t i, ack; - for(i=0;i<8;i++) { - if(byte & 0x80) SDA_HIGH; else SDA_LOW; - SCL_HIGH; - byte = byte << 1; _NOP(); - SCL_LOW; _NOP(); - } - /* check ack */ - P5DIR &= 0xFE; /* P50(SDA) input */ - SCL_HIGH; - if(P5IN & 0x01) ack = 0; else ack = 1; /* test if ack=0, else error */ - _NOP(); - SCL_LOW; - P5DIR |= 0x01; /* P50(SDA) output */ - return ack; -} -/*--------------------------------------------------------------------------*/ -static uint8_t -cl_readFromBus(uint16_t ack) -{ - uint16_t i; - uint8_t byte = 0; - P5DIR &= 0xFE; /* P50(SDA) input */ - for(i=0;i<8;i++) { - byte = byte << 1; - SCL_HIGH; - if(P5IN & 0x01) byte |= 0x01; else byte &= 0xFE; - SCL_LOW; - } - P5DIR |= 0x01; /* P50(SDA) output */ - if(ack) SDA_LOW; else SDA_HIGH; - SCL_HIGH; - SCL_LOW; - return byte; -} -/*--------------------------------------------------------------------------*/ -static uint16_t -getReg16bit(uint8_t acc, uint16_t bitmask) -{ - uint16_t config = 0; - do cl_start(); - while(!cl_writeOnBus(BUS_WRITE)); - cl_writeOnBus(acc); - cl_start(); - cl_writeOnBus(BUS_READ); - config = cl_readFromBus(1); - config = config << 8; - config += cl_readFromBus(0); - cl_stop(); - config &= bitmask; - _NOP(); - _NOP(); - return config; -} -/*--------------------------------------------------------------------------*/ -/* Only first 8 bit of Configuration Status Register can be set */ -static void -setCSReg(uint8_t setting) -{ - do cl_start(); - while(!cl_writeOnBus(BUS_WRITE)); - cl_writeOnBus(ACC_CSR); - cl_writeOnBus(setting); - cl_stop(); - _NOP(); - _NOP(); - _NOP(); - _NOP(); -} -/*--------------------------------------------------------------------------*/ -static void -System_startConversion(void) -{ - do cl_start(); /* do start until BUS_WRITE is acked */ - while(!cl_writeOnBus(BUS_WRITE)); /* control byte */ - cl_writeOnBus(0xEE); /* start conversion */ - cl_stop(); -} -/*--------------------------------------------------------------------------*/ -/* RTC initialization. Initializes RTC with ::CSR_DEFAULT. */ -static void -initClock(void) -{ - uint8_t csr = getReg16bit(ACC_CSR,0xFF00) >> 8; - if(csr!=CSR_DEFAULT) setCSReg(CSR_DEFAULT); /* if desired config isnt in clock => set it */ - /* IMPORTANT: Ensure quartz is generating 32768 Hz */ - /* (sometimes CH bit gets set when clock is read while reset) */ - do cl_start(); /* Do start until BUS_WRITE is acked. */ - while(!cl_writeOnBus(BUS_WRITE)); /* Send control byte */ - cl_writeOnBus(ACC_CLOCK); /* Send command byte ::ACC_CLOCK. */ - cl_writeOnBus(0x00); /* Send starting address 0x00. */ - cl_writeOnBus(0x00); /* Set CH to 0, tseconds and seconds will also be reset! */ - cl_stop(); /* Stop condition. */ -} -/*--------------------------------------------------------------------------*/ -void -ds1629_init() -{ - initClock(); -} -/*--------------------------------------------------------------------------*/ -void -ds1629_start() -{ - System_startConversion(); -} -/*--------------------------------------------------------------------------*/ -signed int -ds1629_temperature() -{ - temp_t temperature; - - ds1629_start(); - - temperature.u = getReg16bit(ACC_RT,0xFFFF); - return temperature.s; -} diff --git a/platform/esb/dev/ds1629.h b/platform/esb/dev/ds1629.h deleted file mode 100644 index a0120fb7e..000000000 --- a/platform/esb/dev/ds1629.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Configurable Sensor Network Application - * Architecture for sensor nodes running the Contiki operating system. - * - * - * ----------------------------------------------------------------- - * - * Author : Adam Dunkels, Joakim Eriksson, Niclas Finne - * Created : 2005-11-08 - * Updated : $Date: 2006/06/18 07:49:33 $ - * $Revision: 1.1 $ - */ - -#ifndef __DS1629_H__ -#define __DS1629_H__ - -/** - * DS1629 initialization function. - * - * This function should be called at startup to initialize the DS1629 - * and its clock. - */ -void ds1629_init(void); - -/** - * DS1629 start conversion function. - * - * This function should be called before requesting the temperature - * the first time. - */ -void ds1629_start(void); - -/** - * Get the temperature. - * - * This function will return the current temperature as a signed 9 bit - * value in terms of a 0.5 degree Celsius least significant bit. - * - * MSB Sign 2^6 2^5 2^4 2^3 2^2 2^1 2^0 - * LSB 2^-1 0 0 0 0 0 0 0 - */ -signed int ds1629_temperature(void); - -#endif /* __DS1629_H__ */ diff --git a/platform/esb/dev/eeprom.c b/platform/esb/dev/eeprom.c deleted file mode 100644 index fb63f4a9c..000000000 --- a/platform/esb/dev/eeprom.c +++ /dev/null @@ -1,323 +0,0 @@ -/** - * \file - * EEPROM functions. - * \author Adam Dunkels - */ - -/* Copyright (c) 2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * - * Author: Adam Dunkels - * - */ - -/* -Copyright 2003/2004, Freie Universitaet Berlin. All rights reserved. - -These sources were developed at the Freie Universit\x{FFFF}t Berlin, Computer -Systems and Telematics group. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - -- Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -- Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -- Neither the name of Freie Universitaet Berlin (FUB) nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -This software is provided by FUB and the contributors on an "as is" -basis, without any representations or warranties of any kind, express -or implied including, but not limited to, representations or -warranties of non-infringement, merchantability or fitness for a -particular purpose. In no event shall FUB or contributors be liable -for any direct, indirect, incidental, special, exemplary, or -consequential damages (including, but not limited to, procurement of -substitute goods or services; loss of use, data, or profits; or -business interruption) however caused and on any theory of liability, -whether in contract, strict liability, or tort (including negligence -or otherwise) arising in any way out of the use of this software, even -if advised of the possibility of such damage. - -This implementation was developed by the CST group at the FUB. -Contributors: Thomas Pietsch, Bjoern Lichtblau - -For documentation and questions please use the web site -http://www.scatterweb.net and the mailinglist -scatterweb@lists.spline.inf.fu-berlin.de (subscription via the Website). -Berlin, 2003/2004 -*/ - -#include "contiki.h" -/* #include */ - -#include "dev/eeprom.h" - -/* Temporary switch for the eeprom address. */ -#define EEPROMADDRESS (0x00) /* use 8k EEPROM, future versions will have only one 64k eeprom at this address */ -/*#define EEPROMADDRESS (0x02)*/ /* use 64k EEPROM */ - -/* must be set together with EEPROMADDRESS */ -/*#define EEPROMPAGEMASK (0x1F) */ /* 8k EEPROM, 32b page writes possible */ -#define EEPROMPAGEMASK (0x7F) /* 64k EEPROM, 128b page writes possible */ - - - -/* - * Macros for accessing the clock and data lines. Data is on P56 and - * clock on P57. - */ -#define SDA_HIGH (P5OUT |= 0x04) /**< EEPROM data line high */ -#define SDA_LOW (P5OUT &= 0xFB) /**< EEPROM data line low */ -#define SCL_HIGH (P5OUT |= 0x08) /**< EEPROM clock line high */ -#define SCL_LOW (P5OUT &= 0xF7) /**< EEPROM clock line low */ - - -/*-----------------------------------------------------------------------------------*/ -/** - * \internal \name Basic functions for interfacing the i2c-like EEPROM bus. - */ -/** @{ */ - -/** - * \internal - * Put start condition on the bus. - */ -static void -start(void) -{ - P5DIR |= 0x0C; /* ensure: P52(SDA), P53(SCL) output */ - SCL_LOW; _NOP(); _NOP(); - SDA_HIGH; _NOP(); _NOP(); - SCL_HIGH; _NOP(); _NOP(); - SDA_LOW; _NOP(); _NOP(); - SCL_LOW; _NOP(); _NOP(); -} - -/*-----------------------------------------------------------------------------------*/ -/** - * \internal - * Put stop condition on the bus. - */ -static void -stop(void) -{ - //P5DIR |= 0x0C; /* ensure: P52(SDA), P53(SCL) output */ - SCL_LOW; _NOP(); _NOP(); - SDA_LOW; _NOP(); _NOP(); - SCL_HIGH; _NOP(); _NOP(); - SDA_HIGH; _NOP(); _NOP(); - SCL_LOW; _NOP(); _NOP(); - P5DIR &= ~0x0C; -} -/*-----------------------------------------------------------------------------------*/ -/** - * \internal - * Write a byte on the bus, return the acknowledge bit. - */ -static int -write_bus(unsigned char byte) -{ - int i, ack; - - /* Write byte, one bit at a time. Start with the leftmost (most - significant) bit and roll in bits from the right. */ - for(i = 0; i < 8; ++i) { - if(byte & 0x80) { - SDA_HIGH; - } else { - SDA_LOW; - } - _NOP(); - _NOP(); - SCL_HIGH; - _NOP(); - _NOP(); - byte = byte << 1; - SCL_LOW; - _NOP(); - _NOP(); - } - - /* check ack */ - P5DIR &= 0xFB; /* P52(SDA) input */ - SCL_HIGH; - _NOP(); - _NOP(); - if(P5IN & 0x04) { - ack = 0; - } else { - ack = 1; /* test if ack=0, else error */ - } - SCL_LOW; - _NOP(); - _NOP(); - P5DIR |= 0x04; /* P52(SDA) output */ - _NOP(); - _NOP(); - _NOP(); - return ack; -} -/*-----------------------------------------------------------------------------------*/ -/** - * \internal - * Read one byte from the bus. - * - * \param ack If set, the ackbit after the received byte will be set. - */ -static unsigned char -read_bus(unsigned char ack) -{ - int i; - unsigned char byte = 0; - - P5DIR &= 0xFB; /* P52(SDA) input */ - - for(i = 0; i < 8; ++i) { - byte = byte << 1; - SCL_HIGH; - _NOP(); - _NOP(); - if(P5IN & 0x04) { - byte |= 0x01; - } else { - byte &= 0xFE; - } - _NOP(); - SCL_LOW; - _NOP(); - _NOP(); - } - - P5DIR |= 0x04; /* P52(SDA) output */ - if(ack) { - SDA_LOW; - } else { - SDA_HIGH; - } - _NOP(); - SCL_HIGH; - _NOP(); - SCL_LOW; - _NOP(); - return byte; -} -/** @} */ -/*-----------------------------------------------------------------------------------*/ -/** - * Read bytes from the EEPROM using sequential read. - */ -void -eeprom_read(unsigned short addr, unsigned char *buf, int size) -{ - unsigned int i; - - if(size <= 0) { - return; - } - - do { - /* Wait if the writecycle has not finished. */ - start(); - /* 1010 control, 000 address, 0=write --- but only inits address */ - } while(!write_bus(0xa0 | EEPROMADDRESS)); - - - /* Write address to bus, low byte first. */ - write_bus(addr >> 8); - write_bus(addr & 0xff); - start(); - /* 1010 control, 000 address, 1=read */ - write_bus(0xa1 | EEPROMADDRESS); - - for(i = 0; i < (size - 1); ++i){ - buf[i] = read_bus(1); - } - buf[size - 1] = read_bus(0); - stop(); -} -/*-----------------------------------------------------------------------------------*/ -/** - * Write bytes to EEPROM using sequencial write. - */ -void -eeprom_write(unsigned short addr, unsigned char *buf, - int size) -{ - unsigned int i = 0; - unsigned int curaddr; - - if(size <= 0) { - return; - } - - /* Disable write protection. */ - P5OUT &= 0xEF; - - curaddr = addr; - for(i = 0; i < size; ++i) { - /* If we are writing the first byte or are on a 128b page boundary - we have to start a new write. */ - if(i == 0 || (curaddr & EEPROMPAGEMASK) == 0) { - do { - start(); - /* 1010 control, 000 addresse, 0=write */ - } while(!write_bus(0xa0 | EEPROMADDRESS)); - - /* Write the new address to the bus. */ - if(write_bus(curaddr >> 8) == 0) { - return; - } - if(write_bus(curaddr) == 0) { - return; - } - } - - /* Write byte. */ - if(write_bus(buf[i]) == 0) { - return; - } - - /* If we are writing the last byte totally or of a 128b page - generate a stop condition */ - if(i == size - 1 || (curaddr & EEPROMPAGEMASK) == EEPROMPAGEMASK) { - stop(); - } - - ++curaddr; - } - - /* Enable write protection. */ - P5OUT |= 0x10; -} - -/*-----------------------------------------------------------------------------------*/ diff --git a/platform/esb/dev/esb-sensors.c b/platform/esb/dev/esb-sensors.c deleted file mode 100644 index 01901dec1..000000000 --- a/platform/esb/dev/esb-sensors.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * \file - * Functions for turning the ESB sensors on or off - * \author - * Adam Dunkels - * - * This file will eventually be changed into a better API. This is - * sufficient for now. - */ - -#include "dev/hwconf.h" -#include "dev/irq.h" -#include "sys/energest.h" - -HWCONF_PIN(SENSORSWITCH, 5, 5); - -/*---------------------------------------------------------------------------*/ -void -esb_sensors_init(void) -{ - SENSORSWITCH_SELECT(); - SENSORSWITCH_MAKE_OUTPUT(); - - irq_init(); -} -/*---------------------------------------------------------------------------*/ -void -esb_sensors_on(void) -{ - SENSORSWITCH_CLEAR(); - ENERGEST_ON(ENERGEST_TYPE_SENSORS); -} -/*---------------------------------------------------------------------------*/ -void -esb_sensors_off(void) -{ - SENSORSWITCH_SET(); - ENERGEST_OFF(ENERGEST_TYPE_SENSORS); -} -/*---------------------------------------------------------------------------*/ diff --git a/platform/esb/dev/esb-sensors.h b/platform/esb/dev/esb-sensors.h deleted file mode 100644 index 599fe65a0..000000000 --- a/platform/esb/dev/esb-sensors.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * \file - * A brief description of what this file is. - * \author - * Adam Dunkels - */ - -#ifndef __ESB_SENSORS_H__ -#define __ESB_SENSORS_H__ - -void esb_sensors_init(void); -void esb_sensors_on(void); -void esb_sensors_off(void); - -#endif /* __ESB_SENSORS_H__ */ diff --git a/platform/esb/dev/ir.c b/platform/esb/dev/ir.c deleted file mode 100644 index 56ac46a27..000000000 --- a/platform/esb/dev/ir.c +++ /dev/null @@ -1,315 +0,0 @@ - - - -/* The software in this file is based on code from FU Berlin. */ - -/* -Copyright 2003/2004, Freie Universitaet Berlin. All rights reserved. - -These sources were developed at the Freie Universität Berlin, Computer -Systems and Telematics group. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - -- Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -- Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -- Neither the name of Freie Universitaet Berlin (FUB) nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -This software is provided by FUB and the contributors on an "as is" -basis, without any representations or warranties of any kind, express -or implied including, but not limited to, representations or -warranties of non-infringement, merchantability or fitness for a -particular purpose. In no event shall FUB or contributors be liable -for any direct, indirect, incidental, special, exemplary, or -consequential damages (including, but not limited to, procurement of -substitute goods or services; loss of use, data, or profits; or -business interruption) however caused and on any theory of liability, -whether in contract, strict liability, or tort (including negligence -or otherwise) arising in any way out of the use of this software, even -if advised of the possibility of such damage. - -This implementation was developed by the CST group at the FUB. -Contributors: Thomas Pietsch, Bjoern Lichtblau - -*/ - -/* \file recir.c - ** \ingroup Firmware - ** \brief Receiving RC5 via IR Receiving Diode. - ** - ** \code - ** RC5: 1780 us bitlength (manchester encoded, so half bitlength of 890 us is important) - ** Transferred packet (2 start + toggle bit + 5 address bits + 6 comand bits)): - ** | S | S | T | A4 | A3 | A2 | A1 | A0 | C5 | C4 | C3 | C2 | C1 | C0 | - ** irdata format: | ? | ? | error | newData | T | A4 | A3 | A2 | A1 | A0 | C5 | C4 | C3 | C2 | C1 | C0 | - ** \endcode - ** - ** - ** See detailed description at http://users.pandora.be/davshomepage/rc5.htm - ** - ** Some common addresses and commands: - ** \code - ** Address: Device: Command: - ** 0 TV1 0...9 Numbers 0...9 (channel select) - ** 1 TV2 12 Standby - ** 5 VCR1 16 Master Volume + - ** 6 VCR2 17 Master Volume - - ** 17 Tuner 18 Brightness + - ** 18 Audio Tape 19 Brightness - - ** 20 CD Player 50 Fast rewind - ** 52 Fast run forward - ** 53 Play - ** 54 Stop - ** 55 Recording - ** \endcode - **/ - -#include "contiki.h" -#include "dev/ir.h" - -#include "dev/leds.h" -#include "dev/beep.h" -#include "isr_compat.h" - -PROCESS(ir_process, "IR receiver"); -process_event_t ir_event_received; -/*---------------------------------------------------------------------------*/ -#define SIR1 (P1OUT |= 0x01) ///< MACRO: Puts IR sending diode high. -#define SIR0 (P1OUT &= 0xFE) ///< MACRO: Puts IR sending diode low. -#define BIT75 3282 ///< 3 quarters of a bit after start, 3282 cyc @ 2,4576Mhz = 1335us. -#define BIT50 2188 ///< Half of bit length, 2188 cyc @ 2,4576Mhz = 890 us. - -/*---------------------------------------------------------------------------*/ -/* Sends a logical one via IR, method is timed for the 2.4576Mhz SMCLK!!! - */ -static volatile void -send1bit(void) -{ - volatile int i; - for(i = 0; i < 34; ++i) { - SIR1; SIR1; SIR1; SIR1; - SIR0; SIR0; SIR0; SIR0; - SIR0; SIR0; SIR0; SIR0; - SIR0; - } -} -/*---------------------------------------------------------------------------*/ -/* Sends a logical 0 via IR, method is timed for the 2.4576Mhz SMCLK!!! - */ -static volatile void -send0bit(void) -{ - volatile int i; - for(i = 0; i < 34; ++i) { - SIR0; SIR0; SIR0; SIR0; - SIR0; SIR0; SIR0; SIR0; - SIR0; SIR0; SIR0; SIR0; - SIR0; - } -} -/*---------------------------------------------------------------------------*/ -/* Sends the lower 12 bits of data via IR, turns interrupt off while - it's sending. - */ -void -ir_send(unsigned short data) -{ - volatile unsigned short mask = 0x2000; - data |= 0xF000; - - dint(); - while(mask != 0){ - if(!(mask & data)){ - send1bit(); - send0bit(); - } else { - send0bit(); - send1bit(); - } - mask /= 2; - } - eint(); -} -/*---------------------------------------------------------------------------*/ -/* Testroutine which repetedly sends two commands. - */ -/*void -ir_test_send(void) -{ - volatile unsigned int i; - send12bits(0xF010); - for(i=0; i<0xFFFF; i++) nop(); - send12bits(0xF011); - for(i=0; i<0xFFFF; i++) nop(); -}*/ -/*---------------------------------------------------------------------------*/ - - -static void setErrorBit(void); -static void clearErrorBit(void); -static void setDataAvailableBit(void); -static void clearDataAvailableBit(void); - - -/// \name Internal variables. -//@{ -static unsigned int ir_pos; ///< current position in frame -static unsigned int recvdata; ///< here a received packet is saved -static unsigned int recvdatabuffer; ///< temporary buffer for receiving -static unsigned char ir_temp; ///< saves the first half of the manchester bit -//@} - -/// \name Public functions. -/// If ::recir_dataAvailable()==1 use the get* functions. -//@{ -unsigned char recir_getCode(void){ return (recvdata & 0x003F); } -unsigned char recir_getAddress(void){ return ((recvdata & 0x07C0) >> 6); } -unsigned char recir_getToggle(void){ return ((recvdata & 0x0800) >> 11); } -unsigned char recir_getError(void){ return ((recvdata & 0x2000) >> 13); } - -uint16_t -ir_data(void) -{ - return recvdata; -} - -uint8_t -ir_poll(void) -{ - if(recvdata & 0x1000) { - clearDataAvailableBit(); - return 1; - } else { - return 0; - } -} - - -///\name Internal functions. -//@{ -static void setErrorBit(void){ recvdata |= 0x2000; } -static void clearErrorBit(void) { recvdata &= 0xDFFF; } -static void setDataAvailableBit(void){ recvdata |= 0x1000; } -static void clearDataAvailableBit(void){ recvdata &= 0xEFFF; } - - -/// Timer B0 interrupt service routine -ISR(TIMERB1, Timer_B1) { - - /*P2OUT = (P2OUT & 0xf7) | (8 - (P2OUT & 0x08));*/ - - if(ir_pos <= 25) { - if(ir_pos % 2) { // odd position - if(ir_temp && !(P1IN & 0x04)) { // 1 - 0 --> write 1 - recvdatabuffer +=1; - recvdatabuffer = recvdatabuffer << 1; - } else if(!ir_temp && (P1IN & 0x04)) { // 0 - 1 --> write 0 - recvdatabuffer = recvdatabuffer << 1; - } else { - setErrorBit(); - if(P1IN & 0x04) { - recvdatabuffer += 1; - } - recvdatabuffer = recvdatabuffer << 1; - } - } else { // even position - ir_temp = P1IN & 0x04; - } - } - - if(ir_pos == 25) { // end reached - recvdatabuffer = recvdatabuffer >> 1; - - if(!recir_getError() && ( (recvdatabuffer & 0x0FFF) != (recvdata & 0x0FFF) ) ){ - recvdata = recvdatabuffer; - setDataAvailableBit(); - } else { - _NOP(); - } - } - - if(ir_pos==27) { - TBCCTL1 &= ~CCIE; - - //GREENOFF; - // temporary debug output - //sendRS232Address(recvdatabuffer); - //if(recir_getError()) sendRS232('E'); - //sendRS232String("\r\n"); - if(!recir_getError()) beep_beep(20); - - // reenable interrupt for falling edge - P1IFG &= ~(0x04); - P1IE |= 0x04; // enable interrupt for recir RC5 - leds_off(LEDS_RED); - } - - ir_pos++; - TBCCR1 += BIT50; // set new interrupt - - TBCCTL1 &= ~CCIFG; -} - - -/** \brief IR Interrupt routine - ** - ** For the falling edge (start of RC5 packet)( mid of first start bit ), IRReceiver is on P12 - ** real interrupt routine, which calls this, is in sensors.c */ -void -ir_irq(void) -{ - if(P1IN & 0x04) return; // high again, just a peak - - ir_pos = 0; - recvdatabuffer = 0; - clearErrorBit(); - - // the first timer interrupt will occur in the mid of the first half of the second start bit - TBCCR1 = TBR + BIT75; // set first TBCCR1 IRQ to 75% of RC5 bitlength - TBCCTL1 &= ~CCIFG; // clear previous compare flag - TBCCTL1 |= CCIE; // CCR0 interrupt enabled, interrupt occurs when timer equals CCR0 - - P1IE &= ~0x04; // disable interrupt for P12 ( ReceiveIR ) - leds_on(LEDS_RED); - //GREENON; -} - -//@} -/*---------------------------------------------------------------------*/ -PROCESS_THREAD(ir_process, ev, data) -{ - PROCESS_BEGIN(); - - // init TIMERB ccr0 to run continouslycreate the 5 ms interval - // ccr1 is used for ir receiving (RC5) - TBCTL = TBSSEL1 + TBCLR; // select SMCLK (2.4576MHz), clear TBR - TBCTL |= MC1; // Start Timer_A in continuous mode - - - P1IES |= 0x04; // Important for IR-RC5 receive to detect the first FALLING edge - - ir_event_received = process_alloc_event(); - - while(1) { - PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_POLL); - - if(ir_poll() == IR_DATA) { - unsigned short irdata; - irdata = ir_data() & 0x7ff; - process_post(PROCESS_BROADCAST, ir_event_received, (process_data_t)irdata); - } - - } - - PROCESS_END(); -} -/*---------------------------------------------------------------------*/ diff --git a/platform/esb/dev/ir.h b/platform/esb/dev/ir.h deleted file mode 100644 index f806c1d55..000000000 --- a/platform/esb/dev/ir.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ -#ifndef __IR_H__ -#define __IR_H__ - -#include "contiki.h" -#include "contiki-net.h" - -/** - * Initialize the IR driver. - * - * This function should be called from the main boot-up procedure in - * order to initialize the IR device driver. - * - */ -void ir_init(void); - -void ir_send(unsigned short low12bits); - -uint8_t ir_poll(void); -#define IR_NODATA 0 -#define IR_DATA 1 - -uint16_t ir_data(void); - -void ir_irq(void); - -#define IR_STANDBY 0x0c -#define IR_VOLUME_UP 0x10 -#define IR_VOLUME_DOWN 0x11 -#define IR_VCR_PLAY 0x35 -#define IR_VCR_STOP 0x36 -#define IR_VCR_RECORD 0x37 -#define IR_VCR_REWIND 0x32 -#define IR_VCR_WIND 0x34 - -extern process_event_t ir_event_received; - -PROCESS_NAME(ir_process); - -#endif /* __IR_H__ */ diff --git a/platform/esb/dev/irq.c b/platform/esb/dev/irq.c deleted file mode 100644 index 20823f27b..000000000 --- a/platform/esb/dev/irq.c +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright (c) 2009, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ -#include "contiki.h" -#include "lib/sensors.h" -#include "dev/irq.h" -#include "dev/lpm.h" -#include "isr_compat.h" - -#define ADC12MCTL_NO(adcno) ((unsigned char *) ADC12MCTL0_)[adcno] - -static int (* adc12_irq[8])(void); -static int (* port1_irq[8])(void); -static unsigned char adcflags; - -/*---------------------------------------------------------------------------*/ -ISR(PORT1, irq_p1) -{ - int i; - ENERGEST_ON(ENERGEST_TYPE_IRQ); - for(i = 0; i < 8; i++) { - if((P1IFG & (1 << i)) && port1_irq[i] != NULL) { - if((port1_irq[i])()) { - LPM4_EXIT; - } - } - } - P1IFG = 0x00; - ENERGEST_OFF(ENERGEST_TYPE_IRQ); -} -/*---------------------------------------------------------------------------*/ -ISR(ADC, irq_adc) -{ - int i; - ENERGEST_ON(ENERGEST_TYPE_IRQ); - for(i = 0; i < 8; i++) { - if(adc12_irq[i] != NULL) { - if((adc12_irq[i])()) { - LPM4_EXIT; - } - } - } - ENERGEST_OFF(ENERGEST_TYPE_IRQ); -} -/*---------------------------------------------------------------------------*/ -void -irq_init(void) -{ - int i; - adcflags = 0; - for(i = 0; i < 8; i++) { - adc12_irq[i] = NULL; - port1_irq[i] = NULL; - } - /* Setup ADC12, ref., sampling time */ - ADC12CTL0 = REF2_5V | SHT0_10 | SHT1_10 | MSC; - - /* Use sampling timer, repeat-sequence-of-channels */ -/* ADC12CTL1 = SHP | CONSEQ_3 | ADC12DIV_3; */ - ADC12CTL1 = SHP | CONSEQ_3 | ADC12DIV_7; -} -/*---------------------------------------------------------------------------*/ -void -irq_port1_activate(unsigned char irqno, int (* irq)(void)) -{ - if(irqno < 8) { - port1_irq[irqno] = irq; - } -} -/*---------------------------------------------------------------------------*/ -void -irq_port1_deactivate(unsigned char irqno) -{ - if(irqno < 8) { - port1_irq[irqno] = NULL; - } -} -/*---------------------------------------------------------------------------*/ -/* Set lowest ADC to be start in sequence and highest to be interrupt - enabled and set end-of-sequence on the highest active ADC */ -static void -sethilo(void) -{ - int c; - - /* Clear start of sequence */ - ADC12CTL1 &= ~(CSTARTADD_15); - - /* Set new start of sequence to lowest active memory holder */ - for(c = 0; c < 8; c++) { - if(adcflags & (1 << c)) { - ADC12CTL1 |= (c * CSTARTADD_1); - break; - } - } - - /* Clear all interrupts and end-of-sequences */ - ADC12IE = 0; - for(c = 0; c < 8; c++) { - ADC12MCTL_NO(c) &= ~EOS; - } - - /* Set highest interrupt and end-of-sequence. This will generate one - interrupt for each sequence of conversions. */ - for(c = 0; c < 8; c++) { - if(adcflags & (128 >> c)) { - ADC12IE |= 128 >> c; - ADC12MCTL_NO(7 - c) |= EOS; - break; - } - } -} -/*---------------------------------------------------------------------------*/ -void -irq_adc12_activate(unsigned char adcno, unsigned char config, - int (* irq)(void)) -{ - if(adcno >= 8) { - return; - } - /* stop converting */ - ADC12CTL0 &= ~ENC; - /* wait for conversion to stop */ - while(ADC12CTL0 & ADC12BUSY); - ADC12CTL0 &= ~(ADC12ON | REFON); - ADC12IE = 0; - - /* clear any pending interrupts */ - ADC12IFG = 0; - - adcflags |= (1 << adcno); - - ADC12MCTL_NO(adcno) = config; - - sethilo(); - - ADC12CTL0 |= ADC12ON | REFON; - - adc12_irq[adcno] = irq; - - /* Delay */ - clock_delay(20000); - - ADC12CTL0 |= ENC | ADC12SC; -} -/*---------------------------------------------------------------------------*/ -void -irq_adc12_deactivate(unsigned char adcno) -{ - if(adcno >= 8) { - return; - } - /* stop converting */ - ADC12CTL0 &= ~ENC; - /* wait for conversion to stop */ - while(ADC12CTL0 & ADC12BUSY); - ADC12CTL0 &= ~(ADC12ON | REFON); - ADC12IE = 0; - - /* clear any pending interrupts */ - ADC12IFG = 0; - - adcflags &= ~(1 << adcno); - - ADC12MCTL_NO(adcno) = 0; - - sethilo(); - - adc12_irq[adcno] = NULL; - - if(adcflags) { - /* Turn on the ADC12 */ - ADC12CTL0 |= (ADC12ON | REFON); - - /* Delay */ - clock_delay(20000); - - /* Still active. Turn on the conversion. */ - ADC12CTL0 |= ENC | ADC12SC; - } -} -/*---------------------------------------------------------------------------*/ -int -irq_adc12_active(unsigned char adcno) -{ - return adcflags & (1 << adcno) ? 1 : 0; -} -/*---------------------------------------------------------------------------*/ diff --git a/platform/esb/dev/irq.h b/platform/esb/dev/irq.h deleted file mode 100644 index 0f1b94132..000000000 --- a/platform/esb/dev/irq.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2009, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ -#ifndef __IRQ_H__ -#define __IRQ_H__ - -void irq_init(void); - -void irq_port1_activate(unsigned char irqno, int (* irq)(void)); -void irq_port1_deactivate(unsigned char irqno); - -void irq_adc12_activate(unsigned char adcno, unsigned char config, - int (* irq)(void)); -void irq_adc12_deactivate(unsigned char adcno); - -int irq_adc12_active(unsigned char adcno); - -#endif /* __IRQ_H__ */ diff --git a/platform/esb/dev/pir-sensor.c b/platform/esb/dev/pir-sensor.c deleted file mode 100644 index 1e9b1e977..000000000 --- a/platform/esb/dev/pir-sensor.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -#include "dev/pir-sensor.h" -#include "dev/irq.h" -#include "dev/hwconf.h" - -const struct sensors_sensor pir_sensor; - -static unsigned int pir; - -#define PIR_IRQ() 3 -HWCONF_PIN(PIR, 1, PIR_IRQ()); -HWCONF_IRQ(PIR, 1, PIR_IRQ()); - -/*---------------------------------------------------------------------------*/ -static int -irq(void) -{ - ++pir; - sensors_changed(&pir_sensor); - return 1; -} -/*---------------------------------------------------------------------------*/ -static int -value(int type) -{ - return pir; -} -/*---------------------------------------------------------------------------*/ -static int -configure(int type, int value) -{ - switch(type) { - case SENSORS_HW_INIT: - pir = 0; - PIR_SELECT(); - PIR_MAKE_INPUT(); - return 1; - case SENSORS_ACTIVE: - if(value) { - if(!PIR_IRQ_ENABLED()) { - irq_port1_activate(PIR_IRQ(), irq); - PIR_ENABLE_IRQ(); - } - } else { - PIR_DISABLE_IRQ(); - irq_port1_deactivate(PIR_IRQ()); - } - return 1; - } - return 0; -} -/*---------------------------------------------------------------------------*/ -static int -status(int type) -{ - switch(type) { - case SENSORS_ACTIVE: - case SENSORS_READY: - return PIR_IRQ_ENABLED(); - } - return 0; -} -/*---------------------------------------------------------------------------*/ -SENSORS_SENSOR(pir_sensor, PIR_SENSOR, - value, configure, status); diff --git a/platform/esb/dev/pir-sensor.h b/platform/esb/dev/pir-sensor.h deleted file mode 100644 index fb32e256d..000000000 --- a/platform/esb/dev/pir-sensor.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ -#ifndef __PIR_SENSOR_H__ -#define __PIR_SENSOR_H__ - -#include "lib/sensors.h" - -extern const struct sensors_sensor pir_sensor; - -#define PIR_SENSOR "PIR" - -#endif /* __PIR_SENSOR_H__ */ diff --git a/platform/esb/dev/radio-sensor.c b/platform/esb/dev/radio-sensor.c deleted file mode 100644 index 185bd4218..000000000 --- a/platform/esb/dev/radio-sensor.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -#include "contiki.h" -#include "dev/radio-sensor.h" -#include "dev/irq.h" -#include "dev/tr1001.h" - -const struct sensors_sensor radio_sensor; - -unsigned int radio_sensor_signal; - -/*---------------------------------------------------------------------------*/ -static int -irq(void) -{ - radio_sensor_signal = ADC12MEM5; - return 0; -} -/*---------------------------------------------------------------------------*/ -static int -value(int type) -{ - switch(type) { - case RADIO_SENSOR_LAST_PACKET: - return tr1001_sstrength(); - case RADIO_SENSOR_LAST_VALUE: - default: - return radio_sensor_signal; - } -} -/*---------------------------------------------------------------------------*/ -static int -configure(int type, int value) -{ - switch(type) { - case SENSORS_HW_INIT: - /* Initialization of ADC12 done by irq */ - radio_sensor_signal = 0; - return 1; - case SENSORS_ACTIVE: - if(value) { - if(!irq_adc12_active(5)) { - irq_adc12_activate(5, (INCH_5 + SREF_0), irq); - } - } else { - irq_adc12_deactivate(5); - radio_sensor_signal = 0; - } - return 1; - } - return 0; -} -/*---------------------------------------------------------------------------*/ -static int -status(int type) -{ - switch(type) { - case SENSORS_ACTIVE: - case SENSORS_READY: - return irq_adc12_active(5); - } - return 0; -} -/*---------------------------------------------------------------------------*/ -SENSORS_SENSOR(radio_sensor, RADIO_SENSOR, - value, configure, status); diff --git a/platform/esb/dev/rs232-putchar.c b/platform/esb/dev/rs232-putchar.c deleted file mode 100644 index fae8e9adc..000000000 --- a/platform/esb/dev/rs232-putchar.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2006, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -#include "dev/rs232.h" - -int -putchar(int c) -{ - rs232_send(c); - return c; -} diff --git a/platform/esb/dev/rs232.c b/platform/esb/dev/rs232.c deleted file mode 100644 index 8f1ed2ffa..000000000 --- a/platform/esb/dev/rs232.c +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** \addtogroup esbrs232 - * @{ */ - -/** - * \file - * RS232 communication device driver for the MSP430. - * \author Adam Dunkels - * - * This file contains an RS232 device driver for the MSP430 microcontroller. - * - */ - -#include "contiki.h" -#include - -#include "contiki-esb.h" -#include "isr_compat.h" - -static int (* input_handler)(unsigned char) = NULL; - -/*---------------------------------------------------------------------------*/ -ISR(UART1RX, rs232_rx_usart1) -{ - ENERGEST_ON(ENERGEST_TYPE_IRQ); - /* Check status register for receive errors. - before reading RXBUF since - it clears the error and interrupt flags */ - if(!(URCTL1 & RXERR) && input_handler != NULL) { - - if(input_handler(RXBUF1)) { - LPM4_EXIT; - } - } else { - /* Else read out the char to clear the I-flags, etc. */ - RXBUF1; - } - ENERGEST_OFF(ENERGEST_TYPE_IRQ); -} -/*---------------------------------------------------------------------------*/ -/** - * Initalize the RS232 port. - * - */ -void -rs232_init(void) -{ - - /* RS232 */ - UCTL1 = CHAR; /* 8-bit character */ - UTCTL1 = SSEL1; /* UCLK = MCLK */ - - rs232_set_speed(RS232_57600); - - input_handler = NULL; - - ME2 |= (UTXE1 | URXE1); /* Enable USART1 TXD/RXD */ - IE2 |= URXIE1; /* Enable USART1 RX interrupt */ -} -/*---------------------------------------------------------------------------*/ -void -rs232_send(char c) -{ - - ENERGEST_ON(ENERGEST_TYPE_SERIAL); - /* Loop until the transmission buffer is available. */ - while((IFG2 & UTXIFG1) == 0) { - } - - /* Transmit the data. */ - TXBUF1 = c; - ENERGEST_OFF(ENERGEST_TYPE_SERIAL); -} -/*---------------------------------------------------------------------------*/ -void -rs232_set_speed(unsigned char speed) -{ - if(speed == RS232_19200) { - /* Set RS232 to 19200 */ - UBR01 = 0x80; /* 2,457MHz/19200 = 128 -> 0x80 */ - UBR11 = 0x00; /* */ - UMCTL1 = 0x00; /* no modulation */ - } else if(speed == RS232_38400) { - /* Set RS232 to 38400 */ - UBR01 = 0x40; /* 2,457MHz/38400 = 64 -> 0x40 */ - UBR11 = 0x00; /* */ - UMCTL1 = 0x00; /* no modulation */ - } else if(speed == RS232_57600) { - UBR01 = 0x2a; /* 2,457MHz/57600 = 42.7 -> 0x2A */ - UBR11 = 0x00; /* */ - UMCTL1 = 0x5b; /* */ - } else if(speed == RS232_115200) { - UBR01 = 0x15; /* 2,457MHz/115200 = 21.4 -> 0x15 */ - UBR11 = 0x00; /* */ - UMCTL1 = 0x4a; /* */ - } else { - rs232_set_speed(RS232_57600); - } - -} -/*---------------------------------------------------------------------------*/ -void -rs232_print(char *cptr) -{ - while(*cptr != 0) { - rs232_send(*cptr); - ++cptr; - } -} -/*---------------------------------------------------------------------------*/ -void -rs232_set_input(int (*f)(unsigned char)) -{ - input_handler = f; -} -/*---------------------------------------------------------------------------*/ -void -slip_arch_writeb(unsigned char c) -{ - rs232_send(c); -} -/*---------------------------------------------------------------------------*/ -/** @} */ diff --git a/platform/esb/dev/rs232.h b/platform/esb/dev/rs232.h deleted file mode 100644 index 6f7c0383a..000000000 --- a/platform/esb/dev/rs232.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** \addtogroup esb - * @{ */ - -/** - * \defgroup esbrs232 ESB RS232 - * - * @{ - */ - -/** - * \file - * Header file for MSP430 RS232 driver. - * \author Adam Dunkels - * - */ -#ifndef __RS232_H__ -#define __RS232_H__ - - -#define RS232_19200 1 -#define RS232_38400 2 -#define RS232_57600 3 -#define RS232_115200 4 - -/** - * \brief Initialize the RS232 module - * - * This function is called from the boot up code to - * initalize the RS232 module. - */ -void rs232_init(void); - -/** - * \brief Set an input handler for incoming RS232 data - * \param f A pointer to a byte input handler - * - * This function sets the input handler for incoming RS232 - * data. The input handler function is called for every - * incoming data byte. The function is called from the - * RS232 interrupt handler, so care must be taken when - * implementing the input handler to avoid race - * conditions. - * - * The return value of the input handler affects the sleep - * mode of the CPU: if the input handler returns non-zero - * (true), the CPU is awakened to let other processing - * take place. If the input handler returns zero, the CPU - * is kept sleeping. - */ -void rs232_set_input(int (* f)(unsigned char)); - -/** - * \brief Configure the speed of the RS232 hardware - * \param speed The speed - * - * This function configures the speed of the RS232 - * hardware. The allowed parameters are RS232_19200, - * RS232_38400, RS232_57600, and RS232_115200. - */ -void rs232_set_speed(unsigned char speed); - -/** - * \brief Print a text string on RS232 - * \param str A pointer to the string that is to be printed - * - * This function prints a string to RS232. The string must - * be terminated by a null byte. The RS232 module must be - * correctly initalized and configured for this function - * to work. - */ -void rs232_print(char *str); - -/** - * \brief Print a character on RS232 - * \param c The character to be printed - * - * This function prints a character to RS232. The RS232 - * module must be correctly initalized and configured for - * this function to work. - */ -void rs232_send(char c); - -#endif /* __RS232_H__ */ - -/** @} */ -/** @} */ diff --git a/platform/esb/dev/sound-sensor.c b/platform/esb/dev/sound-sensor.c deleted file mode 100644 index 6ac134754..000000000 --- a/platform/esb/dev/sound-sensor.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ -#include "contiki.h" -#include "dev/sound-sensor.h" -#include "dev/irq.h" -#include - -#define MIC_MIN_SENS 150 -#define SAMPLE 1 - -const struct sensors_sensor sound_sensor; - -static unsigned int sound, micdiff, micmax, avgmax; -static int8_t mode; -static int8_t sample_div; -static int8_t ctr; -static int16_t *sample_buffer; -static int buffer_size; -static int buf_pos; - -/*---------------------------------------------------------------------------*/ -static int -irq(void) -{ - micdiff = micdiff + abs(ADC12MEM4 - sound) - (micdiff >> 3); - sound = ADC12MEM4; - - if(mode == SAMPLE) { - ctr++; - if(ctr >= sample_div) { - ctr = 0; - sample_buffer[buf_pos++] = sound; - if(buf_pos >= buffer_size) { - mode = 0; - sensors_changed(&sound_sensor); - return 1; - } - } - } - -/* if(micdiff > MIC_MIN_SENS) { */ -/* sensors_changed(&sound_sensor); */ -/* } */ - -/* if(micdiff > (avgmax >> 2)) { */ -/* if(micdiff % 10 == 0) beep_beep(10); */ -/* // Subtract a little... */ -/* micdiff = micdiff - (micdiff >> 4); */ -/* } */ - -/* if(micmax < micdiff) { */ -/* micmax = micdiff; */ -/* } */ - -/* if(micdiff > 2000) { */ -/* leds_on(LEDS_GREEN); */ -/* } */ -/* if(micdiff > 3000) { */ -/* leds_on(LEDS_YELLOW); */ -/* } */ -/* if(micdiff > 4000) { */ -/* leds_on(LEDS_RED); */ -/* } */ - - return 0; -} -/*---------------------------------------------------------------------------*/ -static int -value(int type) -{ - /* try returning the max to see what values we get... */ -/* int mictmp = micmax; */ -/* avgmax = avgmax + micmax - (avgmax >> 3); */ -/* micmax = micdiff; */ -/* return mictmp; */ - return micdiff; -} -/*---------------------------------------------------------------------------*/ -static int -configure(int type, int value) -{ - switch(type) { - case SENSORS_HW_INIT: - /* Initialization of ADC12 done by irq */ - mode = 0; - buffer_size = 0; - return 1; - case SENSORS_ACTIVE: - if(value) { - if(!irq_adc12_active(4)) { - sound = micdiff = micmax = 0; - mode = 0; - ctr = 0; - sample_div = 0; - buf_pos = 0; - avgmax = 5000; - irq_adc12_activate(4, (INCH_0 + SREF_0), irq); - } - } else { - irq_adc12_deactivate(4); - } - return 1; - } - return 0; -} -/*---------------------------------------------------------------------------*/ -static int -status(int type) -{ - switch(type) { - case SENSORS_ACTIVE: - return irq_adc12_active(4); - case SENSORS_READY: - return (mode != SAMPLE) && irq_adc12_active(4); - } - return 0; -} -/*---------------------------------------------------------------------------*/ -void -sound_sensor_start_sample(void) -{ - if(buffer_size > 0) { - buf_pos = 0; - ctr = 0; - mode = SAMPLE; - } -} -/*---------------------------------------------------------------------------*/ -void -sound_sensor_set_buffer(int16_t *buffer, int buf_size, int divider) -{ - sample_buffer = buffer; - buffer_size = buf_size; - sample_div = divider; -} -/*---------------------------------------------------------------------------*/ -SENSORS_SENSOR(sound_sensor, SOUND_SENSOR, - value, configure, status); diff --git a/platform/esb/dev/sound-sensor.h b/platform/esb/dev/sound-sensor.h deleted file mode 100644 index 48d4e27cd..000000000 --- a/platform/esb/dev/sound-sensor.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ -#ifndef __SOUND_SENSOR_H__ -#define __SOUND_SENSOR_H__ - -#include "lib/sensors.h" - -extern const struct sensors_sensor sound_sensor; - -#define SOUND_SENSOR "Sound" - -void sound_sensor_start_sample(); -void sound_sensor_set_buffer(int16_t *buffer, int buf_size, int divider); - -#endif /* __SOUND_SENSOR_H__ */ diff --git a/platform/esb/dev/temperature-sensor.c b/platform/esb/dev/temperature-sensor.c deleted file mode 100644 index 9bb1ff532..000000000 --- a/platform/esb/dev/temperature-sensor.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * - * ----------------------------------------------------------------- - * - * Author : Adam Dunkels, Joakim Eriksson, Niclas Finne - * Created : 2005-11-01 - * Updated : $Date: 2010/02/08 00:00:45 $ - * $Revision: 1.3 $ - */ - -#include "dev/temperature-sensor.h" -#include "dev/ds1629.h" - -const struct sensors_sensor temperature_sensor; -static int active; - -/*---------------------------------------------------------------------------*/ -static int -value(int type) -{ - unsigned int temp; - signed int t; - - t = ds1629_temperature(); - temp = ((t / 128) * 50); - return temp; -} -/*---------------------------------------------------------------------------*/ -static int -configure(int type, int value) -{ - switch(type) { - case SENSORS_HW_INIT: - active = 0; - ds1629_init(); - return 1; - case SENSORS_ACTIVE: - if(value) { - if(!active) { - active = 1; - ds1629_start(); - } - } else { - active = 0; - } - return 1; - } - return 0; -} -/*---------------------------------------------------------------------------*/ -static int -status(int type) -{ - switch(type) { - case SENSORS_ACTIVE: - case SENSORS_READY: - return active; - } - return 0; -} -/*---------------------------------------------------------------------------*/ -SENSORS_SENSOR(temperature_sensor, TEMPERATURE_SENSOR, - value, configure, status); diff --git a/platform/esb/dev/temperature-sensor.h b/platform/esb/dev/temperature-sensor.h deleted file mode 100644 index 6aa37c42e..000000000 --- a/platform/esb/dev/temperature-sensor.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * - * ----------------------------------------------------------------- - * - * Author : Adam Dunkels, Joakim Eriksson, Niclas Finne - * Created : 2005-11-01 - * Updated : $Date: 2006/06/18 07:49:33 $ - * $Revision: 1.1 $ - */ - -#ifndef __TEMPERATURE_SENSOR_H__ -#define __TEMPERATURE_SENSOR_H__ - -#include "lib/sensors.h" - -extern const struct sensors_sensor temperature_sensor; - -#define TEMPERATURE_SENSOR "Temperature" - -#endif /* __TEMPERATURE_SENSOR_H__ */ diff --git a/platform/esb/dev/tr1001-gcr.c b/platform/esb/dev/tr1001-gcr.c deleted file mode 100644 index d751babf2..000000000 --- a/platform/esb/dev/tr1001-gcr.c +++ /dev/null @@ -1,787 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ -/** - * \addtogroup esb - * @{ - */ - -/** - * \defgroup tr1001 TR1001 radio tranciever device driver - * @{ - */ - -/** - * \file - * Device driver and packet framing for the RFM-TR1001 radio module. - * \author Adam Dunkels - * - * This file implements a device driver for the RFM-TR1001 radio - * tranciever. - * - */ - -#include "contiki.h" -#include "contiki-esb.h" - -#include "dev/tr1001.h" -#include "dev/radio-sensor.h" -#include "lib/gcr.h" -#include "lib/crc16.h" -#include "net/netstack.h" -#include "net/rime/rimestats.h" -#include "isr_compat.h" - -#include - -#ifdef TR1001_CONF_BEEP_ON_BAD_CRC -#define BEEP_ON_BAD_CRC TR1001_CONF_BEEP_ON_BAD_CRC -#else -#define BEEP_ON_BAD_CRC 1 -#endif /* TR1001_CONF_BEEP_ON_BAD_CRC */ - -#if BEEP_ON_BAD_CRC -#include "dev/beep.h" -#define BEEP_BEEP(t) beep_beep(t) -#else -#define BEEP_BEEP(t) -#endif /* BEEP_ON_BAD_CRC */ - -#define RXSTATE_READY 0 -#define RXSTATE_RECEIVING 1 -#define RXSTATE_FULL 2 - -#define SYNCH1 0x3c -#define SYNCH2 0x03 - -#ifdef TR1001_CONF_BUFFER_SIZE -#define RXBUFSIZE TR1001_CONF_BUFFER_SIZE -#else -#define RXBUFSIZE PACKETBUF_SIZE -#endif /* TR1001_CONF_BUFFER_SIZE */ - -/* - * Pending data to send when using prepare/transmit functions. - */ -static const void *pending_data; - -/* - * The buffer which holds incoming data. - */ -unsigned char tr1001_rxbuf[RXBUFSIZE]; - -/* - * The length of the packet that currently is being received. - */ -static unsigned short tr1001_rxlen = 0; - -/* - * The reception state. - */ -volatile unsigned char tr1001_rxstate = RXSTATE_READY; - -static uint16_t rxcrc, rxcrctmp; - -/* - * The structure of the packet header. - */ -struct tr1001_hdr { - uint8_t len[2]; /**< The 16-bit length of the packet in network byte - order. */ -}; - -/* - * The length of the packet header. - */ -#define TR1001_HDRLEN sizeof(struct tr1001_hdr) - -#define OFF 0 -#define ON 1 -static uint8_t onoroff = OFF; - -#define NUM_SYNCHBYTES 4 - -void tr1001_default_rxhandler(unsigned char c); -PT_THREAD(tr1001_default_rxhandler_pt(unsigned char c)); -static struct pt rxhandler_pt; - -/* - * This timer is used to keep track of when the last byte was received - * over the radio. If the inter-byte time is too large, the packet - * currently being received is discarded and a new packet reception is - * initiated. - */ -static struct timer rxtimer; - -static unsigned short tmp_sstrength, sstrength; -static unsigned short tmp_count; - -#define DEBUG 0 -#if DEBUG -#include -#define LOG(...) printf(__VA_ARGS__) -#else -#define LOG(...) -#endif - -#define GCRLOG(...) /* printf(__VA_ARGS__)*/ - -/*---------------------------------------------------------------------------*/ -PROCESS(tr1001_process, "TR1001 driver"); -/*---------------------------------------------------------------------------*/ - -static int prepare_packet(const void *data, unsigned short len); -static int transmit_packet(unsigned short len); -static int receiving_packet(void); -static int pending_packet(void); -static int channel_clear(void); -static int tr1001_on(void); -static int tr1001_off(void); - -const struct radio_driver tr1001_driver = { - tr1001_init, - prepare_packet, - transmit_packet, - tr1001_send, - tr1001_read, - channel_clear, - receiving_packet, - pending_packet, - tr1001_on, - tr1001_off -}; - -/*---------------------------------------------------------------------------*/ -/* - * Turn on data transmission in On-Off-Keyed mode. - */ -static void -txook(void) -{ - P3SEL = 0xf0; - P5OUT |= 0x40; - P5OUT &= 0x7f; -} -/*---------------------------------------------------------------------------*/ -/* - * Turn on data reception for the radio tranceiver. - */ -static void -rxon(void) -{ - P3SEL = 0xe0; - P5OUT |= 0xc0; - - /* Enable the receiver. */ - ME1 |= URXE0; - - /* Turn on receive interrupt. */ - IE1 |= URXIE0; - -} -/*---------------------------------------------------------------------------*/ -/* - * Turn off data reception for the radio tranceiver. - */ -static void -rxoff(void) -{ - P5OUT &= 0x3f; - - /* Disable the receiver. */ - ME1 &= ~URXE0; - - /* Turn off receive interrupt. */ - IE1 &= ~URXIE0; -} -/*---------------------------------------------------------------------------*/ -/* - * Clear the recevie buffer and reset the receiver state. - */ -static void -rxclear(void) -{ - tr1001_rxstate = RXSTATE_READY; -} -/*---------------------------------------------------------------------------*/ -/* - * Turn TR1001 radio transceiver off. - */ -/*---------------------------------------------------------------------------*/ -static int -tr1001_off(void) -{ - if(onoroff == OFF) { - return 1; - } - onoroff = OFF; - rxoff(); - rxclear(); - - ENERGEST_OFF(ENERGEST_TYPE_LISTEN); - return 1; -} -/*---------------------------------------------------------------------------*/ -/* - * Turn TR1001 radio transceiver on. - */ -/*---------------------------------------------------------------------------*/ -static int -tr1001_on(void) -{ - if(onoroff == ON) { - return 1; - } - - ENERGEST_ON(ENERGEST_TYPE_LISTEN); - - onoroff = ON; - rxon(); - rxclear(); - return 1; -} -/*---------------------------------------------------------------------------*/ -/* - * Send a byte of data over the radio. - * - * \param b The byte to be sent. - */ -static void -send(unsigned char b) -{ - clock_time_t start; - - start = clock_time(); - - /* Wait until the USART0 TX buffer is ready. */ - while((IFG1 & UTXIFG0) == 0) { - /* Wait no more than one second. */ - if((clock_time_t)(clock_time() - start) > (clock_time_t)CLOCK_SECOND) { - break; - } - } - - /* Send the byte. */ - TXBUF0 = b; -} -/*---------------------------------------------------------------------------*/ -/* - * Send a byte of data and its logical negation (all bits inverted) - * over the radio. - * - * \param b The byte to be sent. - */ -static void -sendx(unsigned char b) -{ - gcr_encode(b); - GCRLOG("(%02x)", b); - - while(gcr_get_encoded(&b)) { - send(b); - GCRLOG("%02x ", b); - } -} - -static uint16_t -sendx_crc16(unsigned char b, uint16_t crcacc) -{ - gcr_encode(b); - GCRLOG("(%02x)", b); - crcacc = crc16_add(b, crcacc); - while(gcr_get_encoded(&b)) { - send(b); - GCRLOG("C%02x ", b); - } - return crcacc; -} -/*---------------------------------------------------------------------------*/ -void -tr1001_set_txpower(unsigned char p) -{ - int i; - - /* Clamp maximum power. */ - if(p > 100) { - p = 100; - } - - /* First, run the potentiometer down to zero so that we know the - start value of the potentiometer. */ - P2OUT &= 0xDF; /* P25 = 0 (down selected) */ - P2OUT &= 0xBF; /* P26 = 0 (chipselect on) */ - for(i = 0; i < 102; ++i) { - P2OUT &= 0xEF; /* P24 = 0 (inc) */ - P2OUT |= 0x10; - } - - /* Now, start to increase the value of the potentiometer until it - reaches the desired value.*/ - - P2OUT |= 0x20; /* P25 = 1 (up selected) */ - for(i = 0; i < p; ++i) { - P2OUT &= 0xEF; /* P24 = 0 (inc) */ - P2OUT |= 0x10; - } - P2OUT |= 0x40; /* P26 = 1 (chipselect off) */ -} -/*---------------------------------------------------------------------------*/ -int -tr1001_init(void) -{ - PT_INIT(&rxhandler_pt); - - onoroff = OFF; - - UCTL0 = CHAR; /* 8-bit character */ - UTCTL0 = SSEL1; /* UCLK = SMCLK */ - - tr1001_set_speed(TR1001_19200); - - ME1 |= UTXE0 + URXE0; /* Enable USART0 TXD/RXD */ - - /* Turn on receive interrupt. */ - IE1 |= URXIE0; - - timer_set(&rxtimer, CLOCK_SECOND / 4); - - - tr1001_on(); - tr1001_set_txpower(100); - - /* Reset reception state. */ - rxclear(); - - process_start(&tr1001_process, NULL); - - return 1; -} -/*---------------------------------------------------------------------------*/ -ISR(UART0RX, tr1001_rxhandler) -{ - ENERGEST_ON(ENERGEST_TYPE_IRQ); - tr1001_default_rxhandler_pt(RXBUF0); - if(tr1001_rxstate == RXSTATE_FULL) { - LPM4_EXIT; - } - ENERGEST_OFF(ENERGEST_TYPE_IRQ); -} -/*---------------------------------------------------------------------------*/ -#if DEBUG -static void -dump_packet(int len) -{ - int i; - for(i = 0; i < len; ++i) { - LOG("%d: 0x%02x\n", i, tr1001_rxbuf[i]); - } -} -#endif /* DEBUG */ -/*---------------------------------------------------------------------------*/ -PT_THREAD(tr1001_default_rxhandler_pt(unsigned char incoming_byte)) -{ - static unsigned char rxtmp, tmppos; - - if(timer_expired(&rxtimer) && tr1001_rxstate != RXSTATE_FULL) { - PT_INIT(&rxhandler_pt); - } - - timer_restart(&rxtimer); - - if(tr1001_rxstate == RXSTATE_RECEIVING) { - unsigned short signal = radio_sensor.value(0); - tmp_sstrength += (signal >> 2); - tmp_count++; - } - - PT_BEGIN(&rxhandler_pt); - - while(1) { - - /* Reset reception state. */ - rxclear(); - - /* Wait until we receive the first syncronization byte. */ - PT_WAIT_UNTIL(&rxhandler_pt, incoming_byte == SYNCH1); - - tr1001_rxstate = RXSTATE_RECEIVING; - - /* Read all incoming syncronization bytes. */ - PT_WAIT_WHILE(&rxhandler_pt, incoming_byte == SYNCH1); - - /* We should receive the second synch byte by now, otherwise we'll - restart the protothread. */ - if(incoming_byte != SYNCH2) { - PT_RESTART(&rxhandler_pt); - } - - /* Start signal strength measurement */ - tmp_sstrength = 0; - tmp_count = 0; - - /* Reset the CRC. */ - rxcrc = 0xffff; - - gcr_init(); - GCRLOG("RECV: "); - - /* Read packet header. */ - for(tmppos = 0; tmppos < TR1001_HDRLEN; ++tmppos) { - - /* Wait for the first byte of the packet to arrive. */ - do { - PT_YIELD(&rxhandler_pt); - GCRLOG("(%02x) ", incoming_byte); - - gcr_decode(incoming_byte); - /* If the incoming byte isn't a valid GCR encoded byte, - we start again from the beginning. */ - if(!gcr_valid()) { - BEEP_BEEP(1000); - LOG("Incorrect GCR in header at byte %d/1 %x\n", tmppos, incoming_byte); - RIMESTATS_ADD(badsynch); - PT_RESTART(&rxhandler_pt); - } - } while(!gcr_get_decoded(&rxtmp)); - GCRLOG("%02x ", rxtmp); - - tr1001_rxbuf[tmppos] = rxtmp; - /* Calculate the CRC. */ - rxcrc = crc16_add(rxtmp, rxcrc); - } - - /* Since we've got the header, we can grab the length from it. */ - tr1001_rxlen = ((((struct tr1001_hdr *)tr1001_rxbuf)->len[0] << 8) + - ((struct tr1001_hdr *)tr1001_rxbuf)->len[1]); - - /* If the length is longer than we can handle, we'll start from - the beginning. */ - if(tmppos + tr1001_rxlen > sizeof(tr1001_rxbuf)) { - RIMESTATS_ADD(toolong); - PT_RESTART(&rxhandler_pt); - } - - /* Read packet data. */ - for(; tmppos < tr1001_rxlen + TR1001_HDRLEN; ++tmppos) { - - /* Wait for the first byte of the packet to arrive. */ - do { - PT_YIELD(&rxhandler_pt); - GCRLOG("(%02x)", incoming_byte); - - gcr_decode(incoming_byte); - /* If the incoming byte isn't a valid Manchester encoded byte, - we start again from the beinning. */ - if(!gcr_valid()) { - BEEP_BEEP(1000); - LOG("Incorrect GCR 0x%02x at byte %d/1\n", incoming_byte, - tmppos - TR1001_HDRLEN); - RIMESTATS_ADD(badsynch); - PT_RESTART(&rxhandler_pt); - } - } while(!gcr_get_decoded(&rxtmp)); - - GCRLOG("%02x ", rxtmp); - - tr1001_rxbuf[tmppos] = rxtmp; - /* Calculate the CRC. */ - rxcrc = crc16_add(rxtmp, rxcrc); - } - - /* Read the frame CRC. */ - for(tmppos = 0; tmppos < 2; ++tmppos) { - do { - PT_YIELD(&rxhandler_pt); - GCRLOG("(%02x)", incoming_byte); - - gcr_decode(incoming_byte); - if(!gcr_valid()) { - BEEP_BEEP(1000); - RIMESTATS_ADD(badsynch); - PT_RESTART(&rxhandler_pt); - } - } while(!gcr_get_decoded(&rxtmp)); - GCRLOG("%02x ", rxtmp); - - rxcrctmp = (rxcrctmp << 8) | rxtmp; - } - GCRLOG("\n"); - - if(rxcrctmp == rxcrc) { - /* A full packet has been received and the CRC checks out. We'll - request the driver to take care of the incoming data. */ - - RIMESTATS_ADD(llrx); - process_poll(&tr1001_process); - - /* We'll set the receive state flag to signal that a full frame - is present in the buffer, and we'll wait until the buffer has - been taken care of. */ - tr1001_rxstate = RXSTATE_FULL; - PT_WAIT_UNTIL(&rxhandler_pt, tr1001_rxstate != RXSTATE_FULL); - - } else { - LOG("Incorrect CRC\n"); - BEEP_BEEP(1000); - RIMESTATS_ADD(badcrc); - } - } - PT_END(&rxhandler_pt); -} -/*---------------------------------------------------------------------------*/ -static int -prepare_packet(const void *data, unsigned short len) -{ - pending_data = data; - return 0; -} -/*---------------------------------------------------------------------------*/ -static int -transmit_packet(unsigned short len) -{ - int ret = RADIO_TX_ERR; - if(pending_data != NULL) { - ret = tr1001_send(pending_data, len); - pending_data = NULL; - } - return ret; -} -/*---------------------------------------------------------------------------*/ -int -tr1001_send(const void *packet, unsigned short len) -{ - int i; - uint16_t crc16; - - LOG("tr1001_send: sending %d bytes\n", len); - - if(onoroff == ON) { - ENERGEST_OFF(ENERGEST_TYPE_LISTEN); - } - ENERGEST_ON(ENERGEST_TYPE_TRANSMIT); - - /* Prepare the transmission. */ - - /* Delay the transmission for a short random duration. */ - clock_delay(random_rand() & 0x3ff); - - - /* Check that we don't currently are receiving a packet, and if so - we wait until the reception has been completed. Reception is done - with interrupts so it is OK for us to wait in a while() loop. */ - - while(tr1001_rxstate == RXSTATE_RECEIVING && - !timer_expired(&rxtimer)) { - /* Delay the transmission for a short random duration. */ - clock_delay(random_rand() & 0x7ff); - } - - - /* Turn on OOK mode with transmission. */ - txook(); - - /* According to the datasheet, the transmitter must wait for 12 us - in order to settle. Empirical tests show that is it better to - wait for something like 283 us... */ - clock_delay(200); - - - /* Transmit preamble and synch bytes. */ - for(i = 0; i < 20; ++i) { - send(0xaa); - } - /* send(0xaa); - send(0xaa);*/ - send(0xff); - - for(i = 0; i < NUM_SYNCHBYTES; ++i) { - send(SYNCH1); - } - send(SYNCH2); - - crc16 = 0xffff; - - gcr_init(); - - GCRLOG("SEND: "); - - /* Send packet header. */ - crc16 = sendx_crc16(len >> 8, crc16); - crc16 = sendx_crc16(len & 0xff, crc16); - - /* Send packet data. */ - for(i = 0; i < len; ++i) { - crc16 = sendx_crc16(((uint8_t *)packet)[i], crc16); - } - - /* Send CRC */ - sendx(crc16 >> 8); - sendx(crc16 & 0xff); - - /* if not encoding has sent all bytes - let it send another GCR specific */ - if (!gcr_finished()) { - sendx(0); - } - - GCRLOG("\n"); - - /* Send trailing bytes. */ - send(0x33); - send(0xcc); - send(0x33); - send(0xcc); - - /* Turn on (or off) reception again. */ - if(onoroff == ON) { - ENERGEST_ON(ENERGEST_TYPE_LISTEN); - rxon(); - rxclear(); - } else { - rxoff(); - rxclear(); - } - - ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT); - RIMESTATS_ADD(lltx); - - return RADIO_TX_OK; -} -/*---------------------------------------------------------------------------*/ -int -tr1001_read(void *buf, unsigned short bufsize) -{ - unsigned short tmplen; - - if(tr1001_rxstate == RXSTATE_FULL) { - -#if DEBUG - dump_packet(tr1001_rxlen + 2); -#endif /* DEBUG */ - - tmplen = tr1001_rxlen; - - if(tmplen > bufsize) { - LOG("tr1001_read: too large packet: %d/%d bytes\n", tmplen, bufsize); - rxclear(); - RIMESTATS_ADD(toolong); - return -1; - } - - memcpy(buf, &tr1001_rxbuf[TR1001_HDRLEN], tmplen); - - /* header + content + CRC */ - sstrength = (tmp_count ? ((tmp_sstrength / tmp_count) << 2) : 0); - - rxclear(); - - LOG("tr1001_read: got %d bytes\n", tmplen); - - return tmplen; - } - return 0; -} -/*---------------------------------------------------------------------------*/ -static int -receiving_packet(void) -{ - return tr1001_rxstate == RXSTATE_RECEIVING && - !timer_expired(&rxtimer); -} -/*---------------------------------------------------------------------------*/ -static int -pending_packet(void) -{ - return tr1001_rxstate == RXSTATE_FULL; -} -/*---------------------------------------------------------------------------*/ -static int -channel_clear(void) -{ - /* TODO add CCA functionality */ - return 0; -} -/*---------------------------------------------------------------------------*/ -PROCESS_THREAD(tr1001_process, ev, data) -{ - int len; - PROCESS_BEGIN(); - - /* Reset reception state now that the process is ready to receive data. */ - rxclear(); - - while(1) { - PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_POLL); - packetbuf_clear(); - len = tr1001_read(packetbuf_dataptr(), PACKETBUF_SIZE); - if(len > 0) { - packetbuf_set_datalen(len); - NETSTACK_RDC.input(); - } - } - - PROCESS_END(); -} -/*---------------------------------------------------------------------------*/ -void -tr1001_set_speed(unsigned char speed) -{ - - if(speed == TR1001_19200) { - /* Set TR1001 to 19200 */ - UBR00 = 0x80; /* 2,457MHz/19200 = 128 -> 0x80 */ - UBR10 = 0x00; /* */ - UMCTL0 = 0x00; /* no modulation */ - } else if(speed == TR1001_38400) { - /* Set TR1001 to 38400 */ - UBR00 = 0x40; /* 2,457MHz/38400 = 64 -> 0x40 */ - UBR10 = 0x00; /* */ - UMCTL0 = 0x00; /* no modulation */ - } else if(speed == TR1001_57600) { - UBR00 = 0x2a; /* 2,457MHz/57600 = 42.7 -> 0x2A */ - UBR10 = 0x00; /* */ - UMCTL0 = 0x5b; /* */ - } else if(speed == TR1001_115200) { - UBR00 = 0x15; /* 2,457MHz/115200 = 21.4 -> 0x15 */ - UBR10 = 0x00; /* */ - UMCTL0 = 0x4a; /* */ - } else { - tr1001_set_speed(TR1001_19200); - } -} -/*---------------------------------------------------------------------------*/ -unsigned short -tr1001_sstrength(void) -{ - return sstrength; -} -/*---------------------------------------------------------------------------*/ -/** @} */ -/** @} */ diff --git a/platform/esb/dev/tr1001.c b/platform/esb/dev/tr1001.c deleted file mode 100644 index 5bee9515f..000000000 --- a/platform/esb/dev/tr1001.c +++ /dev/null @@ -1,773 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ -/** - * \addtogroup esb - * @{ - */ - -/** - * \defgroup tr1001 TR1001 radio tranciever device driver - * @{ - */ - -/** - * \file - * Device driver and packet framing for the RFM-TR1001 radio module. - * \author Adam Dunkels - * - * This file implements a device driver for the RFM-TR1001 radio - * tranciever. - * - */ - -#include "contiki.h" -#include "contiki-esb.h" - -#include "dev/tr1001.h" -#include "dev/radio-sensor.h" -#include "lib/me.h" -#include "lib/crc16.h" -#include "net/netstack.h" -#include "net/rime/rimestats.h" -#include "isr_compat.h" - -#include - -#ifdef TR1001_CONF_BEEP_ON_BAD_CRC -#define BEEP_ON_BAD_CRC TR1001_CONF_BEEP_ON_BAD_CRC -#else -#define BEEP_ON_BAD_CRC 1 -#endif /* TR1001_CONF_BEEP_ON_BAD_CRC */ - -#if BEEP_ON_BAD_CRC -#include "dev/beep.h" -#define BEEP_BEEP(t) beep_beep(t) -#else -#define BEEP_BEEP(t) -#endif /* BEEP_ON_BAD_CRC */ - -#define RXSTATE_READY 0 -#define RXSTATE_RECEIVING 1 -#define RXSTATE_FULL 2 - -#define SYNCH1 0x3c -#define SYNCH2 0x03 - -#ifdef TR1001_CONF_BUFFER_SIZE -#define RXBUFSIZE TR1001_CONF_BUFFER_SIZE -#else -#define RXBUFSIZE PACKETBUF_SIZE -#endif /* TR1001_CONF_BUFFER_SIZE */ - -/* - * Pending data to send when using prepare/transmit functions. - */ -static const void *pending_data; - -/* - * The buffer which holds incoming data. - */ -unsigned char tr1001_rxbuf[RXBUFSIZE]; - -/* - * The length of the packet that currently is being received. - */ -static unsigned short tr1001_rxlen = 0; - -/* - * The reception state. - */ -volatile unsigned char tr1001_rxstate = RXSTATE_READY; - -static uint16_t rxcrc, rxcrctmp; - -/* - * The structure of the packet header. - */ -struct tr1001_hdr { - uint8_t len[2]; /**< The 16-bit length of the packet in network byte - order. */ -}; - -/* - * The length of the packet header. - */ -#define TR1001_HDRLEN sizeof(struct tr1001_hdr) - -#define OFF 0 -#define ON 1 -static uint8_t onoroff = OFF; - -#define NUM_SYNCHBYTES 4 - -void tr1001_default_rxhandler(unsigned char c); -PT_THREAD(tr1001_default_rxhandler_pt(unsigned char c)); -static struct pt rxhandler_pt; - -/* - * This timer is used to keep track of when the last byte was received - * over the radio. If the inter-byte time is too large, the packet - * currently being received is discarded and a new packet reception is - * initiated. - */ -static struct timer rxtimer; - -static unsigned short tmp_sstrength, sstrength; -static unsigned short tmp_count; - -#define DEBUG 0 -#if DEBUG -#include -#define LOG(...) printf(__VA_ARGS__) -#else -#define LOG(...) -#endif - -/*---------------------------------------------------------------------------*/ -PROCESS(tr1001_process, "TR1001 driver"); -/*---------------------------------------------------------------------------*/ - -static int prepare_packet(const void *data, unsigned short len); -static int transmit_packet(unsigned short len); -static int receiving_packet(void); -static int pending_packet(void); -static int channel_clear(void); -static int tr1001_on(void); -static int tr1001_off(void); - -const struct radio_driver tr1001_driver = { - tr1001_init, - prepare_packet, - transmit_packet, - tr1001_send, - tr1001_read, - channel_clear, - receiving_packet, - pending_packet, - tr1001_on, - tr1001_off -}; - -/*---------------------------------------------------------------------------*/ -/* - * Turn on data transmission in On-Off-Keyed mode. - */ -static void -txook(void) -{ - P3SEL = 0xf0; - P5OUT |= 0x40; - P5OUT &= 0x7f; -} -/*---------------------------------------------------------------------------*/ -/* - * Turn on data reception for the radio tranceiver. - */ -static void -rxon(void) -{ - P3SEL = 0xe0; - P5OUT |= 0xc0; - - /* Enable the receiver. */ - ME1 |= URXE0; - - /* Turn on receive interrupt. */ - IE1 |= URXIE0; - -} -/*---------------------------------------------------------------------------*/ -/* - * Turn off data reception for the radio tranceiver. - */ -static void -rxoff(void) -{ - P5OUT &= 0x3f; - - /* Disable the receiver. */ - ME1 &= ~URXE0; - - /* Turn off receive interrupt. */ - IE1 &= ~URXIE0; -} -/*---------------------------------------------------------------------------*/ -/* - * Clear the recevie buffer and reset the receiver state. - */ -static void -rxclear(void) -{ - tr1001_rxstate = RXSTATE_READY; -} -/*---------------------------------------------------------------------------*/ -/* - * Turn TR1001 radio transceiver off. - */ -/*---------------------------------------------------------------------------*/ -static int -tr1001_off(void) -{ - if(onoroff == OFF) { - return 1; - } - onoroff = OFF; - rxoff(); - rxclear(); - - ENERGEST_OFF(ENERGEST_TYPE_LISTEN); - return 1; -} -/*---------------------------------------------------------------------------*/ -/* - * Turn TR1001 radio transceiver on. - */ -/*---------------------------------------------------------------------------*/ -static int -tr1001_on(void) -{ - if(onoroff == ON) { - return 1; - } - - ENERGEST_ON(ENERGEST_TYPE_LISTEN); - - onoroff = ON; - rxon(); - rxclear(); - return 1; -} -/*---------------------------------------------------------------------------*/ -/* - * Send a byte of data over the radio. - * - * \param b The byte to be sent. - */ -static void -send(unsigned char b) -{ - clock_time_t start; - - start = clock_time(); - - /* Wait until the USART0 TX buffer is ready. */ - while((IFG1 & UTXIFG0) == 0) { - /* Wait no more than one second. */ - if((clock_time_t)(clock_time() - start) > (clock_time_t)CLOCK_SECOND) { - break; - } - } - - /* Send the byte. */ - TXBUF0 = b; -} -/*---------------------------------------------------------------------------*/ -/* - * Send a byte of data and its logical negation (all bits inverted) - * over the radio. - * - * \param b The byte to be sent. - */ -static void -send2(unsigned char b) -{ - uint16_t m; - m = me_encode(b); - send(m >> 8); - send(m & 0xff); -} -static uint16_t -send2_crc16(unsigned char b, uint16_t crcacc) -{ - uint16_t m; - m = me_encode(b); - send(m >> 8); - send(m & 0xff); - return crc16_add(b, crcacc); -} -/*---------------------------------------------------------------------------*/ -void -tr1001_set_txpower(unsigned char p) -{ - int i; - - /* Clamp maximum power. */ - if(p > 100) { - p = 100; - } - - /* First, run the potentiometer down to zero so that we know the - start value of the potentiometer. */ - P2OUT &= 0xDF; /* P25 = 0 (down selected) */ - P2OUT &= 0xBF; /* P26 = 0 (chipselect on) */ - for(i = 0; i < 102; ++i) { - P2OUT &= 0xEF; /* P24 = 0 (inc) */ - P2OUT |= 0x10; - } - - /* Now, start to increase the value of the potentiometer until it - reaches the desired value.*/ - - P2OUT |= 0x20; /* P25 = 1 (up selected) */ - for(i = 0; i < p; ++i) { - P2OUT &= 0xEF; /* P24 = 0 (inc) */ - P2OUT |= 0x10; - } - P2OUT |= 0x40; /* P26 = 1 (chipselect off) */ -} -/*---------------------------------------------------------------------------*/ -int -tr1001_init(void) -{ - PT_INIT(&rxhandler_pt); - - onoroff = OFF; - - UCTL0 = CHAR; /* 8-bit character */ - UTCTL0 = SSEL1; /* UCLK = SMCLK */ - - tr1001_set_speed(TR1001_19200); - - ME1 |= UTXE0 + URXE0; /* Enable USART0 TXD/RXD */ - - /* Turn on receive interrupt. */ - IE1 |= URXIE0; - - timer_set(&rxtimer, CLOCK_SECOND / 4); - - - tr1001_on(); - tr1001_set_txpower(100); - - /* Reset reception state. */ - rxclear(); - - process_start(&tr1001_process, NULL); - - return 1; -} -/*---------------------------------------------------------------------------*/ -ISR(UART0RX, tr1001_rxhandler) -{ - ENERGEST_ON(ENERGEST_TYPE_IRQ); - tr1001_default_rxhandler_pt(RXBUF0); - if(tr1001_rxstate == RXSTATE_FULL) { - LPM4_EXIT; - } - ENERGEST_OFF(ENERGEST_TYPE_IRQ); -} -/*---------------------------------------------------------------------------*/ -#if DEBUG -static void -dump_packet(int len) -{ - int i; - for(i = 0; i < len; ++i) { - LOG("%d: 0x%02x\n", i, tr1001_rxbuf[i]); - } -} -#endif /* DEBUG */ -/*---------------------------------------------------------------------------*/ -PT_THREAD(tr1001_default_rxhandler_pt(unsigned char incoming_byte)) -{ - static unsigned char rxtmp, tmppos; - - if(timer_expired(&rxtimer) && tr1001_rxstate != RXSTATE_FULL) { - PT_INIT(&rxhandler_pt); - } - - timer_restart(&rxtimer); - - if(tr1001_rxstate == RXSTATE_RECEIVING) { - unsigned short signal = radio_sensor.value(0); - tmp_sstrength += (signal >> 2); - tmp_count++; - } - - PT_BEGIN(&rxhandler_pt); - - while(1) { - - /* Reset reception state. */ - rxclear(); - - /* Wait until we receive the first syncronization byte. */ - PT_WAIT_UNTIL(&rxhandler_pt, incoming_byte == SYNCH1); - - tr1001_rxstate = RXSTATE_RECEIVING; - - /* Read all incoming syncronization bytes. */ - PT_WAIT_WHILE(&rxhandler_pt, incoming_byte == SYNCH1); - - /* We should receive the second synch byte by now, otherwise we'll - restart the protothread. */ - if(incoming_byte != SYNCH2) { - PT_RESTART(&rxhandler_pt); - } - - /* Start signal strength measurement */ - tmp_sstrength = 0; - tmp_count = 0; - - /* Reset the CRC. */ - rxcrc = 0xffff; - - /* Read packet header. */ - for(tmppos = 0; tmppos < TR1001_HDRLEN; ++tmppos) { - - /* Wait for the first byte of the packet to arrive. */ - PT_YIELD(&rxhandler_pt); - - /* If the incoming byte isn't a valid Manchester encoded byte, - we start again from the beginning. */ - if(!me_valid(incoming_byte)) { - BEEP_BEEP(1000); - LOG("Incorrect manchester in header at byte %d/1\n", tmppos); - RIMESTATS_ADD(badsynch); - PT_RESTART(&rxhandler_pt); - } - - rxtmp = me_decode8(incoming_byte); - - /* Wait for the next byte to arrive. */ - PT_YIELD(&rxhandler_pt); - - if(!me_valid(incoming_byte)) { - BEEP_BEEP(1000); - LOG("Incorrect manchester in header at byte %d/2\n", tmppos); - RIMESTATS_ADD(badsynch); - PT_RESTART(&rxhandler_pt); - } - - /* Put together the two bytes into a single Manchester decoded - byte. */ - - tr1001_rxbuf[tmppos] = (rxtmp << 4) | me_decode8(incoming_byte); - - /* Calculate the CRC. */ - rxcrc = crc16_add(tr1001_rxbuf[tmppos], rxcrc); - - - } - - /* Since we've got the header, we can grab the length from it. */ - tr1001_rxlen = ((((struct tr1001_hdr *)tr1001_rxbuf)->len[0] << 8) + - ((struct tr1001_hdr *)tr1001_rxbuf)->len[1]); - - /* If the length is longer than we can handle, we'll start from - the beginning. */ - if(tmppos + tr1001_rxlen > sizeof(tr1001_rxbuf)) { - RIMESTATS_ADD(toolong); - PT_RESTART(&rxhandler_pt); - } - - /* Read packet data. */ - for(; tmppos < tr1001_rxlen + TR1001_HDRLEN; ++tmppos) { - PT_YIELD(&rxhandler_pt); - - if(!me_valid(incoming_byte)) { - LOG("Incorrect manchester 0x%02x at byte %d/1\n", incoming_byte, - tmppos - TR1001_HDRLEN); - BEEP_BEEP(1000); - RIMESTATS_ADD(badsynch); - PT_RESTART(&rxhandler_pt); - } - - rxtmp = me_decode8(incoming_byte); - - PT_YIELD(&rxhandler_pt); - - if(!me_valid(incoming_byte)) { - LOG("Incorrect manchester at byte %d/2\n", tmppos - TR1001_HDRLEN); - BEEP_BEEP(1000); - RIMESTATS_ADD(badsynch); - PT_RESTART(&rxhandler_pt); - } - - tr1001_rxbuf[tmppos] = (rxtmp << 4) | me_decode8(incoming_byte); - rxcrc = crc16_add(tr1001_rxbuf[tmppos], rxcrc); - - } - - /* Read the frame CRC. */ - for(tmppos = 0; tmppos < 4; ++tmppos) { - - PT_YIELD(&rxhandler_pt); - - if(!me_valid(incoming_byte)) { - BEEP_BEEP(1000); - RIMESTATS_ADD(badsynch); - PT_RESTART(&rxhandler_pt); - } - - rxcrctmp = (rxcrctmp << 4) | me_decode8(incoming_byte); - } - - if(rxcrctmp == rxcrc) { - /* A full packet has been received and the CRC checks out. We'll - request the driver to take care of the incoming data. */ - - RIMESTATS_ADD(llrx); - process_poll(&tr1001_process); - - /* We'll set the receive state flag to signal that a full frame - is present in the buffer, and we'll wait until the buffer has - been taken care of. */ - tr1001_rxstate = RXSTATE_FULL; - PT_WAIT_UNTIL(&rxhandler_pt, tr1001_rxstate != RXSTATE_FULL); - - } else { - LOG("Incorrect CRC\n"); - BEEP_BEEP(1000); - RIMESTATS_ADD(badcrc); - } - } - PT_END(&rxhandler_pt); -} -/*---------------------------------------------------------------------------*/ -static int -prepare_packet(const void *data, unsigned short len) -{ - pending_data = data; - return 0; -} -/*---------------------------------------------------------------------------*/ -static int -transmit_packet(unsigned short len) -{ - int ret = RADIO_TX_ERR; - if(pending_data != NULL) { - ret = tr1001_send(pending_data, len); - pending_data = NULL; - } - return ret; -} -/*---------------------------------------------------------------------------*/ -int -tr1001_send(const void *packet, unsigned short len) -{ - int i; - uint16_t crc16; - - LOG("tr1001_send: sending %d bytes\n", len); - - if(onoroff == ON) { - ENERGEST_OFF(ENERGEST_TYPE_LISTEN); - } - ENERGEST_ON(ENERGEST_TYPE_TRANSMIT); - - /* Prepare the transmission. */ - - /* Delay the transmission for a short random duration. */ - clock_delay(random_rand() & 0x3ff); - - - /* Check that we don't currently are receiving a packet, and if so - we wait until the reception has been completed. Reception is done - with interrupts so it is OK for us to wait in a while() loop. */ - - while(tr1001_rxstate == RXSTATE_RECEIVING && - !timer_expired(&rxtimer)) { - /* Delay the transmission for a short random duration. */ - clock_delay(random_rand() & 0x7ff); - } - - - /* Turn on OOK mode with transmission. */ - txook(); - - /* According to the datasheet, the transmitter must wait for 12 us - in order to settle. Empirical tests show that is it better to - wait for something like 283 us... */ - clock_delay(200); - - - /* Transmit preamble and synch bytes. */ - for(i = 0; i < 20; ++i) { - send(0xaa); - } - /* send(0xaa); - send(0xaa);*/ - send(0xff); - - for(i = 0; i < NUM_SYNCHBYTES; ++i) { - send(SYNCH1); - } - send(SYNCH2); - - crc16 = 0xffff; - - /* Send packet header. */ - crc16 = send2_crc16(len >> 8, crc16); - crc16 = send2_crc16(len & 0xff, crc16); - - /* Send packet data. */ - for(i = 0; i < len; ++i) { - crc16 = send2_crc16(((uint8_t *)packet)[i], crc16); - } - - /* Send CRC */ - send2(crc16 >> 8); - send2(crc16 & 0xff); - - /* Send trailing bytes. */ - send(0x33); - send(0xcc); - send(0x33); - send(0xcc); - - /* Turn on (or off) reception again. */ - if(onoroff == ON) { - ENERGEST_ON(ENERGEST_TYPE_LISTEN); - rxon(); - rxclear(); - } else { - rxoff(); - rxclear(); - } - - ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT); - RIMESTATS_ADD(lltx); - - return RADIO_TX_OK; -} -/*---------------------------------------------------------------------------*/ -int -tr1001_read(void *buf, unsigned short bufsize) -{ - unsigned short tmplen; - - if(tr1001_rxstate == RXSTATE_FULL) { - -#if DEBUG - dump_packet(tr1001_rxlen + 2); -#endif /* DEBUG */ - - tmplen = tr1001_rxlen; - - if(tmplen > bufsize) { - LOG("tr1001_read: too large packet: %d/%d bytes\n", tmplen, bufsize); - rxclear(); - RIMESTATS_ADD(toolong); - return -1; - } - - memcpy(buf, &tr1001_rxbuf[TR1001_HDRLEN], tmplen); - - /* header + content + CRC */ - sstrength = (tmp_count ? ((tmp_sstrength / tmp_count) << 2) : 0); - - rxclear(); - - LOG("tr1001_read: got %d bytes\n", tmplen); - - return tmplen; - } - return 0; -} -/*---------------------------------------------------------------------------*/ -static int -receiving_packet(void) -{ - return tr1001_rxstate == RXSTATE_RECEIVING && - !timer_expired(&rxtimer); -} -/*---------------------------------------------------------------------------*/ -static int -pending_packet(void) -{ - return tr1001_rxstate == RXSTATE_FULL; -} -/*---------------------------------------------------------------------------*/ -static int -channel_clear(void) -{ - /* TODO add CCA functionality */ - return 0; -} -/*---------------------------------------------------------------------------*/ -PROCESS_THREAD(tr1001_process, ev, data) -{ - int len; - PROCESS_BEGIN(); - - /* Reset reception state now that the process is ready to receive data. */ - rxclear(); - - while(1) { - PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_POLL); - packetbuf_clear(); - len = tr1001_read(packetbuf_dataptr(), PACKETBUF_SIZE); - if(len > 0) { - packetbuf_set_datalen(len); - NETSTACK_RDC.input(); - } - } - - PROCESS_END(); -} -/*---------------------------------------------------------------------------*/ -void -tr1001_set_speed(unsigned char speed) -{ - - if(speed == TR1001_19200) { - /* Set TR1001 to 19200 */ - UBR00 = 0x80; /* 2,457MHz/19200 = 128 -> 0x80 */ - UBR10 = 0x00; /* */ - UMCTL0 = 0x00; /* no modulation */ - } else if(speed == TR1001_38400) { - /* Set TR1001 to 38400 */ - UBR00 = 0x40; /* 2,457MHz/38400 = 64 -> 0x40 */ - UBR10 = 0x00; /* */ - UMCTL0 = 0x00; /* no modulation */ - } else if(speed == TR1001_57600) { - UBR00 = 0x2a; /* 2,457MHz/57600 = 42.7 -> 0x2A */ - UBR10 = 0x00; /* */ - UMCTL0 = 0x5b; /* */ - } else if(speed == TR1001_115200) { - UBR00 = 0x15; /* 2,457MHz/115200 = 21.4 -> 0x15 */ - UBR10 = 0x00; /* */ - UMCTL0 = 0x4a; /* */ - } else { - tr1001_set_speed(TR1001_19200); - } -} -/*---------------------------------------------------------------------------*/ -unsigned short -tr1001_sstrength(void) -{ - return sstrength; -} -/*---------------------------------------------------------------------------*/ -/** @} */ -/** @} */ diff --git a/platform/esb/dev/tr1001.h b/platform/esb/dev/tr1001.h deleted file mode 100644 index f9421b27e..000000000 --- a/platform/esb/dev/tr1001.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ -#ifndef __TR1001_H__ -#define __TR1001_H__ - -#include "contiki-net.h" -#include "dev/radio.h" - -#include "contiki-conf.h" - -/** - * Radio driver for TR1001 - */ -extern const struct radio_driver tr1001_driver; - -/** - * Initialize the radio transceiver. - * - * Turns on reception of bytes and installs the receive interrupt - * handler. - */ -int tr1001_init(void); - -/** - * Set the speed of the TR1001 radio device. - * - * This function sets the speed of the TR1001 radio transceiver. Both - * the sender and the receiver must have the same speed for - * communication to work. - * - * \param speed The speed of the TR1001 radio: TR1001_19200, - * TR1001_38400, TR1001_57600 or TR1001_115200. - * - */ -void tr1001_set_speed(unsigned char s); -#define TR1001_19200 1 -#define TR1001_38400 2 -#define TR1001_57600 3 -#define TR1001_115200 4 - -/** - * Set the transmission power of the transceiver. - * - * The sensor board is equipped with a DS1804 100 position trimmer - * potentiometer which is used to set the transmission input current - * to the radio transceiver chip, thus setting the transmission power - * of the radio transceiver. - * - * This function sets the trimmer potentiometer to a value between 1 - * and 100. - * - * \param p The power of the transceiver, between 1 (lowest) and 100 - * (highest). - */ -void tr1001_set_txpower(unsigned char p); - -/** - * \brief The highest transmission power - */ -#define TR1001_TXPOWER_HIGHEST 100 - -/** - * \brief The lowest transmission power - */ -#define TR1001_TXPOWER_LOWEST 1 - -/** - * Send a packet. - * - * This function causes a packet to be sent out after a small random - * delay, but without doing any MAC layer collision detection or - * back-offs. The packet is sent with a 4 byte header that contains a - * a "type" identifier, an 8-bit packet ID field and the length of the - * packet in network byte order. - * - * This function should normally not be called from user - * programs. Rather, the uIP TCP/IP or Rime stack should be used. - */ -int tr1001_send(const void *packet, unsigned short len); - -/** - * Check if an incoming packet has been received. - * - * This function checks the receive buffer to see if an entire packet - * has been received. The actual reception is handled by an interrupt - * handler. - * - * This function should normally not be called from user - * programs. Rather, the uIP TCP/IP or Rime stack should be used. - * - * \return The length of the received packet, or 0 if no packet has - * been received. - */ -int tr1001_read(void *buf, unsigned short bufsize); - -extern unsigned char tr1001_rxbuf[]; -extern volatile unsigned char tr1001_rxstate; - -/** - * Calculate the signal strength of a received packet. - * - * This function calculates the received signal strength of the last - * received packet. This function typically is called when a packet - * has been received. - */ -unsigned short tr1001_sstrength(void); - -#endif /* __TR1001_H__ */ diff --git a/platform/esb/dev/vib-sensor.c b/platform/esb/dev/vib-sensor.c deleted file mode 100644 index 95a29da60..000000000 --- a/platform/esb/dev/vib-sensor.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -#include "dev/vib-sensor.h" -#include "dev/irq.h" -#include "dev/hwconf.h" - -const struct sensors_sensor vib_sensor; - -static unsigned int vib; - -#define VIB_IRQ() 4 -HWCONF_PIN(VIB, 1, VIB_IRQ()); -HWCONF_IRQ(VIB, 1, VIB_IRQ()); - -/*---------------------------------------------------------------------------*/ -static int -irq(void) -{ - ++vib; - sensors_changed(&vib_sensor); - return 1; -} -/*---------------------------------------------------------------------------*/ -static int -value(int type) -{ - return vib; -} -/*---------------------------------------------------------------------------*/ -static int -configure(int type, int value) -{ - switch(type) { - case SENSORS_HW_INIT: - vib = 0; - VIB_SELECT(); - VIB_MAKE_INPUT(); - return 1; - case SENSORS_ACTIVE: - if(value) { - if(!VIB_IRQ_ENABLED()) { - irq_port1_activate(VIB_IRQ(), irq); - VIB_ENABLE_IRQ(); - } - } else { - VIB_DISABLE_IRQ(); - irq_port1_deactivate(VIB_IRQ()); - } - return 1; - } - return 0; -} -/*---------------------------------------------------------------------------*/ -static int -status(int type) -{ - switch(type) { - case SENSORS_ACTIVE: - case SENSORS_READY: - return VIB_IRQ_ENABLED(); - } - return 0; -} -/*---------------------------------------------------------------------------*/ -SENSORS_SENSOR(vib_sensor, VIB_SENSOR, - value, configure, status); diff --git a/platform/esb/dev/vib-sensor.h b/platform/esb/dev/vib-sensor.h deleted file mode 100644 index 53cf70b56..000000000 --- a/platform/esb/dev/vib-sensor.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ -#ifndef __VIB_SENSOR_H__ -#define __VIB_SENSOR_H__ - -#include "lib/sensors.h" - -extern const struct sensors_sensor vib_sensor; - -#define VIB_SENSOR "Vibration" - -#endif /* __VIB_SENSOR_H__ */ diff --git a/platform/esb/doc/doc.txt b/platform/esb/doc/doc.txt deleted file mode 100644 index 9c6e3365c..000000000 --- a/platform/esb/doc/doc.txt +++ /dev/null @@ -1,7 +0,0 @@ -/** - -\defgroup doc Documentation -@{ -*/ - -/** @} */ diff --git a/platform/esb/doc/esb.txt b/platform/esb/doc/esb.txt deleted file mode 100644 index e87ea093e..000000000 --- a/platform/esb/doc/esb.txt +++ /dev/null @@ -1,171 +0,0 @@ -/** \addtogroup platform - * @{ **/ - -/** -\defgroup esb The ESB Embedded Sensor Board - -The ESB (Embedded Sensor Board) is a prototype wireless sensor network -device developed at FU Berlin. - - - -The ESB consists of a Texas Instruments MSP430 low-power -microcontroller with 2k RAM and 60k flash ROM, a TR1001 radio -transceiver, a 32k serial EEPROM, an RS232 port, a JTAG port, a -beeper, and a number of sensors (passive IR, active IR -sender/receiver, vibration/tilt, microphone, temperature). - - -The Contiki/ESB port contains drivers for most of the sensors. The -drivers were mostly adapted from sources from FU Berlin. - -\section esb-getting-started Getting started with Contiki for the ESB platform - -The ESB is equipped with an MSP430 microcontroller. The first step to -getting started with Contiki for the ESB is to install the development -tools for compiling Contiki for the MSP430. - -Windows users, see \ref esb-win-setup. FreeBSD users, see \ref esb-freebsd-setup - -\section esb-win-setup Setting up the Windows environment - -The Contiki development environment under Windows uses the Cygwin -environment. Cygwin is a Linux-like environment for Windows. Cygwin -can be found at http://www.cygwin.com. Click on the icon "Install -Cygwin Now" to the right to get the installation started. - -Choose "Install from Internet" and then specify where you want to -install cygwin (recommended installation path: -C:\\cygwin). Continue with the installation until you are -asked to select packages. Most packages can be left as "Default" but -there is one package that are not installed by default. Install the -following package by clicking at "Default" until it changes to -"Install": - -- Devel - contains things for developers (make, etc). - - - -When cygwin is installed there should be a cygwin icon that starts -up a cygwin bash when clicked on. Whenever it is time to compile and -send programs to the ESB nodes it will be done from a cygwin shell. - -\subsection winintro-installing-editor C programming editor - -If you do not already have a nice programming editor it is a good -idea to download and install one. The Crimson editor is a nice -windows based editor that is both easy to get started with and -fairly powerful. - -Crimson Editor can be found at: -http://www.crimsoneditor.com/ - -The editor is useful both when editing C programs and when -modifying scripts and configuration files. - -\subsection winintro-installing-compiler MSP430 Compiler and tools - -A compiler is needed to compile the programs to the MSP430 -microprocessor that is used on the ESB sensor nodes. Download and -install the GCC toolchain for MSP430 (recommended installation path: -C:\\MSP430\\). - -The GCC toolchain for MSP430 can be found at: -http://sourceforge.net/projects/mspgcc/ - -When the above software is installed you also need to set-up the -PATH so that all of the necessary tools can be reached. In cygwin -this is done by the following line (given that you have installed -at recommended locations): - - -export PATH=\$PATH:/cygdrive/c/MSP430/mspgcc/bin - - -This line can also be added to the .profile startup file in your cygwin -home directory -(C:\\cygwin\\home\\\\\.profile). - -If your home directory is located elsewhere you can find it by -starting cygwin and running \c cd followed by \c pwd. - -\subsection winintro-installing-contiki The Contiki operating system, including examples - -When programming the ESB sensor nodes it is very useful to have an -operating system that takes care of some of the low-level tasks and -also gives you as a programmer APIs for things like events, hardware -and networking. We will use the Contiki operating system developed by -Adam Dunkels, SICS, which is very well suited when programming small -embedded systems. - -The Contiki OS can be found at: -http://www.sics.se/contiki/ - -Unzip the Contiki OS at (for example) C:\\ -and you will get the following directories among others: - -- contiki-2.x/core - the contiki operating system -- contiki-2.x/platform/esb - the contiki operating system drivers, etc for the ESB -- contiki-2.x/examples/esb/ - example applications for the ESB - -\subsection winintro-testing Testing the tools - -Now everything necessary to start developing Contiki-based sensor net -applications should be installed. Start cygwin and change to the -directory contiki-2.x/examples/esb/. Then call make -beeper.esb. - -If you get an error about multiple cygwin dlls when compiling, you -need to delete cygwin1.dll from the MSP430 GCC toolchain -(C:\\MSP430\\bin\\cygwin1.dll). - -Connect a node and turn it on. Upload the test application by calling -make beeper.u. - -\subsection winintro-testing-development Development tools - -- make \ will compile and make a executable file ready -for sending to the ESB nodes. Depending on the \c SPEC it might even -startup the application that sends the executable to the -node. Typically you would write things like "make beeper.u" -to get the file beeper.c compiled, linked and sent out to the -ESB node. - -\subsection winintro-testing-shell Some basic shell commands - -- cd \ change to a specified directory (same as in DOS) -- pwd \ shows your current directory -- ls list the directory -- mkdir \ creates a new directory -- cp \ \ copies a file - -\section esb-freebsd-setup Setting up the FreeBSD environment - -Download the msp430-gcc, msp430-binutils, and -msp430-libc packages from -http://www.sics.se/~adam/contiki/freebsd-packages/. Install the -packages (as root) with pkg_add. - -\section esb-test-compilation Compiling your first Contiki system - -\section esb-burn-node-id Burning node IDs to EEPROM - -The Contiki ESB port comes with a small program, burn-nodeid -that semi-permanently stores a (unique) node ID number in the ESB -EEPROM. When the Contiki ESB port boots up, this node ID is restored -from the EEPROM. To compile and run this program, go into your project -directory and run - -make burn-nodeid.u nodeid=X - -where X is the node ID that will be burned into EEPROM. The -burn-nodeid program stores the node ID in EEPROM, reads it -back, and writes the output to the serial port. - -@{ - -*/ - - -/** @} */ -/** @} */ diff --git a/platform/esb/doc/getting-started.txt b/platform/esb/doc/getting-started.txt deleted file mode 100644 index 39ef619d3..000000000 --- a/platform/esb/doc/getting-started.txt +++ /dev/null @@ -1,18 +0,0 @@ -/** -\addtogroup esb -\section esb-getting-started Getting started with Contiki for the ESB platform - -The ESB is equipped with an MSP430 microcontroller. The first step to -getting started with Contiki for the ESB is to install the development -tools for compiling Contiki for the MSP430. - -For Windows users, see \ref esb-win-setup - - -@{ -*/ - - -/** -@} -*/ diff --git a/platform/esb/doc/quickref.txt b/platform/esb/doc/quickref.txt deleted file mode 100644 index e45689953..000000000 --- a/platform/esb/doc/quickref.txt +++ /dev/null @@ -1,78 +0,0 @@ -/** -\defgroup quickref Function quick reference -@{ - -\section sensors Sensor functions - -Each sensor has a set of functions for controlling it and query it for -its state. Some sensors also generate an events when the sensors -change. A sensor must be activated before it generates events or -relevant values. - -- SENSORS_ACTIVATE(sensor) - activate the sensor -- SENSORS_DEACTIVATE(sensor) - deactivate the sensor -- sensor.value(0) - query the sensor for its last value - -- \ref sensors_event - event sent when a sensor has changed (the data - argument will referer to the actual sensor) - -Example for querying the button: - -- \ref SENSORS_ACTIVATE(button_sensor) - activate the button sensor -- \ref button_sensor.value(0) - the button has been pressed or not - -\subsection quickref-sensors Sensor on the ESB platform - -- \ref battery_sensor - query the battery voltage level -- \ref button_sensor - query the on-board button -- \ref pir_sensor - query the passive IR sensor (motion detector) -- \ref radio_sensor - query the radio signal strength -- \ref sound_sensor - query the microphone -- \ref temperature_sensor - query the temperature sensor -- \ref vib_sensor - query the vibration sensor - -\section quickref-leds LED functions - -- leds_on() - turn LEDs on -- leds_off() - turn LEDs off -- leds_invert() - invert LEDs -- leds_blink() - blink all LEDs - -\section quickref-beeper Beeper functions - -- beep() - click the beeper -- beep_beep() - beep -- beep_down() - pitchbend down beep -- beep_quick() - a number of quick beeps -- beep_spinup() - pitchbend up beep - -\section quickref-timers Timer functions - -Contiki provides a set of timer libraries. Event timers generates an -event when the timer expires and callback timers call a function when -the timer expires. The simple timers on the other hand have to be -actively queried to check when they have expired. - -\subsection quickref-etimer Event timers - -- etimer_expired() - check if an event timer has expired -- etimer_set() - set an event timer -- etimer_reset() - set an expired event timer to the next interval -- etimer_restart() - restart an event timer from the current point in time - -\subsection quickref-ctimer Callback timers - -- ctimer_expired() - check if a callback timer has expired -- ctimer_set() - set a callback timer -- ctimer_reset() - set an expired callback timer to the next interval -- ctimer_restart() - restart a callback timer from the current point in time - -\subsection quickref-timer Simple timers - -- timer_expired() - check if a simple timer has expired -- timer_set() - set a simple timer -- timer_reset() - set a simple event timer to the next interval -- timer_restart() - restart a simple timer from the current point in time - - -*//** @{ */ diff --git a/platform/esb/doc/slipintro.txt b/platform/esb/doc/slipintro.txt deleted file mode 100644 index 1610eceaa..000000000 --- a/platform/esb/doc/slipintro.txt +++ /dev/null @@ -1,127 +0,0 @@ -/** \addtogroup esb -@{ */ -/** -\defgroup slipintro Introduction to Over The Air Reprogramming under Windows -\author Joakim Eriksson, Niclas Finne -@{ - -\section slipintro-intro Introduction - -This is a brief introduction how to program ESB sensor nodes over -radio under Windows. It is assumed that you already have the -environment setup for programming ESB sensor nodes using JTAG cable. - -\section slipintro-configuring Configuring SLIP under Windows XP - -This section describes how to setup a SLIP connection under Windows. A -SLIP connection forwards TCP/IP traffic to/from the sensor nodes and -lets you communicate with them using standard network tools such as -\c ping. - - --# Click start button and choose 'My Computer'. Right-click 'My -Network Places' and choose 'Properties'. - --# Click 'Create a new connection'. - --# Select 'Set up an advanced connection'. - --# Select 'Connect directly to another computer'. - --# Select 'Guest'. - --# Select a name for the slip connection (for example 'ESB'). - --# Select the serial port to use when communicating with the sensor -node. - --# Add the connection by clicking 'Finish'. - --# A connection window will open. Choose 'Properties'. - - --# Click on 'Configure...' and deselect all selected -buttons. Choose the speed 57600 bps. - --# Close the modem configuration window, and go to the 'Options' -tab in the ESB properties. Deselect all except 'Display -progress...'. - --# Go to the 'Networking' tab. Change to 'SLIP: Unix Connection' -and deselect all except the first two items in the connection item -list. - --# Select 'Internet Protocol (TCP/IP)' and click -'Properties'. Enter the IP address '172.16.0.1'. - --# Click 'Advanced' and deselect all checkboxes in the 'Advanced -TCP/IP Settings'. Go to the 'WINS' tab and deselect 'Enable LMHOSTS -lookup' if it is selected. Also select 'Disable NetBIOS over -TCP/IP'. - - - - -\section slipintro-setup Setup ESB for over the air programming - -Make sure you have the latest version of Contiki (older versions of -Contiki might not work with SLIP under Windows). - --# Each node needs an IP address for OTA to work. The node id -is used to construct an IP address for the node. If you specify 2 as -node id, the node will have the IP address 172.16.1.2. Each node -should have its own unique node id. To set the node id move to the -directory 'contiki-2.x/examples/esb' and run -\code -make burn-nodeid.u nodeid=X -\endcode -Use the number 1, 2, 3, etc, as the node id (\c X) for the nodes. This -will give the nodes the IP addresses 172.16.1.1, 172.16.1.2, etc. The -node id only needs to be set once for each node and it will remain -even when new applications are uploaded onto the node. --# You need to compile a core and upload it onto the nodes. All nodes -must run the same core. Move to the directory -'contiki-2.x/examples/esb' and run -\code -make WITH_CODEPROP=1 core -make WITH_CODEPROP=1 core.u -\endcode -to upload the core to your nodes. --# Attach the ESB node to the serial port and make sure it is -turned on. Select your ESB SLIP connection in your 'Network -Connections' and choose 'Connect' (or double click on it). If -everything works Windows should say that you have a new connection. --# Set the IP address for the node by pinging it (it will claim the -IP address of the first ping it hears). Note that the slip interface -has IP address 172.16.0.1 but the node will have the IP address -172.16.1.1. -\code -ping 172.16.1.1 -\endcode - -If everything works the node should click and reply to the pings. - -You also need a program to send the application to connected -nodes. Compile it by running - -\code -make send -\endcode - -\section slipintro-send Send programs over the air - -Contiki applications to be installed via radio are compiled somewhat -different compared to normal applications. - -Make sure you have a node with IP address 172.16.1.1 connected to your -serial port and have SLIP activated. Then compile and send a -testprogram by running - -\code -make beeper.ce -./send 172.16.1.1 beeper.ce -\endcode - -*/ -/** @} */ -/** @} */ diff --git a/platform/esb/loader/loader-arch.h b/platform/esb/loader/loader-arch.h deleted file mode 100644 index 260062d5a..000000000 --- a/platform/esb/loader/loader-arch.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ -#ifndef __LOADER_ARCH_H__ -#define __LOADER_ARCH_H__ - -/** - * Load a program from EEPROM. - * - * This function loads a program from EEPROM into the flash ROM (code) and RAM (data). - * - * \param code The address of the first byte of code in the EEPROM. - * - * \param codelen The length of the code. - * - * \param data The address of the first byte of data in the EEPROM. - * - * \param datalen The length of the data. - * - */ -void loader_arch_load(unsigned short startaddr); - -/** - * Unload a program. - * - * This function should not be called directly, but accessed through - * the macro LOADER_UNLOAD(). The function unloads a program from both - * RAM and ROM. - * - * \param codeaddr A pointer to the first byte of program code. - * - * \param dataaddr A pointer to the first byte of program data. - */ -void loader_arch_free(void *codeaddr, void *dataaddr); - -extern void *loader_arch_codeaddr, *loader_arch_dataaddr; - -#ifndef LOADER_UNLOAD -#define LOADER_UNLOAD() loader_arch_free(&loader_arch_codeaddr, &loader_arch_dataaddr) -#endif - -#define LOADER_ARCH_MAGIC 0x373a -#define LOADER_ARCH_VERSION 0x0001 - -#endif /* __LOADER_ARCH_H__ */ diff --git a/platform/esb/net/uip-driver.c b/platform/esb/net/uip-driver.c deleted file mode 100644 index 27dac8703..000000000 --- a/platform/esb/net/uip-driver.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2010, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -/** - * \file - * A brief description of what this file is - * \author - * Niclas Finne - * Joakim Eriksson - */ - -#include "net/netstack.h" -#include "net/uip.h" -#include "net/tcpip.h" -#include "net/hc.h" -#include "net/packetbuf.h" -#include "net/uip-driver.h" -#include - -/*--------------------------------------------------------------------*/ -static void -init(void) -{ - /* - * Set out output function as the function to be called from uIP to - * send a packet. - */ - tcpip_set_outputfunc(uip_driver_send); -} -/*--------------------------------------------------------------------*/ -static void -input(void) -{ - if(packetbuf_datalen() > 0 && - packetbuf_datalen() <= UIP_BUFSIZE - UIP_LLH_LEN) { - memcpy(&uip_buf[UIP_LLH_LEN], packetbuf_dataptr(), packetbuf_datalen()); - uip_len = hc_inflate(&uip_buf[UIP_LLH_LEN], packetbuf_datalen()); - tcpip_input(); - } -} -/*--------------------------------------------------------------------*/ -uint8_t -uip_driver_send(void) -{ - uip_len = hc_compress(&uip_buf[UIP_LLH_LEN], uip_len); - packetbuf_copyfrom(&uip_buf[UIP_LLH_LEN], uip_len); - - /* XXX we should provide a callback function that is called when the - packet is sent. For now, we just supply a NULL pointer. */ - NETSTACK_MAC.send(NULL, NULL); - return 1; -} -/*--------------------------------------------------------------------*/ -const struct network_driver uip_driver = { - "uip", - init, - input -}; -/*--------------------------------------------------------------------*/ diff --git a/platform/esb/net/uip-driver.h b/platform/esb/net/uip-driver.h deleted file mode 100644 index c067f647b..000000000 --- a/platform/esb/net/uip-driver.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2010, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -/** - * \file - * A brief description of what this file is - * \author - * Niclas Finne - * Joakim Eriksson - */ - -#ifndef __UIP_DRIVER_H__ -#define __UIP_DRIVER_H__ - -#include "net/netstack.h" - -uint8_t uip_driver_send(void); - -extern const struct network_driver uip_driver; - -#endif /* __UIP_DRIVER_H__ */ diff --git a/platform/esb/node-id.c b/platform/esb/node-id.c deleted file mode 100644 index 14dc735d5..000000000 --- a/platform/esb/node-id.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2006, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * \file - * A brief description of what this file is. - * \author - * Adam Dunkels - */ - -#include "sys/node-id.h" -#include "contiki-conf.h" -#include "dev/eeprom.h" - -unsigned short node_id = 0; -/*---------------------------------------------------------------------------*/ -void -node_id_restore(void) -{ - unsigned char buf[2]; - eeprom_read(NODE_ID_EEPROM_OFFSET, buf, 2); - if(buf[0] == 0xad && - buf[1] == 0xde) { - eeprom_read(NODE_ID_EEPROM_OFFSET + 2, buf, 2); - node_id = (buf[0] << 8) | buf[1]; - } else { - node_id = 0; - } -} -/*---------------------------------------------------------------------------*/ -void -node_id_burn(unsigned short id) -{ - unsigned char buf[2]; - buf[0] = 0xad; - buf[1] = 0xde; - eeprom_write(NODE_ID_EEPROM_OFFSET, buf, 2); - buf[0] = id >> 8; - buf[1] = id & 0xff; - eeprom_write(NODE_ID_EEPROM_OFFSET + 2, buf, 2); -} -/*---------------------------------------------------------------------------*/ diff --git a/platform/jcreate/Makefile.jcreate b/platform/jcreate/Makefile.jcreate deleted file mode 100644 index b9501e97f..000000000 --- a/platform/jcreate/Makefile.jcreate +++ /dev/null @@ -1,17 +0,0 @@ -# Use custom platform configuration -CFLAGS += -DPLATFORM_CONF_H=\"platform-jcreate-conf.h\" - -# Some drivers such as ds2411.c only compile under platform sky -CFLAGS += -DCONTIKI_TARGET_SKY - -CONTIKI_TARGET_SOURCEFILES += contiki-jcreate-platform.c \ - battery-sensor.c radio-sensor.c \ - temperature-sensor.c acc-sensor.c ext-sensor.c - -include $(CONTIKI)/platform/sky/Makefile.common - -ifneq ($(TMOTE_BSL), 1) - ${warning No $(TMOTE_BSL_FILE) command for jcreate found. Please install this command in $(CONTIKI)/tools/sky} -endif - -CONTIKI_TARGET_DIRS += ${addprefix ../sky/,. dev apps} diff --git a/platform/jcreate/contiki-jcreate-platform.c b/platform/jcreate/contiki-jcreate-platform.c deleted file mode 100644 index 8d81ceef6..000000000 --- a/platform/jcreate/contiki-jcreate-platform.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2010, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - * Author: Niclas Finne , Joakim Eriksson - * - */ - -#include "dev/battery-sensor.h" - -SENSORS(&battery_sensor); - -void -init_platform(void) -{ - process_start(&sensors_process, NULL); -} diff --git a/platform/jcreate/dev/acc-sensor.c b/platform/jcreate/dev/acc-sensor.c deleted file mode 100644 index bf7de1963..000000000 --- a/platform/jcreate/dev/acc-sensor.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2010, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * - * ----------------------------------------------------------------- - * - * Author : Adam Dunkels, Joakim Eriksson, Niclas Finne - * Created : 2005-11-01 - * Updated : $Date: 2010/08/25 19:34:42 $ - * $Revision: 1.2 $ - */ - -#include "contiki.h" -#include "dev/acc-sensor.h" -#include "dev/sky-sensors.h" - -/* Configure ADC12_2 to sample channel 4, 5, 6 and use */ -/* the Vref+ as reference (SREF_1) since it is a stable reference */ -#define INPUT_CHANNEL ((1 << INCH_4) | (1 << INCH_5) | (1 << INCH_6)) -#define INPUT_REFERENCE SREF_1 -#define ACC_MEM_X ADC12MEM4 /* Xout */ -#define ACC_MEM_Y ADC12MEM5 /* Yout */ -#define ACC_MEM_Z ADC12MEM6 /* Zout */ - -const struct sensors_sensor acc_sensor; - -/*---------------------------------------------------------------------------*/ -static int -value(int type) -{ - switch(type) { - case ACC_SENSOR_X: - return ACC_MEM_X; - case ACC_SENSOR_Y: - return ACC_MEM_Y; - case ACC_SENSOR_Z: - return ACC_MEM_Z; - } - return 0; -} -/*---------------------------------------------------------------------------*/ -static int -configure(int type, int c) -{ - if(type == SENSORS_ACTIVE) { - /* Sleep Mode P2.3 */ - if(c) { - P2OUT |= 0x08; - P2DIR |= 0x08; - } else { - /* Sensor deactivated. Changed to sleep mode. */ - P2OUT &= ~0x08; - } - } else if(type == ACC_SENSOR_SENSITIVITY) { - /* g-Select1 P2.0, g-Select2 P2.1 */ - P2DIR |= 0x03; - P2OUT &= ~0x03; - P2OUT |= c & 0x03; - } - return sky_sensors_configure(INPUT_CHANNEL, INPUT_REFERENCE, type, c); -} -/*---------------------------------------------------------------------------*/ -static int -status(int type) -{ - if(type == ACC_SENSOR_SENSITIVITY) { - return (P2OUT & P2DIR) & 0x03; - } - return sky_sensors_status(INPUT_CHANNEL, type); -} -/*---------------------------------------------------------------------------*/ -SENSORS_SENSOR(acc_sensor, ACC_SENSOR, value, configure, status); diff --git a/platform/jcreate/dev/acc-sensor.h b/platform/jcreate/dev/acc-sensor.h deleted file mode 100644 index bf31d1955..000000000 --- a/platform/jcreate/dev/acc-sensor.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2006, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * - * ----------------------------------------------------------------- - * - * Author : Adam Dunkels, Joakim Eriksson, Niclas Finne - * Created : 2005-11-01 - * Updated : $Date: 2010/08/25 19:34:42 $ - * $Revision: 1.2 $ - */ - -#ifndef __ACC_SENSOR_H__ -#define __ACC_SENSOR_H__ - -#include "lib/sensors.h" - -extern const struct sensors_sensor acc_sensor; - -#define ACC_SENSOR "Acc" - -#define ACC_SENSOR_X 0 -#define ACC_SENSOR_Y 1 -#define ACC_SENSOR_Z 2 - -/* - Sensitivity configuration (g-Select1 and g-Select2) - Value g-Range Sensitivity - 0 1.5g 800mV/g - 1 2g 600mV/g - 2 4g 300mV/g - 3 6g 200mV/g -*/ -#define ACC_SENSOR_SENSITIVITY 10 - -#endif /* __ACC_SENSOR_H__ */ diff --git a/platform/jcreate/dev/ext-sensor.c b/platform/jcreate/dev/ext-sensor.c deleted file mode 100644 index a034448cb..000000000 --- a/platform/jcreate/dev/ext-sensor.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2006, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * - * ----------------------------------------------------------------- - * - * Author : Adam Dunkels, Joakim Eriksson, Niclas Finne, Marcus Lundén, - * Jesper Karlsson - * Created : 2005-11-01 - * Updated : $Date: 2010/08/25 19:34:42 $ - * $Revision: 1.2 $ - */ - - -#include "contiki.h" -#include "dev/ext-sensor.h" -#include "dev/sky-sensors.h" - -/* SREF_0 is AVCC */ -/* SREF_1 is Vref+ */ -/* ADC0 == P6.0/A0 == port "under" logo */ -/* ADC1 == P6.1/A1 == port "over" logo */ -/* ADC2 == P6.2/A2, bottom expansion port */ -/* ADC3 == P6.1/A3, bottom expansion port, End Of (ADC-)Sequence */ - -#define INPUT_CHANNEL ((1 << INCH_0) | (1 << INCH_1) | \ - (1 << INCH_2) | (1 << INCH_3)) -#define INPUT_REFERENCE SREF_0 -#define EXT_MEM0 ADC12MEM0 -#define EXT_MEM1 ADC12MEM1 -#define EXT_MEM2 ADC12MEM2 -#define EXT_MEM3 ADC12MEM3 - -const struct sensors_sensor ext_sensor; -/*---------------------------------------------------------------------------*/ -static int -value(int type) -{ - /* ADC0 corresponds to the port under the logo, ADC1 to the port - over the logo, ADC2 and ADC3 corresponds to port on the JCreate - bottom expansion port) */ - switch(type) { - case ADC0: - return EXT_MEM0; - case ADC1: - return EXT_MEM1; - case ADC2: - return EXT_MEM2; - case ADC3: - return EXT_MEM3; - } - return 0; -} -/*---------------------------------------------------------------------------*/ -static int -status(int type) -{ - return sky_sensors_status(INPUT_CHANNEL, type); -} -/*---------------------------------------------------------------------------*/ -static int -configure(int type, int c) -{ - return sky_sensors_configure(INPUT_CHANNEL, INPUT_REFERENCE, type, c); -} -/*---------------------------------------------------------------------------*/ -SENSORS_SENSOR(ext_sensor, "Ext", value, configure, status); diff --git a/platform/jcreate/dev/ext-sensor.h b/platform/jcreate/dev/ext-sensor.h deleted file mode 100644 index c2c9f36e5..000000000 --- a/platform/jcreate/dev/ext-sensor.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2006, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * - * ----------------------------------------------------------------- - * - * Author : Marcus Lundén - * Created : 2005-11-01 - * Updated : $Date: 2010/05/03 21:57:35 $ - * $Revision: 1.1 $ - */ - -#ifndef __EXT_SENSOR_H__ -#define __EXT_SENSOR_H__ - -#include "lib/sensors.h" - -#define ADC0 0 -#define ADC1 1 -#define ADC2 2 -#define ADC3 3 - -extern const struct sensors_sensor ext_sensor; - -#define EXT_SENSOR "Ext" - -#endif /* __EXT_SENSOR_H__ */ diff --git a/platform/jcreate/leds-arch.c b/platform/jcreate/leds-arch.c deleted file mode 100644 index 4f4dc748c..000000000 --- a/platform/jcreate/leds-arch.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2010, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -/** - * \file - * A leds implementation for the jcreate platform - * \author - * Adam Dunkels - * Niclas Finne - * Joakim Eriksson - */ - -#include "contiki.h" -#include "dev/leds.h" - -/*---------------------------------------------------------------------------*/ -void -leds_arch_init(void) -{ - LEDS_PxDIR = 0xff; - LEDS_PxOUT = 0xff; -} -/*---------------------------------------------------------------------------*/ -unsigned char -leds_arch_get(void) -{ - return ~LEDS_PxOUT; -} -/*---------------------------------------------------------------------------*/ -void -leds_arch_set(unsigned char leds) -{ - LEDS_PxOUT = ~leds; -} -/*---------------------------------------------------------------------------*/ diff --git a/platform/jcreate/platform-jcreate-conf.h b/platform/jcreate/platform-jcreate-conf.h deleted file mode 100644 index 8344f4a1b..000000000 --- a/platform/jcreate/platform-jcreate-conf.h +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright (c) 2011, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/** - * \file - * Platform configuration for the Sentilla JCreate - * \author - * Niclas Finne - * Joakim Eriksson - */ - -#ifndef __PLATFORM_CONF_H__ -#define __PLATFORM_CONF_H__ - -/* - * Definitions below are dictated by the hardware and not really - * changeable! - */ -/* Platform TMOTE_SKY */ -#define TMOTE_SKY 1 - -#define LEDS_CONF_ALL 255 -#define PLATFORM_HAS_LEDS 1 -#define PLATFORM_HAS_BUTTON 0 - -/* CPU target speed in Hz */ -#define F_CPU 3900000uL /*2457600uL*/ - -/* Our clock resolution, this is the same as Unix HZ. */ -#define CLOCK_CONF_SECOND 128UL - -#define BAUD2UBR(baud) ((F_CPU/baud)) - -#define CCIF -#define CLIF - -#define HAVE_STDINT_H -#include "msp430def.h" - - -/* Types for clocks and uip_stats */ -typedef unsigned short uip_stats_t; -typedef unsigned long clock_time_t; -typedef unsigned long off_t; - -/* the low-level radio driver */ -#define NETSTACK_CONF_RADIO cc2420_driver - -/* LED ports */ -#define LEDS_PxDIR P5DIR -#define LEDS_PxOUT P5OUT -#define LEDS_CONF_RED 0x10 -#define LEDS_CONF_GREEN 0x20 -#define LEDS_CONF_YELLOW 0x40 - -/* DCO speed resynchronization for more robust UART, etc. */ -#ifndef DCOSYNCH_CONF_ENABLED -#define DCOSYNCH_CONF_ENABLED 1 -#endif /* DCOSYNCH_CONF_ENABLED */ -#ifndef DCOSYNCH_CONF_PERIOD -#define DCOSYNCH_CONF_PERIOD 30 -#endif /* DCOSYNCH_CONF_PERIOD */ - -#define ROM_ERASE_UNIT_SIZE 512 -#define XMEM_ERASE_UNIT_SIZE (64*1024L) - - -#define CFS_CONF_OFFSET_TYPE long - - -/* Use the first 64k of external flash for node configuration */ -#define NODE_ID_XMEM_OFFSET (0 * XMEM_ERASE_UNIT_SIZE) - -/* Use the second 64k of external flash for codeprop. */ -#define EEPROMFS_ADDR_CODEPROP (1 * XMEM_ERASE_UNIT_SIZE) - -#define CFS_XMEM_CONF_OFFSET (2 * XMEM_ERASE_UNIT_SIZE) -#define CFS_XMEM_CONF_SIZE (1 * XMEM_ERASE_UNIT_SIZE) - -#define CFS_RAM_CONF_SIZE 4096 - -/* - * SPI bus configuration for the TMote Sky. - */ - -/* SPI input/output registers. */ -#define SPI_TXBUF U0TXBUF -#define SPI_RXBUF U0RXBUF - - /* USART0 Tx ready? */ -#define SPI_WAITFOREOTx() while ((U0TCTL & TXEPT) == 0) - /* USART0 Rx ready? */ -#define SPI_WAITFOREORx() while ((IFG1 & URXIFG0) == 0) - /* USART0 Tx buffer ready? */ -#define SPI_WAITFORTxREADY() while ((IFG1 & UTXIFG0) == 0) - -#define SCK 1 /* P3.1 - Output: SPI Serial Clock (SCLK) */ -#define MOSI 2 /* P3.2 - Output: SPI Master out - slave in (MOSI) */ -#define MISO 3 /* P3.3 - Input: SPI Master in - slave out (MISO) */ - -/* - * SPI bus - M25P80 external flash configuration. - */ - -#define FLASH_PWR 3 /* P4.3 Output */ -#define FLASH_CS 4 /* P4.4 Output */ -#define FLASH_HOLD 7 /* P4.7 Output */ - -/* Enable/disable flash access to the SPI bus (active low). */ - -#define SPI_FLASH_ENABLE() ( P4OUT &= ~BV(FLASH_CS) ) -#define SPI_FLASH_DISABLE() ( P4OUT |= BV(FLASH_CS) ) - -#define SPI_FLASH_HOLD() ( P4OUT &= ~BV(FLASH_HOLD) ) -#define SPI_FLASH_UNHOLD() ( P4OUT |= BV(FLASH_HOLD) ) - -/* - * SPI bus - CC2420 pin configuration. - */ - -#define CC2420_CONF_SYMBOL_LOOP_COUNT 800 - -/* P1.0 - Input: FIFOP from CC2420 */ -#define CC2420_FIFOP_PORT(type) P1##type -#define CC2420_FIFOP_PIN 0 -/* P1.3 - Input: FIFO from CC2420 */ -#define CC2420_FIFO_PORT(type) P1##type -#define CC2420_FIFO_PIN 3 -/* P1.4 - Input: CCA from CC2420 */ -#define CC2420_CCA_PORT(type) P1##type -#define CC2420_CCA_PIN 4 -/* P4.1 - Input: SFD from CC2420 */ -#define CC2420_SFD_PORT(type) P4##type -#define CC2420_SFD_PIN 1 -/* P4.2 - Output: SPI Chip Select (CS_N) */ -#define CC2420_CSN_PORT(type) P4##type -#define CC2420_CSN_PIN 2 -/* P4.5 - Output: VREG_EN to CC2420 */ -#define CC2420_VREG_PORT(type) P4##type -#define CC2420_VREG_PIN 5 -/* P4.6 - Output: RESET_N to CC2420 */ -#define CC2420_RESET_PORT(type) P4##type -#define CC2420_RESET_PIN 6 - -#define CC2420_IRQ_VECTOR PORT1_VECTOR - -/* Pin status. */ -#define CC2420_FIFOP_IS_1 (!!(CC2420_FIFOP_PORT(IN) & BV(CC2420_FIFOP_PIN))) -#define CC2420_FIFO_IS_1 (!!(CC2420_FIFO_PORT(IN) & BV(CC2420_FIFO_PIN))) -#define CC2420_CCA_IS_1 (!!(CC2420_CCA_PORT(IN) & BV(CC2420_CCA_PIN))) -#define CC2420_SFD_IS_1 (!!(CC2420_SFD_PORT(IN) & BV(CC2420_SFD_PIN))) - -/* The CC2420 reset pin. */ -#define SET_RESET_INACTIVE() (CC2420_RESET_PORT(OUT) |= BV(CC2420_RESET_PIN)) -#define SET_RESET_ACTIVE() (CC2420_RESET_PORT(OUT) &= ~BV(CC2420_RESET_PIN)) - -/* CC2420 voltage regulator enable pin. */ -#define SET_VREG_ACTIVE() (CC2420_VREG_PORT(OUT) |= BV(CC2420_VREG_PIN)) -#define SET_VREG_INACTIVE() (CC2420_VREG_PORT(OUT) &= ~BV(CC2420_VREG_PIN)) - -/* CC2420 rising edge trigger for external interrupt 0 (FIFOP). */ -#define CC2420_FIFOP_INT_INIT() do { \ - CC2420_FIFOP_PORT(IES) &= ~BV(CC2420_FIFOP_PIN); \ - CC2420_CLEAR_FIFOP_INT(); \ - } while(0) - -/* FIFOP on external interrupt 0. */ -#define CC2420_ENABLE_FIFOP_INT() do {CC2420_FIFOP_PORT(IE) |= BV(CC2420_FIFOP_PIN);} while(0) -#define CC2420_DISABLE_FIFOP_INT() do {CC2420_FIFOP_PORT(IE) &= ~BV(CC2420_FIFOP_PIN);} while(0) -#define CC2420_CLEAR_FIFOP_INT() do {CC2420_FIFOP_PORT(IFG) &= ~BV(CC2420_FIFOP_PIN);} while(0) - -/* - * Enables/disables CC2420 access to the SPI bus (not the bus). - * (Chip Select) - */ - - /* ENABLE CSn (active low) */ -#define CC2420_SPI_ENABLE() (CC2420_CSN_PORT(OUT) &= ~BV(CC2420_CSN_PIN)) - /* DISABLE CSn (active low) */ -#define CC2420_SPI_DISABLE() (CC2420_CSN_PORT(OUT) |= BV(CC2420_CSN_PIN)) -#define CC2420_SPI_IS_ENABLED() ((CC2420_CSN_PORT(OUT) & BV(CC2420_CSN_PIN)) != BV(CC2420_CSN_PIN)) - -#endif /* __PLATFORM_CONF_H__ */ diff --git a/platform/msb430/Makefile b/platform/msb430/Makefile deleted file mode 100644 index 120434cd0..000000000 --- a/platform/msb430/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# $Id: Makefile,v 1.3 2007/08/17 13:10:16 nvt-se Exp $ - -all: test-abc -upload: test-abc test-abc.u - -test-abc: - $(MAKE) test-abc.firmware && \ - $(MAKE) test-abc.firmware && \ - $(MAKE) test-abc.firmware - -CONTIKI=../.. -TARGET=msb430 - -include $(CONTIKI)/Makefile.include diff --git a/platform/msb430/Makefile.msb430 b/platform/msb430/Makefile.msb430 deleted file mode 100644 index 8ac7f68f9..000000000 --- a/platform/msb430/Makefile.msb430 +++ /dev/null @@ -1,74 +0,0 @@ -SENSORS = sensors.c sht11.c -MSB = dma.c infomem.c node-id.c \ - msb430-uart1.c rs232.c \ - cc1020.c cc1020-uip.c adc.c \ - msb430-slip-arch.c sd.c sd-arch.c \ - cfs-coffee.c cfs-coffee-arch.c - -CONTIKI_TARGET_DIRS = . dev apps loader -ifndef CONTIKI_TARGET_MAIN -CONTIKI_TARGET_MAIN = contiki-msb430-main.c -endif - -CONTIKI_TARGET_SOURCEFILES += $(SENSORS) $(MSB) $(CONTIKI_TARGET_MAIN) - -MCU=msp430f1612 -include $(CONTIKI)/cpu/msp430/Makefile.msp430 - -contiki-$(TARGET).a: ${addprefix $(OBJECTDIR)/,symbols.o} -# $(AR) rcf $@ $^ - -ifndef BASE_IP -BASE_IP := 172.16.1.1 -endif - -### System dependent Makefile - -ifeq ($(HOST_OS),FreeBSD) - # settings for FreeBSD - -include $(CONTIKI)/platform/$(TARGET)/buildscripts/Makefile.freebsd -else - ifeq ($(HOST_OS),Windows) - # settings for Windows - -include $(CONTIKI)/platform/$(TARGET)/buildscripts/Makefile.win - else - # settings for an arbitary unix-like platform - -include $(CONTIKI)/platform/$(TARGET)/buildscripts/Makefile.unix - endif -endif - -# If we are not running under Windows, we assume Linux -ifndef MOTELIST - USBDEVPREFIX= - SERIALDUMP = $(CONTIKI)/tools/sky/serialdump-linux - MOTELIST = $(CONTIKI)/tools/sky/motelist-linux - MOTES = $(shell $(MOTELIST) 2>&- | grep USB | \ - cut -f 4 -d \ | \ - perl -ne 'print $$1 . " " if(m-(/dev/\w+)-);') - CMOTES=$(MOTES) -endif - -msb-motelist: - $(MOTELIST) -msb-motes: - @echo $(MOTES) - -ifdef MOTE -serialdump: - $(SERIALDUMP) -b115200 $(USBDEVPREFIX)$(word $(MOTE), $(CMOTES)) | $(CONTIKI)/tools/timestamp | tee serialdump-`date +%Y%m%d-%H%M` - -serialview: - $(SERIALDUMP) -b115200 $(USBDEVPREFIX)$(word $(MOTE), $(CMOTES)) | $(CONTIKI)/tools/timestamp - -login: - $(SERIALDUMP) -b115200 $(USBDEVPREFIX)$(word $(MOTE), $(CMOTES)) -else -serialdump: - $(SERIALDUMP) -b115200 $(USBDEVPREFIX)$(firstword $(CMOTES)) | $(CONTIKI)/tools/timestamp | tee serialdump-`date +%Y%m%d-%H%M` - -serialview: - $(SERIALDUMP) -b115200 $(USBDEVPREFIX)$(firstword $(CMOTES)) | $(CONTIKI)/tools/timestamp - -login: - $(SERIALDUMP) -b115200 $(USBDEVPREFIX)$(firstword $(CMOTES)) -endif diff --git a/platform/msb430/apps/Makefile.apps b/platform/msb430/apps/Makefile.apps deleted file mode 100644 index faa02d97d..000000000 --- a/platform/msb430/apps/Makefile.apps +++ /dev/null @@ -1,2 +0,0 @@ -helloworld: helloworld.c -test-abc: test-abc.c diff --git a/platform/msb430/apps/acc-test.c b/platform/msb430/apps/acc-test.c deleted file mode 100644 index 09cf96842..000000000 --- a/platform/msb430/apps/acc-test.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2007, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -#include "contiki.h" -#include "net/rime.h" -#include "dev/sd.h" - -#include -#include - -/*---------------------------------------------------------------------------*/ -PROCESS(test_acc_process, "Accelerometer test"); -AUTOSTART_PROCESSES(&test_acc_process); -/*---------------------------------------------------------------------------*/ -PROCESS_THREAD(test_acc_process, ev, data) -{ - static struct etimer et; - static int x, y, z; - static uint32_t xa, ya, za; - - PROCESS_BEGIN(); - - while(1) { - etimer_set(&et, CLOCK_SECOND / 8); - PROCESS_WAIT_EVENT(); - if (etimer_expired(&et)) { - adc_on(); - x = ADC12MEM0; - y = ADC12MEM1; - z = ADC12MEM2; - xa = xa + x - (xa >> 4); - ya = ya + y - (ya >> 4); - za = za + z - (za >> 4); - adc_off(); - printf("x=%ld, y=%ld, z=%ld\n", - (xa >> 4) - x, (ya >> 4) - y, (za >> 4) - z); - } - } - PROCESS_END(); -} -/*---------------------------------------------------------------------------*/ diff --git a/platform/msb430/apps/sd-test.c b/platform/msb430/apps/sd-test.c deleted file mode 100644 index 53acd9eb9..000000000 --- a/platform/msb430/apps/sd-test.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2009, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * \file - * Test for an SD driver. - * \author - * Nicolas Tsiftes - */ - - -#include "contiki.h" -#include "dev/sd.h" -#include "lib/random.h" - -#include -#include - -PROCESS(sd_test, "SD test process"); -AUTOSTART_PROCESSES(&sd_test); - -#define BUF_SIZE 64 - -PROCESS_THREAD(sd_test, event, data) -{ - static unsigned long iter; - static unsigned long offset; - char buf[BUF_SIZE]; - static struct etimer et; - int r, buflen; - - PROCESS_BEGIN(); - - etimer_set(&et, CLOCK_SECOND / 16); - - offset = 0; - for(iter = 1;; iter++) { - PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); - - memset(buf, 0, sizeof(buf)); - buflen = sprintf(buf, "(%ld) Testing the SD card (%ld)", iter, iter); - - if((iter & 7) == 0) { - offset = random_rand() & 0xffff; - } else { - offset += random_rand() & 0xff; - } - - r = sd_write(offset, buf, buflen + 1); - if(r > 0) { - memset(buf, 0, sizeof(buf)); - r = sd_read(offset, buf, buflen + 1); - if(r > 0) { - printf("read %s (offset %lu)\n", buf, offset); - } else { - printf("read error: %d (%s)\n", r, sd_error_string(r)); - } - } else { - printf("write error: %d (%s)\n", r, sd_error_string(r)); - } - etimer_restart(&et); - } - - PROCESS_END(); -} diff --git a/platform/msb430/apps/test-abc.c b/platform/msb430/apps/test-abc.c deleted file mode 100644 index 5f2f7180a..000000000 --- a/platform/msb430/apps/test-abc.c +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2007, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * \file - * Testing the abc layer in Rime - * \author - * Adam Dunkels - */ - -#include "contiki.h" -#include "net/rime.h" -#include "sys/node-id.h" - -#include - -#ifndef SENDER_ID -#define SENDER_ID 1 -#endif - -#ifndef SEND_INTERVAL -#define SEND_INTERVAL (CLOCK_SECOND * 3) -#endif - -/*---------------------------------------------------------------------------*/ -PROCESS(test_abc_process, "ABC test"); -AUTOSTART_PROCESSES(&test_abc_process); -/*---------------------------------------------------------------------------*/ -static void -abc_recv(struct abc_conn *c) -{ - char *s; - int i; - - s = packetbuf_dataptr(); - - printf("abc message received '%s'\n", (char *)packetbuf_dataptr()); - printf("message length: %u\n", packetbuf_datalen()); - for (i = 0; i < packetbuf_datalen(); i++) { - printf("0x%x ", s[i]); - } - printf("\n"); -} -const static struct abc_callbacks abc_call = {abc_recv}; -static struct abc_conn abc; -/*---------------------------------------------------------------------------*/ -PROCESS_THREAD(test_abc_process, ev, data) -{ - static unsigned i; - static struct etimer et; - static int len; - static char buf[32]; - - PROCESS_EXITHANDLER(abc_close(&abc);) - - PROCESS_BEGIN(); - - abc_open(&abc, 128, &abc_call); - - while(1) { - etimer_set(&et, SEND_INTERVAL); - PROCESS_WAIT_EVENT(); - if (etimer_expired(&et) && node_id == SENDER_ID) { - len = snprintf(buf, sizeof (buf), "%u", ++i); - printf("Sending packet %d\n", i); - packetbuf_copyfrom(buf, len + 1); - abc_send(&abc); - } - } - - PROCESS_END(); -} -/*---------------------------------------------------------------------------*/ diff --git a/platform/msb430/apps/test-sht11.c b/platform/msb430/apps/test-sht11.c deleted file mode 100644 index 7ceb6fe13..000000000 --- a/platform/msb430/apps/test-sht11.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2007, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * \file - * Testing the SHT11 sensor. - * \author - * Nicolas Tsiftes - */ - -#include "contiki.h" -#include "dev/sht11.h" - -#include - -PROCESS(test_sht11_process, "SHT11 test"); -AUTOSTART_PROCESSES(&test_sht11_process); - -PROCESS_THREAD(test_sht11_process, ev, data) -{ - static struct etimer et; - static unsigned rh; - - PROCESS_BEGIN(); - - for (etimer_set(&et, CLOCK_SECOND);; etimer_reset(&et)) { - PROCESS_YIELD(); - printf("Temperature: %u degrees Celsius\n", - (unsigned) (-39.60 + 0.01 * sht11_temp())); - rh = sht11_humidity(); - printf("Rel. humidity: %u%%\n", - (unsigned) (-4 + 0.0405*rh - 2.8e-6*(rh*rh))); - } - - PROCESS_END(); -} diff --git a/platform/msb430/buildscripts/Makefile.freebsd b/platform/msb430/buildscripts/Makefile.freebsd deleted file mode 100644 index 625d3bb81..000000000 --- a/platform/msb430/buildscripts/Makefile.freebsd +++ /dev/null @@ -1,18 +0,0 @@ -ifndef JTAG - JTAG := $(CONTIKI)/platform/$(TARGET)/buildscripts/jtag/pyjtag/jtag.py -endif - -ifndef JTAG_PORT - JTAG_PORT = /dev/ppi0 -endif - -%.u: %.$(TARGET) - $(JTAG) -l $(JTAG_PORT) -m - $(JTAG) -l $(JTAG_PORT) -D -D -S -R 2048 -p $^ - $(JTAG) -l $(JTAG_PORT) -D -r - -r: - $(JTAG) -l $(JTAG_PORT) -r - -erase: - $(JTAG) -l $(JTAG_PORT) -e diff --git a/platform/msb430/buildscripts/Makefile.unix b/platform/msb430/buildscripts/Makefile.unix deleted file mode 100644 index 58f308b79..000000000 --- a/platform/msb430/buildscripts/Makefile.unix +++ /dev/null @@ -1,18 +0,0 @@ -ifndef JTAG - JTAG := $(CONTIKI)/platform/$(TARGET)/buildscripts/jtag/pyjtag/jtag.py -endif - -ifndef JTAG_PORT - JTAG_PORT = /dev/parport0 -endif - -%.u: %.$(TARGET) - $(JTAG) -l $(JTAG_PORT) -m - $(JTAG) -l $(JTAG_PORT) -D -D -S -R 2048 -p $^ - $(JTAG) -l $(JTAG_PORT) -D -r - -r: - $(JTAG) -l $(JTAG_PORT) -r - -erase: - $(JTAG) -l $(JTAG_PORT) -e diff --git a/platform/msb430/buildscripts/Makefile.win b/platform/msb430/buildscripts/Makefile.win deleted file mode 100644 index 3f7928b87..000000000 --- a/platform/msb430/buildscripts/Makefile.win +++ /dev/null @@ -1,15 +0,0 @@ -ifndef JTAG_PORT - JTAG_PORT = LPT1 -endif - -ifdef DEBUG - DEBUG_ARGS = -D -D -D -D -endif - -%.u: %.ihex - msp430-jtag $(DEBUG_ARGS) -l $(JTAG_PORT) -mI $^ - -#CW=cw23 - -#%.u: %.ihex -# $(CW) -d f430p $^ \ No newline at end of file diff --git a/platform/msb430/buildscripts/jtag/pyjtag/_parjtag.so b/platform/msb430/buildscripts/jtag/pyjtag/_parjtag.so deleted file mode 100755 index 3eeec6b89..000000000 Binary files a/platform/msb430/buildscripts/jtag/pyjtag/_parjtag.so and /dev/null differ diff --git a/platform/msb430/buildscripts/jtag/pyjtag/elf.py b/platform/msb430/buildscripts/jtag/pyjtag/elf.py deleted file mode 100644 index 2ab16b1c2..000000000 --- a/platform/msb430/buildscripts/jtag/pyjtag/elf.py +++ /dev/null @@ -1,318 +0,0 @@ -#!/usr/bin/env python -import struct - -# ELF object file reader -# (C) 2003 cliechti@gmx.net -# Python license - -# size alignment -# Elf32_Addr 4 4 Unsigned program address -# Elf32_Half 2 2 Unsigned medium integer -# Elf32_Off 4 4 Unsigned file offset -# Elf32_Sword 4 4 Signed large integer -# Elf32_Word 4 4 Unsigned large integer -# unsignedchar 1 1 Unsigned small integer - -#define EI_NIDENT 16 -#~ typedef struct{ - #~ unsigned char e_ident[EI_NIDENT]; - #~ Elf32_Half e_type; - #~ Elf32_Half e_machine; - #~ Elf32_Word e_version; - #~ Elf32_Addr e_entry; - #~ Elf32_Off e_phoff; - #~ Elf32_Off e_shoff; - #~ Elf32_Word e_flags; - #~ Elf32_Half e_ehsize; - #~ Elf32_Half e_phentsize; - #~ Elf32_Half e_phnum; - #~ Elf32_Half e_shentsize; - #~ Elf32_Half e_shnum; - #~ Elf32_Half e_shstrndx; -#~ } Elf32_Ehdr; - - -#Section Header -#~ typedef struct { - #~ Elf32_Word sh_name; - #~ Elf32_Word sh_type; - #~ Elf32_Word sh_flags; - #~ Elf32_Addr sh_addr; - #~ Elf32_Off sh_offset; - #~ Elf32_Word sh_size; - #~ Elf32_Word sh_link; - #~ Elf32_Word sh_info; - #~ Elf32_Word sh_addralign; - #~ Elf32_Word sh_entsize; -#~ } Elf32_Shdr; - -#~ typedef struct { - #~ Elf32_Word p_type; - #~ Elf32_Off p_offset; - #~ Elf32_Addr p_vaddr; - #~ Elf32_Addr p_paddr; - #~ Elf32_Word p_filesz; - #~ Elf32_Word p_memsz; - #~ Elf32_Word p_flags; - #~ Elf32_Word p_align; -#~ } Elf32_Phdr; - - -class ELFException(Exception): pass - -class ELFSection: - """read and store a section""" - Elf32_Shdr = "= section.sh_addr + section.sh_size) \ - and (not (section.sh_flags & ELFSection.SHF_ALLOC and section.sh_type != ELFSection.SHT_NOBITS) \ - or (p.p_offset <= section.sh_offset \ - and (p.p_offset + p.p_filesz >= section.sh_offset + section.sh_size)))): - return section.sh_addr + p.p_paddr - p.p_vaddr - return section.sh_addr - - def getSections(self): - """get sections relevant for the application""" - res = [] - for section in self.sections: - if section.sh_flags & ELFSection.SHF_ALLOC and section.sh_type != ELFSection.SHT_NOBITS: - res.append(section) - return res - - def __str__(self): - """pretty print for debug...""" - return "%s(self.e_type=%r, self.e_machine=%r, self.e_version=%r, sections=%r)" % ( - self.__class__.__name__, - self.e_type, self.e_machine, self.e_version, - [section.name for section in self.sections]) - - -if __name__ == '__main__': - print "This is only a module test!" - elf = ELFObject() - elf.fromFile(open("test.elf")) - if elf.e_type != ELFObject.ET_EXEC: - raise Exception("No executable") - print elf - - #~ print repr(elf.getSection('.text').data) - #~ print [(s.name, hex(s.sh_addr)) for s in elf.getSections()] - print "-"*20 - for p in elf.sections: print p - print "-"*20 - for p in elf.getSections(): print p - print "-"*20 - for p in elf.getProgrammableSections(): print p diff --git a/platform/msb430/buildscripts/jtag/pyjtag/elf.pyc b/platform/msb430/buildscripts/jtag/pyjtag/elf.pyc deleted file mode 100644 index 10662cddb..000000000 Binary files a/platform/msb430/buildscripts/jtag/pyjtag/elf.pyc and /dev/null differ diff --git a/platform/msb430/buildscripts/jtag/pyjtag/gen-ihex.py b/platform/msb430/buildscripts/jtag/pyjtag/gen-ihex.py deleted file mode 100644 index c917ec975..000000000 --- a/platform/msb430/buildscripts/jtag/pyjtag/gen-ihex.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env python -"""Test File generator. -This tool generates a hex file, of given size, ending on address -0xffff. - -USAGE: hen-ihex.py size_in_kilobyte - -The resulting Intel-hex file is output to stdout, use redirection -to save the data to a file. -""" - -#return a string with data in intel hex format -def makeihex(address, data): - out = [] - start = 0 - while start len(data): end = len(data) - out.append(_ihexline(address, [ord(x) for x in data[start:end]])) - start += 16 - address += 16 - out.append(_ihexline(address, [], end=1)) #append no data but an end line - return ''.join(out) - -def _ihexline(address, buffer, end=0): - out = [] - if end: - type = 1 - else: - type = 0 - out.append( ':%02X%04X%02X' % (len(buffer),address&0xffff,type) ) - sum = len(buffer) + ((address>>8)&255) + (address&255) - for b in buffer: - if b == None: b = 0 #substitute nonexistent values with zero - out.append('%02X' % (b&255) ) - sum += b&255 - out.append('%02X\n' %( (-sum)&255)) - return ''.join(out) - -if __name__ == '__main__': - import struct, sys - if len(sys.argv) != 2: - print __doc__ - sys.exit(1) - - size = int(sys.argv[1]) #in kilo - startadr = 0x10000 - 1024*size - data = ''.join([struct.pack(">H", x) for x in range(startadr, startadr+ 1024*size, 2)]) - print makeihex(startadr, data) diff --git a/platform/msb430/buildscripts/jtag/pyjtag/install-pyjtag.nsi b/platform/msb430/buildscripts/jtag/pyjtag/install-pyjtag.nsi deleted file mode 100644 index a2cb801b8..000000000 --- a/platform/msb430/buildscripts/jtag/pyjtag/install-pyjtag.nsi +++ /dev/null @@ -1,108 +0,0 @@ -Name "install-pyjtag" -OutFile "install-pyjtag.exe" - -!define SF_SELECTED 1 -!define SF_SUBSEC 2 -!define SF_SUBSECEND 4 -!define SF_BOLD 8 -!define SF_RO 16 -!define SF_EXPAND 32 - -!define SECTION_OFF 0xFFFFFFFE - -LicenseText License -LicenseData license.txt - -SetOverwrite on -SetDateSave on - -; The default installation directory -InstallDir $PROGRAMFILES\mspgcc -; Registry key to check for directory (so if you install again, it will -; overwrite the old one automatically) -InstallDirRegKey HKLM SOFTWARE\mspgcc "rootdir" - -; The text to prompt the user to enter a directory -DirText "This will install the pyjtag executables. You can choose the same \ - directory as for the other mspgcc tools." - -; The text to prompt the user to enter a directory -ComponentText "Select which optional things you want installed." - -Section "msp430-jtag (required)" - SectionIn RO - SetOutPath $INSTDIR - - File /r bin - File /oname=license-pyjtag.txt license.txt - File /oname=readme-pyjtag.txt readme.txt - File /oname=bin\jtag.py jtag.py - - ; Write the installation path into the registry - WriteRegStr HKLM SOFTWARE\mspgcc "rootdir" "$INSTDIR" - ; Write the uninstall keys for Windows - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\mspgcc-pyjtag" "DisplayName" "mspgcc pyjtag (remove only)" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\mspgcc-pyjtag" "UninstallString" '"$INSTDIR\uninstall-pyjtag.exe"' - WriteUninstaller "uninstall-pyjtag.exe" -SectionEnd - -Section "giveio (needed on Win NT/2k/XP, but NOT on 9x/ME)" - SetOutPath $INSTDIR\bin - File ..\jtag\hardware_access\giveio\giveio.sys - File ..\jtag\hardware_access\giveio\loaddrv.exe - SetOutPath $INSTDIR - nsExec::ExecToLog '$INSTDIR\bin\loaddrv.exe install giveio $INSTDIR\bin\giveio.sys' - Pop $0 ;return value/error/timeout - IntCmp $0 2 ext_here ;assume its alredy installed - IntCmp $0 0 0 ext_err ext_err ;if not 0 -> error - nsExec::ExecToLog '$INSTDIR\bin\loaddrv.exe start giveio' - Pop $0 ;return value/error/timeout - IntCmp $0 0 0 ext_err ext_err ;if not 0 -> error - nsExec::ExecToLog '$INSTDIR\bin\loaddrv.exe starttype giveio auto' - Pop $0 ;return value/error/timeout - IntCmp $0 0 0 ext_err ext_err ;if not 0 -> error - WriteRegStr HKLM SOFTWARE\mspgcc "giveio" "started" - Goto ext_ok -ext_err: - DetailPrint "Error while installing and starting giveio" - MessageBox MB_OK|MB_ICONSTOP "Error while installing and starting giveio" - Goto ext_ok -ext_here: - DetailPrint "Installing giveio gave an error, assuming its already installed" -ext_ok: -SectionEnd - -; special uninstall section. -Section "Uninstall" - ; remove registry keys - DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\mspgcc-pyjtag" - DeleteRegKey HKLM SOFTWARE\NSIS_Example2 - ; remove files - Delete $INSTDIR\bin\msp430-jtag.exe - Delete $INSTDIR\bin\_parjtag.pyd - Delete $INSTDIR\bin\jtag.py - Delete $INSTDIR\bin\HIL.dll - Delete $INSTDIR\bin\MSP430mspgcc.dll - ;XXX python22.dll is left installed as it is used by pybsl and other tools - Delete $INSTDIR\license-pyjtag.txt - Delete $INSTDIR\readme-pyjtag.txt - ; giveio - ; if it was started by us, stop it - ReadRegStr $0 HKLM SOFTWARE\mspgcc "giveio" - StrCmp $0 '' no_giveio - nsExec::ExecToLog '$INSTDIR\bin\loaddrv.exe stop giveio' - Pop $0 ;return value/error/timeout - IntCmp $0 0 0 giveio_err giveio_err ;if not 0 -> error - nsExec::ExecToLog '$INSTDIR\bin\loaddrv.exe remove giveio' - Pop $0 ;return value/error/timeout - IntCmp $0 0 0 giveio_err giveio_err ;if not 0 -> error - Goto no_giveio -giveio_err: - DetailPrint "Error while uninstalling giveio service" - MessageBox MB_OK|MB_ICONSTOP "Error while uninstalling giveio service" -no_giveio: - Delete loaddrv.exe - Delete giveio.sys - ; MUST REMOVE UNINSTALLER, too - Delete $INSTDIR\uninstall-pyjtag.exe -SectionEnd diff --git a/platform/msb430/buildscripts/jtag/pyjtag/jtag.py b/platform/msb430/buildscripts/jtag/pyjtag/jtag.py deleted file mode 100755 index 0cb556a91..000000000 --- a/platform/msb430/buildscripts/jtag/pyjtag/jtag.py +++ /dev/null @@ -1,604 +0,0 @@ -#!/usr/bin/env python -#Parallel JTAG programmer for the MSP430 embedded proccessor. -# -#(C) 2002 Chris Liechti -#this is distributed under a free software license, see license.txt -# -#Requires Python 2+ and the binary extension _parjtag. - -import sys -import _parjtag - -VERSION = "1.3" - -DEBUG = 0 #disable debug messages by default - - -#frame specific consts -ERASE_MASS = 2 -ERASE_MAIN = 1 -ERASE_SGMT = 0 - -#states -FREERUNNING = 0 -STOPPED = 1 - -#Configurations of the MSP430 driver -VERIFICATION_MODE = 0 #Verify data downloaded to FLASH memories. -RAMSIZE_OPTION = 1 #Change RAM used to download and program flash blocks -DEBUG_OPTION = 2 #Set debug level. Enables debug outputs. - -#enumeration of output formats for uploads -HEX = 0 -INTELHEX = 1 -BINARY = 2 - -#exceptions -class JTAGException(Exception): pass - -#for the use with memread -def hexdump( (adr, memstr) ): - """Print a hex dump of data collected with memread - arg1: tuple with adress, memory - return None""" - count = 0 - ascii = '' - for value in map(ord, memstr): - if not count: print "%04x: " % adr, - print "%02x" % value, - ascii += (32 <= value < 128) and chr(value) or '.' - count += 1 - adr += 1 - if count == 16: - count = 0 - print " ", ascii - ascii = '' - if count < 16: print " "*(16-count), " ", ascii - -def makeihex( (address, data) ): - """work though the data and output lines in inzel hex format. - and end tag is appended""" - start = 0 - while start len(data): end = len(data) - _ihexline(address, [ord(x) for x in data[start:end]]) - start += 16 - address += 16 - _ihexline(address, [], type=1) #append no data but an end line - -def _ihexline(address, buffer, type=0): - """encode one line, output with checksum""" - sys.stdout.write( ':%02X%04X%02X' % (len(buffer), address & 0xffff, type) ) - sum = len(buffer) + ((address >> 8) & 255) + (address & 255) - for b in buffer: - if b == None: b = 0 #substitute nonexistent values with zero - sys.stdout.write('%02X' % (b & 255)) - sum += b&255 - sys.stdout.write('%02X\n' %( (-sum) & 255)) - - -class Segment: - """store a string with memory contents along with its startaddress""" - def __init__(self, startaddress = 0, data=None): - if data is None: - self.data = '' - else: - self.data = data - self.startaddress = startaddress - - def __getitem__(self, index): - return self.data[index] - - def __len__(self): - return len(self.data) - - def __repr__(self): - return "Segment(startaddress = 0x%04x, data=%r)" % (self.startaddress, self.data) - -class Memory: - """represent memory contents. with functions to load files""" - def __init__(self, filename=None): - self.segments = [] - if filename: - self.filename = filename - self.loadFile(filename) - - def append(self, seg): - self.segments.append(seg) - - def __getitem__(self, index): - return self.segments[index] - - def __len__(self): - return len(self.segments) - - def loadIHex(self, file): - """load data from a (opened) file in Intel-HEX format""" - segmentdata = [] - currentAddr = 0 - startAddr = 0 - lines = file.readlines() - for l in lines: - if not l.strip(): continue #skip empty lines - if l[0] != ':': raise Exception("File Format Error\n") - l = l.strip() #fix CR-LF issues... - length = int(l[1:3],16) - address = int(l[3:7],16) - type = int(l[7:9],16) - check = int(l[-2:],16) - if type == 0x00: - if currentAddr != address: - if segmentdata: - self.segments.append( Segment(startAddr, ''.join(segmentdata)) ) - startAddr = currentAddr = address - segmentdata = [] - for i in range(length): - segmentdata.append( chr(int(l[9+2*i:11+2*i],16)) ) - currentAddr = length + currentAddr - elif type == 0x01: - pass - else: - sys.stderr.write("Ignored unknown field (type 0x%02x) in ihex file.\n" % type) - if segmentdata: - self.segments.append( Segment(startAddr, ''.join(segmentdata)) ) - - def loadTIText(self, file): - """load data from a (opened) file in TI-Text format""" - next = 1 - currentAddr = 0 - startAddr = 0 - segmentdata = [] - #Convert data for MSP430, TXT-File is parsed line by line - while next >= 1: - #Read one line - l = file.readline() - if not l: break #EOF - l = l.strip() - if l[0] == 'q': break - elif l[0] == '@': #if @ => new address => send frame and set new addr. - #create a new segment - if segmentdata: - self.segments.append( Segment(startAddr, ''.join(segmentdata)) ) - startAddr = currentAddr = int(l[1:],16) - segmentdata = [] - else: - for i in l.split(): - segmentdata.append(chr(int(i,16))) - if segmentdata: - self.segments.append( Segment(startAddr, ''.join(segmentdata)) ) - - def loadELF(self, file): - """load data from a (opened) file in ELF object format. - File must be seekable""" - import elf - obj = elf.ELFObject() - obj.fromFile(file) - if obj.e_type != elf.ELFObject.ET_EXEC: - raise Exception("No executable") - for section in obj.getSections(): - if DEBUG: - sys.stderr.write("ELF section %s at 0x%04x %d bytes\n" % (section.name, section.lma, len(section.data))) - if len(section.data): - self.segments.append( Segment(section.lma, section.data) ) - - def loadFile(self, filename): - """fill memory with the contents of a file. file type is determined from extension""" - #TODO: do a contents based detection - if filename[-4:].lower() == '.txt': - self.loadTIText(open(filename, "rb")) - elif filename[-4:].lower() in ('.a43', '.hex'): - self.loadIHex(open(filename, "rb")) - else: - self.loadELF(open(filename, "rb")) - - def getMemrange(self, fromadr, toadr): - """get a range of bytes from the memory. unavailable values are filled with 0xff.""" - res = '' - toadr = toadr + 1 #python indxes are excluding end, so include it - while fromadr < toadr: - for seg in self.segments: - segend = seg.startaddress + len(seg.data) - if seg.startaddress <= fromadr and fromadr < segend: - if toadr > segend: #not all data in segment - catchlength = segend-fromadr - else: - catchlength = toadr-fromadr - res = res + seg.data[fromadr-seg.startaddress : fromadr-seg.startaddress+catchlength] - fromadr = fromadr + catchlength #adjust start - if len(res) >= toadr-fromadr: - break #return res - else: #undefined memory is filled with 0xff - res = res + chr(255) - fromadr = fromadr + 1 #adjust start - return res - -class JTAG: - """wrap the _parjtag extension""" - - def __init__(self): - self.showprogess = 0 - - def connect(self, lpt=None): - """connect to specified or default port""" - if lpt is None: - _parjtag.connect() - else: - _parjtag.connect(lpt) - - def close(self): - """release JTAG""" - _parjtag.release() - - def uploadData(self, startaddress, size): - """upload a datablock""" - if DEBUG > 1: sys.stderr.write("* uploadData()\n") - return _parjtag.memread(startaddress, size) - - def actionMassErase(self): - """Erase the flash memory completely (with mass erase command)""" - sys.stderr.write("Mass Erase...\n") - _parjtag.memerase(ERASE_MASS) - - def actionMainErase(self): - """Erase the MAIN flash memory, leave the INFO mem""" - sys.stderr.write("Erase Main Flash...\n") - _parjtag.memerase(ERASE_MAIN, 0xfffe) - - def makeActionSegmentErase(self, address): - """Selective segment erase""" - class SegmentEraser: - def __init__(self, segaddr): - self.address = segaddr - def __call__(self): - sys.stderr.write("Erase Segment @ 0x%04x...\n" % self.address) - _parjtag.memerase(ERASE_SGMT, self.address) - return SegmentEraser(address) - - def actionEraseCheck(self): - """check the erasure of required flash cells.""" - sys.stderr.write("Erase Check by file ...\n") - if self.data is not None: - for seg in self.data: - data = _parjtag.memread(seg.startaddress, len(seg.data)) - if data != '\xff'*len(seg.data): raise JTAGException("Erase check failed") - else: - raise JTAGException("cannot do erase check against data with not knowing the actual data") - - def progess_update(self, count, total): - sys.stderr.write("\r%d%%" % (100*count/total)) - - def actionProgram(self): - """program data into flash memory.""" - if self.data is not None: - sys.stderr.write("Program ...\n") - if self.showprogess: - _parjtag.set_flash_callback(self.progess_update) - bytes = 0 - for seg in self.data: - _parjtag.memwrite(seg.startaddress, seg.data) - bytes += len(seg.data) - if self.showprogess: - sys.stderr.write("\r") - sys.stderr.write("%i bytes programmed.\n" % bytes) - else: - raise JTAGException("programming without data not possible") - - def actionVerify(self): - """Verify programmed data""" - if self.data is not None: - sys.stderr.write("Verify ...\n") - for seg in self.data: - data = _parjtag.memread(seg.startaddress, len(seg.data)) - if data != seg.data: raise JTAGException("Verify failed") - else: - raise JTAGException("verify without data not possible") - - def actionReset(self): - """perform a reset""" - sys.stderr.write("Reset device ...\n") - _parjtag.reset(0, 0) - - def actionRun(self, address): - """start program at specified address""" - raise NotImplementedError - #sys.stderr.write("Load PC with 0x%04x ...\n" % address) - - def funclet(self): - """download and start funclet""" - sys.stderr.write("Download and execute of funclet...\n") - if len(self.data) > 1: - raise JTAGException("don't know how to handle multiple segments in funclets") - _parjtag.funclet(self.data[0].data) - sys.stderr.write("Funclet OK.\n") - -def usage(): - """print some help message""" - sys.stderr.write(""" -USAGE: %s [options] [file] -Version: %s - -If "-" is specified as file the data is read from the stdinput. -A file ending with ".txt" is considered to be in TIText format all -other filenames are considered IntelHex. - -General options: - -h, --help Show this help screen. - -l, --lpt=name Specify an other parallel port. - (defaults to LPT1 (/dev/parport0 on unix) - -D, --debug Increase level of debug messages. This won't be - very useful for the average user... - -I, --intelhex Force fileformat to IntelHex - -T, --titext Force fileformat to be TIText - -f, --funclet The given file is a funclet (a small program to - be run in RAM) - -R, --ramsize Specify the amont of RAM to be used to program - flash (default 256). - -Program Flow Specifiers: - - -e, --masserase Mass Erase (clear all flash memory) - -m, --mainerase Erase main flash memory only - --eraseinfo Erase info flash memory only (0x1000-0x10ff) - --erase=address Selectively erase segment at the specified address - -E, --erasecheck Erase Check by file - -p, --program Program file - -v, --verify Verify by file - -The order of the above options matters! The table is ordered by normal -execution order. For the options "Epv" a file must be specified. -Program flow specifiers default to "p" if a file is given. -Don't forget to specify "e" or "eE" when programming flash! -"p" already verifies the programmed data, "v" adds an additional -verification though uploading the written data for a 1:1 compare. -No default action is taken if "p" and/or "v" is given, say specifying -only "v" does a check by file of a programmed device. - -Data retreiving: - -u, --upload=addr Upload a datablock (see also: -s). - -s, --size=num Size of the data block do upload. (Default is 2) - -x, --hex Show a hexadecimal display of the uploaded data. - (Default) - -b, --bin Get binary uploaded data. This can be used - to redirect the output into a file. - -i, --ihex Uploaded data is output in Intel HEX format. - This can be used to clone a device. - -Do before exit: - -g, --go=address Start programm execution at specified address. - This implies option "w" (wait) - -r, --reset Reset connected MSP430. Starts application. - This is a normal device reset and will start - the programm that is specified in the reset - interrupt vector. (see also -g) - -w, --wait Wait for before closing parallel port. -""" % (sys.argv[0], VERSION)) - -def main(): - global DEBUG - import getopt - filetype = None - filename = None - reset = 0 - wait = 0 - goaddr = None - jtag = JTAG() - toinit = [] - todo = [] - startaddr = None - size = 2 - outputformat= HEX - lpt = None - funclet = None - ramsize = None - - sys.stderr.write("MSP430 parallel JTAG programmer Version: %s\n" % VERSION) - try: - opts, args = getopt.getopt(sys.argv[1:], - "hl:weEmpvrg:Du:d:s:xbiITfR:S", - ["help", "lpt=", "wait" - "masserase", "erasecheck", "mainerase", "program", - "erase=", "eraseinfo", - "verify", "reset", "go=", "debug", - "upload=", "download=", "size=", "hex", "bin", "ihex", - "intelhex", "titext", "funclet", "ramsize=", "progress"] - ) - except getopt.GetoptError: - # print help information and exit: - usage() - sys.exit(2) - - for o, a in opts: - if o in ("-h", "--help"): - usage() - sys.exit() - elif o in ("-l", "--lpt"): - lpt = a - elif o in ("-w", "--wait"): - wait = 1 - elif o in ("-e", "--masserase"): - toinit.append(jtag.actionMassErase) #Erase Flash - elif o in ("-E", "--erasecheck"): - toinit.append(jtag.actionEraseCheck) #Erase Check (by file) - elif o in ("-m", "--mainerase"): - toinit.append(jtag.actionMainErase) #Erase main Flash - elif o == "--erase": - try: - seg = int(a, 0) - toinit.append(jtag.makeActionSegmentErase(seg)) - except ValueError: - sys.stderr.write("segment address must be a valid number in dec, hex or octal\n") - sys.exit(2) - elif o == "--eraseinfo": - toinit.append(jtag.makeActionSegmentErase(0x1000)) - toinit.append(jtag.makeActionSegmentErase(0x1080)) - elif o in ("-p", "--program"): - todo.append(jtag.actionProgram) #Program file - elif o in ("-v", "--verify"): - todo.append(jtag.actionVerify) #Verify file - elif o in ("-r", "--reset"): - reset = 1 - elif o in ("-g", "--go"): - try: - goaddr = int(a, 0) #try to convert decimal - except ValueError: - sys.stderr.write("upload address must be a valid number in dec, hex or octal\n") - sys.exit(2) - elif o in ("-D", "--debug"): - DEBUG = DEBUG + 1 - elif o in ("-u", "--upload"): - try: - startaddr = int(a, 0) #try to convert number of any base - except ValueError: - sys.stderr.write("upload address must be a valid number in dec, hex or octal\n") - sys.exit(2) - elif o in ("-s", "--size"): - try: - size = int(a, 0) - except ValueError: - sys.stderr.write("upload address must be a valid number in dec, hex or octal\n") - sys.exit(2) - #outut formats - elif o in ("-x", "--hex"): - outputformat = HEX - elif o in ("-b", "--bin"): - outputformat = BINARY - elif o in ("-i", "--ihex"): - outputformat = INTELHEX - #input formats - elif o in ("-I", "--intelhex"): - filetype = 0 - elif o in ("-T", "--titext"): - filetype = 1 - #others - elif o in ("-f", "--funclet"): - funclet = 1 - elif o in ("-R", "--ramsize"): - try: - ramsize = int(a, 0) - except ValueError: - sys.stderr.write("ramsize must be a valid number in dec, hex or octal\n") - sys.exit(2) - elif o in ("-S", "--progress"): - jtag.showprogess = 1 - - if len(args) == 0: - sys.stderr.write("Use -h for help\n") - elif len(args) == 1: #a filename is given - if not funclet: - if not todo: #if there are no actions yet - todo.extend([ #add some useful actions... - jtag.actionProgram, - ]) - filename = args[0] - else: #number of args is wrong - usage() - sys.exit(2) - - if DEBUG: #debug infos - sys.stderr.write("debug level set to %d\n" % DEBUG) - _parjtag.configure(DEBUG_OPTION, DEBUG) - sys.stderr.write("python version: %s\n" % sys.version) - - - #sanity check of options - if goaddr and reset: - sys.stderr.write("Warning: option --reset ignored as --go is specified!\n") - reset = 0 - - if startaddr and reset: - sys.stderr.write("Warning: option --reset ignored as --upload is specified!\n") - reset = 0 - - #prepare data to download - jtag.data = Memory() #prepare downloaded data - if filetype is not None: #if the filetype is given... - if filename is None: - raise ValueError("no filename but filetype specified") - if filename == '-': #get data from stdin - file = sys.stdin - else: - file = open(filename,"rb") #or from a file - if filetype == 0: #select load function - jtag.data.loadIHex(file) #intel hex - elif filetype == 1: - jtag.data.loadTIText(file) #TI's format - else: - raise ValueError("illegal filetype specified") - else: #no filetype given... - if filename == '-': #for stdin: - jtag.data.loadIHex(sys.stdin) #assume intel hex - elif filename: - jtag.data.loadFile(filename) #autodetect otherwise - - if DEBUG > 5: sys.stderr.write("File: %r\n" % filename) - - try: - jtag.connect(lpt) #try to open port - except IOError: - raise #do not handle here - else: #continue if open was successful - if ramsize is not None: - _parjtag.configure(RAMSIZE_OPTION, ramsize) - #initialization list - if toinit: #erase and erase check - if DEBUG: sys.stderr.write("Preparing device ...\n") - for f in toinit: f() - - #work list - if todo: - if DEBUG > 0: #debug - #show a nice list of sheduled actions - sys.stderr.write("TODO list:\n") - for f in todo: - try: - sys.stderr.write(" %s\n" % f.func_name) - except AttributeError: - sys.stderr.write(" %r\n" % f) - for f in todo: f() #work through todo list - - if reset: #reset device first if desired - jtag.actionReset() - - if funclet is not None: #download and start funclet - jtag.funclet() - - if goaddr is not None: #start user programm at specified address - jtag.actionRun(goaddr) #load PC and execute - - #upload datablock and output - if startaddr is not None: - if goaddr: #if a program was started... - raise NotImplementedError - #TODO: - #sys.stderr.write("Waiting to device for reconnect for upload: ") - data = jtag.uploadData(startaddr, size) #upload data - if outputformat == HEX: #depending on output format - hexdump( (startaddr, data) ) #print a hex display - elif outputformat == INTELHEX: - makeihex( (startaddr, data) ) #ouput a intel-hex file - else: - sys.stdout.write(data) #binary output w/o newline! - wait = 0 #wait makes no sense as after the upload the device is still stopped - - if wait: #wait at the end if desired - sys.stderr.write("Press ...\n") #display a prompt - raw_input() #wait for newline - - _parjtag.reset(1, 1) #reset and release target - #~ jtag.actionReset() - jtag.close() #Release communication port - -if __name__ == '__main__': - try: - main() - except SystemExit: - raise #let pass exit() calls - except KeyboardInterrupt: - if DEBUG: raise #show full trace in debug mode - sys.stderr.write("user abort.\n") #short messy in user mode - sys.exit(1) #set errorlevel for script usage - except Exception, msg: #every Exception is caught and displayed - if DEBUG: raise #show full trace in debug mode - sys.stderr.write("\nAn error occoured:\n%s\n" % msg) #short messy in user mode - sys.exit(1) #set errorlevel for script usage diff --git a/platform/msb430/buildscripts/jtag/pyjtag/license.txt b/platform/msb430/buildscripts/jtag/pyjtag/license.txt deleted file mode 100644 index 810a2d24c..000000000 --- a/platform/msb430/buildscripts/jtag/pyjtag/license.txt +++ /dev/null @@ -1,62 +0,0 @@ -Copyright (c) 2001-2002 Chris Liechti - -All Rights Reserved. - -This is the Python license. In short, you can use this product in -commercial and non-commercial applications, modify it, redistribute it. -A notification to the author when you use and/or modify it is welcome. - -TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING THIS SOFTWARE -============================================ - -LICENSE AGREEMENT ------------------ - -1. This LICENSE AGREEMENT is between the copyright holder of this -product, and the Individual or Organization ("Licensee") accessing -and otherwise using this product in source or binary form and its -associated documentation. - -2. Subject to the terms and conditions of this License Agreement, -the copyright holder hereby grants Licensee a nonexclusive, -royalty-free, world-wide license to reproduce, analyze, test, -perform and/or display publicly, prepare derivative works, distribute, -and otherwise use this product alone or in any derivative version, -provided, however, that copyright holders License Agreement and -copyright holders notice of copyright are retained in this product -alone or in any derivative version prepared by Licensee. - -3. In the event Licensee prepares a derivative work that is based on -or incorporates this product or any part thereof, and wants to make -the derivative work available to others as provided herein, then -Licensee hereby agrees to include in any such work a brief summary of -the changes made to this product. - -4. The copyright holder is making this product available to Licensee -on an "AS IS" basis. THE COPYRIGHT HOLDER MAKES NO REPRESENTATIONS -OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE, BUT NOT -LIMITATION, THE COPYRIGHT HOLDER MAKES NO AND DISCLAIMS ANY -REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS FOR -ANY PARTICULAR PURPOSE OR THAT THE USE OF THIS PRODUCT WILL -NOT INFRINGE ANY THIRD PARTY RIGHTS. - -5. THE COPYRIGHT HOLDER SHALL NOT BE LIABLE TO LICENSEE OR ANY -OTHER USERS OF THIS PRODUCT FOR ANY INCIDENTAL, SPECIAL, OR -CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF MODIFYING, -DISTRIBUTING, OR OTHERWISE USING THIS PRODUCT, OR ANY -DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY -THEREOF. - -6. This License Agreement will automatically terminate upon a -material breach of its terms and conditions. - -7. Nothing in this License Agreement shall be deemed to create any -relationship of agency, partnership, or joint venture between the -copyright holder and Licensee. This License Agreement does not grant -permission to use trademarks or trade names from the copyright holder -in a trademark sense to endorse or promote products or services of -Licensee, or any third party. - -8. By copying, installing or otherwise using this product, Licensee -agrees to be bound by the terms and conditions of this License -Agreement. diff --git a/platform/msb430/buildscripts/jtag/pyjtag/makefile b/platform/msb430/buildscripts/jtag/pyjtag/makefile deleted file mode 100644 index 5482fa2f1..000000000 --- a/platform/msb430/buildscripts/jtag/pyjtag/makefile +++ /dev/null @@ -1,33 +0,0 @@ - -.PHONY: all FORCE clean windist - -all: windist - -#wrap py to exe and build windows installer -windist: - python setup.py py2exe - rm -r bin - mv dist/jtag/jtag.exe dist/msp430-jtag.exe - mv dist/jtag/* dist/ - rmdir dist/jtag - mv dist bin - rm -r build - - -#generate test files -fill60k.a43: - python gen-ihex.py 60 >$@ -fill48k.a43: - python gen-ihex.py 48 >$@ -fill32k.a43: - python gen-ihex.py 32 >$@ -fill16k.a43: - python gen-ihex.py 16 >$@ -fill8k.a43: - python gen-ihex.py 8 >$@ -fill4k.a43: - python gen-ihex.py 4 >$@ - -#clean up the mess... -clean: - rm -r dist build bin \ No newline at end of file diff --git a/platform/msb430/buildscripts/jtag/pyjtag/readme.txt b/platform/msb430/buildscripts/jtag/pyjtag/readme.txt deleted file mode 100644 index bdd3da6c2..000000000 --- a/platform/msb430/buildscripts/jtag/pyjtag/readme.txt +++ /dev/null @@ -1,182 +0,0 @@ -pyJTAG ------- - -Software to talk to the parallel port JTAG PCB as seen with the FET kits. -It is released under a free software license, -see license.txt for more details. - -(C) 2002-2003 Chris Liechti - -Features --------- - -- understands TI-Text and Intel-hex -- download to Flash and/or RAM, erase, verify -- reset device -- load addres into R0/PC and run -- upload a memory block MSP->PC (output as binary data or hex dump) -- written in Python, runs on Win32, Linux, BSD -- use per command line, or in a Python script - -Requirements ------------- -- Linux, BSD, Un*x or Windows PC -- Python 2.0 or newer, 2.2 recomeded -- Parallel JTAG hardware with an MSP430 device connected - -Installation ------------- -Python installations are available from www.python.org. On Windows simply -use the installer. The win32all package has an installer too. These -installations should run fine with the deafults. - -On Linux just Python is needed. On some distributions is Python 1.5.2 -installed per default. You may meed to change the first line in the script -from "python" to "python2". Maybe Python 2.x is in a separate package that -has to be installed. There are rpm and deb binary packages and a source -tarball available through the Python homepage. - -The pyjtag archive can simply be unpacked to a directory, Windows users -can use WinZip or WinRar among others to extract the gzipped tar file. -If you want to run it from everywhere the directory where the file jtag.py -is, should be added to the PATH. -Look at "~/.profile", "/etc/profile" on Linux, "autoexec.bat" on Win9x/ME, -System Properties/Environment in Win2000/NT/XP. - -_parjtag.so/dll from the jtag archive must be copied to the same directory as -jtag.py. On Windows also MSP430mspgcc.dll and HIL.dll must be located in the -same dir or somewhere in the PATH. - -Short introduction ------------------- -This software uses the JTAG hardware that comes with the FET kits. It is -connected to the parallel port. - -The program can be started by typing "python jtag.py" in a console. Often -it works also with just "jtag.py" or "./jtag.py". - -USAGE: jtag.py [options] [file] -If "-" is specified as file the data is read from the stdinput. -A file ending with ".txt" is considered to be in TIText format all -other filenames are considered IntelHex. - -General options: - -h, --help Show this help screen. - -l, --lpt=name Specify an other parallel port. - (defaults to LPT1 (/dev/parport0 on unix) - -D, --debug Increase level of debug messages. This won't be - very useful for the average user... - -I, --intelhex Force fileformat to IntelHex - -T, --titext Force fileformat to be TIText - -f, --funclet The given file is a funclet (a small program to - be run in RAM) - -R, --ramsize Specify the amont of RAM to be used to program - flash (default 256). - -Program Flow Specifiers: - - -e, --masserase Mass Erase (clear all flash memory) - -m, --mainerase Erase main flash memory only - --eraseinfo Erase info flash memory only (0x1000-0x10ff) - --erase=address Selectively erase segment at the specified address - -E, --erasecheck Erase Check by file - -p, --program Program file - -v, --verify Verify by file - -The order of the above options matters! The table is ordered by normal -execution order. For the options "Epv" a file must be specified. -Program flow specifiers default to "p" if a file is given. -Don't forget to specify "e" or "eE" when programming flash! -"p" already verifies the programmed data, "v" adds an additional -verification though uploading the written data for a 1:1 compare. -No default action is taken if "p" and/or "v" is given, say specifying -only "v" does a check by file of a programmed device. - -Data retreiving: - -u, --upload=addr Upload a datablock (see also: -s). - -s, --size=num Size of the data block do upload. (Default is 2) - -x, --hex Show a hexadecimal display of the uploaded data. - (Default) - -b, --bin Get binary uploaded data. This can be used - to redirect the output into a file. - -i, --ihex Uploaded data is output in Intel HEX format. - This can be used to clone a device. - -Do before exit: - -g, --go=address Start programm execution at specified address. - This implies option "w" (wait) - -r, --reset Reset connected MSP430. Starts application. - This is a normal device reset and will start - the programm that is specified in the reset - interrupt vector. (see also -g) - -w, --wait Wait for before closing parallel port. - - -Examples --------- -These examples assume that you have added the installation directory to -the PATH. Type the full path to jtag.py otherwise and maybe use -"python jtag.py". Depending on installation it may also appear under the -name "msp430-jtag". - -jtag.py -e - Only erase flash. - -jtag.py -eErw 6port.a43 - Erase flash, erase check, download an executable, run it (reset) - and wait. - -jtag.py -mS -R 2048 6port.a43 - Use ramsize option on a device with 2k RAM to speed up - download. Of course any value from 128B up to the maximum - a device has is allowed. - The progress and mainerase options are also activated. - Only erasing the main memory is useful to keep calibration - data in the information memory. - -jtag.py 6port.a43 - Download of an executable to en empty (new or erased) device. - (Note that in new devices some of the first bytes in the - information memory are random data. If data should be - downloaded there, specify -eE.) - -jtag.py --go=0x220 ramtest.a43 - Download a program into RAM and run it, may not work - with all devices. - -jtag.py -f blinking.a43 - Download a program into RAM and run it. It must be - a special format with "startadr", "entrypoint", - "exitpoint" as the first three words in the data - and it must end on "jmp $". See MSP430debug sources - for more info. - -jtag.py -u 0x0c00 -s 1024 - Get a memory dump in HEX, from the bootstrap loader. - or save the binary in a file: - "python jtag.py -u 0x0c00 -s 1024 -b >dump.bin" - or as an intel-hex file: - "python jtag.py -u 0x0c00 -s 1024 -i >dump.a43" - -jtag.py -r - Just start the user program (with a reset). - -cat 6port.a43|jtag.py -e - - Pipe the data from "cat" to jtag.py to erase and program the - flash. (un*x example, don't forget the dash at the end of the - line) - -History -------- -1.0 public release -1.1 fix of verify error -1.2 use the verification during programming -1.3 meinerase, progress options, ihex output - -References ----------- -- Python: http://www.python.org - -- Texas Instruments MSP430 Homepage, links to Datasheets and Application - Notes: http://www.ti.com/sc/msp430 - diff --git a/platform/msb430/buildscripts/jtag/pyjtag/setup.py b/platform/msb430/buildscripts/jtag/pyjtag/setup.py deleted file mode 100644 index 982b58340..000000000 --- a/platform/msb430/buildscripts/jtag/pyjtag/setup.py +++ /dev/null @@ -1,9 +0,0 @@ -# setup.py -from distutils.core import setup -import glob -import py2exe - -setup( - name="msp430-jtag", - scripts=["jtag.py"], - ) \ No newline at end of file diff --git a/platform/msb430/cfs-coffee-arch.c b/platform/msb430/cfs-coffee-arch.c deleted file mode 100644 index 605ee79ff..000000000 --- a/platform/msb430/cfs-coffee-arch.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2009, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * \file - * Coffee functions the MSB-430 platform. - * \author - * Nicolas Tsiftes - */ - -#include "cfs-coffee-arch.h" -#include "dev/sd.h" - -#include - -int -cfs_coffee_arch_erase(unsigned sector) -{ - char buf[SD_DEFAULT_BLOCK_SIZE]; - sd_offset_t start_offset; - sd_offset_t end_offset; - sd_offset_t offset; - - memset(buf, 0, sizeof(buf)); - - start_offset = COFFEE_START + sector * COFFEE_SECTOR_SIZE; - end_offset = start_offset + COFFEE_SECTOR_SIZE; - - for(offset = start_offset; offset < end_offset; offset += SD_DEFAULT_BLOCK_SIZE) { - if(sd_write(offset, buf, sizeof(buf)) < 0) { - return -1; - } - } - return 0; -} diff --git a/platform/msb430/cfs-coffee-arch.h b/platform/msb430/cfs-coffee-arch.h deleted file mode 100644 index 6c1b960a0..000000000 --- a/platform/msb430/cfs-coffee-arch.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2009, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * \file - * Coffee header for the Tmote Sky platform. - * \author - * Nicolas Tsiftes - */ - -#ifndef CFS_COFFEE_ARCH_H -#define CFS_COFFEE_ARCH_H - -#include "contiki-conf.h" -#include "dev/sd.h" - -/* Coffee configuration parameters. */ -#define COFFEE_SECTOR_SIZE (10*1024*1024UL) -#define COFFEE_PAGE_SIZE 1024UL -#define COFFEE_START 0 -#define COFFEE_SIZE (COFFEE_SECTOR_SIZE * 2) -#define COFFEE_NAME_LENGTH 16 -#define COFFEE_MAX_OPEN_FILES 6 -#define COFFEE_FD_SET_SIZE 8 -#define COFFEE_LOG_TABLE_LIMIT 256 -#define COFFEE_DYN_SIZE 32*1024UL -#define COFFEE_LOG_SIZE 8*1024UL -#define COFFEE_MICRO_LOGS 0 - -/* Flash operations. */ -#define COFFEE_WRITE(buf, size, offset) \ - sd_write(COFFEE_START + (offset), (char *)(buf), (size)) - -#define COFFEE_READ(buf, size, offset) \ - sd_read(COFFEE_START + (offset), (char *)buf, (size)) - -#define COFFEE_ERASE(sector) \ - cfs_coffee_arch_erase(sector) - -/* Coffee types. */ -typedef int16_t coffee_page_t; -typedef sd_offset_t coffee_offset_t; - -int cfs_coffee_arch_erase(unsigned); - -#endif /* !COFFEE_ARCH_H */ diff --git a/platform/msb430/contiki-conf.h b/platform/msb430/contiki-conf.h deleted file mode 100644 index e6b525d40..000000000 --- a/platform/msb430/contiki-conf.h +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef CONTIKI_CONF_H -#define CONTIKI_CONF_H - -#define HAVE_STDINT_H -#include "msp430def.h" - -#define WITH_SD 0 - -#define NETSTACK_CONF_RADIO cc1020_driver -#define NETSTACK_CONF_RDC lpp_driver -#define NETSTACK_CONF_MAC csma_driver -#define NETSTACK_CONF_NETWORK rime_driver -#define NETSTACK_CONF_FRAMER framer_nullmac - -#define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8 - -#define ENERGEST_CONF_ON 1 - -#define IRQ_PORT1 0x01 -#define IRQ_PORT2 0x02 -#define IRQ_ADC 0x03 - -/* MSP430 information memory */ -#define INFOMEM_START 0x1000 -#define INFOMEM_BLOCK_SIZE 128 -#define INFOMEM_NODE_ID 0x0000 /* - 0x0004 */ - -#define CC_CONF_REGISTER_ARGS 1 -#define CC_CONF_FUNCTION_POINTER_ARGS 1 -#define CC_CONF_INLINE inline -#define CC_CONF_VA_ARGS 1 - -#define LPP_CONF_LISTEN_TIME 2 -#define LPP_CONF_OFF_TIME (CLOCK_SECOND - (LPP_CONF_LISTEN_TIME)) -#define QUEUEBUF_CONF_NUM 4 - - -#define CCIF -#define CLIF - -/* Clear channel assessment timeout for sending with the CC1020 radio. (ms) */ -#define CC1020_CONF_CCA_TIMEOUT 10 - -/* Clock */ -typedef unsigned clock_time_t; -#define CLOCK_CONF_SECOND 64 -#define F_CPU 2457600uL /* CPU target speed in Hz. */ - -#define BAUD2UBR(baud) (F_CPU/(baud)) - -#include "ctk/ctk-vncarch.h" - -#define LOG_CONF_ENABLED 0 - -/** - * The statistics data type. - * - * This datatype determines how high the statistics counters are able - * to count. - */ -typedef uint16_t uip_stats_t; - -typedef int bool; -#define TRUE 1 -#define FALSE 0 - -#define UIP_CONF_ICMP_DEST_UNREACH 1 -#define UIP_CONF_DHCP_LIGHT -#define UIP_CONF_LLH_LEN 0 -#define UIP_CONF_BUFFER_SIZE 116 -#define UIP_CONF_RECEIVE_WINDOW (UIP_CONF_BUFFER_SIZE - 40) -#define UIP_CONF_MAX_CONNECTIONS 4 -#define UIP_CONF_MAX_LISTENPORTS 8 -#define UIP_CONF_UDP_CONNS 8 -#define UIP_CONF_FWCACHE_SIZE 20 -#define UIP_CONF_BROADCAST 1 -#define UIP_ARCH_IPCHKSUM 1 -#define UIP_CONF_UDP_CHECKSUMS 1 -#define UIP_CONF_PINGADDRCONF 0 -#define UIP_CONF_LOGGING 0 - -#define LOADER_CONF_ARCH "loader/loader-arch.h" - -#define ELFLOADER_CONF_DATAMEMORY_SIZE 100 -#define ELFLOADER_CONF_TEXTMEMORY_SIZE 0x1000 - -/* LEDs ports MSB430 */ -#define LEDS_PxDIR P5DIR -#define LEDS_PxOUT P5OUT -#define LEDS_CONF_RED 0x80 -#define LEDS_CONF_GREEN 0x00 -#define LEDS_CONF_YELLOW 0x00 - -#endif /* !CONTIKI_CONF_H */ diff --git a/platform/msb430/contiki-msb430-main.c b/platform/msb430/contiki-msb430-main.c deleted file mode 100644 index 8b6b4f187..000000000 --- a/platform/msb430/contiki-msb430-main.c +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Copyright (c) 2007, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * \file - * Main system file for the MSB-430 port. - * \author - * Michael Baar , Nicolas Tsiftes - */ -#include -#include - -#include "contiki.h" -#include "contiki-msb430.h" -#include "dev/adc.h" -#include "dev/sd.h" -#include "dev/serial-line.h" -#include "dev/sht11.h" -#include "dev/watchdog.h" - -extern volatile bool uart_edge; - -extern void init_net(void); - -SENSORS(NULL); - -static void -msb_ports_init(void) -{ - P1SEL = 0x00; P1OUT = 0x00; P1DIR = 0x00; - P2SEL = 0x00; P2OUT = 0x18; P2DIR = 0x1A; - P3SEL = 0x00; P3OUT = 0x09; P3DIR = 0x21; - P4SEL = 0x00; P4OUT = 0x00; P4DIR = 0x00; - P5SEL = 0x0E; P5OUT = 0xF9; P5DIR = 0xFD; - P6SEL = 0x07; P6OUT = 0x00; P6DIR = 0xC8; -} - -int -main(void) -{ -#if WITH_SD - int r; -#endif /* WITH_SD */ - - msp430_cpu_init(); - watchdog_stop(); - - /* Platform-specific initialization. */ - msb_ports_init(); - adc_init(); - - clock_init(); - rtimer_init(); - - sht11_init(); - leds_init(); - leds_on(LEDS_ALL); - - process_init(); - - /* serial interface */ - rs232_set_input(serial_line_input_byte); - rs232_init(); - serial_line_init(); - - uart_lock(UART_MODE_RS232); - uart_unlock(UART_MODE_RS232); -#if WITH_UIP - slip_arch_init(BAUD2UBR(115200)); -#endif - - -#if WITH_SD - r = sd_initialize(); - if(r < 0) { - printf("Failed to initialize the SD driver: %s\n", sd_error_string(r)); - } else { - sd_offset_t capacity; - printf("The SD driver was successfully initialized\n"); - capacity = sd_get_capacity(); - if(capacity < 0) { - printf("Failed to get the SD card capacity: %s\n", sd_error_string(r)); - } else { - printf("SD card capacity: %u MB\n", - (unsigned)(capacity / (1024UL * 1024))); - } - } -#endif - - node_id_restore(); - - /* System timers */ - process_start(&etimer_process, NULL); - ctimer_init(); - - /* Networking stack. */ - NETSTACK_RADIO.init(); - NETSTACK_RDC.init(); - NETSTACK_MAC.init(); - NETSTACK_NETWORK.init(); - { - rimeaddr_t rimeaddr; - - rimeaddr.u8[0] = node_id & 0xff; - rimeaddr.u8[1] = node_id >> 8; - rimeaddr_set_node_addr(&rimeaddr); - } - - energest_init(); - -#if PROFILE_CONF_ON - profile_init(); -#endif /* PROFILE_CONF_ON */ - - leds_off(LEDS_ALL); - - printf("Node %d.%d: %s %s, channel check rate %u Hz\n", - rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1], - NETSTACK_MAC.name, NETSTACK_RDC.name, - CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? - 1 : (unsigned)NETSTACK_RDC.channel_check_interval())); - - autostart_start(autostart_processes); - - /* - * This is the scheduler loop. - */ - ENERGEST_ON(ENERGEST_TYPE_CPU); - - while (1) { - int r; -#if PROFILE_CONF_ON - profile_episode_start(); -#endif /* PROFILE_CONF_ON */ - do { - /* Reset watchdog. */ - watchdog_periodic(); - r = process_run(); - } while(r > 0); - -#if PROFILE_CONF_ON - profile_episode_end(); -#endif /* PROFILE_CONF_ON */ - - /* - * Idle processing. - */ - int s = splhigh(); /* Disable interrupts. */ - if (process_nevents() != 0) { - splx(s); /* Re-enable interrupts. */ - } else { - static unsigned long irq_energest = 0; - /* Re-enable interrupts and go to sleep atomically. */ - ENERGEST_OFF(ENERGEST_TYPE_CPU); - ENERGEST_ON(ENERGEST_TYPE_LPM); - /* - * We only want to measure the processing done in IRQs when we - * are asleep, so we discard the processing time done when we - * were awake. - */ - energest_type_set(ENERGEST_TYPE_IRQ, irq_energest); - - if (uart_edge) { - _BIC_SR(LPM1_bits + GIE); - } else { - _BIS_SR(LPM1_bits + GIE); - } - - /* - * We get the current processing time for interrupts that was - * done during the LPM and store it for next time around. - */ - dint(); - irq_energest = energest_type_time(ENERGEST_TYPE_IRQ); - eint(); - ENERGEST_OFF(ENERGEST_TYPE_LPM); - ENERGEST_ON(ENERGEST_TYPE_CPU); -#if PROFILE_CONF_ON - profile_clear_timestamps(); -#endif /* PROFILE_CONF_ON */ - } - } - - return 0; -} diff --git a/platform/msb430/contiki-msb430.h b/platform/msb430/contiki-msb430.h deleted file mode 100644 index 80afabd21..000000000 --- a/platform/msb430/contiki-msb430.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -#ifndef CONTIKI_MSB430_H -#define CONTIKI_MSB430_H - -#include "contiki.h" -#include "contiki-net.h" -#include "contiki-lib.h" - -#include "dev/cc1020.h" -#include "dev/hwconf.h" -#include "dev/infomem.h" -#include "dev/leds.h" -#include "dev/lpm.h" -#include "dev/msb430-uart1.h" -#include "dev/rs232.h" -#include "dev/serial-line.h" -#include "dev/slip.h" - -#include "lib/sensors.h" -#include "net/rime.h" -#include "sys/node-id.h" - -#if WITH_SD -#include "dev/sd.h" -#endif /* WITH_SD */ - -#endif /* !CONTIKI_MSB430_H */ diff --git a/platform/msb430/dev/adc.c b/platform/msb430/dev/adc.c deleted file mode 100644 index fb14d3723..000000000 --- a/platform/msb430/dev/adc.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2007, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * \file - * ADC functions. - * \author - * Nicolas Tsiftes - */ - -#include "contiki.h" -#include "contiki-msb430.h" - -void -adc_init(void) -{ - ADC12CTL0 = SHT0_15 | SHT1_15 | MSC; - - /* - * SHP: sampling timer - * CONSEQ3: repeat sequence of channels - * CSTARTADD: conversion start address 0 - */ - ADC12CTL1 = SHP | CONSEQ_3 | CSTARTADD_0; - - /* P60: A0 */ - ADC12MCTL0 = INCH_0 | SREF_0; - ADC12MCTL1 = INCH_1 | SREF_0; - ADC12MCTL2 = INCH_2 | SREF_0; - - /* P61: A1 */ - ADC12MCTL3 = ADC12MCTL4 = ADC12MCTL5 = INCH_1 | SREF_0; - - /* P62: A2 */ - ADC12MCTL6 = ADC12MCTL7 = ADC12MCTL8 = ADC12MCTL9 = INCH_2 | SREF_0; - - /* P63: A3 */ - ADC12MCTL10 = INCH_3 | SREF_0; - - /* P64: A4 */ - ADC12MCTL11 = INCH_4 | SREF_0; - - /* P65: A5 */ - ADC12MCTL12 = INCH_5 | SREF_0; - - /* INCH10: Temperature sensor. */ - ADC12MCTL13 = INCH_10 | SREF_0 | EOS; -} - -void -adc_on(void) -{ - ADC12CTL0 |= ADC12ON; - clock_delay(20000); - ADC12CTL0 |= ENC; - ADC12CTL0 |= ADC12SC; -} - -void -adc_off(void) -{ - ADC12CTL0 &= ~ENC; - clock_delay(20000); - ADC12CTL0 &= ~ADC12ON; -} diff --git a/platform/msb430/dev/adc.h b/platform/msb430/dev/adc.h deleted file mode 100644 index e8d5a2dd9..000000000 --- a/platform/msb430/dev/adc.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2007, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -#ifndef ADC_H -#define ADC_H - -void adc_init(void); -void adc_on(void); -void adc_off(void); - -#endif /* !ADC_H */ diff --git a/platform/msb430/dev/cc1020-internal.h b/platform/msb430/dev/cc1020-internal.h deleted file mode 100644 index f0053ea97..000000000 --- a/platform/msb430/dev/cc1020-internal.h +++ /dev/null @@ -1,263 +0,0 @@ -#ifndef CC1020_INTERNAL_H -#define CC1020_INTERNAL_H - -#include "contiki.h" - -#define CC1020_MAIN 0x00 -#define CC1020_INTERFACE 0x01 -#define CC1020_RESET 0x02 -#define CC1020_SEQUENCING 0x03 -#define CC1020_FREQ_2A 0x04 -#define CC1020_FREQ_1A 0x05 -#define CC1020_FREQ_0A 0x06 -#define CC1020_CLOCK_A 0x07 -#define CC1020_FREQ_2B 0x08 -#define CC1020_FREQ_1B 0x09 -#define CC1020_FREQ_0B 0x0A -#define CC1020_CLOCK_B 0x0B -#define CC1020_VCO 0x0C -#define CC1020_MODEM 0x0D -#define CC1020_DEVIATION 0x0E -#define CC1020_AFC_CONTROL 0x0F -#define CC1020_FILTER 0x10 -#define CC1020_VGA1 0x11 -#define CC1020_VGA2 0x12 -#define CC1020_VGA3 0x13 -#define CC1020_VGA4 0x14 -#define CC1020_LOCK 0x15 -#define CC1020_FRONTEND 0x16 -#define CC1020_ANALOG 0x17 -#define CC1020_BUFF_SWING 0x18 -#define CC1020_BUFF_CURRENT 0x19 -#define CC1020_PLL_BW 0x1A -#define CC1020_CALIBRATE 0x1B -#define CC1020_PA_POWER 0x1C -#define CC1020_MATCH 0x1D -#define CC1020_PHASE_COMP 0x1E -#define CC1020_GAIN_COMP 0x1F -#define CC1020_POWERDOWN 0x20 -#define CC1020_TEST1 0x21 -#define CC1020_TEST2 0x22 -#define CC1020_TEST3 0x23 -#define CC1020_TEST4 0x24 -#define CC1020_TEST5 0x25 -#define CC1020_TEST6 0x26 -#define CC1020_TEST7 0x27 -#define CC1020_STATUS 0x40 -#define CC1020_RESET_DONE 0x41 -#define CC1020_RSS 0x42 -#define CC1020_AFC 0x43 -#define CC1020_GAUSS_FILTER 0x44 -#define CC1020_STATUS1 0x45 -#define CC1020_STATUS2 0x46 -#define CC1020_STATUS3 0x47 -#define CC1020_STATUS4 0x48 -#define CC1020_STATUS5 0x49 -#define CC1020_STATUS6 0x4A -#define CC1020_STATUS7 0x4B - -/* Flags for the MAIN register. */ -#define RESET_N 1 -#define BIAS_PD (1<<1) -#define XOSC_PD (1<<2) -#define FS_PD (1<<3) -#define PD_MODE_1 (1<<4) -#define PD_MODE_2 (1<<5) -#define F_REG (1<<6) -#define RXTX (1<<7) - -/* In power up mode, the MAIN register modifies some flags to the following. */ -#define SEQ_PD (1<<1) -#define SEQ_CAL_1 (1<<2) -#define SEQ_CAL_2 (1<<3) - -// For CC1020_STATUS -#define CARRIER_SENSE 0x08 -#define LOCK_CONTINUOUS 0x10 -#define LOCK_INSTANT 0x20 -#define SEQ_ERROR 0x40 -#define CAL_COMPLETE 0x80 - -#define PA_POWER 0x0F // initial default for output power -#define LOCK_NOK 0x00 -#define LOCK_OK 0x01 -#define LOCK_RECAL_OK 0x02 -#define CAL_TIMEOUT 0x7FFE -#define LOCK_TIMEOUT 0x7FFE -#define RESET_TIMEOUT 0x7FFE -#define TX_CURRENT 0x87 -#define RX_CURRENT 0x86 - -// CC1020 driver configuration - -// PDI (Data in) is on P21 -#define PDO (P2IN & 0x01) - -// PSEL is on P30 and low active -#define PSEL_ON do { P3OUT &= ~0x01; } while(0) -#define PSEL_OFF do { P3OUT |= 0x01; } while(0) -#define PCLK_HIGH do { P2OUT |= 0x08; } while(0) -#define PCLK_LOW do { P2OUT &= ~0x08; } while(0) - -// PDO (Data out) is on P22 -#define PDI_HIGH do { P2OUT |= 0x02; } while(0) - -#define PDI_LOW do { P2OUT &= ~0x02; } while(0) - -// Enable power for LNA (P24, low-active) -#define LNA_POWER_ON() do { P2OUT &= ~0x10; } while(0) - -#define LNA_POWER_OFF() do { P2OUT |= 0x10; } while(0) - -#define CC_LOCK (P2IN & 0x04) - -#define DISABLE_RX_IRQ() \ - do { IE1 &= ~(URXIE0); } while(0) - -#define ENABLE_RX_IRQ() \ - do { IFG1 &= ~URXIFG0; IE1 |= URXIE0; } while(0) - -#define ACK_TIMEOUT_115 4 // In RADIO_STROKE ticks -#define ACK_TIMEOUT_19 16 - -#define MHZ_869525 1 - -const uint8_t cc1020_config_19200[41] = { - 0x01, // 0x00, MAIN - 0x0F, // 0x01, INTERFACE - 0xFF, // 0x02, RESET - 0x8F, // 0x03, SEQUENCING - // 869.525 at 50kHz - 0x3A, // 0x04, FREQ_2A - 0x32, // 0x05, FREQ_1A - 0x97, // 0x06, FREQ_0A // 19200 - 0x38, // 0x07, CLOCK_A // 19200 - 0x3A, // 0x08, FREQ_2B - 0x37, // 0x09, FREQ_1B - 0xEB, // 0x0A, FREQ_0B // 19200 - 0x38, // 0x0B, CLOCK_B // 19200 - 0x44, // 0x0C, VCO 44 - 0x51, // 0x0D, MODEM Manchester - 0x2B, // 0x0E, DEVIATION // FSK - 0x4C, // 0x0F, AFC_CONTROL Ruetten 0xCC - 0x25, // 0x10, FILTER Bandwith 51.2 kHz i.e. channel spacing 100kHz - 0x61, // 0x11, VGA1 - 0x55, // 0x12, VGA2 - 0x2D, // 0x13, VGA3 - 0x37, // 0x14, VGA4 // 0x29, VGA4 ADJUSTED CS to 23! - 0x40, // 0x15, LOCK is Carrier SENSE - 0x76, // 0x16, FRONTEND - 0x87, // 0x17, ANALOG, RX=86/TX=87 - 0x10, // 0x18, BUFF_SWING - 0x25, // 0x19, BUFF_CURRENT - 0xAE, // 0x1A, PLL_BW - 0x34, // 0x1B, CALIBRATE - PA_POWER, // 0x1C, PA_POWER AN025 = 0xA0 - 0xF0, // 0x1D, MATCH - 0x00, // 0x1E, PHASE_COMP - 0x00, // 0x1F, GAIN_COMP - 0x00, // 0x20, POWERDOWN - 0x4d, // 0x4d, // 0x21, - 0x10, // 0x10, // 0x22, - 0x06, // 0x06, // 0x23, - 0x00, // 0x00, // 0x24, - 0x40, // 0x40, // 0x25, - 0x00, // 0x00, // 0x26, - 0x00, // 0x00, // 0x27, - // Not in real config of chipCon from here!!! - ACK_TIMEOUT_19 -}; - -const uint8_t cc1020_config_115200[41] = { - 0x01, // 0x00, MAIN - 0x0F, // 0x01, INTERFACE - 0xFF, // 0x02, RESET - 0x8F, // 0x03, SEQUENCING - // 869.525 at 200kHz - 0x3A, // 0x04, FREQ_2A - 0x32, // 0x05, FREQ_1A - 0x97, // 0x06, FREQ_0A // 19200 - 0x29, // 0x07, CLOCK_A // 19200 - 0x3A, // 0x08, FREQ_2B - 0x37, // 0x09, FREQ_1B - 0xEB, // 0x0A, FREQ_0B // 19200 - 0x29, // 0x0B, CLOCK_B // 19200 - 0x44, // 0x0C, VCO 44 - 0x51, // 0x0D, MODEM Manchester - 0x58, // 0x0E, DEVIATION // FSK - 0x4C, // 0x0F, AFC_CONTROL Ruetten 0xCC - 0x80, // 0x10, FILTER Bandwith 307.2kHz, i.e. channel spacing 500 kHz - 0x61, // 0x11, VGA1 - 0x57, // 0x12, VGA2 - 0x30, // 0x13, VGA3 - 0x35, // 0x14, VGA4 - 0x20, // 0x15, LOCK is Carrier SENSE - 0x76, // 0x16, FRONTEND - 0x87, // 0x17, ANALOG, RX=86/TX=87 - 0x10, // 0x18, BUFF_SWING - 0x25, // 0x19, BUFF_CURRENT - 0xAE, // 0x1A, PLL_BW - 0x34, // 0x1B, CALIBRATE - PA_POWER, // 0x1C, PA_POWER AN025 = 0xA0 - 0xF0, // 0x1D, MATCH - 0x00, // 0x1E, PHASE_COMP - 0x00, // 0x1F, GAIN_COMP - 0x00, // 0x20, POWERDOWN - 0x4d, // 0x21, - 0x10, // 0x22, - 0x06, // 0x23, - 0x00, // 0x24, - 0x40, // 0x25, - 0x00, // 0x26, - 0x00, // 0x27, - // Not in real config of chipCon from here!!! - ACK_TIMEOUT_115 -}; - -/// cc1020 state -enum cc1020_state { - CC1020_OFF = 0, - CC1020_RX = 0x01, - CC1020_TX = 0x02, - - CC1020_RX_SEARCHING = 0x10, // searching for preamble + sync word - CC1020_RX_RECEIVING = 0x20, // receiving bytes - CC1020_RX_PROCESSING = 0x40, // processing data in buffer - - CC1020_OP_STATE = 0x73, - - CC1020_TURN_OFF = 0x80, -}; - -#define CC1020_SET_OPSTATE(opstate) cc1020_state = ((cc1020_state & ~CC1020_OP_STATE) | (opstate)) - -/****************************************************************************** - * @name Packet specification - * @{ - */ - -// header: number of bytes in packet including header -struct cc1020_header { - uint8_t pad; - uint8_t length; -} __attribute__((packed)); - - -#define CC1020_BUFFERSIZE 128 - - -#define PREAMBLE_SIZE 6 -#define PREAMBLE 0xAA - -#define SYNCWORD_SIZE 2 -#define HDR_SIZE (sizeof (struct cc1020_header)) - -#define CRC_SIZE 2 - -#define TAIL_SIZE 2 -#define TAIL 0xFA - - -///@} - -#endif /* CC1020_INTERNAL_H */ diff --git a/platform/msb430/dev/cc1020-uip.c b/platform/msb430/dev/cc1020-uip.c deleted file mode 100644 index 78f18c4e9..000000000 --- a/platform/msb430/dev/cc1020-uip.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2007, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * \file - * Chipcon CC1020 glue driver for uIP - * \author - * Nicolas Tsiftes - */ - -#include "contiki.h" -#include "cc1020.h" -#include "cc1020-uip.h" -#include "net/uip.h" -#include "net/hc.h" - -static void -receiver(const struct radio_driver *d) -{ - uip_len = cc1020_read(&uip_buf[UIP_LLH_LEN], UIP_BUFSIZE - UIP_LLH_LEN); - if(uip_len > 0) { - uip_len = hc_inflate(&uip_buf[UIP_LLH_LEN], uip_len); - tcpip_input(); - } -} - -void -cc1020_uip_init(void) -{ - cc1020_set_receiver(&receiver); -} - -uint8_t -cc1020_uip_send(void) -{ - uip_len = hc_compress(&uip_buf[UIP_LLH_LEN], uip_len); - return cc1020_send(&uip_buf[UIP_LLH_LEN], uip_len); -} diff --git a/platform/msb430/dev/cc1020-uip.h b/platform/msb430/dev/cc1020-uip.h deleted file mode 100644 index 652b40b3d..000000000 --- a/platform/msb430/dev/cc1020-uip.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2007, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ -#ifndef CC1020_UIP_H -#define CC1020_UIP_H - -void cc1020_uip_init(void); -uint8_t cc1020_uip_send(void); - -#endif /* !CC1020_UIP_H */ diff --git a/platform/msb430/dev/cc1020.c b/platform/msb430/dev/cc1020.c deleted file mode 100644 index f5c9ba291..000000000 --- a/platform/msb430/dev/cc1020.c +++ /dev/null @@ -1,803 +0,0 @@ -/* - * Copyright 2006, Freie Universitaet Berlin. All rights reserved. - * - * These sources were developed at the Freie Universitaet Berlin, Computer - * Systems and Telematics group. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * - Neither the name of Freie Universitaet Berlin (FUB) nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided by FUB and the contributors on an "as is" - * basis, without any representations or warranties of any kind, express - * or implied including, but not limited to, representations or - * warranties of non-infringement, merchantability or fitness for a - * particular purpose. In no event shall FUB or contributors be liable - * for any direct, indirect, incidental, special, exemplary, or - * consequential damages (including, but not limited to, procurement of - * substitute goods or services; loss of use, data, or profits; or - * business interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including negligence - * or otherwise) arising in any way out of the use of this software, - * even if advised of the possibility of such damage. - * - * This implementation was originally developed by the CST group at the FUB. - */ - -/** - * \file cc1020.c - * \author FUB ScatterWeb Developers, Michael Baar, Nicolas Tsiftes - **/ - -#include -#include - -#include "contiki.h" -#include "contiki-msb430.h" -#include "cc1020-internal.h" -#include "cc1020.h" -#include "lib/random.h" -#include "lib/crc16.h" -#include "net/rime/rimestats.h" -#include "dev/dma.h" -#include "sys/energest.h" -#include "isr_compat.h" - -#define DEBUG 0 -#if DEBUG -#include -#define PRINTF(...) printf(__VA_ARGS__) -#else -#define PRINTF(...) -#endif - -#define SEND_TIMEOUT 10 - -static int cc1020_calibrate(void); -static int cc1020_setupTX(int); -static int cc1020_setupRX(int); -static void cc1020_setupPD(void); -static void cc1020_wakeupTX(int); -static void cc1020_wakeupRX(int); -static uint8_t cc1020_read_reg(uint8_t addr); -static void cc1020_write_reg(uint8_t addr, uint8_t adata); -static void cc1020_load_config(const uint8_t *); -static void cc1020_reset(void); - -static const uint8_t syncword[SYNCWORD_SIZE] = {0xD3, 0x91}; - -/* current mode of cc1020 chip */ -static volatile enum cc1020_state cc1020_state = CC1020_OFF; -static volatile uint8_t cc1020_rxbuf[HDR_SIZE + CC1020_BUFFERSIZE]; -static uint8_t cc1020_txbuf[PREAMBLE_SIZE + SYNCWORD_SIZE + HDR_SIZE + - CC1020_BUFFERSIZE + TAIL_SIZE]; - -/* number of bytes in receive and transmit buffers respectively. */ -static uint8_t cc1020_rxlen; -static uint8_t cc1020_txlen; - -/* received signal strength indicator reading for last received packet */ -static volatile uint8_t rssi; - -/* callback when a packet has been received */ -static uint8_t cc1020_pa_power = PA_POWER; - -static volatile char dma_done; - -/* Radio driver AAPI functions. */ -static int cc1020_init(void); -static int cc1020_prepare(const void *payload, unsigned short payload_len); -static int cc1020_transmit(unsigned short transmit_len); -static int cc1020_send(const void *payload, unsigned short payload_len); -static int cc1020_read(void *buf, unsigned short buf_len); -static int cc1020_channel_clear(void); -static int cc1020_receiving_packet(void); -static int cc1020_pending_packet(void); -static int cc1020_on(void); -static int cc1020_off(void); - -const struct radio_driver cc1020_driver = - { - cc1020_init, - cc1020_prepare, - cc1020_transmit, - cc1020_send, - cc1020_read, - cc1020_channel_clear, - cc1020_receiving_packet, - cc1020_pending_packet, - cc1020_on, - cc1020_off - }; - -#define MS_DELAY(x) clock_delay(354 * (x)) - -PROCESS(cc1020_receiver_process, "CC1020 receiver"); - -static void -dma_callback(void) -{ - dma_done = 1; -} - -static void -reset_receiver(void) -{ - /* reset receiver */ - cc1020_rxlen = 0; - - if((cc1020_state & CC1020_TURN_OFF) && (cc1020_txlen == 0)) { - cc1020_off(); - } else { - CC1020_SET_OPSTATE(CC1020_RX | CC1020_RX_SEARCHING); - cc1020_set_rx(); - ENABLE_RX_IRQ(); - } -} - -static int -cc1020_init(void) -{ - cc1020_setupPD(); - cc1020_reset(); - cc1020_load_config(cc1020_config_19200); - - /* init tx buffer with preamble + syncword */ - memset(cc1020_txbuf, PREAMBLE, PREAMBLE_SIZE); - cc1020_txbuf[PREAMBLE_SIZE] = syncword[0]; - cc1020_txbuf[PREAMBLE_SIZE + 1] = syncword[1]; - - /* calibrate receiver */ - cc1020_wakeupRX(RX_CURRENT); - if(!cc1020_calibrate()) { - PRINTF("cc1020: rx calibration failed\n"); - return -1; - } - - /* calibrate transmitter */ - cc1020_wakeupTX(TX_CURRENT); - if(!cc1020_calibrate()) { - PRINTF("cc1020: tx calibration failed\n"); - return -1; - } - - /* power down */ - cc1020_setupPD(); - - process_start(&cc1020_receiver_process, NULL); - dma_subscribe(0, dma_callback); - - return 0; -} - -void -cc1020_set_rx(void) -{ - int s; - - s = splhigh(); - - /* Reset SEL for P3[1-3] (CC DIO, DIO, DCLK) and P3[4-5] (Camera Rx+Tx) */ - P3SEL &= ~0x3E; - IFG1 &= ~(UTXIE0 | URXIE0); /* Clear interrupt flags */ - ME1 &= ~(UTXE0 | URXE0); /* Disable Uart0 Tx + Rx */ - UCTL0 = SWRST; /* U0 into reset state. */ - UCTL0 |= CHAR | SYNC; /* 8-bit character, SPI, Slave mode */ - - /* CKPH works also, but not CKPH+CKPL or none of them!! */ - UTCTL0 = CKPL | STC; - URCTL0 = 0x00; - UBR00 = 0x00; /* No baudrate divider */ - UBR10 = 0x00; /* settings for a spi */ - UMCTL0 = 0x00; /* slave. */ - ME1 |= URXE0; /* Enable USART0 RXD, disabling does not yield any powersavings */ - P3SEL |= 0x0A; /* Select rx line and clk */ - UCTL0 &= ~SWRST; /* Clear reset bit */ - splx(s); - - /* configure driver */ - cc1020_rxlen = 0; /* receive buffer position to start */ - CC1020_SET_OPSTATE(CC1020_RX | CC1020_RX_SEARCHING); /* driver state to receive mode */ - - /* configure radio */ - ENERGEST_ON(ENERGEST_TYPE_LISTEN); - cc1020_wakeupRX(RX_CURRENT); - cc1020_setupRX(RX_CURRENT); - LNA_POWER_ON(); /* enable amplifier */ - - /* activate */ - IE1 |= URXIE0; /* enable interrupt */ -} - -void -cc1020_set_tx(void) -{ - int s; - - /* configure radio rx */ - ENERGEST_OFF(ENERGEST_TYPE_LISTEN); - LNA_POWER_OFF(); /* power down LNA */ - s = splhigh(); - DISABLE_RX_IRQ(); - P3SEL &= ~0x02; /* Ensure Rx line is off */ - splx(s); - - /* configure radio tx */ - ENERGEST_ON(ENERGEST_TYPE_TRANSMIT); - cc1020_wakeupTX(TX_CURRENT); - cc1020_setupTX(TX_CURRENT); - P3SEL |= 0x0C; /* select Tx line and clk */ - U0CTL |= SWRST; /* UART to reset mode */ - IFG1 &= ~UTXIFG0; /* Reset IFG. */ - - /* configure driver */ - CC1020_SET_OPSTATE(CC1020_TX); -} - -void -cc1020_set_power(uint8_t pa_power) -{ - cc1020_pa_power = pa_power; -} - -static int -cc1020_prepare(const void *payload, unsigned short payload_len) -{ - return -1; -} - -static int -cc1020_transmit(unsigned short transmit_len) -{ - return 0; -} - -static int -cc1020_send(const void *buf, unsigned short len) -{ - int normal_header = HDR_SIZE + len; - uint16_t rxcrc = 0xffff; /* For checksum purposes */ - rtimer_clock_t timeout_time; - - timeout_time = RTIMER_NOW() + RTIMER_SECOND / 1000 * SEND_TIMEOUT; - while(cc1020_state & CC1020_RX_RECEIVING) { - if(RTIMER_CLOCK_LT(timeout_time, RTIMER_NOW())) { - PRINTF("cc1020: transmission blocked by reception in progress\n"); - return RADIO_TX_ERR; - } - } - - if(cc1020_state == CC1020_OFF) { - return RADIO_TX_ERR; - } - - if(len > CC1020_BUFFERSIZE) { - return RADIO_TX_ERR; - } - - /* The preamble and the sync word are already in buffer. */ - cc1020_txlen = PREAMBLE_SIZE + SYNCWORD_SIZE; - - /* header */ - cc1020_txbuf[cc1020_txlen++] = 0x00; - cc1020_txbuf[cc1020_txlen++] = normal_header + CRC_SIZE; - - /* Adding the checksum on header and data */ - rxcrc = crc16_add(normal_header & 0xff, rxcrc); - rxcrc = crc16_add((normal_header >> 8) & 0xff, rxcrc); - - rxcrc = crc16_data(buf, len, rxcrc); - - /* data to send */ - memcpy((char *)cc1020_txbuf + cc1020_txlen, buf, len); - cc1020_txlen += len; - - /* Send checksum */ - cc1020_txbuf[cc1020_txlen++] = rxcrc >> 8; - cc1020_txbuf[cc1020_txlen++] = rxcrc & 0xff; - - /* suffix */ - cc1020_txbuf[cc1020_txlen++] = TAIL; - cc1020_txbuf[cc1020_txlen++] = TAIL; - - /* Switch to transceive mode. */ - cc1020_set_tx(); - - /* Initiate radio transfer. */ - dma_done = 0; - dma_transfer((unsigned char *)&TXBUF0, cc1020_txbuf, cc1020_txlen); - while(!dma_done); - - ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT); - RIMESTATS_ADD(lltx); - - /* clean up */ - cc1020_txlen = 0; - if(cc1020_state & CC1020_TURN_OFF) { - cc1020_off(); - } else { - cc1020_set_rx(); - } - - return RADIO_TX_OK; -} - -static int -cc1020_read(void *buf, unsigned short size) -{ - unsigned len; - - if(cc1020_rxlen <= HDR_SIZE) { - return 0; - } - - len = cc1020_rxlen - HDR_SIZE; - if(len > size) { - RIMESTATS_ADD(toolong); - return -1; - } - - memcpy(buf, (char *)cc1020_rxbuf + HDR_SIZE, len); - RIMESTATS_ADD(llrx); - reset_receiver(); - - return len; -} - -static int -cc1020_channel_clear(void) -{ - return (cc1020_read_reg(CC1020_STATUS) & CARRIER_SENSE); -} - -static int -cc1020_receiving_packet(void) -{ - return cc1020_state & CC1020_RX_RECEIVING; -} - -static int -cc1020_pending_packet(void) -{ - return cc1020_state & CC1020_RX_PROCESSING; -} - -int -cc1020_on(void) -{ - if(cc1020_state == CC1020_OFF) { - cc1020_set_rx(); - } else if(cc1020_state & CC1020_TURN_OFF) { - cc1020_state &= ~CC1020_TURN_OFF; - cc1020_set_rx(); - } - - return 1; -} - -int -cc1020_off(void) -{ - int s; - - if(cc1020_state != CC1020_OFF) { - if(cc1020_state & CC1020_RX_SEARCHING) { - /* Discard the current read buffer when the radio is shutting down. */ - cc1020_rxlen = 0; - - LNA_POWER_OFF(); /* power down lna */ - s = splhigh(); - DISABLE_RX_IRQ(); - cc1020_state = CC1020_OFF; - splx(s); - cc1020_setupPD(); /* power down radio */ - ENERGEST_OFF(ENERGEST_TYPE_LISTEN); - cc1020_state = CC1020_OFF; - } else { - cc1020_state |= CC1020_TURN_OFF; - } - } - return 1; -} - -uint8_t -cc1020_get_rssi(void) -{ - return (cc1020_read_reg(CC1020_RSS) & 0x7F); -} - -uint8_t -cc1020_get_packet_rssi(void) -{ - return rssi; -} - -PROCESS_THREAD(cc1020_receiver_process, ev, data) -{ - int len; - - PROCESS_BEGIN(); - - while(1) { - ev = PROCESS_EVENT_NONE; - PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_POLL); - - /* Verify the checksum. */ - uint16_t expected_crc = 0xffff; - uint16_t actual_crc; - - actual_crc = (cc1020_rxbuf[cc1020_rxlen - CRC_SIZE] << 8) | - cc1020_rxbuf[cc1020_rxlen - CRC_SIZE + 1]; - cc1020_rxlen -= CRC_SIZE; - - expected_crc = crc16_add(cc1020_rxlen & 0xff, expected_crc); - expected_crc = crc16_add((cc1020_rxlen >> 8) & 0xff, expected_crc); - expected_crc = crc16_data((char *)&cc1020_rxbuf[HDR_SIZE], - cc1020_rxlen - HDR_SIZE, expected_crc); - - if(expected_crc == actual_crc) { - len = cc1020_read(packetbuf_dataptr(), PACKETBUF_SIZE); - packetbuf_set_datalen(len); - NETSTACK_RDC.input(); - } else { - RIMESTATS_ADD(badcrc); - reset_receiver(); - } - } - - PROCESS_END(); -} - -ISR(UART0RX, cc1020_rxhandler) -{ - static signed char syncbs; - static union { - struct { - uint8_t b2; - uint8_t b1; - uint8_t b4; - uint8_t b3; - }; - struct { - uint16_t i1; - uint16_t i2; - }; - } shiftbuf; - static unsigned char pktlen; - - if(cc1020_state & CC1020_RX_SEARCHING) { - shiftbuf.b1 = shiftbuf.b2; - shiftbuf.b2 = shiftbuf.b3; - shiftbuf.b3 = shiftbuf.b4; - shiftbuf.b4 = RXBUF0; - if(shiftbuf.i1 == 0xAAD3 && shiftbuf.b3 == 0x91) { - /* 0 AA D3 91 00 | FF 00 | */ - syncbs = 0; - cc1020_rxbuf[cc1020_rxlen++] = shiftbuf.b4; - } else if(shiftbuf.i1 == 0x5569 && shiftbuf.i2 == 0xC880) { - /* 1 55 69 C8 80 | 7F 80 | */ - syncbs = -1; - } else if(shiftbuf.i1 == 0xAAB4 && shiftbuf.i2 == 0xE440) { - /* 2 AA B4 E4 40 | 3F C0 | */ - syncbs = -2; - } else if(shiftbuf.i1 == 0x555A && shiftbuf.i2 == 0x7220) { - /* 3 55 5A 72 20 | 1F E0 | */ - syncbs = -3; - } else if(shiftbuf.i1 == 0xAAAD && shiftbuf.i2 == 0x3910) { - /* 4 AA AD 39 10 | 0F F0 | */ - syncbs = -4; - } else if(shiftbuf.i1 == 0x5556 && shiftbuf.i2 == 0x9C88) { - /* 5 55 56 9C 88 | 07 F8 | */ - syncbs = +3; - } else if(shiftbuf.i1 == 0xAAAB && shiftbuf.i2 == 0x4E44) { - /* 6 AA AB 4E 44 | 03 FC | */ - syncbs = +2; - } else if(shiftbuf.i1 == 0x5555 && shiftbuf.i2 == 0xA722) { - /* 7 55 55 A7 22 | 01 FE | */ - syncbs = +1; - } else { - return; - } - rssi = cc1020_get_rssi(); - CC1020_SET_OPSTATE(CC1020_RX | CC1020_RX_RECEIVING); - } else if(cc1020_state & CC1020_RX_RECEIVING) { - if(syncbs == 0) { - cc1020_rxbuf[cc1020_rxlen] = RXBUF0; - } else { - shiftbuf.b3 = shiftbuf.b4; - shiftbuf.b4 = RXBUF0; - if(syncbs < 0) { - shiftbuf.i1 = shiftbuf.i2 << -syncbs; - cc1020_rxbuf[cc1020_rxlen] = shiftbuf.b1; - } else { - shiftbuf.i1 = shiftbuf.i2 >> syncbs; - cc1020_rxbuf[cc1020_rxlen] = shiftbuf.b2; - } - } - - cc1020_rxlen++; - - if(cc1020_rxlen == HDR_SIZE) { - pktlen = ((struct cc1020_header *)cc1020_rxbuf)->length; - if(pktlen == 0 || pktlen > sizeof (cc1020_rxbuf)) { - cc1020_rxlen = 0; - CC1020_SET_OPSTATE(CC1020_RX | CC1020_RX_SEARCHING); - } - } else if(cc1020_rxlen > HDR_SIZE) { - if(cc1020_rxlen == pktlen) { - /* Disable interrupts while processing the packet. */ - DISABLE_RX_IRQ(); - CC1020_SET_OPSTATE(CC1020_RX | CC1020_RX_PROCESSING); - _BIC_SR_IRQ(LPM3_bits); - process_poll(&cc1020_receiver_process); - } - } - } -} - -static void -cc1020_write_reg(uint8_t addr, uint8_t adata) -{ - unsigned int i; - uint8_t data; - - data = addr << 1; - PSEL_ON; - - /* Send address bits */ - for(i = 0; i < 7; i++) { - PCLK_LOW; - if(data & 0x80) { - PDI_HIGH; - } else { - PDI_LOW; - } - data = data << 1; - PCLK_HIGH; - nop(); - } - - /* Send read/write bit */ - /* Ignore bit in data, always use 1 */ - PCLK_LOW; - PDI_HIGH; - PCLK_HIGH; - nop(); - data = adata; - - /* Send data bits */ - for(i = 0; i < 8; i++) { - PCLK_LOW; - if(data & 0x80) { - PDI_HIGH; - } else { - PDI_LOW; - } - data = data << 1; - PCLK_HIGH; - nop(); - } - - PCLK_LOW; - PSEL_OFF; -} - -static uint8_t -cc1020_read_reg(uint8_t addr) -{ - unsigned int i; - uint8_t data; - - data = addr << 1; - PSEL_ON; - - /* Send address bits */ - for(i = 0; i < 7; i++) { - PCLK_LOW; - if(data & 0x80) { - PDI_HIGH; - } else { - PDI_LOW; - } - data = data << 1; - PCLK_HIGH; - nop(); - } - - /* Send read/write bit */ - /* Ignore bit in data, always use 0 */ - PCLK_LOW; - PDI_LOW; - PCLK_HIGH; - nop(); - PCLK_LOW; - - /* Receive data bits */ - for(i = 0; i < 8; i++) { - nop(); - PCLK_HIGH; - nop(); - data = data << 1; - if(PDO) { - data++; - } - PCLK_LOW; - } - - PSEL_OFF; - - return data; -} - -static void -cc1020_load_config(const uint8_t * config) -{ - int i; - - for(i = 0; i < 0x28; i++) - cc1020_write_reg(i, config[i]); -} - -static void -cc1020_reset(void) -{ - /* Reset CC1020 */ - cc1020_write_reg(CC1020_MAIN, 0x0FU & ~0x01U); - - /* Bring CC1020 out of reset */ - cc1020_write_reg(CC1020_MAIN, 0x1F); -} - -static int -cc1020_calibrate(void) -{ - unsigned int timeout_cnt; - - /* Turn off PA to avoid spurs during calibration in TX mode */ - cc1020_write_reg(CC1020_PA_POWER, 0x00); - - /* Start calibration */ - cc1020_write_reg(CC1020_CALIBRATE, 0xB5); - while((cc1020_read_reg(CC1020_STATUS) & CAL_COMPLETE) == 0); - - /* Monitor lock */ - for(timeout_cnt = LOCK_TIMEOUT; timeout_cnt > 0; timeout_cnt--) { - if(cc1020_read_reg(CC1020_STATUS) & LOCK_CONTINUOUS) { - break; - } - } - - /* Restore PA_POWER */ - cc1020_write_reg(CC1020_PA_POWER, cc1020_pa_power); - - /* Return state of LOCK_CONTINUOUS bit */ - return (cc1020_read_reg(CC1020_STATUS) & LOCK_CONTINUOUS) == LOCK_CONTINUOUS; -} - -static int -cc1020_lock(void) -{ - char lock_status; - int i; - - /* Monitor LOCK, lasts 420 - 510 cycles @ 4505600 = 93 us - 113 us */ - for(i = LOCK_TIMEOUT; i > 0; i--) { - lock_status = cc1020_read_reg(CC1020_STATUS) & LOCK_CONTINUOUS; - if(lock_status) { - break; - } - } - - if(lock_status == LOCK_CONTINUOUS) { - return LOCK_OK; - } - - return cc1020_calibrate() ? LOCK_RECAL_OK : LOCK_NOK; -} - -static int -cc1020_setupRX(int analog) -{ - char lock_status; - - /* Switch into RX, switch to freq. reg A */ - cc1020_write_reg(CC1020_MAIN, 0x01); - lock_status = cc1020_lock(); - - /* Switch RX part of CC1020 on */ - cc1020_write_reg(CC1020_INTERFACE, 0x02); - - /* Return LOCK status to application */ - return lock_status; -} - -static int -cc1020_setupTX(int analog) -{ - char lock_status; - - /* Switch into TX, switch to freq. reg B */ - cc1020_write_reg(CC1020_MAIN, 0xC1); - lock_status = cc1020_lock(); - - /* Restore PA_POWER */ - cc1020_write_reg(CC1020_PA_POWER, cc1020_pa_power); - - /* Turn OFF DCLK squelch in TX */ - cc1020_write_reg(CC1020_INTERFACE, 0x01); - - /* Return LOCK status to application */ - return lock_status; -} - -static void -cc1020_setupPD(void) -{ - /* - * Power down components and reset all registers except MAIN - * to their default values. - */ - cc1020_write_reg(CC1020_MAIN, - RESET_N | BIAS_PD | FS_PD | XOSC_PD | PD_MODE_1); - - /* Turn off the power amplifier. */ - cc1020_write_reg(CC1020_PA_POWER, 0x00); - - cc1020_write_reg(CC1020_POWERDOWN, 0x1F); -} - -static void -cc1020_wakeupRX(int analog) -{ - /* Turn on crystal oscillator core. */ - cc1020_write_reg(CC1020_MAIN, 0x1B); - - /* Setup bias current adjustment. */ - cc1020_write_reg(CC1020_ANALOG, analog); - - /* - * Wait for the crystal oscillator to stabilize. - * This typically takes 2-5 ms. - */ - MS_DELAY(5); - - /* Turn on bias generator. */ - cc1020_write_reg(CC1020_MAIN, 0x19); - - /* Turn on frequency synthesizer. */ - cc1020_write_reg(CC1020_MAIN, 0x11); -} - -static void -cc1020_wakeupTX(int analog) -{ - /* Turn on crystal oscillator core. */ - cc1020_write_reg(CC1020_MAIN, 0xDB); - - /* Setup bias current adjustment. */ - cc1020_write_reg(CC1020_ANALOG, analog); - - /* - * Wait for the crystal oscillator to stabilize. - * This typically takes 2-5 ms. - */ - MS_DELAY(5); - - /* Turn on bias generator. */ - cc1020_write_reg(CC1020_MAIN, 0xD9); - - /* Turn on frequency synthesizer. */ - MS_DELAY(1); - cc1020_write_reg(CC1020_MAIN, 0xD1); -} - diff --git a/platform/msb430/dev/cc1020.h b/platform/msb430/dev/cc1020.h deleted file mode 100644 index 364b71650..000000000 --- a/platform/msb430/dev/cc1020.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -Copyright 2006, Freie Universitaet Berlin. All rights reserved. - -These sources were developed at the Freie Universitaet Berlin, Computer -Systems and Telematics group. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - -- Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -- Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -- Neither the name of Freie Universitaet Berlin (FUB) nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -This software is provided by FUB and the contributors on an "as is" -basis, without any representations or warranties of any kind, express -or implied including, but not limited to, representations or -warranties of non-infringement, merchantability or fitness for a -particular purpose. In no event shall FUB or contributors be liable -for any direct, indirect, incidental, special, exemplary, or -consequential damages (including, but not limited to, procurement of -substitute goods or services; loss of use, data, or profits; or -business interruption) however caused and on any theory of liability, -whether in contract, strict liability, or tort (including negligence -or otherwise) arising in any way out of the use of this software, even -if advised of the possibility of such damage. - -This implementation was developed by the CST group at the FUB. - -For documentation and questions please use the web site -http://scatterweb.mi.fu-berlin.de and the mailinglist -scatterweb@lists.spline.inf.fu-berlin.de (subscription via the Website). -Berlin, 2006 -*/ - -/** - * \file cc1020.h - * \author FUB ScatterWeb Developers, Michael Baar, Nicolas Tsiftes - **/ - -#ifndef CC1020_H -#define CC1020_H - -#include "dev/radio.h" - -extern const uint8_t cc1020_config_19200[]; -extern const uint8_t cc1020_config_115200[]; - -#if 0 -void cc1020_init(const uint8_t* config); -#endif -void cc1020_set_rx(void); -void cc1020_set_tx(void); -void cc1020_set_power(uint8_t pa_power); -int cc1020_carrier_sense(void); -uint8_t cc1020_get_rssi(void); -uint8_t cc1020_get_packet_rssi(void); -int cc1020_sending(void); -#if 0 -int cc1020_send(const void *buf, unsigned short size); -int cc1020_read(void *buf, unsigned short size); -void cc1020_set_receiver(void (*recv)(const struct radio_driver *)); -int cc1020_on(void); -int cc1020_off(void); -#endif -extern const struct radio_driver cc1020_driver; - -PROCESS_NAME(cc1020_sender_process); - -#endif diff --git a/platform/msb430/dev/dma.c b/platform/msb430/dev/dma.c deleted file mode 100644 index ce175ee12..000000000 --- a/platform/msb430/dev/dma.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2007, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * \file - * DMA interrupt handling. - * \author - * Nicolas Tsiftes - */ -#include "contiki.h" - -#include "contiki-msb430.h" -#include "dev/cc1020.h" -#include "dev/dma.h" -#include "isr_compat.h" - -static void (*callbacks[DMA_LINES])(void); - -ISR(DACDMA, irq_dacdma) -{ - if(DMA0CTL & DMAIFG) { - DMA0CTL &= ~(DMAIFG | DMAIE); - if(callbacks[0] != NULL) { - callbacks[0](); - } - _BIC_SR_IRQ(LPM3_bits); - } - - if(DMA1CTL & DMAIFG) { - DMA1CTL &= ~(DMAIFG | DMAIE); - if(callbacks[1] != NULL) { - callbacks[1](); - } - _BIC_SR_IRQ(LPM3_bits); - } - - if(DMA2CTL & DMAIFG) { - DMA2CTL &= ~(DMAIFG | DMAIE); - if(callbacks[2] != NULL) { - callbacks[2](); - } - _BIC_SR_IRQ(LPM3_bits); - } - - if(DAC12_0CTL & DAC12IFG) { - DAC12_0CTL &= ~(DAC12IFG | DAC12IE); - } - - if(DAC12_1CTL & DAC12IFG) { - DAC12_1CTL &= ~(DAC12IFG | DAC12IE); - } -} - -int -dma_subscribe(int line, void (*callback)(void)) -{ - if(line >= DMA_LINES) { - return -1; - } - - callbacks[line] = callback; - return 0; -} - -void -dma_transfer(unsigned char *dst, unsigned char *src, unsigned len) -{ - /* Configure DMA Channel 0 for UART0 TXIFG. */ - DMACTL0 = DMA0TSEL_4; - - /* No DMAONFETCH, ROUNDROBIN, ENNMI. */ - DMACTL1 = 0x0000; - - /* - * Set single transfer mode with byte-per-byte transfers. - * - * The source address is incremented for each byte, while the - * destination address remains constant. - * - * In order to avoid missing the first rising edge of the trigger - * signal, it is important to use the level-sensitive trigger when - * using USART transfer interrupts. - */ - DMA0CTL = DMADT_0 | DMADSTINCR_0 | DMASRCINCR_3 | DMASBDB | DMALEVEL; - - DMA0SA = (unsigned) src; - DMA0DA = (unsigned) dst; - DMA0SZ = len; - - DMA0CTL |= DMAEN | DMAIE; /* enable DMA and interrupts */ - U0CTL &= ~SWRST; /* enable the UART state machine */ -} diff --git a/platform/msb430/dev/dma.h b/platform/msb430/dev/dma.h deleted file mode 100644 index cabcad4d7..000000000 --- a/platform/msb430/dev/dma.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2007, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -#ifndef DMA_H -#define DMA_H - -#define DMA_LINES 2 - -void dma_init(void); -int dma_subscribe(int, void (*)(void)); -void dma_transfer(unsigned char *, unsigned char *, unsigned); - -extern process_event_t dma_event; - -#endif diff --git a/platform/msb430/dev/infomem.c b/platform/msb430/dev/infomem.c deleted file mode 100644 index 53cd27448..000000000 --- a/platform/msb430/dev/infomem.c +++ /dev/null @@ -1,122 +0,0 @@ -/* -Copyright 2007, Freie Universitaet Berlin. All rights reserved. - -These sources were developed at the Freie Universität Berlin, Computer -Systems and Telematics group. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - -- Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -- Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -- Neither the name of Freie Universitaet Berlin (FUB) nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -This software is provided by FUB and the contributors on an "as is" -basis, without any representations or warranties of any kind, express -or implied including, but not limited to, representations or -warranties of non-infringement, merchantability or fitness for a -particular purpose. In no event shall FUB or contributors be liable -for any direct, indirect, incidental, special, exemplary, or -consequential damages (including, but not limited to, procurement of -substitute goods or services; loss of use, data, or profits; or -business interruption) however caused and on any theory of liability, -whether in contract, strict liability, or tort (including negligence -or otherwise) arising in any way out of the use of this software, even -if advised of the possibility of such damage. - -This implementation was developed by the CST group at the FUB. - -For documentation and questions please use the web site -http://scatterweb.mi.fu-berlin.de and the mailinglist -scatterweb@lists.spline.inf.fu-berlin.de (subscription via the Website). -Berlin, 2007 -*/ - -/** - * @file infomem.c - * @addtogroup storage - * @brief MSP430 Infomemory Storage - * @author Michael Baar - * - * Functions to store and read data from the two infomemories (2 x 128 Bytes). - * Offset addresses start at zero, size has a maximum of 128, write operations - * across both blocks are not allowed. - */ -#include -#include -#include "contiki-conf.h" -#include "infomem.h" - -void -infomem_read(void *buffer, unsigned int offset, unsigned char size) -{ - uint8_t *address = (uint8_t *)INFOMEM_START + offset; - memcpy(buffer, address, size); -} - -bool -infomem_write(unsigned int offset, unsigned char count, ...) -{ - char backup[INFOMEM_BLOCK_SIZE]; - uint8_t *buffer; - uint16_t i; - uint8_t *flash; - va_list argp; - uint16_t size; - uint8_t *data; - int s; - - if(offset > (2 * INFOMEM_BLOCK_SIZE)) { - return FALSE; - } - - flash = (uint8_t *)INFOMEM_START; - - s = splhigh(); - - /* backup into RAM */ - memcpy(backup, flash, INFOMEM_BLOCK_SIZE); - - /* merge backup with new data */ - va_start(argp, count); - - buffer = (uint8_t *)backup + offset; - for(i = 0; i < count; i++) { - data = va_arg(argp, uint8_t *); - size = va_arg(argp, uint16_t); - memcpy(buffer, data, size); - buffer += size; - } - - va_end(argp); - - /* init flash access */ - FCTL2 = FWKEY + FSSEL1 + FN2; - FCTL3 = FWKEY; - - /* erase flash */ - FCTL1 = FWKEY + ERASE; - *flash = 0; - - /* write flash */ - FCTL1 = FWKEY + WRT; - buffer = (uint8_t *)backup; - for(i = 0; i < INFOMEM_BLOCK_SIZE; i++) { - *flash++ = *buffer++; - } - - FCTL1 = FWKEY; - FCTL3 = FWKEY + LOCK; - - splx(s); - - return TRUE; -} diff --git a/platform/msb430/dev/infomem.h b/platform/msb430/dev/infomem.h deleted file mode 100644 index 6885551be..000000000 --- a/platform/msb430/dev/infomem.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -Copyright 2006, Freie Universitaet Berlin. All rights reserved. - -These sources were developed at the Freie Universität Berlin, Computer -Systems and Telematics group. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - -- Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -- Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -- Neither the name of Freie Universitaet Berlin (FUB) nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -This software is provided by FUB and the contributors on an "as is" -basis, without any representations or warranties of any kind, express -or implied including, but not limited to, representations or -warranties of non-infringement, merchantability or fitness for a -particular purpose. In no event shall FUB or contributors be liable -for any direct, indirect, incidental, special, exemplary, or -consequential damages (including, but not limited to, procurement of -substitute goods or services; loss of use, data, or profits; or -business interruption) however caused and on any theory of liability, -whether in contract, strict liability, or tort (including negligence -or otherwise) arising in any way out of the use of this software, even -if advised of the possibility of such damage. - -This implementation was developed by the CST group at the FUB. - -For documentation and questions please use the web site -http://scatterweb.mi.fu-berlin.de and the mailinglist -scatterweb@lists.spline.inf.fu-berlin.de (subscription via the Website). -Berlin, 2006 -*/ - -/** - * @file infomem.h - * @addtogroup storage - * @brief MSP430 Infomemory Storage - * - * @author Michael Baar - */ - -#ifndef INFOMEM_H -#define INFOMEM_H - -#if !defined(INFOMEM_START) || !defined(INFOMEM_BLOCK_SIZE) - #error "infomem position (INFOMEM_START) and block size (INFOMEM_BLOCK_SIZE) need to be defined for the platform" -#endif - -/** - * @brief Read bytes from infomemory - * @param[out] buffer Pointer to buffer for read data - * @param[in] offset Offset in infomemory (0-254) - * @param[in] size Number of bytes to read - */ -void infomem_read(void *buffer, unsigned int offset, unsigned char size); - -/** - * @brief Write bytes to infomemory - * @param[in] offset Offset in infomemory (0-254) - * @param[in] count Number of items following - * each item is a pair pointer, length - * - * Example: Infomem_write( 0, 2, &a,3, &b,1 ); - * - * \note: The MSP430 has two consecutive blocks of infomemory. - * Each is 128 bytes large. The offset is the relative address - * starting at the beginning of the first block. You can write an - * arbitrary number of bytes at any offset, but this function - * cannot write across the two blocks of infomemory. - */ -bool infomem_write(unsigned int offset, unsigned char count, ...); - -#endif // !INFOMEM_H diff --git a/platform/msb430/dev/msb430-uart1.c b/platform/msb430/dev/msb430-uart1.c deleted file mode 100644 index d8ce6a44c..000000000 --- a/platform/msb430/dev/msb430-uart1.c +++ /dev/null @@ -1,231 +0,0 @@ -/* -Copyright 2007, Freie Universitaet Berlin. All rights reserved. - -These sources were developed at the Freie Universität Berlin, Computer -Systems and Telematics group. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - -- Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -- Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -- Neither the name of Freie Universitaet Berlin (FUB) nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -This software is provided by FUB and the contributors on an "as is" -basis, without any representations or warranties of any kind, express -or implied including, but not limited to, representations or -warranties of non-infringement, merchantability or fitness for a -particular purpose. In no event shall FUB or contributors be liable -for any direct, indirect, incidental, special, exemplary, or -consequential damages (including, but not limited to, procurement of -substitute goods or services; loss of use, data, or profits; or -business interruption) however caused and on any theory of liability, -whether in contract, strict liability, or tort (including negligence -or otherwise) arising in any way out of the use of this software, even -if advised of the possibility of such damage. - -This implementation was developed by the CST group at the FUB. - -For documentation and questions please use the web site -http://scatterweb.mi.fu-berlin.de and the mailinglist -scatterweb@lists.spline.inf.fu-berlin.de (subscription via the Website). -Berlin, 2007 -*/ - -/** - * @file ScatterWeb.Uart.c - * @addtogroup interfaces - * @brief UART interface - * @author Michael Baar - * - * UART switch for RS232 and SPI protocols on UART1 written for - * ScatterWeb MSB boards. Compatible to ScatterWeb EOS, - * ScatterWeb Bootload and Contiki. - */ - -#include "contiki.h" -#include -#include "dev/msb430-uart1.h" -#include "dev/lpm.h" -#include "isr_compat.h" - -#ifndef U1ME -#define U1ME ME2 -#endif - -volatile unsigned char uart_mode = UART_MODE_RESET; -volatile unsigned char uart_lockcnt = 0; -volatile uint8_t uart_edge = 0; - -static unsigned char uart_speed_br0[UART_NUM_MODES]; -static unsigned char uart_speed_br1[UART_NUM_MODES]; -static unsigned char uart_speed_bmn[UART_NUM_MODES]; -static uart_handler_t uart_handler[UART_NUM_MODES] = {NULL, NULL}; - -/*---------------------------------------------------------------------------*/ -static void -uart_configure(unsigned mode) -{ - _DINT(); /* disable interrupts */ - - UART_WAIT_TXDONE(); /* wait till all buffered data has been transmitted */ - - if(mode == UART_MODE_RS232) { - P5OUT |= 0x01; - /* unselect SPI */ - P3SEL |= 0xC0; - /* select rs232 */ - UCTL1 = SWRST | CHAR; /* 8-bit character */ - UTCTL1 |= SSEL1; /* UCLK = MCLK */ - /* activate */ - U1ME |= UTXE1 | URXE1; /* Enable USART1 TXD/RXD */ - } else if(mode == UART_MODE_SPI) { - P3SEL &= ~0xC0; /* unselect RS232 */ - // to SPI mode - UCTL1 = SWRST | CHAR | SYNC | MM; /* 8-bit SPI Master */ - /* - * SMCLK, 3-pin mode, clock idle low, data valid on - * rising edge, UCLK delayed - */ - UTCTL1 |= CKPH | SSEL1 | SSEL0 | STC; /* activate */ - U1ME |= USPIE1; /* Enable USART1 SPI */ - } - - /* restore speed settings */ - UBR01 = uart_speed_br0[mode]; /* set baudrate */ - UBR11 = uart_speed_br1[mode]; - UMCTL1 = uart_speed_bmn[mode]; /* set modulation */ - - UCTL1 &= ~SWRST; /* clear reset flag */ - _EINT(); /* enable interrupts */ -} -/*---------------------------------------------------------------------------*/ -void -uart_set_speed(unsigned mode, unsigned ubr0, - unsigned ubr1, unsigned umctl) -{ - /* store the setting */ - uart_speed_br0[mode] = ubr0; /* baudrate */ - uart_speed_br1[mode] = ubr1; /* baudrate */ - uart_speed_bmn[mode] = umctl; /* modulation */ - - /* reconfigure, if mode active */ - if(uart_mode == mode) { - uart_configure(mode); - } -} -/*---------------------------------------------------------------------------*/ -void -uart_set_handler(unsigned mode, uart_handler_t handler) -{ - /* store the setting */ - uart_handler[mode] = handler; - if(mode == uart_mode) { - if(handler == NULL) { - IE2 &= ~URXIE1; /* Disable USART1 RX interrupt */ - } else { - IE2 |= URXIE1; /* Enable USART1 RX interrupt */ - } - } -} -/*---------------------------------------------------------------------------*/ -int -uart_lock(unsigned mode) -{ - /* already locked? */ - if(uart_mode != mode && uart_lockcnt > 0) { - return 0; - } - - /* increase lock count */ - uart_lockcnt++; - /* switch mode (if neccessary) */ - uart_set_mode(mode); - return 1; -} -/*---------------------------------------------------------------------------*/ -int -uart_lock_wait(unsigned mode) -{ - while(UART_WAIT_LOCK(mode)) { - _NOP(); - } - return uart_lock(mode); -} -/*---------------------------------------------------------------------------*/ -int -uart_unlock(unsigned mode) -{ - if((uart_lockcnt == 0) || (mode != uart_mode)) { - uart_lockcnt = 0; - uart_set_mode(UART_MODE_DEFAULT); - return 0; - } - - /* decrement lock */ - if(uart_lockcnt > 0) { - uart_lockcnt--; - /* if no more locks, switch back to default mode */ - if(uart_lockcnt == 0) { - uart_set_mode(UART_MODE_DEFAULT); - } - return 1; - } - return 0; -} -/*---------------------------------------------------------------------------*/ -void -uart_set_mode(unsigned mode) -{ - /* do nothing if the mode is already set */ - if(mode == uart_mode) { - return; - } - - IE2 &= ~(URXIE1 | UTXIE1); /* disable irq */ - uart_configure(mode); /* configure uart parameters */ - uart_mode = mode; - - if(uart_handler[mode] != NULL) { - IE2 |= URXIE1; /* Enable USART1 RX interrupt */ - } -} -/*---------------------------------------------------------------------------*/ -int -uart_get_mode(void) -{ - return uart_mode; -} -/*---------------------------------------------------------------------------*/ -ISR(UART1RX, uart_rx) -{ - uart_handler_t handler = uart_handler[uart_mode]; - int c; - - if(!(IFG2 & URXIFG1)) { - /* If rising edge is detected, toggle & return */ - uart_edge = 1; - U1TCTL &= ~URXSE; - U1TCTL |= URXSE; - _BIC_SR_IRQ(LPM3_bits); - return; - } - uart_edge = 0; - if(!(URCTL1 & RXERR)) { - c = UART_RX; - if(handler(c)) { - _BIC_SR_IRQ(LPM3_bits); - } - } else { - /* read out the char to clear the interrupt flags. */ - c = UART_RX; - } -} diff --git a/platform/msb430/dev/msb430-uart1.h b/platform/msb430/dev/msb430-uart1.h deleted file mode 100644 index 470eb852d..000000000 --- a/platform/msb430/dev/msb430-uart1.h +++ /dev/null @@ -1,111 +0,0 @@ -/* -Copyright 2007, Freie Universitaet Berlin. All rights reserved. - -These sources were developed at the Freie Universität Berlin, Computer -Systems and Telematics group. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - -- Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -- Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -- Neither the name of Freie Universitaet Berlin (FUB) nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -This software is provided by FUB and the contributors on an "as is" -basis, without any representations or warranties of any kind, express -or implied including, but not limited to, representations or -warranties of non-infringement, merchantability or fitness for a -particular purpose. In no event shall FUB or contributors be liable -for any direct, indirect, incidental, special, exemplary, or -consequential damages (including, but not limited to, procurement of -substitute goods or services; loss of use, data, or profits; or -business interruption) however caused and on any theory of liability, -whether in contract, strict liability, or tort (including negligence -or otherwise) arising in any way out of the use of this software, even -if advised of the possibility of such damage. - -This implementation was developed by the CST group at the FUB. - -For documentation and questions please use the web site -http://scatterweb.mi.fu-berlin.de and the mailinglist -scatterweb@lists.spline.inf.fu-berlin.de (subscription via the Website). -Berlin, 2007 -*/ - -/** - * @addtogroup interfaces - * @{ */ - -/** - * @defgroup uart1 UART1 - * The UART module multiplexes differenct protocol on the MSB's UART1 - * interface. Currently RS232 and SPI are supported. - * @{ - */ - -/** - * \file Header file for for the MSB430 UART driver. - * \author Michael Baar - */ - -#ifndef MSB430_UART1_H -#define MSB430_UART1_H - -#define UART_RX RXBUF1 -#define UART_TX TXBUF1 -#define UART_RESET_RX() do { U1IFG &= ~URXIFG1; } while(0) -#define UART_RESET_RXTX() do { U1IFG &= ~(URXIFG1 | UTXIFG1); } while(0) -#define UART_WAIT_RX() while((U1IFG & URXIFG1) == 0) { _NOP(); } -#define UART_WAIT_TX() while((U1IFG & UTXIFG1) == 0) { _NOP(); } -#define UART_WAIT_TXDONE() while((UTCTL1 & TXEPT) == 0) { _NOP(); } - -/** - * @brief Operating state - */ -extern volatile unsigned char uart_mode; -extern volatile unsigned char uart_lockcnt; - -/** - * @name UART mode flags - * @{ - */ -#define UART_MODE_RS232 (0x00u) ///< RS232 mode -#define UART_MODE_SPI (0x01u) ///< SPI mode -#define UART_MODE_DEFAULT UART_MODE_RS232 -#define UART_NUM_MODES (UART_MODE_SPI + 1) ///< Highest mode number -#define UART_MODE_RESET (0xFFu) ///< reset with current settings -/** @} */ - -#define UART_WAIT_LOCK(x) ((uart_mode != x) && (uart_lockcnt)) -#define UART_MODE_IS(x) (uart_mode == x) - -typedef int(*uart_handler_t)(unsigned char); - -/** - * \brief Initialize the UART module - * - * This function is called from the boot up code to - * initalize the UART module. - */ -void uart_init(void); - -void uart_set_speed(unsigned, unsigned, unsigned, unsigned); -void uart_set_handler(unsigned, uart_handler_t); -int uart_lock(unsigned); -int uart_lock_wait(unsigned); -int uart_unlock(unsigned); -void uart_set_mode(unsigned); -int uart_get_mode(void); - -#endif /* !MSB430_UART1_H */ - -/** @} */ -/** @} */ diff --git a/platform/msb430/dev/rs232.c b/platform/msb430/dev/rs232.c deleted file mode 100644 index 44a299813..000000000 --- a/platform/msb430/dev/rs232.c +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** \addtogroup esbrs232 - * @{ */ - -/** - * \file - * RS232 communication device driver for the MSP430. - * \author Adam Dunkels - * - * This file contains an RS232 device driver for the MSP430 microcontroller. - * - */ -#include "contiki.h" -#include -#include "dev/msb430-uart1.h" -#include "rs232.h" - -#ifndef U1IFG -#define U1IFG IFG2 -#endif - -/*---------------------------------------------------------------------------*/ -/** - * Initalize the RS232 port. - * - */ -void -rs232_init(void) -{ - rs232_set_speed(RS232_115200); -} -/*---------------------------------------------------------------------------*/ -int -putchar(int c) -{ - if(uart_get_mode() == UART_MODE_RS232) { - /* Loop until the transmission buffer is available. */ - UART_WAIT_TX(); - /* Transmit the data. */ - UART_TX = c; - return c; - } else { - return -1; - } -} -/*---------------------------------------------------------------------------*/ -void -rs232_send(char c) -{ - /* Check if the UART is in RS232 mode before sending. - This check can be ommitted if every access to rs232 locks the uart - before using it. - */ - - putchar(c); -} -/*---------------------------------------------------------------------------*/ -void -rs232_set_speed(enum rs232_speed speed) -{ - // baud - const unsigned char br_table[5][3] = { - {0x00, 0x01, 0x00}, // 9600 - {0x80, 0x00, 0x00}, // 19200 - {0x40, 0x00, 0x00}, // 38400 - {0x2a, 0x00, 0x5b}, // 57600 - {0x15, 0x00, 0x4a} // 115200 - }; - - uart_set_speed(UART_MODE_RS232, br_table[speed][0], - br_table[speed][1], br_table[speed][2]); -} -/*---------------------------------------------------------------------------*/ -void -rs232_print(char *cptr) -{ - /* lock UART for the print operation */ - if(uart_lock(UART_MODE_RS232)) { - while(*cptr != 0) { - rs232_send(*cptr); - ++cptr; - } - uart_unlock(UART_MODE_RS232); - } -} -/*---------------------------------------------------------------------------*/ -void -rs232_set_input(uart_handler_t f) -{ - uart_set_handler(UART_MODE_RS232, f); -} -/** @} */ diff --git a/platform/msb430/dev/rs232.h b/platform/msb430/dev/rs232.h deleted file mode 100644 index 59f1ffe33..000000000 --- a/platform/msb430/dev/rs232.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** \addtogroup esb - * @{ */ - -/** - * \defgroup esbrs232 ESB RS232 - * - * @{ - */ - -/** - * \file - * Header file for MSP430 RS232 driver. - * \author Adam Dunkels - * - */ -#ifndef __RS232_H__ -#define __RS232_H__ - -#include "dev/msb430-uart1.h" - -enum rs232_speed { - RS232_9600 = 0, - RS232_19200 = 1, - RS232_38400 = 2, - RS232_57600 = 3, - RS232_115200 = 4 -}; - -/** - * \brief Initialize the RS232 module - * - * This function is called from the boot up code to - * initalize the RS232 module. - */ -void rs232_init(void); - -/** - * \brief Set an input handler for incoming RS232 data - * \param f A pointer to a byte input handler - * - * This function sets the input handler for incoming RS232 - * data. The input handler function is called for every - * incoming data byte. The function is called from the - * RS232 interrupt handler, so care must be taken when - * implementing the input handler to avoid race - * conditions. - * - * The return value of the input handler affects the sleep - * mode of the CPU: if the input handler returns non-zero - * (true), the CPU is awakened to let other processing - * take place. If the input handler returns zero, the CPU - * is kept sleeping. - */ -void rs232_set_input(uart_handler_t f); - -/** - * \brief Configure the speed of the RS232 hardware - * \param speed The speed - * - * This function configures the speed of the RS232 - * hardware. The allowed parameters are RS232_9600, - * RS232_19200, RS232_38400, RS232_57600, and RS232_115200. - */ -void rs232_set_speed(enum rs232_speed speed); - -/** - * \brief Print a text string on RS232 - * \param str A pointer to the string that is to be printed - * - * This function prints a string to RS232. The string must - * be terminated by a null byte. The RS232 module must be - * correctly initalized and configured for this function - * to work. - */ -void rs232_print(char *text); - -/** - * \brief Print a character on RS232 - * \param c The character to be printed - * - * This function prints a character to RS232. The RS232 - * module must be correctly initalized and configured for - * this function to work. - */ -void rs232_send(char c); - -#endif /* __RS232_H__ */ - -/** @} */ -/** @} */ diff --git a/platform/msb430/dev/sd-arch.c b/platform/msb430/dev/sd-arch.c deleted file mode 100644 index 02f5666f0..000000000 --- a/platform/msb430/dev/sd-arch.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2009, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * \file - * Architecture-dependent functions for SD over SPI. - * \author - * Nicolas Tsiftes - */ - -#include "contiki.h" -#include "msb430-uart1.h" -#include "sd-arch.h" - -#define SPI_IDLE 0xff - -int -sd_arch_init(void) -{ - P2SEL &= ~64; - P2DIR &= ~64; - - P5SEL |= 14; - P5SEL &= ~1; - P5OUT |= 1; - P5DIR |= 13; - P5DIR &= ~2; - - uart_set_speed(UART_MODE_SPI, 2, 0, 0); - - return 0; -} - - -void -sd_arch_spi_write(int c) -{ - UART_TX = c; - UART_WAIT_TXDONE(); -} - -void -sd_arch_spi_write_block(uint8_t *bytes, int amount) -{ - int i; - volatile char dummy; - - for(i = 0; i < amount; i++) { - UART_TX = bytes[i]; - UART_WAIT_TXDONE(); - UART_WAIT_RX(); - dummy = UART_RX; - } -} - - -unsigned -sd_arch_spi_read(void) -{ - if((U1IFG & URXIFG1) == 0) { - UART_TX = SPI_IDLE; - UART_WAIT_RX(); - } - return UART_RX; -} diff --git a/platform/msb430/dev/sd-arch.h b/platform/msb430/dev/sd-arch.h deleted file mode 100644 index f540505f6..000000000 --- a/platform/msb430/dev/sd-arch.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2009, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * \file - * SD driver implementation using SPI. - * \author - * Nicolas Tsiftes - */ - -#ifndef SD_ARCH_H -#define SD_ARCH_H - -#include "msb430-uart1.h" - -#ifndef U1IFG -#define U1IFG IFG2 -#endif /* U1IFG */ - -#define MS_DELAY(x) clock_delay(354 * (x)) - -/* Machine-dependent macros. */ -#define LOCK_SPI() do { \ - if(!uart_lock(UART_MODE_SPI)) {\ - return 0; \ - } \ - } while(0) -#define UNLOCK_SPI() do { \ - uart_unlock(UART_MODE_SPI); \ - } while(0) - -#define SD_CONNECTED() !(P2IN & 0x40) -#define LOWER_CS() (P5OUT &= ~0x01) -#define RAISE_CS() do { \ - UART_WAIT_TXDONE(); \ - P5OUT |= 0x01; \ - UART_TX = SPI_IDLE; \ - UART_WAIT_TXDONE(); \ - } while(0) - -/* Configuration parameters. */ -#define SD_TRANSACTION_ATTEMPTS 512 -#define SD_READ_RESPONSE_ATTEMPTS 8 -#define SD_READ_BLOCK_ATTEMPTS 2 - -int sd_arch_init(void); -void sd_arch_spi_write(int c); -void sd_arch_spi_write_block(uint8_t *bytes, int amount); -unsigned sd_arch_spi_read(void); - -#endif /* !SD_ARCH_H */ diff --git a/platform/msb430/dev/sd.c b/platform/msb430/dev/sd.c deleted file mode 100644 index b1ef4c21b..000000000 --- a/platform/msb430/dev/sd.c +++ /dev/null @@ -1,513 +0,0 @@ -/* - * Copyright (c) 2009, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * \file - * SD driver implementation using SPI. - * \author - * Nicolas Tsiftes - */ - -#include "contiki.h" -#include "sd.h" -#include "sd-arch.h" - -#include - -#define DEBUG 0 -#if DEBUG -#include -#define PRINTF(...) printf(__VA_ARGS__) -#else -#define PRINTF(...) -#endif - -#ifndef MIN -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#endif /* MIN */ - -#define SPI_IDLE 0xff - -/* SD commands */ -#define GO_IDLE_STATE 0 -#define SEND_OP_COND 1 -#define SWITCH_FUNC 6 -#define SEND_IF_COND 8 -#define SEND_CSD 9 -#define SEND_CID 10 -#define STOP_TRANSMISSION 12 -#define SEND_STATUS 13 -#define READ_SINGLE_BLOCK 17 -#define WRITE_BLOCK 24 -#define READ_OCR 58 - -/* SD response lengths. */ -#define R1 1 -#define R2 2 -#define R3 5 -#define R7 5 - -#define START_BLOCK_TOKEN 0xfe - -/* Status codes returned after writing a block. */ -#define DATA_ACCEPTED 2 -#define DATA_CRC_ERROR 5 -#define DATA_WRITE_ERROR 6 - -static uint16_t rw_block_size; -static uint16_t block_size; - -static int read_register(int register_cmd, char *buf, int register_size); -/*---------------------------------------------------------------------------*/ -static int -send_command(uint8_t cmd, uint32_t argument) -{ - uint8_t req[6]; - - req[0] = 0x40 | cmd; - req[1] = argument >> 24; - req[2] = argument >> 16; - req[3] = argument >> 8; - req[4] = argument; - /* The CRC hard-wired to 0x95 is only needed for the initial - GO_IDLE_STATE command. */ - req[5] = 0x95; - - sd_arch_spi_write(SPI_IDLE); - sd_arch_spi_write_block(req, sizeof(req)); - sd_arch_spi_write(SPI_IDLE); - - return 0; -} -/*---------------------------------------------------------------------------*/ -static uint8_t * -get_response(int length) -{ - int i; - int x; - static uint8_t r[R7]; - - for(i = 0; i < SD_READ_RESPONSE_ATTEMPTS; i++) { - x = sd_arch_spi_read(); - if((x & 0x80) == 0) { - /* A get_response byte is indicated by the MSB being 0. */ - r[0] = x; - break; - } - } - - if(i == SD_READ_RESPONSE_ATTEMPTS) { - return NULL; - } - - for(i = 1; i < length; i++) { - r[i] = sd_arch_spi_read(); - } - - return r; -} -/*---------------------------------------------------------------------------*/ -static unsigned char * -transaction(int command, unsigned long argument, - int response_type, unsigned attempts) -{ - unsigned i; - unsigned char *r; - - LOCK_SPI(); - r = NULL; - for(i = 0; i < attempts; i++) { - LOWER_CS(); - send_command(command, argument); - r = get_response(response_type); - RAISE_CS(); - if(r != NULL) { - break; - } - } - UNLOCK_SPI(); - - return r; -} -/*---------------------------------------------------------------------------*/ -int -sd_initialize(void) -{ - unsigned char reg[16]; - int i; - uint8_t *r, read_bl_len; - - if(sd_arch_init() < 0) { - return SD_INIT_ERROR_ARCH; - } - - if(SD_CONNECTED() < 0) { - return SD_INIT_ERROR_NO_CARD; - } - - r = transaction(GO_IDLE_STATE, 0, R1, SD_TRANSACTION_ATTEMPTS); - if(r != NULL) { - PRINTF("Go-idle result: %d\n", r[0]); - } else { - PRINTF("Failed to get go-idle response\n"); - } - - r = transaction(SEND_IF_COND, 0, R7, SD_TRANSACTION_ATTEMPTS); - if(r != NULL) { - PRINTF("IF cond: %d %d %d %d %d\n", r[0], r[1], r[2], r[3], r[4]); - } else { - PRINTF("failed to get IF cond\n"); - return SD_INIT_ERROR_NO_IF_COND; - } - - LOCK_SPI(); - - for(i = 0; i < SD_TRANSACTION_ATTEMPTS; i++) { - LOWER_CS(); - send_command(SEND_OP_COND, 0); - r = get_response(R1); - RAISE_CS(); - if(r != NULL && !(r[0] & 1)) { - break; - } - } - - UNLOCK_SPI(); - - if(r != NULL) { - PRINTF("OP cond: %d (%d iterations)\n", r[0], i); - } else { - PRINTF("Failed to get OP cond get_response\n"); - } - - LOCK_SPI(); - - for(i = 0; i < SD_TRANSACTION_ATTEMPTS; i++) { - LOWER_CS(); - send_command(READ_OCR, 0); - r = get_response(R3); - RAISE_CS(); - if(r != NULL) { - break; - } - } - - UNLOCK_SPI(); - - if(r != NULL) { - PRINTF("OCR: %d %d %d %d %d\n", r[0], r[1], r[2], r[3], r[4]); - } - - - if(read_register(SEND_CSD, reg, sizeof(reg)) < 0) { - PRINTF("Failed to get block size of SD card\n"); - return SD_INIT_ERROR_NO_BLOCK_SIZE; - } - - read_bl_len = reg[5] & 0x0f; - block_size = 1 << read_bl_len; - rw_block_size = (block_size > SD_DEFAULT_BLOCK_SIZE) ? - SD_DEFAULT_BLOCK_SIZE : block_size; - PRINTF("Found block size %d\n", block_size); - - /* XXX Arbitrary wait time here. Need to investigate why this is needed. */ - MS_DELAY(5); - - return SD_OK; -} -/*---------------------------------------------------------------------------*/ -int -sd_write_block(sd_offset_t offset, char *buf) -{ - unsigned char *r; - int retval; - int i; - unsigned char data_response; - unsigned char status_code; - - LOCK_SPI(); - r = NULL; - retval = SD_WRITE_ERROR_NO_CMD_RESPONSE; - for(i = 0; i < SD_TRANSACTION_ATTEMPTS; i++) { - LOWER_CS(); - send_command(WRITE_BLOCK, offset); - r = get_response(R1); - if(r != NULL) { - break; - } - RAISE_CS(); - } - - if(r != NULL && r[0] == 0) { - /* We received an R1 response with no errors. - Send a start block token to the card now. */ - sd_arch_spi_write(START_BLOCK_TOKEN); - - /* Write the data block. */ - sd_arch_spi_write_block(buf, rw_block_size); - - /* Get a response from the card. */ - retval = SD_WRITE_ERROR_NO_BLOCK_RESPONSE; - for(i = 0; i < SD_TRANSACTION_ATTEMPTS; i++) { - data_response = sd_arch_spi_read(); - if((data_response & 0x11) == 1) { - /* Data response token received. */ - status_code = (data_response >> 1) & 0x7; - if(status_code == DATA_ACCEPTED) { - retval = rw_block_size; - } else { - retval = SD_WRITE_ERROR_PROGRAMMING; - } - break; - } - } - } - - RAISE_CS(); - UNLOCK_SPI(); - - return retval; -} -/*---------------------------------------------------------------------------*/ -static int -read_block(unsigned read_cmd, sd_offset_t offset, char *buf, int len) -{ - unsigned char *r; - int i; - int token; - int retval; - - LOCK_SPI(); - - r = NULL; - for(i = 0; i < SD_TRANSACTION_ATTEMPTS; i++) { - LOWER_CS(); - send_command(read_cmd, offset); - r = get_response(R1); - if(r != NULL) { - break; - } - RAISE_CS(); - } - - if(r != NULL && r[0] == 0) { - /* We received an R1 response with no errors. - Get a token from the card now. */ - for(i = 0; i < SD_TRANSACTION_ATTEMPTS; i++) { - token = sd_arch_spi_read(); - if(token == START_BLOCK_TOKEN || (token > 0 && token <= 8)) { - break; - } - } - - if(token == START_BLOCK_TOKEN) { - /* A start block token has been received. Read the block now. */ - for(i = 0; i < len; i++) { - buf[i] = sd_arch_spi_read(); - } - - /* Consume CRC. TODO: Validate the block. */ - sd_arch_spi_read(); - sd_arch_spi_read(); - - retval = len; - } else if(token > 0 && token <= 8) { - /* The card returned a data error token. */ - retval = SD_READ_ERROR_TOKEN; - } else { - /* The card never returned a token after our read attempts. */ - retval = SD_READ_ERROR_NO_TOKEN; - } - - RAISE_CS(); - UNLOCK_SPI(); - return retval; - } - - RAISE_CS(); - UNLOCK_SPI(); - - if(r != NULL) { - PRINTF("status during read: %d\n", r[0]); - } - - return SD_READ_ERROR_NO_CMD_RESPONSE; -} -/*---------------------------------------------------------------------------*/ -int -sd_read_block(sd_offset_t offset, char *buf) -{ - return read_block(READ_SINGLE_BLOCK, offset, buf, rw_block_size); -} -/*---------------------------------------------------------------------------*/ -static int -read_register(int register_cmd, char *buf, int register_size) -{ - return read_block(register_cmd, 0, buf, register_size); -} -/*---------------------------------------------------------------------------*/ -sd_offset_t -sd_get_capacity(void) -{ - unsigned char reg[16]; - int r; - uint16_t c_size; - uint8_t c_size_mult; - sd_offset_t block_nr; - sd_offset_t mult; - - r = read_register(SEND_CSD, reg, sizeof(reg)); - if(r < 0) { - return r; - } - - c_size = ((reg[6] & 3) << 10) + (reg[7] << 2) + ((reg[8] >> 6) & 3); - c_size_mult = ((reg[9] & 3) << 1) + ((reg[10] & 0x80) >> 7); - mult = 1 << (c_size_mult + 2); - block_nr = (c_size + 1) * mult; - - return block_nr * block_size; -} -/*---------------------------------------------------------------------------*/ -char * -sd_error_string(int error_code) -{ -#if DEBUG - switch(error_code) { - case SD_OK: - return "operation succeeded"; - case SD_INIT_ERROR_NO_CARD: - return "no card was found"; - case SD_INIT_ERROR_ARCH: - return "architecture-dependent initialization failed"; - case SD_INIT_ERROR_NO_IF_COND: - return "unable to obtain the interface condition"; - case SD_INIT_ERROR_NO_BLOCK_SIZE: - return "unable to obtain the block size"; - case SD_WRITE_ERROR_NO_CMD_RESPONSE: - return "no response from the card after submitting a write request"; - case SD_WRITE_ERROR_NO_BLOCK_RESPONSE: - return "no response from the card after sending a data block"; - case SD_WRITE_ERROR_PROGRAMMING: - return "the write request failed because of a card error"; - case SD_WRITE_ERROR_TOKEN: - return "the card is not ready to grant a write request"; - case SD_READ_ERROR_NO_TOKEN: - case SD_WRITE_ERROR_NO_TOKEN: - return "did not receive a start block token"; - case SD_READ_ERROR_INVALID_SIZE: - return "invalid read block size"; - case SD_READ_ERROR_TOKEN: - return "the card is not ready to read a data block"; - case SD_READ_ERROR_NO_CMD_RESPONSE: - return "no response from the card after submitting a read request"; - default: - break; - } -#endif - return "unspecified error"; -} -/*---------------------------------------------------------------------------*/ -int -sd_write(sd_offset_t offset, char *buf, size_t size) -{ - sd_offset_t address; - uint16_t offset_in_block; - int r, i; - size_t written; - size_t to_write; - char sd_buf[rw_block_size]; - - /* Emulation of data writing using arbitrary offsets and chunk sizes. */ - memset(sd_buf, 0, sizeof(sd_buf)); - written = 0; - offset_in_block = offset & (rw_block_size - 1); - - do { - to_write = MIN(size - written, rw_block_size - offset_in_block); - address = (offset + written) & ~(rw_block_size - 1); - - for(i = 0; i < SD_READ_BLOCK_ATTEMPTS; i++) { - r = sd_read_block(address, sd_buf); - if(r == sizeof(sd_buf)) { - break; - } - } - if(r != sizeof(sd_buf)) { - return r; - } - - memcpy(&sd_buf[offset_in_block], &buf[written], to_write); - r = sd_write_block(address, sd_buf); - if(r != sizeof(sd_buf)) { - return r; - } - written += to_write; - offset_in_block = 0; - } while(written < size); - - return written; -} -/*---------------------------------------------------------------------------*/ -int -sd_read(sd_offset_t offset, char *buf, size_t size) -{ - size_t total_read; - size_t to_read; - char sd_buf[rw_block_size]; - uint16_t offset_in_block; - int r, i; - - /* Emulation of data reading using arbitrary offsets and chunk sizes. */ - total_read = 0; - offset_in_block = offset & (rw_block_size - 1); - - do { - to_read = MIN(size - total_read, rw_block_size - offset_in_block); - for(i = 0; i < SD_READ_BLOCK_ATTEMPTS; i++) { - r = sd_read_block((offset + total_read) & ~(rw_block_size - 1), sd_buf); - if(r == sizeof(sd_buf)) { - break; - } - } - if(r != sizeof(sd_buf)) { - return r; - } - - memcpy(&buf[total_read], &sd_buf[offset_in_block], to_read); - total_read += to_read; - offset_in_block = 0; - } while(total_read < size); - - return size; -} -/*---------------------------------------------------------------------------*/ diff --git a/platform/msb430/dev/sd.h b/platform/msb430/dev/sd.h deleted file mode 100644 index 8efc33305..000000000 --- a/platform/msb430/dev/sd.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2009, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * \file - * SD driver interface. - * \author - * Nicolas Tsiftes - */ - -#ifndef SD_H -#define SD_H - -#include "sd-arch.h" - -#define SD_DEFAULT_BLOCK_SIZE 512 -#define SD_REGISTER_SIZE 16 - -/* API return codes. */ -#define SD_OK 1 - -#define SD_INIT_ERROR_NO_CARD -1 -#define SD_INIT_ERROR_ARCH -2 -#define SD_INIT_ERROR_NO_IF_COND -3 -#define SD_INIT_ERROR_NO_BLOCK_SIZE -4 - -#define SD_WRITE_ERROR_NO_CMD_RESPONSE -5 -#define SD_WRITE_ERROR_NO_BLOCK_RESPONSE -6 -#define SD_WRITE_ERROR_PROGRAMMING -7 -#define SD_WRITE_ERROR_TOKEN -8 -#define SD_WRITE_ERROR_NO_TOKEN -9 - -#define SD_READ_ERROR_NO_CMD_RESPONSE -10 -#define SD_READ_ERROR_INVALID_SIZE -11 -#define SD_READ_ERROR_TOKEN -12 -#define SD_READ_ERROR_NO_TOKEN -13 - -/* Type definition. */ -typedef uint32_t sd_offset_t; - -/* API */ -int sd_initialize(void); -int sd_write(sd_offset_t, char *, unsigned); -int sd_read(sd_offset_t, char *, unsigned); -int sd_write_block(sd_offset_t, char *); -int sd_read_block(sd_offset_t, char *); -sd_offset_t sd_get_capacity(void); -char *sd_error_string(int); - -#endif /* !SD_H */ diff --git a/platform/msb430/dev/sht11-arch.h b/platform/msb430/dev/sht11-arch.h deleted file mode 100644 index 42dc6b3c8..000000000 --- a/platform/msb430/dev/sht11-arch.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2007, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * \file - * Architecture-specific definitions for the SHT11 sensor on MSB-430. - * \author - * Nicolas Tsiftes - */ - -#ifndef SHT11_ARCH_H -#define SHT11_ARCH_H - -#define SHT11_ARCH_SDA 4 /* P3.4 */ -#define SHT11_ARCH_SCL 5 /* P3.5 */ -#define SHT11_ARCH_PWR 6 /* P3.6 */ - -#define SHT11_PxDIR P3DIR -#define SHT11_PxIN P3IN -#define SHT11_PxOUT P3OUT -#define SHT11_PxSEL P3SEL - -#endif diff --git a/platform/msb430/doc/msb430.txt b/platform/msb430/doc/msb430.txt deleted file mode 100644 index 840f6db5d..000000000 --- a/platform/msb430/doc/msb430.txt +++ /dev/null @@ -1,51 +0,0 @@ -/** \addtogroup platform - * @{ - **/ - -/** -\defgroup msb430 The Modular Sensor Board - -The Modular Sensor Board (MSB430) was developed by FU-Berlin and was -added as a platform in Contiki in the spring of 2007. In its basic form, -this board consists of a Texas Instruments MSP430f1612 processor, a -Chipcon CC1020 radio chip, an MMA7260Q accelerometer, and a Sensirion -SHT11 temperature and humidity sensor. The MSB also has an SD device, -which makes it suitable for storage-centric sensor networks. There are -also extended versions of the board that are equipped with a GPRS-modem -and a GPS-receiver. - -\section msb430-programming Programming the MSB430 - -The msb430 port requires an installation of mspgcc -(http://mspgcc.sourceforge.net) to compile. Once the compilation tools -have been installed, you can compile your software and Contiki with -three main target types: - -.firmware - A system image in ELF format. -.ihex - A firmware file converted to the Intel Hex format. -.u - Direct upload to a node. - -Before compiling your system, you may want to look at the configuration -options in platform/msb430/configure-conf.h. - -The node is typically programmed by typing - - make TARGET=msb430 .u - -Alternatively, a ready .ihex file can be uploaded to the node by running - - msp430-jtag -l -e -I - -Platform-specific example programs are included in platform/msb430/apps -and can be compiled and uploaded from platform/msb430. A larger set of -examples for Contiki in general are in the examples/ directory. - -More information about the MSB430 platform can be found at -Scatterweb: http://www.scatterweb.com/content/products/MSB_en.html - -@{ - -*/ - -/** @} */ -/** @} */ diff --git a/platform/msb430/init-net-uip.c b/platform/msb430/init-net-uip.c deleted file mode 100644 index 66ee618cd..000000000 --- a/platform/msb430/init-net-uip.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2007, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * \file - * uIP initialization for the MSB-430 port. - * \author - * Nicolas Tsiftes - */ - -#include "contiki.h" -#include "contiki-net.h" -#include "sys/node-id.h" -#include "dev/slip.h" -#include "dev/cc1020-uip.h" -#include "contiki-msb430.h" - -static struct uip_fw_netif slipif = -{UIP_FW_NETIF(172,16,0,0, 255,255,255,0, slip_send)}; - -static struct uip_fw_netif wsnif = -{UIP_FW_NETIF(0,0,0,0, 0,0,0,0, cc1020_uip_send)}; - -void -init_net(void) -{ - uip_ipaddr_t hostaddr; - cc1020_init(cc1020_config_19200); - - uip_init(); - uip_fw_init(); - /*tcpip_set_forwarding(1);*/ - - process_start(&tcpip_process, NULL); - process_start(&slip_process, NULL); - process_start(&uip_fw_process, NULL); - - rs232_set_input(slip_input_byte); - - cc1020_uip_init(); - cc1020_on(); - - if (node_id > 0) { - uip_ipaddr(&hostaddr, 172, 16, 1, node_id); - uip_sethostaddr(&hostaddr); - } - - uip_fw_register(&slipif); - uip_fw_default(&wsnif); -} diff --git a/platform/msb430/loader/loader-arch.h b/platform/msb430/loader/loader-arch.h deleted file mode 100644 index 260062d5a..000000000 --- a/platform/msb430/loader/loader-arch.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ -#ifndef __LOADER_ARCH_H__ -#define __LOADER_ARCH_H__ - -/** - * Load a program from EEPROM. - * - * This function loads a program from EEPROM into the flash ROM (code) and RAM (data). - * - * \param code The address of the first byte of code in the EEPROM. - * - * \param codelen The length of the code. - * - * \param data The address of the first byte of data in the EEPROM. - * - * \param datalen The length of the data. - * - */ -void loader_arch_load(unsigned short startaddr); - -/** - * Unload a program. - * - * This function should not be called directly, but accessed through - * the macro LOADER_UNLOAD(). The function unloads a program from both - * RAM and ROM. - * - * \param codeaddr A pointer to the first byte of program code. - * - * \param dataaddr A pointer to the first byte of program data. - */ -void loader_arch_free(void *codeaddr, void *dataaddr); - -extern void *loader_arch_codeaddr, *loader_arch_dataaddr; - -#ifndef LOADER_UNLOAD -#define LOADER_UNLOAD() loader_arch_free(&loader_arch_codeaddr, &loader_arch_dataaddr) -#endif - -#define LOADER_ARCH_MAGIC 0x373a -#define LOADER_ARCH_VERSION 0x0001 - -#endif /* __LOADER_ARCH_H__ */ diff --git a/platform/msb430/msb430-slip-arch.c b/platform/msb430/msb430-slip-arch.c deleted file mode 100644 index 45768acb1..000000000 --- a/platform/msb430/msb430-slip-arch.c +++ /dev/null @@ -1,56 +0,0 @@ -#include "dev/msb430-uart1.h" -#include "dev/rs232.h" -#include "sys/clock.h" -#include "dev/slip.h" - - -void -slip_arch_writeb(unsigned char c) -{ - rs232_send(c); -} -/*---------------------------------------------------------------------------*/ - -/* - * The serial line is used to transfer IP packets using slip. To make - * it possible to send debug output over the same line we send debug - * output as slip frames (i.e delimeted by SLIP_END). - * - */ -int -putchar(int c) -{ -#define SLIP_END 0300 - static char debug_frame = 0; - - if(!debug_frame) { /* Start of debug output */ - slip_arch_writeb(SLIP_END); - slip_arch_writeb('\r'); /* Type debug line == '\r' */ - debug_frame = 1; - } - - slip_arch_writeb((char)c); - - /* - * Line buffered output, a newline marks the end of debug output and - * implicitly flushes debug output. - */ - if(c == '\n') { - slip_arch_writeb(SLIP_END); - debug_frame = 0; - } - - clock_delay(100); - - return c; -} - -/** - * Initalize the RS232 port and the SLIP driver. - * - */ -void -slip_arch_init(unsigned long ubr) -{ - rs232_set_input(slip_input_byte); -} diff --git a/platform/msb430/node-id.c b/platform/msb430/node-id.c deleted file mode 100644 index 62691813e..000000000 --- a/platform/msb430/node-id.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2006, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -#include "sys/node-id.h" -#include "dev/infomem.h" - -uint16_t node_id = 0; - -/*---------------------------------------------------------------------------*/ -void -node_id_restore(void) -{ - uint16_t newid[2]; - - infomem_read(newid, INFOMEM_NODE_ID, sizeof(newid)); - node_id = (newid[0] == 0xdead) ? newid[1] : 0; -} -/*---------------------------------------------------------------------------*/ -void -node_id_burn(uint16_t id) -{ - uint16_t buffer[2] = { 0xdead, id }; - infomem_write(INFOMEM_NODE_ID, 1, buffer, sizeof(buffer)); -} -/*---------------------------------------------------------------------------*/ diff --git a/platform/msb430/symbols.c b/platform/msb430/symbols.c deleted file mode 100644 index e2f43ffdb..000000000 --- a/platform/msb430/symbols.c +++ /dev/null @@ -1,3 +0,0 @@ -#include "symbols.h" -const int symbols_nelts = 0; -const struct symbols symbols[] = {{0,0}}; diff --git a/platform/msb430/symbols.h b/platform/msb430/symbols.h deleted file mode 100644 index 378215565..000000000 --- a/platform/msb430/symbols.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "loader/symbols.h" -extern const struct symbols symbols[1]; diff --git a/platform/pc-6001/Makefile b/platform/pc-6001/Makefile deleted file mode 100644 index 13095ffcc..000000000 --- a/platform/pc-6001/Makefile +++ /dev/null @@ -1,87 +0,0 @@ -# -# Makefile for PC-6001 using z80/SDCC -# @author Takahide Matsutsuka -# -# $Id: Makefile,v 1.7 2009/12/16 06:47:18 matsutsuka Exp $ -# - -CONTIKI = ../.. -TARGET=pc-6001 -APPS_DESKTOP = program-handler calc process-list shell about -APPS_NETWORK_CLIENT = $(APPS_DESKTOP) netconf webbrowser email telnet ftp irc -APPS_NETWORK_SERVER = program-handler cmdd telnetd shell -# editor netconf dhcp webbrowser ftp irc email telnet telnetd -# cmdd codeprop webserver vnc -# directory - -PLATFORM_APPS_DESKTOP = multithread tinysample -PLATFORM_APPS_NETWORK = webserver-mini -PLATFORM_APPS=$(PLATFORM_APPS_DESKTOP) - -ifeq ($(MAKECMDGOALS),client) - APPS = $(APPS_NETWORK_CLIENT) -else ifeq ($(MAKECMDGOALS),server) - APPS = $(APPS_NETWORK_SERVER) -else - APPS = $(APPS_DESKTOP) -endif - -# Default values -MEMORY=32K -PLATFORM_APPS=$(PLATFORM_APPS_DESKTOP) -CONTIKI_TARGET_MAIN = contiki-desktop-main.c -CTKCONF = NORMAL -LOADER = 0 - -# Target dependent options -ifeq ($(MAKECMDGOALS),p62) - ARCH=PC6001MK2 -else ifeq ($(MAKECMDGOALS),p6A) - ARCH=PC6001A -else ifeq ($(MAKECMDGOALS),minimal) - MEMORY=16K - CONTIKI_TARGET_MAIN=contiki-minimal-main.c -else ifeq ($(MAKECMDGOALS),serial) - CONTIKI_TARGET_MAIN=contiki-serial-main.c -else ifeq ($(MAKECMDGOALS),rom) - CTKCONF=NOICON - MEMORY=ROM - LOADER = 1 - CONTIKI_TARGET_MAIN=contiki-loader-main.c -else ifeq ($(MAKECMDGOALS),load) - CTKCONF=NOICON - LOADER = 1 - CONTIKI_TARGET_MAIN=contiki-loader-main.c -else ifeq ($(MAKECMDGOALS),server) - CTKCONF=SERVER - PLATFORM_APPS = $(PLATFORM_APPS_NETWORK) - CONTIKI_TARGET_MAIN=contiki-server-main.c -else ifeq ($(MAKECMDGOALS),client) - CTKCONF=CLIENT - PLATFORM_APPS = $(PLATFORM_APPS_NETWORK) - CONTIKI_TARGET_MAIN=contiki-client-main.c -endif - -all : p6 - -p6 : contiki -p62 : contiki -p6A : contiki -minimal : contiki -serial : contiki -rom : contiki.rom -load : contiki -server : contiki -client : contiki - -remove-ctk: - rm -f obj_$(TARGET)/ctk*; - rm -f contiki.ihex -remove-net: - rm -f ${addprefix obj_$(TARGET)/,uip*.o hc.o psock.o rawpacket-udp.o resolv.o slip*.o tcp*.o uaod*.o rime*.o http*.o web*.o}; - rm -f contiki.ihex -remove-mt: - rm -f obj_$(TARGET)/mt*.o - rm -f contiki.ihex - -include $(CONTIKI)/Makefile.include diff --git a/platform/pc-6001/Makefile.pc-6001 b/platform/pc-6001/Makefile.pc-6001 deleted file mode 100644 index 2dde283a3..000000000 --- a/platform/pc-6001/Makefile.pc-6001 +++ /dev/null @@ -1,103 +0,0 @@ -# -# Makefile for PC-6001 using z80/SDCC -# @author Takahide Matsutsuka -# -# $Id: Makefile.pc-6001,v 1.13 2009/12/16 06:47:18 matsutsuka Exp $ -# - -ifndef CONTIKI - $(error CONTIKI not defined! You must specify where CONTIKI resides!) -endif - -### setup default values -ifndef ARCH - ARCH=PC6001 -endif -ifndef MEMORY - MEMORY=32K -endif -ifndef CONTIKI_TARGET_MAIN - CONTIKI_TARGET_MAIN = contiki-main.c -endif -ifndef CTKCONF - CTKCONF=NORMAL -endif -ifndef LOADER - LOADER=0 -endif - -ifndef HEX2BIN - HEX2BINDIR = ../../tools/z80/hex2bin/ - HEX2BIN = $(HEX2BINDIR)/hexameter -endif - -### setup flags to be used in compiler, assembler, and HEX2BIN -PLATFORM = $(CONTIKI)/platform/$(TARGET) -CONTIKI_TARGET_DIRS = . ctk dev loader -CFLAGS += -DMEMORY_$(MEMORY) -DARCH_$(ARCH) -DCTK_$(CTKCONF) - -ifeq ($(MEMORY),16K) - LDFLAGS += --code-loc 0xc40f --data-loc 0 - HEX2BINFLAGS = -d TAPE=contki $(HEX2BINDIR)/ihx/mode1.ihx -o contiki.p6 -else ifeq ($(MEMORY),ROM) - LDFLAGS += --code-loc 0x4004 --data-loc 0xf000 - HEX2BINFLAGS = -d ROMEXEC=4004 $(HEX2BINDIR)/ihx/rom60.ihx -b 4000 -o contiki.rom -else ifeq ($(ARCH),PC6001MK2) - LDFLAGS += --code-loc 0x800f --data-loc 0 - HEX2BINFLAGS = -d TAPE=contki $(HEX2BINDIR)/ihx/mode5.ihx -o contiki2.p6 -else - LDFLAGS += --code-loc 0x840f --data-loc 0 - HEX2BINFLAGS = -d TAPE=contki $(HEX2BINDIR)/ihx/mode2.ihx -o contiki.p6 -endif - -ifeq ($(LOADER),1) - CFLAGS += -DWITH_LOADER_ARCH=1 -endif - -### Include platform-depend application makefiles - -ifdef PLATFORM_APPS - PLATFORM_APPDIRS += ${addprefix $(PLATFORM)/apps/, $(PLATFORM_APPS)} - PLATFORM_APPINCLUDES = ${foreach APP, $(PLATFORM_APPS), $(PLATFORM)/apps/$(APP)/Makefile.$(APP)} - -include $(PLATFORM_APPINCLUDES) - PLATFORM_APP_SOURCES = ${foreach APP, $(PLATFORM_APPS), $($(APP)_src)} - PLATFORM_DSC_SOURCES = ${foreach APP, $(PLATFORM_APPS), $($(APP)_dsc)} - CONTIKI_SOURCEFILES += $(PLATFORM_APP_SOURCES) $(PLATFORM_DSC_SOURCES) -endif - -CONTIKI_TARGET_SOURCEFILES = \ - $(CTK) cfs-ram.c serial-line.c slip.c \ - resolv.c loader_arch.c \ - ctk-conio_arch.c $(CONTIKI_TARGET_MAIN) - -#you can use the below instead of ctk-conio_arch.c, ctk-conio_arch-asm.cS, -# and libconio_arch-asm.cS -#ctk-conio_arch-source.c - -CONTIKI_ASMFILES += getkey.S isprint_arch.S clock.S rs232-asm.S -CONTIKI_CASMFILES += ctk-conio_arch-asm.cS libconio_arch-asm.cS\ - libconio_arch-small.cS - -CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES) - -CLEAN += *.rom *.p6 - -contiki: $(HEX2BIN) contiki.p6 - -.SUFFIXES: - -%.p6: %.ihx - $(HEX2BIN) $(HEX2BINFLAGS) $< $(HEX2BINDIR)/ihx/suffix.ihx -%.rom: %.ihx - $(HEX2BIN) $(HEX2BINFLAGS) $< - -$(HEX2BIN): - cd $(HEX2BINDIR); make - -### Define the CPU directory -CONTIKI_CPU=$(CONTIKI)/cpu/z80 -include $(CONTIKI_CPU)/Makefile.z80 - -### Setup directory search path for source files -PROJECTDIRS += $(PLATFORM_APPDIRS) - diff --git a/platform/pc-6001/apps/multithread/Makefile.multithread b/platform/pc-6001/apps/multithread/Makefile.multithread deleted file mode 100644 index 13f57f481..000000000 --- a/platform/pc-6001/apps/multithread/Makefile.multithread +++ /dev/null @@ -1,2 +0,0 @@ -multithread_src = mt-test.c -multithread_dsc = mt-test-dsc.c diff --git a/platform/pc-6001/apps/multithread/mt-test-dsc.c b/platform/pc-6001/apps/multithread/mt-test-dsc.c deleted file mode 100644 index d5e248916..000000000 --- a/platform/pc-6001/apps/multithread/mt-test-dsc.c +++ /dev/null @@ -1,38 +0,0 @@ -#include "sys/dsc.h" - -/*-----------------------------------------------------------------------------------*/ -#if CTK_CONF_ICON_BITMAPS -static unsigned char mttesticon_bitmap[3*3*8] = { - 0x00, 0x7f, 0x43, 0x4c, 0x58, 0x53, 0x60, 0x6f, - 0x00, 0xff, 0x00, 0x7e, 0x00, 0xff, 0x00, 0xff, - 0x00, 0xfe, 0xc2, 0x32, 0x1a, 0xca, 0x06, 0xf6, - - 0x40, 0x5f, 0x40, 0x5f, 0x40, 0x5f, 0x40, 0x4f, - 0x00, 0xff, 0x00, 0xff, 0x00, 0xfc, 0x01, 0xf3, - 0x02, 0xfa, 0x02, 0x82, 0x3e, 0xfe, 0xfe, 0xfe, - - 0x60, 0x67, 0x50, 0x59, 0x4c, 0x43, 0x7f, 0x00, - 0x07, 0xe7, 0x0f, 0xef, 0x0f, 0x0f, 0xff, 0x00, - 0x8e, 0x06, 0x06, 0x06, 0x8e, 0xfe, 0xfe, 0x00 -}; -#endif /* CTK_CONF_ICON_BITMAPS */ - -#if CTK_CONF_ICON_TEXTMAPS -static char mttesticon_textmap[9] = { - 'T', 'h', 'r', - 'e', 'a', 'd', - '=', '=', '>' -}; -#endif /* CTK_CONF_ICON_TEXTMAPS */ - -#if CTK_CONF_ICONS -static struct ctk_icon mttest_icon = - {CTK_ICON("Multithread test", mttesticon_bitmap, mttesticon_textmap)}; -#endif /* CTK_CONF_ICONS */ -/*-----------------------------------------------------------------------------------*/ -DSC(mttest_dsc, - "MultithreadTest", - "mt-test.prg", - mt_process, - &mttest_icon); -/*-----------------------------------------------------------------------------------*/ diff --git a/platform/pc-6001/apps/multithread/mt-test-dsc.h b/platform/pc-6001/apps/multithread/mt-test-dsc.h deleted file mode 100644 index 51fdf58c3..000000000 --- a/platform/pc-6001/apps/multithread/mt-test-dsc.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef MTTESTDSC_H_ -#define MTTESTDSC_H_ -#include "sys/dsc.h" - -DSC_HEADER(mttest_dsc); - -#endif /*MTTESTDSC_H_*/ diff --git a/platform/pc-6001/apps/multithread/mt-test.c b/platform/pc-6001/apps/multithread/mt-test.c deleted file mode 100644 index c43d1b096..000000000 --- a/platform/pc-6001/apps/multithread/mt-test.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (c) 2007, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - * Author: Oliver Schmidt - * - */ - -/** - * \file - * A very simple Contiki application showing how to use the Contiki - * Multi-threading library - * \author - * Oliver Schmidt - * \author for PC-6001 version - * Takahide Matsutsuka - */ - -#include - -#include "contiki.h" -#include "ctk.h" -#include "sys/mt.h" -#include "mtarch.h" - -#define WIN_XSIZE 10 -#define WIN_YSIZE 10 - -static char log[WIN_XSIZE * WIN_YSIZE]; -static struct ctk_window window; -static struct ctk_label loglabel = {CTK_LABEL(0, 0, WIN_XSIZE, WIN_YSIZE, log)}; -PROCESS(mt_process, "Multi-threading test"); - -static char buf[20]; - -void -println(char *str1) -{ - unsigned int i; - - for(i = 1; i < WIN_YSIZE; i++) { - memcpy(&log[(i - 1) * WIN_XSIZE], &log[i * WIN_XSIZE], WIN_XSIZE); - } - memset(&log[(WIN_YSIZE - 1) * WIN_XSIZE], 0, WIN_XSIZE); - - strncpy(&log[(WIN_YSIZE - 1) * WIN_XSIZE], str1, WIN_XSIZE); - - CTK_WIDGET_REDRAW(&loglabel); -} -/*---------------------------------------------------------------------------*/ -static void -thread_func(char *str, int len) -{ - println((char *) (str + len)); - mt_yield(); - - if(len) { - thread_func(str, len - 1); - mt_yield(); - } - - println((char *) (str + len)); -} -/*---------------------------------------------------------------------------*/ -static void -thread_main(void *data) -{ - while(1) { - thread_func((char *)data, 9); - } - mt_exit(); -} - -/*---------------------------------------------------------------------------*/ -PROCESS_THREAD(mt_process, ev, data) -{ - - static struct etimer timer; - static int toggle = 0; - static struct mt_thread th1; - static struct mt_thread th2; - - PROCESS_BEGIN(); - - ctk_window_new(&window, WIN_XSIZE, WIN_YSIZE, "Multithread"); - CTK_WIDGET_ADD(&window, &loglabel); - memset(log, 0, sizeof(log)); - ctk_window_open(&window); - mt_init(); - mt_start(&th1, thread_main, "JIHGFEDCBA"); - mt_start(&th2, thread_main, "9876543210"); - - etimer_set(&timer, CLOCK_SECOND / 2); - while(1) { - PROCESS_WAIT_EVENT(); - if(ev == PROCESS_EVENT_TIMER) { - if(toggle) { - mt_exec(&th1); - toggle--; - } else { - mt_exec(&th2); - toggle++; - } - etimer_set(&timer, CLOCK_SECOND / 2); - } else if(ev == ctk_signal_window_close || ev == PROCESS_EVENT_EXIT) { - ctk_window_close(&window); - process_exit(&mt_process); - LOADER_UNLOAD(); - } - } - - mt_stop(&th1); - mt_stop(&th2); - mt_remove(); - - while(1) { - PROCESS_WAIT_EVENT(); - } - PROCESS_END(); -} -/*---------------------------------------------------------------------------*/ diff --git a/platform/pc-6001/apps/tinysample/Makefile.tinysample b/platform/pc-6001/apps/tinysample/Makefile.tinysample deleted file mode 100644 index 2a58b3ff9..000000000 --- a/platform/pc-6001/apps/tinysample/Makefile.tinysample +++ /dev/null @@ -1,2 +0,0 @@ -tinysample_src = tinysample.c -tinysample_dsc = tinysample-dsc.c diff --git a/platform/pc-6001/apps/tinysample/tinysample-dsc.c b/platform/pc-6001/apps/tinysample/tinysample-dsc.c deleted file mode 100644 index 4aafc7107..000000000 --- a/platform/pc-6001/apps/tinysample/tinysample-dsc.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2007, Takahide Matsutsuka. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - * Author: Oliver Schmidt - * - */ - -/** - * \file - * A very small sample Contiki application using console. - * \author - * Takahide Matsutsuka - */ - -#include "sys/dsc.h" - -/*-----------------------------------------------------------------------------------*/ -#if CTK_CONF_ICON_BITMAPS -static unsigned char tiny_bitmap[3*3*8] = { - 0x00, 0x7f, 0x43, 0x4c, 0x58, 0x53, 0x60, 0x6f, - 0x00, 0xff, 0x00, 0x7e, 0x00, 0xff, 0x00, 0xff, - 0x00, 0xfe, 0xc2, 0x32, 0x1a, 0xca, 0x06, 0xf6, - - 0x40, 0x5f, 0x40, 0x5f, 0x40, 0x5f, 0x40, 0x4f, - 0x00, 0xff, 0x00, 0xff, 0x00, 0xfc, 0x01, 0xf3, - 0x02, 0xfa, 0x02, 0x82, 0x3e, 0xfe, 0xfe, 0xfe, - - 0x60, 0x67, 0x50, 0x59, 0x4c, 0x43, 0x7f, 0x00, - 0x07, 0xe7, 0x0f, 0xef, 0x0f, 0x0f, 0xff, 0x00, - 0x8e, 0x06, 0x06, 0x06, 0x8e, 0xfe, 0xfe, 0x00 -}; -#endif /* CTK_CONF_ICON_BITMAPS */ - -#if CTK_CONF_ICON_TEXTMAPS -static char tiny_textmap[9] = { - 'T', 'i', 'n', - 'y', 'S', 'a', - 'm', 'p', 'l' -}; -#endif /* CTK_CONF_ICON_TEXTMAPS */ - -#if CTK_CONF_ICONS -static struct ctk_icon tiny_icon = - {CTK_ICON("Tiny sample", tiny_bitmap, tiny_textmap)}; -#endif /* CTK_CONF_ICONS */ -/*-----------------------------------------------------------------------------------*/ -DSC(tiny_dsc, - "Tinysample", - "tinysmaple.prg", - tiny_process, - &tiny_icon); -/*-----------------------------------------------------------------------------------*/ diff --git a/platform/pc-6001/apps/tinysample/tinysample-dsc.h b/platform/pc-6001/apps/tinysample/tinysample-dsc.h deleted file mode 100644 index aab795b70..000000000 --- a/platform/pc-6001/apps/tinysample/tinysample-dsc.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2007, Takahide Matsutsuka. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - * Author: Oliver Schmidt - * - */ - -/** - * \file - * A very small sample Contiki application using console. - * \author - * Takahide Matsutsuka - */ - -#ifndef TINYSAMPLE_DSC_H_ -#define TINYSAMPLE_DSC_H_ -#include "sys/dsc.h" - -DSC_HEADER(tiny_dsc); - -#endif /*TINYSAMPLE_DSC_H_*/ diff --git a/platform/pc-6001/apps/tinysample/tinysample.c b/platform/pc-6001/apps/tinysample/tinysample.c deleted file mode 100644 index 457156e6d..000000000 --- a/platform/pc-6001/apps/tinysample/tinysample.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2007, Takahide Matsutsuka. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - * Author: Oliver Schmidt - * - */ - -/** - * \file - * A very small sample Contiki application using console. - * \author - * Takahide Matsutsuka - */ - -#include "contiki.h" -#include "libconio_arch-small.h" - -PROCESS(tiny_process, "Tiny Sample"); - -static char ch[] = "A"; -/*---------------------------------------------------------------------------*/ -PROCESS_THREAD(tiny_process, ev, data) -{ - static struct etimer timer; - - PROCESS_BEGIN(); - - clrscr_arch(); - - while(1) { - etimer_set(&timer, CLOCK_SECOND / 32); - PROCESS_WAIT_EVENT(); - if(etimer_expired(&timer)) { - libputs_arch(ch); - ch[0]++; - } - } - PROCESS_END(); -} -/*---------------------------------------------------------------------------*/ diff --git a/platform/pc-6001/apps/webserver-mini/Makefile.webserver-mini b/platform/pc-6001/apps/webserver-mini/Makefile.webserver-mini deleted file mode 100644 index 3d6b8babe..000000000 --- a/platform/pc-6001/apps/webserver-mini/Makefile.webserver-mini +++ /dev/null @@ -1,2 +0,0 @@ -webserver-mini_src = webserver-nogui.c httpd.c http-strings.c psock.c memb.c \ - httpd-fs.c httpd-cgi.c diff --git a/platform/pc-6001/apps/webserver-mini/http-strings b/platform/pc-6001/apps/webserver-mini/http-strings deleted file mode 100644 index 6a3fba34f..000000000 --- a/platform/pc-6001/apps/webserver-mini/http-strings +++ /dev/null @@ -1,34 +0,0 @@ -http_http "http://" -http_200 "200 " -http_301 "301 " -http_302 "302 " -http_get "GET " -http_10 "HTTP/1.0" -http_11 "HTTP/1.1" -http_content_type "content-type: " -http_texthtml "text/html" -http_location "location: " -http_host "host: " -http_crnl "\n" -http_index_html "/index.html" -http_404_html "/404.html" -http_referer "Referer:" -http_header_200 "HTTP/1.0 200 OK\nServer: Contiki/2.0\nConnection: close\n" -http_header_404 "HTTP/1.0 404 Not found\nServer: Contiki/2.0\nConnection: close\n" -http_content_type_plain "Content-type: text/plain\n\n" -http_content_type_html "Content-type: text/html\n\n" -http_content_type_css "Content-type: text/css\n\n" -http_content_type_text "Content-type: text/text\n\n" -http_content_type_png "Content-type: image/png\n\n" -http_content_type_gif "Content-type: image/gif\n\n" -http_content_type_jpg "Content-type: image/jpeg\n\n" -http_content_type_binary "Content-type: application/octet-stream\n\n" -http_html ".html" -http_shtml ".shtml" -http_htm ".htm" -http_css ".css" -http_png ".png" -http_gif ".gif" -http_jpg ".jpg" -http_text ".text" -http_txt ".txt" diff --git a/platform/pc-6001/apps/webserver-mini/http-strings.c b/platform/pc-6001/apps/webserver-mini/http-strings.c deleted file mode 100644 index 924f15f12..000000000 --- a/platform/pc-6001/apps/webserver-mini/http-strings.c +++ /dev/null @@ -1,36 +0,0 @@ -const char http_200[5] = -/* "200 " */ -{0x32, 0x30, 0x30, 0x20, }; -const char http_get[5] = -/* "GET " */ -{0x47, 0x45, 0x54, 0x20, }; -const char http_index_html[12] = -/* "/index.html" */ -{0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, }; -const char http_404_html[10] = -/* "/404.html" */ -{0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, }; -const char http_referer[9] = -/* "Referer:" */ -{0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x72, 0x3a, }; -const char http_header_200[55] = -/* "HTTP/1.0 200 OK\nServer: Contiki/2.0\nConnection: close\n" */ -{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 0x30, 0x30, 0x20, 0x4f, 0x4b, 0xa, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x32, 0x2e, 0x30, 0xa, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xa, }; -const char http_header_404[62] = -/* "HTTP/1.0 404 Not found\nServer: Contiki/2.0\nConnection: close\n" */ -{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x34, 0x30, 0x34, 0x20, 0x4e, 0x6f, 0x74, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0xa, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x32, 0x2e, 0x30, 0xa, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xa, }; -const char http_content_type_plain[27] = -/* "Content-type: text/plain\n\n" */ -{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0xa, 0xa, }; -const char http_content_type_html[26] = -/* "Content-type: text/html\n\n" */ -{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0xa, }; -const char http_content_type_binary[41] = -/* "Content-type: application/octet-stream\n\n" */ -{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6f, 0x63, 0x74, 0x65, 0x74, 0x2d, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0xa, 0xa, }; -const char http_html[6] = -/* ".html" */ -{0x2e, 0x68, 0x74, 0x6d, 0x6c, }; -const char http_shtml[7] = -/* ".shtml" */ -{0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, }; diff --git a/platform/pc-6001/apps/webserver-mini/http-strings.h b/platform/pc-6001/apps/webserver-mini/http-strings.h deleted file mode 100644 index 8da08cad6..000000000 --- a/platform/pc-6001/apps/webserver-mini/http-strings.h +++ /dev/null @@ -1,34 +0,0 @@ -extern const char http_http[8]; -extern const char http_200[5]; -extern const char http_301[5]; -extern const char http_302[5]; -extern const char http_get[5]; -extern const char http_10[9]; -extern const char http_11[9]; -extern const char http_content_type[15]; -extern const char http_texthtml[10]; -extern const char http_location[11]; -extern const char http_host[7]; -extern const char http_crnl[2]; -extern const char http_index_html[12]; -extern const char http_404_html[10]; -extern const char http_referer[9]; -extern const char http_header_200[55]; -extern const char http_header_404[62]; -extern const char http_content_type_plain[27]; -extern const char http_content_type_html[26]; -extern const char http_content_type_css [25]; -extern const char http_content_type_text[26]; -extern const char http_content_type_png [26]; -extern const char http_content_type_gif [26]; -extern const char http_content_type_jpg [27]; -extern const char http_content_type_binary[41]; -extern const char http_html[6]; -extern const char http_shtml[7]; -extern const char http_htm[5]; -extern const char http_css[5]; -extern const char http_png[5]; -extern const char http_gif[5]; -extern const char http_jpg[5]; -extern const char http_text[6]; -extern const char http_txt[5]; diff --git a/platform/pc-6001/apps/webserver-mini/httpd-cfs.c b/platform/pc-6001/apps/webserver-mini/httpd-cfs.c deleted file mode 100644 index 389e7e82a..000000000 --- a/platform/pc-6001/apps/webserver-mini/httpd-cfs.c +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (c) 2004, Adam Dunkels. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - * Author: Adam Dunkels - * - */ - -#include - -#include "contiki-net.h" -#include "cfs/cfs.h" - -#include "webserver.h" -#include "libconio_arch-small.h" - -#include "httpd-cfs.h" - -#define STATE_WAITING 0 -#define STATE_OUTPUT 1 - -#define SEND_STRING(s, str) PSOCK_SEND(s, str, strlen(str)) -MEMB(conns, struct httpd_state, 2); - -/*---------------------------------------------------------------------------*/ -static -PT_THREAD(send_file(struct httpd_state *s)) -{ - PSOCK_BEGIN(&s->sout); - - do { - /* Read data from file system into buffer */ - s->len = cfs_read(s->fd, s->outputbuf, sizeof(s->outputbuf)); - - /* If there is data in the buffer, send it */ - if(s->len > 0) { - PSOCK_SEND(&s->sout, s->outputbuf, s->len); - } else { - break; - } - } while(s->len > 0); - - PSOCK_END(&s->sout); -} -/*---------------------------------------------------------------------------*/ -static -PT_THREAD(send_headers(struct httpd_state *s, char *statushdr)) -{ - char *ptr; - - PSOCK_BEGIN(&s->sout); - - SEND_STRING(&s->sout, statushdr); - SEND_STRING(&s->sout, "Server: " CONTIKI_VERSION_STRING "\r\n"); - - ptr = strrchr(s->filename, '.'); - if(ptr == NULL) { - SEND_STRING(&s->sout, "Content-type: text/plain\r\n\r\n"); - } else if(strncmp(".html", ptr, 5) == 0) { - SEND_STRING(&s->sout, "Content-type: text/html\r\n\r\n"); - } else if(strncmp(".css", ptr, 4) == 0) { - SEND_STRING(&s->sout, "Content-type: text/css\r\n\r\n"); - } else if(strncmp(".png", ptr, 4) == 0) { - SEND_STRING(&s->sout, "Content-type: image/png\r\n\r\n"); - } else if(strncmp(".jpg", ptr, 4) == 0) { - SEND_STRING(&s->sout, "Content-type: image/jpeg\r\n\r\n"); - } else { - SEND_STRING(&s->sout, "Content-type: application/octet-stream\r\n\r\n"); - } - PSOCK_END(&s->sout); -} -/*---------------------------------------------------------------------------*/ -static -PT_THREAD(handle_output(struct httpd_state *s)) -{ - PT_BEGIN(&s->outputpt); - - s->fd = cfs_open(s->filename, CFS_READ); - if(s->fd < 0) { - s->fd = cfs_open("404.html", CFS_READ); - if(s->fd < 0) { - uip_abort(); - PT_EXIT(&s->outputpt); - } - PT_WAIT_THREAD(&s->outputpt, - send_headers(s, "HTTP/1.0 404 Not found\r\n")); - PT_WAIT_THREAD(&s->outputpt, - send_file(s)); - } else { - PT_WAIT_THREAD(&s->outputpt, - send_headers(s, "HTTP/1.0 200 OK\r\n")); - PT_WAIT_THREAD(&s->outputpt, - send_file(s)); - cfs_close(s->fd); - } - PSOCK_CLOSE(&s->sout); - PT_END(&s->outputpt); -} -/*---------------------------------------------------------------------------*/ -static -PT_THREAD(handle_input(struct httpd_state *s)) -{ - PSOCK_BEGIN(&s->sin); - - PSOCK_READTO(&s->sin, ' '); - - if(strncmp(s->inputbuf, "GET ", 4) != 0) { - PSOCK_CLOSE_EXIT(&s->sin); - } - PSOCK_READTO(&s->sin, ' '); - - if(s->inputbuf[0] != '/') { - PSOCK_CLOSE_EXIT(&s->sin); - } - - if(s->inputbuf[1] == ' ') { - strncpy(s->filename, "index.html", sizeof(s->filename)); - } else { - s->inputbuf[PSOCK_DATALEN(&s->sin) - 1] = 0; - strncpy(s->filename, &s->inputbuf[1], sizeof(s->filename)); - } - - // webserver_log_file(&uip_conn->ripaddr, s->filename); - libputs_arch(s->filename); - s->state = STATE_OUTPUT; - - while(1) { - PSOCK_READTO(&s->sin, '\n'); - - if(strncmp(s->inputbuf, "Referer:", 8) == 0) { - s->inputbuf[PSOCK_DATALEN(&s->sin) - 2] = 0; - libputs_arch(&s->inputbuf[9]); - // webserver_log(&s->inputbuf[9]); - } - } - - PSOCK_END(&s->sin); -} -/*---------------------------------------------------------------------------*/ -static void -handle_connection(struct httpd_state *s) -{ - handle_input(s); - if(s->state == STATE_OUTPUT) { - handle_output(s); - } -} -/*---------------------------------------------------------------------------*/ -void -httpd_appcall(void *state) -{ - struct httpd_state *s = (struct httpd_state *)state; - - if(uip_closed() || uip_aborted() || uip_timedout()) { - if(s != NULL) { - memb_free(&conns, s); - } - } else if(uip_connected()) { - s = (struct httpd_state *)memb_alloc(&conns); - if(s == NULL) { - uip_abort(); - return; - } - tcp_markconn(uip_conn, s); - PSOCK_INIT(&s->sin, s->inputbuf, sizeof(s->inputbuf) - 1); - PSOCK_INIT(&s->sout, s->inputbuf, sizeof(s->inputbuf) - 1); - PT_INIT(&s->outputpt); - s->state = STATE_WAITING; - timer_set(&s->timer, CLOCK_SECOND * 10); - handle_connection(s); - } else if(s != NULL) { - if(uip_poll()) { - if(timer_expired(&s->timer)) { - uip_abort(); - } - } else { - timer_reset(&s->timer); - } - handle_connection(s); - } else { - uip_abort(); - } -} -/*---------------------------------------------------------------------------*/ -void -httpd_init(void) -{ - tcp_listen(UIP_HTONS(80)); - memb_init(&conns); -} -/*---------------------------------------------------------------------------*/ diff --git a/platform/pc-6001/apps/webserver-mini/httpd-cfs.h b/platform/pc-6001/apps/webserver-mini/httpd-cfs.h deleted file mode 100644 index 868c39d03..000000000 --- a/platform/pc-6001/apps/webserver-mini/httpd-cfs.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2001, Adam Dunkels. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This file is part of the uIP TCP/IP stack. - * - * - */ - -#ifndef __HTTPD_CFS_H__ -#define __HTTPD_CFS_H__ - -#include "contiki-net.h" - -struct httpd_state { - struct timer timer; - struct psock sin, sout; - struct pt outputpt; - char inputbuf[50]; - char outputbuf[UIP_TCP_MSS]; - char filename[20]; - char state; - int fd; - int len; -}; - - -void httpd_init(void); -void httpd_appcall(void *state); - -#endif /* __HTTPD_CFS_H__ */ diff --git a/platform/pc-6001/apps/webserver-mini/httpd-cgi.c b/platform/pc-6001/apps/webserver-mini/httpd-cgi.c deleted file mode 100644 index ec4ed0095..000000000 --- a/platform/pc-6001/apps/webserver-mini/httpd-cgi.c +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Copyright (c) 2001, Adam Dunkels. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This file is part of the uIP TCP/IP stack. - * - * - */ - -/* - * This file includes functions that are called by the web server - * scripts. The functions takes no argument, and the return value is - * interpreted as follows. A zero means that the function did not - * complete and should be invoked for the next packet as well. A - * non-zero value indicates that the function has completed and that - * the web server should move along to the next script line. - * - */ - - -#include "contiki-net.h" -#include "httpd.h" -#include "httpd-cgi.h" -#include "httpd-fs.h" - -#include "lib/petsciiconv.h" - -#include -#include - - -static struct httpd_cgi_call *calls = NULL; - -/*struct cgifunction { - char *name; - httpd_cgifunction function; -}; - -static struct cgifunction cgitab[] = { - {"file-stats", file_stats}, - {"tcp-connections", tcp_stats}, - {"processes", processes}, - {NULL, NULL} - };*/ - - -static const char closed[] = /* "CLOSED",*/ -{0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0}; -static const char syn_rcvd[] = /* "SYN-RCVD",*/ -{0x53, 0x59, 0x4e, 0x2d, 0x52, 0x43, 0x56, - 0x44, 0}; -static const char syn_sent[] = /* "SYN-SENT",*/ -{0x53, 0x59, 0x4e, 0x2d, 0x53, 0x45, 0x4e, - 0x54, 0}; -static const char established[] = /* "ESTABLISHED",*/ -{0x45, 0x53, 0x54, 0x41, 0x42, 0x4c, 0x49, 0x53, 0x48, - 0x45, 0x44, 0}; -static const char fin_wait_1[] = /* "FIN-WAIT-1",*/ -{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49, - 0x54, 0x2d, 0x31, 0}; -static const char fin_wait_2[] = /* "FIN-WAIT-2",*/ -{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49, - 0x54, 0x2d, 0x32, 0}; -static const char closing[] = /* "CLOSING",*/ -{0x43, 0x4c, 0x4f, 0x53, 0x49, - 0x4e, 0x47, 0}; -static const char time_wait[] = /* "TIME-WAIT,"*/ -{0x54, 0x49, 0x4d, 0x45, 0x2d, 0x57, 0x41, - 0x49, 0x54, 0}; -static const char last_ack[] = /* "LAST-ACK"*/ -{0x4c, 0x41, 0x53, 0x54, 0x2d, 0x41, 0x43, - 0x4b, 0}; -static const char none[] = "NONE"; -static const char init[] = "INIT"; -static const char running[] = "RUNNING"; -static const char needs_poll[] = "NEEDS POLL"; - -static const char *states[] = { - closed, - syn_rcvd, - syn_sent, - established, - fin_wait_1, - fin_wait_2, - closing, - time_wait, - last_ack, - none, - init, - running, - needs_poll}; - - -/*---------------------------------------------------------------------------*/ -static -PT_THREAD(nullfunction(struct httpd_state *s, char *ptr)) -{ - PSOCK_BEGIN(&s->sout); - PSOCK_END(&s->sout); -} -/*---------------------------------------------------------------------------*/ -httpd_cgifunction -httpd_cgi(char *name) -{ - struct httpd_cgi_call *f; - - /* Find the matching name in the table, return the function. */ - for(f = calls; f != NULL; f = f->next) { - if(strncmp(f->name, name, strlen(f->name)) == 0) { - return f->function; - } - } - return nullfunction; -} -/*---------------------------------------------------------------------------*/ -static unsigned short -generate_file_stats(void *arg) -{ - char *f = (char *)arg; - return sprintf((char *)uip_appdata, "%5u", httpd_fs_count(f)); -} -/*---------------------------------------------------------------------------*/ -static -PT_THREAD(file_stats(struct httpd_state *s, char *ptr)) -{ - PSOCK_BEGIN(&s->sout); - - PSOCK_GENERATOR_SEND(&s->sout, generate_file_stats, (void *) (strchr(ptr, ' ') + 1)); - - PSOCK_END(&s->sout); -} -/*---------------------------------------------------------------------------*/ -static unsigned short -make_tcp_stats(void *arg) -{ - struct uip_conn *conn; - struct httpd_state *s = (struct httpd_state *)arg; - - conn = &uip_conns[s->u.count]; - return sprintf((char *)uip_appdata, - "%d%u.%u.%u.%u:%u%s%u%u%c %c\r\n", - uip_htons(conn->lport), - conn->ripaddr.u8[0], - conn->ripaddr.u8[1], - conn->ripaddr.u8[2], - conn->ripaddr.u8[3], - uip_htons(conn->rport), - states[conn->tcpstateflags & UIP_TS_MASK], - conn->nrtx, - conn->timer, - (uip_outstanding(conn))? '*':' ', - (uip_stopped(conn))? '!':' '); -} -/*---------------------------------------------------------------------------*/ -static -PT_THREAD(tcp_stats(struct httpd_state *s, char *ptr)) -{ - - PSOCK_BEGIN(&s->sout); - - for(s->u.count = 0; s->u.count < UIP_CONNS; ++s->u.count) { - if((uip_conns[s->u.count].tcpstateflags & UIP_TS_MASK) != UIP_CLOSED) { - PSOCK_GENERATOR_SEND(&s->sout, make_tcp_stats, s); - } - } - - PSOCK_END(&s->sout); -} -/*---------------------------------------------------------------------------*/ -static unsigned short -make_processes(void *p) -{ - char name[40]; - - strncpy(name, PROCESS_NAME_STRING((struct process *)p), 40); - petsciiconv_toascii(name, 40); - - return sprintf((char *)uip_appdata, - "%p%s%p%s\r\n", - p, name, - (char *)((struct process *)p)->thread, - states[9 + ((struct process *)p)->state]); -} -/*---------------------------------------------------------------------------*/ -static -PT_THREAD(processes(struct httpd_state *s, char *ptr)) -{ - PSOCK_BEGIN(&s->sout); - for(s->u.ptr = PROCESS_LIST(); s->u.ptr != NULL; s->u.ptr = ((struct process *)s->u.ptr)->next) { - PSOCK_GENERATOR_SEND(&s->sout, make_processes, s->u.ptr); - } - PSOCK_END(&s->sout); -} -/*---------------------------------------------------------------------------*/ -void -httpd_cgi_add(struct httpd_cgi_call *c) -{ - struct httpd_cgi_call *l; - - c->next = NULL; - if(calls == NULL) { - calls = c; - } else { - for(l = calls; l->next != NULL; l = l->next); - l->next = c; - } -} -/*---------------------------------------------------------------------------*/ - -HTTPD_CGI_CALL(file, "file-stats", file_stats); -HTTPD_CGI_CALL(tcp, "tcp-connections", tcp_stats); -HTTPD_CGI_CALL(proc, "processes", processes); - -void -httpd_cgi_init(void) -{ - httpd_cgi_add(&file); - httpd_cgi_add(&tcp); - httpd_cgi_add(&proc); -} -/*---------------------------------------------------------------------------*/ diff --git a/platform/pc-6001/apps/webserver-mini/httpd-cgi.h b/platform/pc-6001/apps/webserver-mini/httpd-cgi.h deleted file mode 100644 index 21b337a82..000000000 --- a/platform/pc-6001/apps/webserver-mini/httpd-cgi.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2001, Adam Dunkels. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This file is part of the uIP TCP/IP stack. - * - * - */ - -#ifndef __HTTPD_CGI_H__ -#define __HTTPD_CGI_H__ - -#include "contiki.h" -#include "httpd.h" - -typedef PT_THREAD((* httpd_cgifunction)(struct httpd_state *, char *)); - -httpd_cgifunction httpd_cgi(char *name); - -struct httpd_cgi_call { - struct httpd_cgi_call *next; - const char *name; - httpd_cgifunction function; -}; - -void httpd_cgi_add(struct httpd_cgi_call *c); - -#define HTTPD_CGI_CALL(name, str, function) \ -static struct httpd_cgi_call name = {NULL, str, function} - -void httpd_cgi_init(void); -#endif /* __HTTPD_CGI_H__ */ diff --git a/platform/pc-6001/apps/webserver-mini/httpd-fs.c b/platform/pc-6001/apps/webserver-mini/httpd-fs.c deleted file mode 100644 index a07b79b7d..000000000 --- a/platform/pc-6001/apps/webserver-mini/httpd-fs.c +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2001, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "contiki-net.h" -#include "httpd.h" -#include "httpd-fs.h" -#include "httpd-fsdata.h" - -#include "httpd-fsdata.c" -#include "ctk/libconio_arch-small.h" - -#if HTTPD_FS_STATISTICS -static uint16_t count[HTTPD_FS_NUMFILES]; -#endif /* HTTPD_FS_STATISTICS */ - -/*-----------------------------------------------------------------------------------*/ -static uint8_t -httpd_fs_strcmp(const char *str1, const char *str2) -{ - uint8_t i; - i = 0; - -loop: - if(str2[i] == 0 || - str1[i] == '\r' || - str1[i] == '\n') { - return 0; - } - - if(str1[i] != str2[i]) { - return 1; - } - - ++i; - goto loop; -} -/*-----------------------------------------------------------------------------------*/ -int -httpd_fs_open(const char *name, struct httpd_fs_file *file) -{ -#if HTTPD_FS_STATISTICS - uint16_t i = 0; -#endif /* HTTPD_FS_STATISTICS */ - char* ch; - struct httpd_fsdata_file_noconst *f; - - libputs_arch(name); - for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT; - f != NULL; - f = (struct httpd_fsdata_file_noconst *)f->next) { - - if(httpd_fs_strcmp(name, f->name) == 0) { - file->data = f->data; - file->len = f->len; -#if HTTPD_FS_STATISTICS - ++count[i]; -#endif /* HTTPD_FS_STATISTICS */ - return 1; - } -#if HTTPD_FS_STATISTICS - ++i; -#endif /* HTTPD_FS_STATISTICS */ - - } - return 0; -} -/*-----------------------------------------------------------------------------------*/ -void -httpd_fs_init(void) -{ -#if HTTPD_FS_STATISTICS - uint16_t i; - for(i = 0; i < HTTPD_FS_NUMFILES; i++) { - count[i] = 0; - } -#endif /* HTTPD_FS_STATISTICS */ -} -/*-----------------------------------------------------------------------------------*/ -#if HTTPD_FS_STATISTICS -uint16_t -httpd_fs_count(char *name) -{ - struct httpd_fsdata_file_noconst *f; - uint16_t i; - - i = 0; - for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT; - f != NULL; - f = (struct httpd_fsdata_file_noconst *)f->next) { - - if(httpd_fs_strcmp(name, f->name) == 0) { - return count[i]; - } - ++i; - } - return 0; -} -#endif /* HTTPD_FS_STATISTICS */ -/*-----------------------------------------------------------------------------------*/ diff --git a/platform/pc-6001/apps/webserver-mini/httpd-fs.h b/platform/pc-6001/apps/webserver-mini/httpd-fs.h deleted file mode 100644 index c8cab68d3..000000000 --- a/platform/pc-6001/apps/webserver-mini/httpd-fs.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2001, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __HTTPD_FS_H__ -#define __HTTPD_FS_H__ - -#include "contiki-net.h" - -#define HTTPD_FS_STATISTICS 1 - -struct httpd_fs_file { - char *data; - int len; -}; - -/* file must be allocated by caller and will be filled in - by the function. */ -int httpd_fs_open(const char *name, struct httpd_fs_file *file); - -#ifdef HTTPD_FS_STATISTICS -#if HTTPD_FS_STATISTICS == 1 -uint16_t httpd_fs_count(char *name); -#endif /* HTTPD_FS_STATISTICS */ -#endif /* HTTPD_FS_STATISTICS */ - -void httpd_fs_init(void); - -#endif /* __HTTPD_FS_H__ */ diff --git a/platform/pc-6001/apps/webserver-mini/httpd-fs/404.html b/platform/pc-6001/apps/webserver-mini/httpd-fs/404.html deleted file mode 100644 index 51e053a23..000000000 --- a/platform/pc-6001/apps/webserver-mini/httpd-fs/404.html +++ /dev/null @@ -1 +0,0 @@ -

404 - file not found

Contiki PC-6001 \ No newline at end of file diff --git a/platform/pc-6001/apps/webserver-mini/httpd-fs/index.html b/platform/pc-6001/apps/webserver-mini/httpd-fs/index.html deleted file mode 100644 index 3255ed2d8..000000000 --- a/platform/pc-6001/apps/webserver-mini/httpd-fs/index.html +++ /dev/null @@ -1 +0,0 @@ -Contiki on PC-6001

This website is being served by PC-6001 Contiki!

Front page
Network connections
System processes
\ No newline at end of file diff --git a/platform/pc-6001/apps/webserver-mini/httpd-fsdata.c b/platform/pc-6001/apps/webserver-mini/httpd-fsdata.c deleted file mode 100644 index 2cfcf9801..000000000 --- a/platform/pc-6001/apps/webserver-mini/httpd-fsdata.c +++ /dev/null @@ -1,50 +0,0 @@ -static const unsigned char data_404_html[] = { - /* /404.html */ - 0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0, - 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0x3c, 0x62, 0x6f, 0x64, - 0x79, 0x3e, 0x3c, 0x68, 0x31, 0x3e, 0x34, 0x30, 0x34, 0x20, - 0x2d, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x6e, 0x6f, 0x74, - 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x3c, 0x2f, 0x68, 0x31, - 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, - 0x2f, 0x22, 0x3e, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, - 0x20, 0x50, 0x43, 0x2d, 0x36, 0x30, 0x30, 0x31, 0x3c, 0x2f, - 0x61, 0x3e, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0x3c, - 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0}; - -static const unsigned char data_index_html[] = { - /* /index.html */ - 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0, - 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0x3c, 0x68, 0x65, 0x61, - 0x64, 0x3e, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x43, - 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x20, 0x6f, 0x6e, 0x20, - 0x50, 0x43, 0x2d, 0x36, 0x30, 0x30, 0x31, 0x3c, 0x2f, 0x74, - 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x3c, 0x2f, 0x68, 0x65, 0x61, - 0x64, 0x3e, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0x3c, 0x68, - 0x33, 0x3e, 0x54, 0x68, 0x69, 0x73, 0x20, 0x77, 0x65, 0x62, - 0x73, 0x69, 0x74, 0x65, 0x20, 0x69, 0x73, 0x20, 0x62, 0x65, - 0x69, 0x6e, 0x67, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, - 0x20, 0x62, 0x79, 0x20, 0x50, 0x43, 0x2d, 0x36, 0x30, 0x30, - 0x31, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x21, - 0x3c, 0x2f, 0x68, 0x33, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, - 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x22, 0x3e, 0x46, 0x72, 0x6f, - 0x6e, 0x74, 0x20, 0x70, 0x61, 0x67, 0x65, 0x3c, 0x2f, 0x61, - 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, - 0x65, 0x66, 0x3d, 0x22, 0x74, 0x63, 0x70, 0x2e, 0x73, 0x68, - 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x4e, 0x65, 0x74, 0x77, 0x6f, - 0x72, 0x6b, 0x20, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x62, - 0x72, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, - 0x22, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, - 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x53, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x20, 0x70, 0x72, 0x6f, 0x63, 0x65, - 0x73, 0x73, 0x65, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x62, - 0x72, 0x3e, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0x3c, - 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0}; - -const struct httpd_fsdata_file file_404_html[] = {{NULL, data_404_html, data_404_html + 10, sizeof(data_404_html) - 10}}; - -const struct httpd_fsdata_file file_index_html[] = {{file_404_html, data_index_html, data_index_html + 12, sizeof(data_index_html) - 12}}; - -#define HTTPD_FS_ROOT file_index_html - -#define HTTPD_FS_NUMFILES 2 diff --git a/platform/pc-6001/apps/webserver-mini/httpd-fsdata.h b/platform/pc-6001/apps/webserver-mini/httpd-fsdata.h deleted file mode 100644 index 5d27e299d..000000000 --- a/platform/pc-6001/apps/webserver-mini/httpd-fsdata.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2001, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __HTTPD_FSDATA_H__ -#define __HTTPD_FSDATA_H__ - -#include "contiki-net.h" - -struct httpd_fsdata_file { - const struct httpd_fsdata_file *next; - const char *name; - const char *data; - const int len; -#ifdef HTTPD_FS_STATISTICS -#if HTTPD_FS_STATISTICS == 1 - uint16_t count; -#endif /* HTTPD_FS_STATISTICS */ -#endif /* HTTPD_FS_STATISTICS */ -}; - -struct httpd_fsdata_file_noconst { - struct httpd_fsdata_file *next; - char *name; - char *data; - int len; -#ifdef HTTPD_FS_STATISTICS -#if HTTPD_FS_STATISTICS == 1 - uint16_t count; -#endif /* HTTPD_FS_STATISTICS */ -#endif /* HTTPD_FS_STATISTICS */ -}; - -#endif /* __HTTPD_FSDATA_H__ */ diff --git a/platform/pc-6001/apps/webserver-mini/httpd.c b/platform/pc-6001/apps/webserver-mini/httpd.c deleted file mode 100644 index c9058b2a9..000000000 --- a/platform/pc-6001/apps/webserver-mini/httpd.c +++ /dev/null @@ -1,343 +0,0 @@ -/* - * Copyright (c) 2004, Adam Dunkels. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - * Author: Adam Dunkels - * - */ - -#include - -#include "contiki-net.h" - -#include "webserver-nogui.h" -#include "httpd-fs.h" -#include "httpd-cgi.h" -#include "http-strings.h" - -#include "httpd.h" -#include "ctk/libconio_arch-small.h" - -#define STATE_WAITING 0 -#define STATE_OUTPUT 1 - -#define SEND_STRING(s, str) PSOCK_SEND(s, str, (unsigned int)strlen(str)) -MEMB(conns, struct httpd_state, 4); - -#define ISO_nl 0x0a -#define ISO_space 0x20 -#define ISO_bang 0x21 -#define ISO_percent 0x25 -#define ISO_period 0x2e -#define ISO_slash 0x2f -#define ISO_colon 0x3a - -/*---------------------------------------------------------------------------*/ -static unsigned short -generate(void *state) -{ - struct httpd_state *s = (struct httpd_state *)state; - - if(s->file.len > uip_mss()) { - s->len = uip_mss(); - } else { - s->len = s->file.len; - } - memcpy(uip_appdata, s->file.data, s->len); - - return s->len; -} -/*---------------------------------------------------------------------------*/ -static -PT_THREAD(send_file(struct httpd_state *s)) -{ - PSOCK_BEGIN(&s->sout); - - do { - PSOCK_GENERATOR_SEND(&s->sout, generate, s); - s->file.len -= s->len; - s->file.data += s->len; - } while(s->file.len > 0); - - PSOCK_END(&s->sout); -} -/*---------------------------------------------------------------------------*/ -static -PT_THREAD(send_part_of_file(struct httpd_state *s)) -{ - PSOCK_BEGIN(&s->sout); - - PSOCK_SEND(&s->sout, s->file.data, s->len); - - PSOCK_END(&s->sout); -} -/*---------------------------------------------------------------------------*/ -#if HTTPD_CONF_SCRIPT -static void -next_scriptstate(struct httpd_state *s) -{ - char *p; - - if((p = strchr(s->scriptptr, ISO_nl)) != NULL) { - p += 1; - s->scriptlen -= (unsigned short)(p - s->scriptptr); - s->scriptptr = p; - } else { - s->scriptlen = 0; - } - /* char *p; - p = strchr(s->scriptptr, ISO_nl) + 1; - s->scriptlen -= (unsigned short)(p - s->scriptptr); - s->scriptptr = p;*/ -} -/*---------------------------------------------------------------------------*/ -static -PT_THREAD(handle_script(struct httpd_state *s)) -{ - char *ptr; - - PT_BEGIN(&s->scriptpt); - - while(s->file.len > 0) { - - /* Check if we should start executing a script. */ - if(*s->file.data == ISO_percent && - *(s->file.data + 1) == ISO_bang) { - s->scriptptr = s->file.data + 3; - s->scriptlen = s->file.len - 3; - if(*(s->scriptptr - 1) == ISO_colon) { - httpd_fs_open(s->scriptptr + 1, &s->file); - PT_WAIT_THREAD(&s->scriptpt, send_file(s)); -#if HTTPD_CONF_CGI - } else { - PT_WAIT_THREAD(&s->scriptpt, - httpd_cgi(s->scriptptr)(s, s->scriptptr)); -#endif /* HTTPD_CONF_CGI */ - } - next_scriptstate(s); - - /* The script is over, so we reset the pointers and continue - sending the rest of the file. */ - s->file.data = s->scriptptr; - s->file.len = s->scriptlen; - } else { - /* See if we find the start of script marker in the block of HTML - to be sent. */ - - if(s->file.len > uip_mss()) { - s->len = uip_mss(); - } else { - s->len = s->file.len; - } - - if(*s->file.data == ISO_percent) { - ptr = strchr(s->file.data + 1, ISO_percent); - } else { - ptr = strchr(s->file.data, ISO_percent); - } - if(ptr != NULL && - ptr != s->file.data) { - s->len = (int)(ptr - s->file.data); - if(s->len >= uip_mss()) { - s->len = uip_mss(); - } - } - PT_WAIT_THREAD(&s->scriptpt, send_part_of_file(s)); - s->file.data += s->len; - s->file.len -= s->len; - } - } - - PT_END(&s->scriptpt); -} -#endif /* HTTPD_CONF_SCRIPT */ -/*---------------------------------------------------------------------------*/ -static -PT_THREAD(send_headers(struct httpd_state *s, const char *statushdr)) -{ - char *ptr; - - PSOCK_BEGIN(&s->sout); - - SEND_STRING(&s->sout, statushdr); - - ptr = strrchr(s->filename, ISO_period); - if(ptr == NULL) { - SEND_STRING(&s->sout, http_content_type_binary); - } else if(strncmp(http_html, ptr, 5) == 0 || - strncmp(http_shtml, ptr, 6) == 0) { - SEND_STRING(&s->sout, http_content_type_html); -#if 0 - } else if(strncmp(http_css, ptr, 4) == 0) { - SEND_STRING(&s->sout, http_content_type_css); - } else if(strncmp(http_png, ptr, 4) == 0) { - SEND_STRING(&s->sout, http_content_type_png); - } else if(strncmp(http_gif, ptr, 4) == 0) { - SEND_STRING(&s->sout, http_content_type_gif); - } else if(strncmp(http_jpg, ptr, 4) == 0) { - SEND_STRING(&s->sout, http_content_type_jpg); -#endif - } else { - SEND_STRING(&s->sout, http_content_type_plain); - } - PSOCK_END(&s->sout); -} -/*---------------------------------------------------------------------------*/ -static -PT_THREAD(handle_output(struct httpd_state *s)) -{ - char *ptr; - - PT_BEGIN(&s->outputpt); - - if(!httpd_fs_open(s->filename, &s->file)) { - httpd_fs_open(http_404_html, &s->file); - PT_WAIT_THREAD(&s->outputpt, - send_headers(s, - http_header_404)); - PT_WAIT_THREAD(&s->outputpt, - send_file(s)); - } else { - PT_WAIT_THREAD(&s->outputpt, - send_headers(s, - http_header_200)); - ptr = strchr(s->filename, ISO_period); -#if HTTPD_CONF_SCRIPT - if(ptr != NULL && strncmp(ptr, http_shtml, 6) == 0) { - PT_INIT(&s->scriptpt); - PT_WAIT_THREAD(&s->outputpt, handle_script(s)); - } else { - PT_WAIT_THREAD(&s->outputpt, - send_file(s)); - } -#else /* HTTPD_CONF_SCRIPT */ - PT_WAIT_THREAD(&s->outputpt, - send_file(s)); -#endif /* HTTPD_CONF_SCRIPT */ - } - PSOCK_CLOSE(&s->sout); - PT_END(&s->outputpt); -} -/*---------------------------------------------------------------------------*/ -static -PT_THREAD(handle_input(struct httpd_state *s)) -{ - PSOCK_BEGIN(&s->sin); - - PSOCK_READTO(&s->sin, ISO_space); - - if(strncmp(s->inputbuf, http_get, 4) != 0) { - PSOCK_CLOSE_EXIT(&s->sin); - } - PSOCK_READTO(&s->sin, ISO_space); - - if(s->inputbuf[0] != ISO_slash) { - PSOCK_CLOSE_EXIT(&s->sin); - } - - if(s->inputbuf[1] == ISO_space) { - strncpy(s->filename, http_index_html, sizeof(s->filename)); - } else { - s->inputbuf[PSOCK_DATALEN(&s->sin) - 1] = 0; - strncpy(s->filename, &s->inputbuf[0], sizeof(s->filename)); - } - - libputs_arch(s->filename); - - s->state = STATE_OUTPUT; - - while(1) { - PSOCK_READTO(&s->sin, ISO_nl); - - if(strncmp(s->inputbuf, http_referer, 8) == 0) { - s->inputbuf[PSOCK_DATALEN(&s->sin) - 2] = 0; - } - } - - PSOCK_END(&s->sin); -} -/*---------------------------------------------------------------------------*/ -static void -handle_connection(struct httpd_state *s) -{ - handle_input(s); - if(s->state == STATE_OUTPUT) { - handle_output(s); - } -} -/*---------------------------------------------------------------------------*/ -void -httpd_appcall(void *state) -{ - struct httpd_state *s = (struct httpd_state *)state; - - if(uip_closed() || uip_aborted() || uip_timedout()) { - if(s != NULL) { - memb_free(&conns, s); - } - } else if(uip_connected()) { - s = (struct httpd_state *)memb_alloc(&conns); - if(s == NULL) { - uip_abort(); - return; - } - tcp_markconn(uip_conn, s); - PSOCK_INIT(&s->sin, s->inputbuf, sizeof(s->inputbuf) - 1); - PSOCK_INIT(&s->sout, s->inputbuf, sizeof(s->inputbuf) - 1); - PT_INIT(&s->outputpt); - s->state = STATE_WAITING; - /* timer_set(&s->timer, CLOCK_SECOND * 100);*/ - s->timer = 0; - handle_connection(s); - } else if(s != NULL) { - if(uip_poll()) { - ++s->timer; - if(s->timer >= 20) { - uip_abort(); - memb_free(&conns, s); - } - } else { - s->timer = 0; - } - handle_connection(s); - } else { - uip_abort(); - } -} -/*---------------------------------------------------------------------------*/ -void -httpd_init(void) -{ - tcp_listen(UIP_HTONS(80)); - memb_init(&conns); -#if HTTPD_CONF_CGI - httpd_cgi_init(); -#endif /* HTTPD_CONF_CGI */ -} -/*---------------------------------------------------------------------------*/ diff --git a/platform/pc-6001/apps/webserver-mini/httpd.h b/platform/pc-6001/apps/webserver-mini/httpd.h deleted file mode 100644 index 68d5e6fc6..000000000 --- a/platform/pc-6001/apps/webserver-mini/httpd.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2001-2005, Adam Dunkels. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This file is part of the uIP TCP/IP stack. - * - * - */ - -#ifndef __HTTPD_H__ -#define __HTTPD_H__ - - -#include "contiki-net.h" -#include "httpd-fs.h" - -#ifndef HTTPD_CONF_CGI -#define HTTPD_CONF_CGI 1 -#endif -#ifndef HTTPD_CONF_SCRIPT -#define HTTPD_CONF_SCRIPT 1 -#endif - -struct httpd_state { - unsigned char timer; - struct psock sin, sout; - struct pt outputpt -#if HTTPD_CONF_SCRIPT - , scriptpt; -#else - ; -#endif /* HTTPD_CONF_SCRIPT */ - char inputbuf[50]; - char filename[20]; - char state; - struct httpd_fs_file file; - int len; -#if HTTPD_CONF_SCRIPT - char *scriptptr; - int scriptlen; -#endif /* HTTPD_CONF_SCRIPT */ - union { - unsigned short count; - void *ptr; - } u; -}; - - -void httpd_init(void); -void httpd_appcall(void *state); - -#endif /* __HTTPD_H__ */ diff --git a/platform/pc-6001/apps/webserver-mini/webserver-nogui.c b/platform/pc-6001/apps/webserver-mini/webserver-nogui.c deleted file mode 100644 index b8c9df139..000000000 --- a/platform/pc-6001/apps/webserver-mini/webserver-nogui.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2002, Adam Dunkels. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This file is part of the Contiki OS. - * - * - */ - -#include -#include - -#include "contiki.h" - -#include "http-strings.h" -#include "webserver-nogui.h" -#include "httpd.h" - -PROCESS(webserver_nogui_process, "Web server"); -/*---------------------------------------------------------------------------*/ -PROCESS_THREAD(webserver_nogui_process, ev, data) -{ - PROCESS_BEGIN(); - - httpd_init(); - - while(1) { - PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event); - httpd_appcall(data); - } - - PROCESS_END(); -} -/*---------------------------------------------------------------------------*/ diff --git a/platform/pc-6001/apps/webserver-mini/webserver-nogui.h b/platform/pc-6001/apps/webserver-mini/webserver-nogui.h deleted file mode 100644 index 551800615..000000000 --- a/platform/pc-6001/apps/webserver-mini/webserver-nogui.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2002, Adam Dunkels. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This file is part of the Contiki OS - * - * - */ -#ifndef __WEBSERVER_NOGUI_H__ -#define __WEBSERVER_NOGUI_H__ - -#include "contiki-net.h" - -PROCESS_NAME(webserver_nogui_process); - -#ifdef WEBSERVER_CONF_LOG_ENABLED -#define webserver_log(msg) webserver_log(msg) -#define webserver_log_file(requester, file) \ - webserver_log_file(requester, file) -void weblog_message(char *msg); -#else /* WEBSERVER_CONF_LOG_ENABLED */ -void weblog_message(char *msg); -#define webserver_log(msg) -#define webserver_log_file(requester, file) -#endif /* WEBSERVER_CONF_LOG_ENABLED */ - -#endif /* __WEBSERVER_H__ */ diff --git a/platform/pc-6001/contiki-client-main.c b/platform/pc-6001/contiki-client-main.c deleted file mode 100644 index ae09e9196..000000000 --- a/platform/pc-6001/contiki-client-main.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2007, Takahide Matsutsuka. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - */ - -/* - * \file - * This is a sample main file with slip network. - * \author - * Takahide Matsutsuka - */ - -//#define WITH_LOADER_ARCH 1 - -#include "contiki.h" - -/* devices */ -#include "net/uip.h" -#include "net/uip-fw-drv.h" -#include "dev/slip.h" -#include "dev/rs232.h" -#include "sys/process.h" - -/* desktop programs */ -#include "program-handler.h" -//#include "process-list-dsc.h" - -/* network programs */ -#include "netconf-dsc.h" -#include "www-dsc.h" -#include "telnet-dsc.h" -//#include "dhcp-dsc.h" -#include "email-dsc.h" -#include "ftp-dsc.h" -#include "irc-dsc.h" - - -/*---------------------------------------------------------------------------*/ -/* inteface */ -static struct uip_fw_netif slipif = - {UIP_FW_NETIF(0, 0, 0, 0, 0, 0, 0, 0, slip_send)}; - -/* ip address of contiki */ -const uip_ipaddr_t hostaddr = { { 10, 0, 1, 10 } }; - -PROCESS_NAME(netconf_process); -PROCESS_NAME(email_process); -PROCESS_NAME(www_process); -PROCESS_NAME(simpletelnet_process); -PROCESS_NAME(ftp_process); -PROCESS_NAME(irc_process); - -/*---------------------------------------------------------------------------*/ -int -main(void) -{ - /* initialize process manager. */ - process_init(); - - uip_init(); - uip_sethostaddr(&hostaddr); - uip_fw_default(&slipif); - - /* start services */ - process_start(&etimer_process, NULL); - process_start(&ctk_process, NULL); -// process_start(&program_handler_process, NULL); - process_start(&tcpip_process, NULL); - process_start(&slip_process, NULL); - process_start(&uip_fw_process, NULL); - process_start(&rs232_process, NULL); - -// process_start(&email_process, NULL); -// process_start(&www_process, NULL); -// process_start(&ftp_process, NULL); -// process_start(&irc_process, NULL); - -// process_start(&netconf_process, NULL); - process_start(&simpletelnet_process, NULL); - -#if 0 - /* register programs to the program handler */ - program_handler_add(&processes_dsc, "Processes", 1); - program_handler_add(&netconf_dsc, "Network conf", 1); - program_handler_add(&email_dsc, "E-mail", 1); - program_handler_add(&irc_dsc, "IRC", 1); - program_handler_add(&vnc_dsc, "VNC client", 1); - program_handler_add(&dhcp_dsc, "DHCP client", 1); -#endif - while(1) { - process_run(); - etimer_request_poll(); - } -} diff --git a/platform/pc-6001/contiki-conf.h b/platform/pc-6001/contiki-conf.h deleted file mode 100644 index 8f20e2c5e..000000000 --- a/platform/pc-6001/contiki-conf.h +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (c) 2007, Takahide Matsutsuka. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - */ - -/* - * \file - * contiki-conf.h - * A set of configurations of contiki for PC-6001 family. - * \author - * Takahide Matsutsuka - */ - -#ifndef __CONTIKI_CONF_H__ -#define __CONTIKI_CONF_H__ - -#include "z80def.h" -#include "sys/cc.h" -#include -#include -#include "ctk/ctk_arch.h" -#include "strcasecmp.h" -#include "log.h" - -/* Time type. */ -typedef unsigned long clock_time_t; - -/* Defines tick counts for a second. */ -#define CLOCK_CONF_SECOND 1024 - -#define rtimer_arch_now() clock_time() - -/* Memory filesystem RAM size. */ -#define CFS_RAM_CONF_SIZE 512 - -/* Logging.. */ -#define LOG_CONF_ENABLED 0 - -#undef MALLOC_TEST - -/*---------------------------------------------------------------------------*/ -/* screen properties */ -#define LIBCONIO_CONF_ATTRIBUTES_ENABLED -#if defined(ARCH_PC6001MK2) -#define LIBCONIO_VRAM_ATTR 0x4000 -#define LIBCONIO_VRAM_CHAR 0x4400 -#define LIBCONIO_CONF_SCREEN_WIDTH 40 -#define LIBCONIO_CONF_SCREEN_HEIGHT 20 -#define LIBCONIO_COLOR_NORMAL 0x0f -#define LIBCONIO_COLOR_REVERSED 0x70 -#elif (defined(ARCH_PC6001) || defined(ARCH_PC6001A)) && defined(MEMORY_16K) -#define LIBCONIO_VRAM_ATTR 0xc000 -#define LIBCONIO_VRAM_CHAR 0xc200 -#define LIBCONIO_CONF_SCREEN_WIDTH 32 -#define LIBCONIO_CONF_SCREEN_HEIGHT 16 -#define LIBCONIO_COLOR_NORMAL 0x20 -#define LIBCONIO_COLOR_REVERSED 0x21 -#elif (defined(ARCH_PC6001) || defined(ARCH_PC6001A)) && (defined(MEMORY_32K) || defined(MEMORY_ROM)) -#define LIBCONIO_VRAM_ATTR 0x8000 -#define LIBCONIO_VRAM_CHAR 0x8200 -#define LIBCONIO_CONF_SCREEN_WIDTH 32 -#define LIBCONIO_CONF_SCREEN_HEIGHT 16 -#define LIBCONIO_COLOR_NORMAL 0x20 -#define LIBCONIO_COLOR_REVERSED 0x21 -#else -#error Specify appropriate ARCH & MEMORY combination -#endif /* ARCH_PC6001MK2 */ - -#if 0 /* ctk-conio case */ -#define SCREENCOLOR 0x20 -#define BORDERCOLOR 0x20 -#define WIDGETCOLOR 0x20 -#define WIDGETCOLOR_FWIN 0x20 -#define BACKGROUNDCOLOR 0x20 -#define DIALOGCOLOR 0x20 -#define WINDOWCOLOR 0x20 -#define WINDOWCOLOR_FOCUS 0x21 -#define MENUCOLOR 0x21 -#define MENUCOLOR 0x21 -#define OPENMENUCOLOR 0x22 -#define ACTIVEMENUITEMCOLOR 0x23 -#define WIDGETCOLOR_HLINK 0x21 -#define WIDGETCOLOR_FOCUS 0x20 -#define WIDGETCOLOR_DIALOG 0x22 -#endif - -/* uIP configuration */ -#define UIP_CONF_MAX_CONNECTIONS 4 -#define UIP_CONF_MAX_LISTENPORTS 4 -#define UIP_CONF_BUFFER_SIZE 400 -#define UIP_CONF_BYTE_ORDER LITTLE_ENDIAN -#define UIP_CONF_TCP_SPLIT 0 -#define UIP_CONF_LOGGING 0 - -/* uses SLIP */ -#define UIP_CONF_UDP 0 -#define UIP_CONF_UDP_CHECKSUMS 0 -#define UIP_CONF_LLH_LEN 0 -#undef UIP_CONF_BROADCAST -#undef RS232_CONF_CALLBACK -/* #define RS232_CONF_CALLBACK serial_input_byte */ -#define slip_arch_init(ubr) rs232_arch_init(ubr) -#define slip_arch_writeb(c) rs232_arch_writeb(c) - -#ifdef WITH_LOADER_ARCH -//#define AUTOSTART_ENABLE 1 -#define LOADER_CONF_ARCH "loader_arch.h" -#endif /* WITH_LOADER_ARCH */ - -/*---------------------------------------------------------------------------*/ -/* Application specific configurations. */ - -/* Command shell */ -#define SHELL_GUI_CONF_XSIZE 26 -#define SHELL_GUI_CONF_YSIZE 10 - -/* Text editor */ -#define EDITOR_CONF_WIDTH 26 -#define EDITOR_CONF_HEIGHT 8 - -/* Process list */ -#define PROCESSLIST_CONF_HEIGHT 12 - -/* File dialog */ -#define FILES_CONF_HEIGHT 6 - -/* Shell */ -//#define SHELL_CONF_WITH_PROGRAM_HANDLER 1 - -/* Telnet */ -#define TELNET_CONF_WINDOW_WIDTH 30 -#define TELNET_CONF_WINDOW_HEIGHT 13 -//#define TELNET_CONF_TEXTAREA_HEIGHT 5 // TELNET_WINDOW_HEIGHT - 8 -//#define TELNET_CONF_ENTRY_WIDTH 22 // TELNET_WINDOW_WIDTH - 8 - -/* Telnetd */ -#define TELNETD_CONF_GUI 0 -#define SHELL_CONF_WITH_PROGRAM_HANDLER 0 - -/* Web server */ -#undef WEBSERVER_CONF_LOG_ENABLED -#define HTTPD_CONF_CGI 0 -#define HTTPD_CONF_SCRIPT 0 -#define HTTPD_CONF_STATISTICS 0 - -/* unused yet */ -#define VNC_CONF_REFRESH_ROWS 8 - -#define WWW_CONF_WEBPAGE_WIDTH 76 -#define WWW_CONF_WEBPAGE_HEIGHT 30 - -#endif /* __CONTIKI_CONF_H__ */ diff --git a/platform/pc-6001/contiki-desktop-main.c b/platform/pc-6001/contiki-desktop-main.c deleted file mode 100644 index 5389e3d96..000000000 --- a/platform/pc-6001/contiki-desktop-main.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2007, Takahide Matsutsuka. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - */ - -/* - * \file - * This is a sample main file with desktop. - * \author - * Takahide Matsutsuka - */ - -#include "contiki.h" - -#include "program-handler.h" -#include "about-dsc.h" -#include "calc-dsc.h" -#include "process-list-dsc.h" -#include "shell-dsc.h" -#include "mt-test-dsc.h" - -#if WITH_LOADER_ARCH -#include "directory-dsc.h" -#endif - -/*---------------------------------------------------------------------------*/ -int -main(void) -{ - /* initialize process manager. */ - process_init(); - - /* start services */ - process_start(&ctk_process, NULL); - process_start(&program_handler_process, NULL); - process_start(&etimer_process, NULL); - - /* register programs to the program handler */ -#if WITH_LOADER_ARCH - program_handler_add(&directory_dsc, "Directory", 1); - program_handler_add(&processes_dsc, "Processes", 1); - // program_handler_add(&shell_dsc, "Command shell", 1); -#else - program_handler_add(&processes_dsc, "Processes", 1); - program_handler_add(&mttest_dsc, "Multithread", 1); - program_handler_add(&calc_dsc, "Calculator", 1); - program_handler_add(&about_dsc, "About", 1); -// program_handler_add(&shell_dsc, "Command shell", 1); -#endif - - while(1) { - process_run(); - etimer_request_poll(); - } -} diff --git a/platform/pc-6001/contiki-loader-main.c b/platform/pc-6001/contiki-loader-main.c deleted file mode 100644 index 90ff4df76..000000000 --- a/platform/pc-6001/contiki-loader-main.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2007, Takahide Matsutsuka. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - */ - -/* - * \file - * This is a main file with loader. - * \author - * Takahide Matsutsuka - */ - -#include "contiki.h" - -#include "program-handler.h" -//#include "process-list-dsc.h" -//#include "shell-dsc.h" -//#include "directory-dsc.h" - -/*---------------------------------------------------------------------------*/ -int -main(void) -{ - /* initialize process manager. */ - process_init(); - - /* start services */ - process_start(&ctk_process, NULL); - process_start(&program_handler_process, NULL); - process_start(&etimer_process, NULL); - - /* register programs to the program handler */ - /* - program_handler_add(&directory_dsc, "Directory", 1); - program_handler_add(&processes_dsc, "Processes", 1); - program_handler_add(&shell_dsc, "Command shell", 1); - */ - while(1) { - process_run(); - etimer_request_poll(); - } -} diff --git a/platform/pc-6001/contiki-main.c b/platform/pc-6001/contiki-main.c deleted file mode 100644 index 1505d9a5a..000000000 --- a/platform/pc-6001/contiki-main.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2007, Takahide Matsutsuka. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - */ - -/* - * \file - * This is a main file for standard configuration. - * \author - * Takahide Matsutsuka - */ - -#include "contiki.h" -#include "ctk/ctk.h" - -#ifndef WITHOUT_GUI -#define CTK_PROCESS &ctk_process, -#else /* WITH_GUI */ -#define CTK_PROCESS -#endif /* WITH_GUI */ - -PROCINIT(CTK_PROCESS - &etimer_process); - -/*---------------------------------------------------------------------------*/ -int -main(void) -{ - /* initialize process manager. */ - process_init(); - autostart_start(autostart_processes); - - while(1) { - process_run(); - etimer_request_poll(); - } -} diff --git a/platform/pc-6001/contiki-minimal-main.c b/platform/pc-6001/contiki-minimal-main.c deleted file mode 100644 index 4fa3daa2f..000000000 --- a/platform/pc-6001/contiki-minimal-main.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2007, Takahide Matsutsuka. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - */ - -/* - * \file - * This is a minimal main file with desktop. - * \author - * Takahide Matsutsuka - */ - -#include "contiki.h" - -#include "program-handler.h" -#include "tinysample-dsc.h" - -PROCESS_NAME(tiny_process); -/*---------------------------------------------------------------------------*/ -int -main(void) -{ - /* initialize process manager. */ - process_init(); - - /* start services */ -// process_start(&ctk_process, NULL); -// process_start(&program_handler_process, NULL); - process_start(&etimer_process, NULL); - process_start(&tiny_process, NULL); - -// program_handler_add(&tiny_dsc, "Tiny", 1); - - while(1) { - process_run(); - etimer_request_poll(); - } -} diff --git a/platform/pc-6001/contiki-serial-main.c b/platform/pc-6001/contiki-serial-main.c deleted file mode 100644 index 0bb64b248..000000000 --- a/platform/pc-6001/contiki-serial-main.c +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2007, Takahide Matsutsuka. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - */ - -/* - * \file - * This is a sample main file with serial. - * \author - * Takahide Matsutsuka - */ - -#include "contiki.h" - -/* devices */ -#include "dev/serial-line.h" -#include "ctk/libconio_arch-small.h" - -#undef RS232_INTR -#ifdef RS232_INTR -void rs232_arch_writeb(uint8_t ch); -void rs232_arch_init(int (* callback)(unsigned char), unsigned long ubr); -#else -#include "dev/rs232.h" -#endif - -PROCESS(stest_process, "Serial test process"); -/*---------------------------------------------------------------------------*/ -static void -rs232_print(char* str) { - while (*str != 0) { - rs232_arch_writeb(*str++); - } -} -/*---------------------------------------------------------------------------*/ -static void -log(char* str) { - while (*str != 0) { - libputc_arch(*str++); - } -} -/*---------------------------------------------------------------------------*/ -PROCESS_THREAD(stest_process, ev, data) -{ - static struct etimer timer; - PROCESS_BEGIN(); - - clrscr_arch(); -#ifdef RS232_INTR - rs232_arch_init(serial_line_input_byte, 0); -#endif - - etimer_set(&timer, CLOCK_SECOND); - - log("Starting serial test process"); - while(1) { - PROCESS_WAIT_EVENT(); - - if (etimer_expired(&timer)) { - log("Sending serial data now"); - rs232_print("GNU's not Unix\n"); - etimer_reset(&timer); - } - - if(ev == serial_line_event_message) { - log(data); - } - } - - PROCESS_END(); -} -/*---------------------------------------------------------------------------*/ -void -main(void) -{ - /* initialize process manager. */ - process_init(); - - /* start services */ - process_start(&etimer_process, NULL); - process_start(&serial_line_process, NULL); -#ifndef RS232_INTR - process_start(&rs232_process, NULL); -#endif - process_start(&stest_process, NULL); - - while(1) { - process_run(); - etimer_request_poll(); - } -} diff --git a/platform/pc-6001/contiki-server-main.c b/platform/pc-6001/contiki-server-main.c deleted file mode 100644 index 3a53667bb..000000000 --- a/platform/pc-6001/contiki-server-main.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2007, Takahide Matsutsuka. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - */ - -/* - * \file - * This is a sample main file with slip network. - * \author - * Takahide Matsutsuka - */ - -#include "contiki.h" - -/* devices */ -#include "uip.h" -#include "dev/slip.h" -#include "dev/rs232.h" - -/* network server programs */ -#include "webserver-nogui.h" -#include "cmdd.h" -#include "telnetd.h" -#include "ctk/libconio_arch-small.h" - -/*---------------------------------------------------------------------------*/ -/* inteface */ -static struct uip_fw_netif slipif = - {UIP_FW_NETIF(0, 0, 0, 0, 0, 0, 0, 0, slip_send)}; - -/* ip address of contiki */ -const uip_ipaddr_t hostaddr = { { 10, 0, 1, 10 } }; - -/*---------------------------------------------------------------------------*/ -int -main(void) -{ - /* initialize process manager. */ - process_init(); - - clrscr_arch(); - uip_init(); - uip_sethostaddr(&hostaddr); - uip_fw_default(&slipif); - - /* start services */ - process_start(&etimer_process, NULL); - process_start(&tcpip_process, NULL); - process_start(&slip_process, NULL); - process_start(&uip_fw_process, NULL); - process_start(&rs232_process, NULL); - - process_start(&webserver_nogui_process, NULL); -// process_start(&cmdd_process, NULL); -// process_start(&telnetd_process, NULL); - - while(1) { - process_run(); - etimer_request_poll(); - } -} diff --git a/platform/pc-6001/ctk/ctk-conio_arch-asm.cS b/platform/pc-6001/ctk/ctk-conio_arch-asm.cS deleted file mode 100644 index f954c7f5c..000000000 --- a/platform/pc-6001/ctk/ctk-conio_arch-asm.cS +++ /dev/null @@ -1,1175 +0,0 @@ -;;; -;;; -;;; ctk-conio_arch-asm.hS -;;; -;;; Architecture depend ctk-conio implementation. -;;; This assembler source contributes saving speed and memory. -;;; -;;; @author Takahide Matsutsuka -;;; -;;; $Id: ctk-conio_arch-asm.cS,v 1.3 2009/12/11 15:00:38 matsutsuka Exp $ -;;; - - ;; uses preprocessor to enable definitions -#include "ctk_arch-def.h" - - ;; export symbols - .globl _ctk_draw_init - .globl _ctk_draw_clear - .globl _ctk_draw_clear_window - .globl _ctk_draw_window - .globl _ctk_draw_dialog - .globl _ctk_draw_widget - .globl _ctk_draw_windowtitle_height -.if CTK_CONF_MENUS - .globl _ctk_draw_menus -.endif - .globl _ctk_draw_width - .globl _ctk_draw_height - - ;; import symbols - .globl _wherex_arch - .globl _wherey_arch - - .globl _cputc_arch_asm - .globl _cputs_arch_asm - .globl _cputsn_arch_asm - .globl _clip_arch_asm - .globl _clearto_arch_asm - .globl _revers_arch_asm - .globl _chline_arch_asm - .globl _cvline_arch_asm - .globl _gotoxy_arch_asm - - ;; offsets - .globl _off_window_x - .globl _off_window_y - .globl _off_window_h - .globl _off_window_w - .globl _off_window_inactive - .globl _off_window_active - .globl _off_window_next - .globl _off_window_focused - - .globl _off_widget_x - .globl _off_widget_y - .globl _off_widget_w - .globl _off_widget_h - .globl _off_widget_type - .globl _off_widget_window - .globl _off_widget_label_text - .globl _off_widget_button_text - .globl _off_widget_textentry_text - .globl _off_widget_textentry_xpos - .globl _off_widget_textentry_ypos - .globl _off_widget_textentry_state -.if CTK_CONF_HYPERLINK - .globl _off_widget_hyperlink_text -.endif -.if CTK_CONF_ICONS - .globl _off_widget_icon_title - .globl _off_widget_icon_textmap -.endif -.if CTK_CONF_MENUS - .globl _off_menu_title - .globl _off_menu_active - .globl _off_menu_nitems - .globl _off_menu_items - .globl _off_menu_next - .globl _off_menuitem_title - .globl _size_menuitem - .globl _off_menus_open - .globl _off_menus_menus - .globl _off_menus_desktopmenu -.endif - - .area _DATA - - .area _CODE -_ctk_draw_windowtitle_height: - .db 1 - -_ctk_conio_arch_asm_start:: - ;; --------------------------------- - ;; void ctk_draw_init(void) - ;; Stack; retl reth - ;; _F____HL____ AFBCDEHL____ - ;; return void - ;; --------------------------------- -_ctk_draw_init: - xor a - call _revers_arch_asm - ld h, #SCREEN_HEIGHT - ld l, #0 - jr _ctk_draw_clear_asm - - ;; --------------------------------- - ;; ctk_draw_clear(unsigned char clipy1, unsigned char clipy2); - ;; Stack; retl reth clipy1 clipy2 - ;; AFBCDEHL____ - ;; return void - ;; --------------------------------- -_ctk_draw_clear: - ld hl, #2 - add hl, sp - ld e, (hl) ; clipy1 - inc hl - ld d, (hl) ; clipy2 - ;; E = clip1, D = clip2 - ex de, hl -_ctk_draw_clear_asm: - call _clip_arch_asm - ld a, h - sub l ; A = clipy2 - clipy1 - ld b, a ; height - ld c, #SCREEN_WIDTH ; width - ld d, l ; y - ld e, #0 ; x - call _clearbox_arch_asm - ret - -_get_offset: - ;; BC = offset address - ;; HL = base address - ;; return DE = data - ;; ___DE______ - push af - push hl - ld a, (bc) - add a, l - ld l, a - ld a, h - adc #0 - ld h, a - ld e, (hl) - inc hl - ld d, (hl) - pop hl - pop af - ret - - ;; --------------------------------- - ;; ctk_draw_clear_window(struct ctk_window *window, - ;; unsigned char focus, - ;; unsigned char clipy1, - ;; unsigned char clipy2) - ;; Stack; retl reth winl winh focus clipy1 clipy2 - ;; AFBCDEHL____ - ;; return void - ;; --------------------------------- -_ctk_draw_clear_window: - ;; clip_arch(clipy1, clipy2); - ld hl, #5 - add hl, sp - ld e, (hl) - inc hl - ld d, (hl) - ex de, hl - call _clip_arch_asm - ;; clearbox_arch(window->x + 1, window->y + 2, window->w, window->h); - ld hl, #2 - add hl, sp - ld e, (hl) - inc hl - ld d, (hl) - ld h, d - ld l, e ; HL = window - - ld bc, #_off_window_h - call _get_offset - ld d, e ; D = window->h - ld bc, #_off_window_w - call _get_offset ; E = window->w - push de - ld bc, #_off_window_y - call _get_offset ; E = window->y - ld a, e - inc a - inc a - ld bc, #_off_window_x - call _get_offset ; E = window->x - inc e - ld d, a ; D = window->y + 2, E = window->x + 1 - pop bc ; B = h, C = w - call _clearbox_arch_asm - ret - - ;; --------------------------------- - ;; void ctk_draw_dialog(struct ctk_window *dialog) - ;; Stack; retl reth dialogl dialogh - ;; AFBCDEHL____ - ;; return void - ;; --------------------------------- -_ctk_draw_dialog: - ;; ctk_draw_clear_window(dialog, 0, 0, SCREEN_HEIGHT) - ld hl, #2 - add hl, sp - ld e, (hl) - inc hl - ld d, (hl) - ld h, #SCREEN_HEIGHT - ld l, #0 - push hl - xor a - push af - inc sp - push de - call _ctk_draw_clear_window - pop de - inc sp - pop hl - - ;; draw_window_asm(dialog, CTK_FOCUS_DIALOG) - ld a, #_CTK_FOCUS_DIALOG - call _draw_window_asm - ret - - ;; --------------------------------- - ;; void ctk_draw_window(struct ctk_window *window, unsigned char focus, - ;; unsigned char clipy1, unsigned char clipy2, - ;; unsigned char draw_borders) - ;; Stack; retl reth winl winh focus cy1 cy2 borders - ;; AFBCDEHL____ - ;; return void - ;; --------------------------------- -_ctk_draw_window: - ;; clip_arch(clipy1, clipy2); - ld hl, #5 - add hl, sp - ld e, (hl) - inc hl - ld d, (hl) - ex de, hl - call _clip_arch_asm - - ;; DE = window - ;; A = focus = focus & CTK_FOCUS_WINDOW - ;; draw_window_asm(window, focus); - ld hl, #2 - add hl, sp - ld e, (hl) - inc hl - ld d, (hl) - inc hl - ld a, (hl) - and a, #_CTK_FOCUS_WINDOW - call _draw_window_asm - ret - - ;; --------------------------------- - ;; void draw_window_asm - ;; (struct ctk_window *window, unsigned char focus) - ;; DE = window, A = focus - ;; Stack; retl reth - ;; AFBCDEHL____ - ;; return void - ;; --------------------------------- -_draw_window_asm: - ;; drawbox_asm(window->x, window->y + 1, window->w, window->h); - push af ; focus - ld h, d - ld l, e ; HL = window - ld bc, #_off_window_h - call _get_offset - ld a, e - ld bc, #_off_window_w - call _get_offset - ld d, a - push de ; D = window->h, E = window->w - ld bc, #_off_window_y - call _get_offset - ld a, e - inc a - ld bc, #_off_window_x - call _get_offset - ld d, a ; D = window->y + 1, E = window->x - pop bc ; B = h, C = w, HL = window - call _drawbox_asm - inc d ; D = y = window->y + 2 - inc e ; E = x = window->x + 1 - push de ; Stack; yx focus - - ;; for(w = window->inactive; w != NULL; w = w->next) { - ld bc, #_off_window_inactive - call _get_offset ; DE = w = window->inactive - pop bc ; yx - pop af ; focus - push hl - ;; de = widget, bc = yx, a = focus, hl = window; Stack; window -_ctk_draw_window_asm_loop1: ; draw inactive widgets - ;; HL = e4cd - push af ; Stack; focus window - ld a, d - or e - jr z, _draw_window_asm_next1 ; if (DE == NULL) - pop af ; A = focus, Stack; window - ;; bc = yx, de = w, a = focus - ;; draw_widget(w, x, y, focus); - call _draw_widget_asm - push bc ; Stack; BC=xy HL=window - ld h, d - ld l, e ; HL = w - ld bc, #_off_window_next - call _get_offset ; DE = window->next - pop bc ; bc = yx, Stack; window - jr _ctk_draw_window_asm_loop1 - ;; for(w = window->active; w != NULL; w = w->next) - ;; HL = window, BC = xy, A = focus; Stack; focus -_draw_window_asm_next1: ; Stack; focus window - pop af ; A = focus - pop hl ; HL = window; Stack null - push bc ; Stack yx - ;; calc window->focused - ld bc, #_off_window_focused - call _get_offset ; DE = window->focused - push de ; Stack focused yx - ld bc, #_off_window_active - call _get_offset ; DE = window->active - pop hl ; HL = window->focused, Stack; yx - pop bc ; BC = yx, Stack; null - push af ; Stack; focus - push hl ; Stack; focused focus - - ;; BC = yx, DE = widget, Stack; focused focus -_ctk_draw_window_asm_loop2: ; draw active widgets - ld a, d ; DE = w - or e - jr z, _draw_window_asm_next2 - ;; if (w == window->focused) focus |= CTK_FOCUS_WIDGET; - pop hl ; HL = window->focused; Stack focus - ld a, h - cp d - jr nz, _draw_window_asm_nofocus - ld a, l - cp e - jr nz, _draw_window_asm_nofocus - pop af - push af - or a, #_CTK_FOCUS_WIDGET - jr _draw_window_asm_draw -_draw_window_asm_nofocus: - pop af - push af - ;; A = wfocus, BC = yx de = widget hl = focused -_draw_window_asm_draw: ; Stack; focus - ;; draw_widget(w, posx, posy, wfocus); - call _draw_widget_asm - - push hl ; Stack; focused focus - push bc ; Stack; yx focused focus - ld h, d - ld l, e - ld bc, #_off_window_next - call _get_offset ; DE = w->next - pop bc ; BC = yx, Stack; focused focus - jr _ctk_draw_window_asm_loop2 -_draw_window_asm_next2: ; Stack; focused focus - pop hl - pop af - ret - - - ;; --------------------------------- - ;; ctk_draw_widget(struct ctk_widget *w, - ;; unsigned char focus, - ;; unsigned char clipy1, - ;; unsigned char clipy2); - ;; Stack; retl reth wl wh focus clipy1 clipy2 - ;; AFBCDEHL____ - ;; return void - ;; --------------------------------- -_ctk_draw_widget: - ld hl, #2 - add hl, sp - ld e, (hl) - inc hl - ld d, (hl) ; DE = widget - inc hl - ld a, (hl) ; A = focus - inc hl - ld c, (hl) ; clipy1 - inc hl - ld b, (hl) ; clipy2 - push af ; focus - ld h, b - ld l, c - call _clip_arch_asm - push de ; Stack; widget focus - ex de, hl ; HL = widget - ld bc, #_off_widget_window - call _get_offset - ex de, hl ; HL = window - ld bc, #_off_window_focused - call _get_offset ; DE = focused - pop bc ; pop widget, Stack focus - ld a, b ; compare DE(fucosed) and BC(widget) - sub d - jr nz, _ctk_draw_widget_nofocus - ld a, c - sub e - jr nz, _ctk_draw_widget_nofocus - pop af - or a, #_CTK_FOCUS_WIDGET - push af -_ctk_draw_widget_nofocus: - push bc ; widget, Stack widget focus - ld bc, #_off_window_x - call _get_offset - inc e - ld c, e - push bc - ld bc, #_off_window_y - call _get_offset - inc e - inc e - pop bc - ld b, e ; yx - pop de ; widget - pop af ; focus - ;; FALL THROUGH - - ;; --------------------------------- - ;; static void draw_widget_asm(struct ctk_widget *w, - ;; unsigned char x, unsigned char y, - ;; unsigned char focus) - ;; Stack; retl reth - ;; in; A = focus, BC = yx, DE = widget - ;; ____________ - ;; return void - ;; --------------------------------- -_draw_widget_asm: - push hl - push de - push bc - push af - - push de ; Stack; w - ld h, d - ld l, e - push af - push bc ; Stack; xy, focus, w - ld bc, #_off_widget_x - call _get_offset - ld a, e - pop bc ; Stack; focus w - add c - ld c, a - push bc - ld bc, #_off_widget_y - call _get_offset - ld a, e - pop bc ; Stack; focus, w - add b - ld b, a ; B = ypos, C = xpos - pop af - and a, #_CTK_FOCUS_WIDGET - call _revers_arch_asm - ld h, b - ld l, c - call _gotoxy_arch_asm - pop hl ; Stack; null, HL = w - push hl - push bc - ld bc, #_off_widget_type - call _get_offset - ld a, e ; A = type - ld bc, #_off_widget_w - call _get_offset ; E = w->w; - pop bc ; B = ypos, C = xpos - pop hl ; HL = w - cp a, #_CTK_WIDGET_SEPARATOR - jp z, _draw_widget_separator - cp a, #_CTK_WIDGET_LABEL - jp z, _draw_widget_label - cp a, #_CTK_WIDGET_BUTTON - jp z, _draw_widget_button -.if CTK_CONF_HYPERLINK - cp a, #_CTK_WIDGET_HYPERLINK - jp z, _draw_widget_hyperlink -.endif - cp a, #_CTK_WIDGET_TEXTENTRY - jp z, _draw_widget_textentry -.if CTK_CONF_ICONS - cp a, #_CTK_WIDGET_ICON - jp z, _draw_widget_icon -.endif -_draw_widget_ret: - xor a - call _revers_arch_asm - - pop af - pop bc - pop de - pop hl - ret - ;; BC = ypos, xpos, HL = w, E = w->w, Stack; null -_draw_widget_separator: - ld b, e - call _chline_arch_asm - jr _draw_widget_ret - ;; BC = ypos, xpos, HL = w, E = w->w, Stack; null -_draw_widget_label: - ld a, e - push bc - push hl - ld bc, #_off_widget_h - call _get_offset ; E = h - ld h, e - ld l, a ; H = h, L = w->w - ex (sp), hl ; Stack; H = h, L = w->w; HL = w - ld bc, #_off_widget_label_text - call _get_offset ; DE = text - pop hl ; Stack; yx; H = h, L = w->w - pop bc ; BC = yx -_draw_widget_label_loop: - ld a, h - or a - jr z, _draw_widget_ret - - ;; BC = ypos, xpos, H = h, L = w->w, DE = text - push hl ; Stack; hw - ld h, b - ld l, c - call _gotoxy_arch_asm - pop hl - ;; cputsn_arch(text, w->w); - push hl - push bc - push de ; Stack; text yx hw - ld b, l - call _cputsn_arch_asm ; DE = text - pop de - pop bc - pop hl ; Stack; null - ;; clearto_arch(xpos + w->w); - ld a, c - add a, l - push hl - push de - push bc - call _clearto_arch_asm - pop bc - pop de - pop hl - ;; ++ypos; - inc b - ;; text += w->w; - ld a, e - add a, l - ld e, a - ld a, d - adc a, #0 - ld d, a - - dec h - jr _draw_widget_label_loop - - ;; BC = ypos, xpos, HL = w, E = w->w, Stack; null -_draw_widget_button: - push hl ; w - push de ; w->w - ld a, #0x5b ; '[' - call _cputc_arch_asm - pop de - pop hl - ld a, e - ld bc, #_off_widget_button_text - call _get_offset - ld b, a - call _cputsn_arch_asm - ld a, #0x5d ; ']' - call _cputc_arch_asm - jp _draw_widget_ret -.if CTK_CONF_HYPERLINK - ;; BC = ypos, xpos, HL = w, E = w->w, Stack; null -_draw_widget_hyperlink: - ld a, e - ld bc, #_off_widget_hyperlink_text - call _get_offset - ld b, a - call _cputsn_arch_asm - jp _draw_widget_ret -.endif - - ;; BC = ypos, xpos, HL = w, E = w->w, Stack; null -_draw_widget_textentry: ; 0xc5dc sp=0xf97e ;widget=e3be - ;; e3cd;textentry.xpos<-b224 - ;; stable variables; - ;; w->w, w->h, w->widget.textentry.{state,ypos,xpos), xscroll - push ix - ld ix, #-6 - add ix, sp - ld sp, ix - push bc ; yx - - ld 0(ix), e ; w->w - ld bc, #_off_widget_h - call _get_offset - ld 1(ix), e ; w->h - ld bc, #_off_widget_textentry_state - call _get_offset - ld a, e - sub a, #_CTK_TEXTENTRY_EDIT - ld 2(ix), a ; w->widget.textentry.state - ld bc, #_off_widget_textentry_ypos - call _get_offset - ld 3(ix), e ; w->widget.textentry.ypos - ld bc, #_off_widget_textentry_xpos - call _get_offset - ld 4(ix), e ; w->widget.textentry.xpos - - ;; xscroll = 0; - ;; if(w->widget.textentry.xpos >= w->w - 1) { - ;; xscroll = w->widget.textentry.xpos - w->w + 1; - ;; } - ld a, e - inc a - sub 0(ix) ; xscroll = w->widget.textentry.xpos - w->w + 1 - jr nc, _draw_widget_textentry_next - xor a ; if (xscroll < 0) xscroll = 0 -_draw_widget_textentry_next: ; A = xscroll, Stack; yx - IX - ld 5(ix), a ; xscroll - - ld bc, #_off_widget_textentry_text - call _get_offset ; DE = text - - ld l, #0 ; loop counter - pop bc - ;; L = counter, IX = sp, DE = text, BC = yx, Stack; null -_draw_widget_textentry_loop1: ; 0xc629 - ;; gotoxy_arch(xpos, ypos); - push hl ; Stack; text - ld h, b - ld l, c - call _gotoxy_arch_asm - - ;; if(w->widget.textentry.state == CTK_TEXTENTRY_EDIT && - ;; w->widget.textentry.ypos == j) - pop hl ; Stack; null, BC = yx, DE = text, L = count - push bc ; Stack; yx - ld a, l - cp a, 1(ix) ; j - w->h - jp nc, _draw_widget_textentry_ret - ld a, 2(ix) ; state - or a ; state == EDIT? - jr nz, _draw_widget_textentry_else - ld a, 3(ix) ; ypos - cp a, l ; ypos == j? - jr nz, _draw_widget_textentry_else - ;; revers_arch(0); - push hl ; Stack count yx - push de ; Stack text count yx - xor a - call _revers_arch_asm - ;; cputc_arch('>'); - ld a, #0x3e ; '>' - call _cputc_arch_asm - - pop de ; Stack count yx - push de ; Stack text count yx - ld a, 5(ix) ; xscroll - add a, e - ld e, a - ld a, d - adc a, #0 - ld d, a ; DE = text[xscroll] - - ld h, #0 ; loop counter - ;; for(i = 0; i < w->w; ++i) -_draw_widget_textentry_loop2: ; 0xc39d Stack text count yx - ;; H = count2, DE = text[xscroll + i] - ld a, h - cp a, 0(ix) ; i - w->w - jr nc, _draw_widget_textentry_loop2exit - ;; revers_arch(i == w->widget.textentry.xpos - xscroll); - push hl ; Stack count2 text count1 yx - ld a, 4(ix) ; w->w.widget.textentry.xpos - sub 5(ix) ; xscroll - sub h ; textentry.xpos - xscroll- i - ld a, #00 ; flags do not change - jr nz, _draw_widget_textentry_revers - ld a, #01 -_draw_widget_textentry_revers: - call _revers_arch_asm - ;; DE = text, Stack; count2 text count1 yx - ;; cputc((c == 0) ? CH_SPACE : c); - ld a, (de) ; ch - or a - jr nz, _draw_widget_textentry_nospace - ld a, #CH_SPACE -_draw_widget_textentry_nospace: - push de - call _cputc_arch_asm - pop de - pop hl ; Stack text count1 yx, H = count2 - inc h - inc de - jr _draw_widget_textentry_loop2 -_draw_widget_textentry_loop2exit: ; Stack text count yx - xor a - call _revers_arch_asm - ld a, #0x3c ; '<' - call _cputc_arch_asm - jr _draw_widget_textentry_endif - -_draw_widget_textentry_else: ; 0xc68a DE = text, L = count1, Stack yx - ;; cputc_arch(CH_VERTLINE); - ld a, #CH_VERTLINE - push hl - push de - call _cputc_arch_asm - pop de - ;; cputsn_arch(text, w->w); - ld b, 0(ix) ; w->w - push de - call _cputsn_arch_asm - pop de ; Stack count1 yx - ;; clearto_arch(xpos + w->w + 1); - pop hl - pop bc - push bc - push hl - push de ; Stack text count yx - ld a, 0(ix) ; w->w - add a, c - inc a ; xpos + w->w + 1 - call _clearto_arch_asm - ;; cputc_arch(CH_VERTLINE); - ld a, #CH_VERTLINE - call _cputc_arch_asm -_draw_widget_textentry_endif: ; Stack text count yx - ;; text += w->w - pop de - ld a, e - add a, 0(ix) - ld e, a - ld a, d - adc a, #0 - ld d, a - - pop hl - ;; i++ - inc l - pop bc - ;; ++ypos; - inc b - jp _draw_widget_textentry_loop1 -_draw_widget_textentry_ret: - pop bc - ld hl, #6 - add hl, sp - ld sp, hl - pop ix - jp _draw_widget_ret - -.if CTK_CONF_ICONS - ;; BC = ypos, xpos, HL = w, E = w->w, Stack; null -_draw_widget_icon: - push bc ; Stack; yx - ld bc, #_off_widget_icon_title - call _get_offset - push de ; Stack; title yx - ld bc, #_off_widget_icon_textmap - call _get_offset - pop hl ; HL = title, DE = textmap - pop bc ; BC = yx - - ;; BC = yx, DE = textmap, HL = title - push hl ; Stack; title - ld h, b - ld l, c ; HL = yx - ld a, e - or d - jr z, _draw_widget_icon_title - - ;; push hl - ;; call _wherex_arch - ;; ld c, l - ;; call _wherey_arch - ;; ld b, l - ;; pop hl - - ld a, #3 ; loop counter -_draw_widget_icon_loop: ; HL = yx, DE = textmap, Stack; title - call _gotoxy_arch_asm - - push af ; Stack; loop title - push hl ; DE = textmap, Stack; yx loop title - - ld b, #3 - call _cputsn_arch_asm ; DE = DE + 3 - - pop hl - pop af ; HL = yx, A = count, Stack; title - - inc h ; y++ - dec a - jr nz, _draw_widget_icon_loop - ;; Stack; title, HL = yx -_draw_widget_icon_title: - pop de ; Stack; null, HL = yx, DE = title - push de ; Stack; title, HL = yx, DE = title - ld b, h - ld c, l ; BC = yx - ex de, hl ; BC = yx, HL = title - ld d, #0 -_draw_widget_icon_title_strlen: - ld a, (hl) - or a - jr z, _draw_widget_icon_title_setpos - inc hl - inc d - jr _draw_widget_icon_title_strlen - ;; D = len, BC = yx, Stack; title -_draw_widget_icon_title_setpos: - ld h, d ; H = len - ld a, d - add a, c ; x + len - cp a, #SCREEN_WIDTH ; x + len - SCREEN_WIDTH - jr c, _draw_widget_icon_title_show - ld a, #SCREEN_WIDTH - sub h - ld c, a - ;; B = y, C = x; H = len, Stack; title -_draw_widget_icon_title_show: - ld a, h ; A = len - ld h, b - ld l, c - call _gotoxy_arch_asm - pop de ; DE = title - ld b, a ; B = len - call _cputsn_arch_asm - jp _draw_widget_ret - -.endif - -.if CTK_CONF_MENUS - ;; --------------------------------- - ;; static void draw_menu(struct ctk_menu *m, struct ctk_menu *open) - ;; in; HL = menu, BC = open - ;; AFBCDEHL____ - ;; return void - ;; --------------------------------- -_draw_menu_asm: - ;; x = wherex_arch(); - push hl - call _wherex_arch ; A = x - pop hl - push af - ;; cputs_arch(m->title); - push bc - ld bc, #_off_menu_title - call _get_offset ; DE = m->title - push hl ; Stack; menu open x - call _cputs_arch_asm - ;; cputc_arch(CH_SPACE); - ld a, #CH_SPACE - call _cputc_arch_asm - - pop hl ; menu - pop bc ; open, Stack; x - ld a, h - sub b - jp nz, _draw_menu_ret2 - ld a, l - sub c - jp nz, _draw_menu_ret2 - ;; x2 = wherex_arch(); - ;; 0xc473 - push hl - call _wherex_arch ; A = x2 - ld c, l ; C = x2 - pop hl ; Stack; x - ;; HL = menu - push bc - ld bc, #_off_menu_active - call _get_offset - pop bc ; E = m->active - ld d, #0 ; D = y - pop af ; A = x, Stack; null - ld b, a - add a, #CTK_CONF_MENUWIDTH - sub #SCREEN_WIDTH - jr c, _draw_menu_loop1 - jr z, _draw_menu_loop1 - ld a, #SCREEN_WIDTH - sub #CTK_CONF_MENUWIDTH - ld b, a - ;; B = x, C = x2, D = y, E = m->active, HL = menu -_draw_menu_loop1: - ;; if (y == m->nitems) _draw_menu_ret - ld a, d - push de - push hl - push bc - ld bc, #_off_menu_nitems - call _get_offset - cp e - pop bc - pop hl - jr z, _draw_menu_ret ; leave 2byte to pop while return - pop de - ;; if (y == m->active) revers_arch(0); - cp e - jr nz, _draw_menu_next1 - xor a - push hl - call _revers_arch_asm - pop hl - ;; B = x, C = x2, D = y, HL = menu -_draw_menu_next1: ; c4ae - ;; gotoxy_arch(x, y + 1); - push hl - ld h, d - ld l, b - inc h - call _gotoxy_arch_asm - pop hl ; HL = menu, Stack; null - ;; if(m->items[y].title[0] == '-') - push de - push hl ; e7ca - push bc ; Stack; x2x menu y - - ld bc, #_off_menu_items - ld a, (bc) - add a, l - ld l, a - ld a, h - adc #0 - ld h, a ; HL = m->items[0] - - ld bc, #_size_menuitem - ld a, (bc) - ld c, a - ld b, #0 ; BC = sizeof(struct menuitem) - - ld a, d ; A = y -_draw_menu_loop2: - or a - jr z, _draw_menu_next2 - add hl, bc - dec a - jr _draw_menu_loop2 -_draw_menu_next2: - ld bc, #_off_menuitem_title - call _get_offset - ld a, (de) - cp a, #0x2d ; '-' - jr nz, _draw_menu_else - ;; chline_arch(CTK_CONF_MENUWIDTH); - ld b, #CTK_CONF_MENUWIDTH - call _chline_arch_asm - jr _draw_menu_next3 -_draw_menu_else: - ;; cputs_arch(m->items[y].title); - call _cputs_arch_asm -_draw_menu_next3: - ;; clearto_arch(x + CTK_CONF_MENUWIDTH); - pop bc ; B = x, C = x2, Stack; menu y - push bc - ld a, b - add a, #CTK_CONF_MENUWIDTH - call _clearto_arch_asm - ;; revers_arch(1); - ld a, #1 - call _revers_arch_asm - pop bc - pop hl - pop de - inc d - jr _draw_menu_loop1 -_draw_menu_ret: ; C = x2 - ld h, #0 - ld l, c - call _gotoxy_arch_asm -_draw_menu_ret2: - pop af - ret - -_ctk_draw_menus: - ;; --------------------------------- - ;; void ctk_draw_menus(struct ctk_menus *menus); - ;; Stack; retl reth menusl menush - ;; AFBCDEHL____ - ;; return void - ;; --------------------------------- - ;; clip_arch(0, SCREEN_HEIGHT); - ld h, #SCREEN_HEIGHT - ld l, #0 - call _clip_arch_asm - ;; gotoxy_arch(0, 0); - ld h, #0 - call _gotoxy_arch_asm - ;; revers_arch(1); - ld a, #1 - call _revers_arch_asm - - ld hl, #2 - add hl, sp - ld e, (hl) - inc hl - ld d, (hl) - ld h, d - ld l, e ; HL = menus - ld bc, #_off_menus_desktopmenu - call _get_offset - push de ; Stack; menus->desktopmenu - ld bc, #_off_menus_open - call _get_offset - push de ; Stack; menus->open menus->desktopmenu - ld bc, #_off_menus_menus - call _get_offset - ld h, d - ld l, e ; HL = menu -_ctk_draw_menus_loop1: - ld bc, #_off_menu_next - call _get_offset - ;; if (menu == NULL) _ctk_draw_menus_next1 - ld a, d - or e - jr z, _ctk_draw_menus_next1 - ;; draw_menu_asm(m, menus->open); - ld h, d - ld l, e ; HL = menu->next - pop bc - push bc ; Stack; menus->open menus->desktopmenu - push hl ; Stack; menu menus->open menus->desktopmenu - call _draw_menu_asm - pop hl ; Stack; menus->open menus->desktopmenu - jr _ctk_draw_menus_loop1 -_ctk_draw_menus_next1: - pop de ; menus->open - pop hl ; menus->desktopmenu - push de ; Stack; menus->open - ;; clearto_arch(SCREEN_WIDTH - strlen(menus->desktopmenu->title) - 1); - ld bc, #_off_menu_title - call _get_offset - ld b ,#0 -_ctk_draw_menus_loop2: - ld a, (de) - or a - jr z, _ctk_draw_menus_next2 - inc b - inc de - jr _ctk_draw_menus_loop2 -_ctk_draw_menus_next2: - ld a, #SCREEN_WIDTH - sub b ; strlen(menus->desktopmenu->title) - dec a ; SCREEN_WIDTH - strlen(menus->desktopmenu->title) - 1 - push hl - call _clearto_arch_asm - pop hl ; desktopmenu - pop bc ; open, Stack; null - call _draw_menu_asm - xor a - call _revers_arch_asm - ret -.endif - - ;; --------------------------------- - ;; unsigned char ctk_draw_width(void); - ;; Stack; retl reth - ;; _______L____ - ;; return width - ;; --------------------------------- -_ctk_draw_width: - ld l, #SCREEN_WIDTH - ret - - ;; --------------------------------- - ;; unsigned char ctk_draw_height(void); - ;; Stack; retl reth - ;; _______L____ - ;; return width - ;; --------------------------------- -_ctk_draw_height: - ld l, #SCREEN_HEIGHT - ret - - - ;; --------------------------------- - ;; internal functions - ;; --------------------------------- - - ;; --------------------------------- - ;; static void clearbox_arch_asm(unsigned char x, y, w, h) - ;; Stack; retl reth - ;; AFBCDEHL____ - ;; return void - ;; --------------------------------- - ;; DE = yx, B = h, C = w -_clearbox_arch_asm: - ld a, e - add a, c - ld c, a ; to_x = x + w - ld h, d - ld l, e -_clearbox_arch_loop:: - call _gotoxy_arch_asm ; (x, y) - push hl - push bc ; B = h, HL = yx - ld a, c - call _clearto_arch_asm - pop bc - pop hl - inc h ; y++ - djnz _clearbox_arch_loop - ret - - ;; --------------------------------- - ;; void drawbox_asm(unsigned char x, y, w, h) - ;; Stack; retl reth - ;; B = h, C = w, D = y, E = x - ;; AF__________ - ;; return void - ;; --------------------------------- -_drawbox_asm: - push bc - push de - push hl - - ld h, d - ld l, e - inc h - call _gotoxy_arch_asm ; (x, y + 1) - dec h - push hl - push bc ; Stack; hw, yx, B = h - call _cvline_arch_asm - ld a, #CH_LLCORNER - call _cputc_arch_asm - pop bc - push bc ; Stack; hw yx - ld b, c ; w - call _chline_arch_asm - ld a, #CH_LRCORNER - call _cputc_arch_asm - pop bc - pop hl - call _gotoxy_arch_asm ; (x, y) - push hl - push bc ; Stack; hw yx - ld a, #CH_ULCORNER - call _cputc_arch_asm - pop bc - push bc ; Stack; hw yx - ld b, c ; B = w - call _chline_arch_asm - ld a, #CH_URCORNER - call _cputc_arch_asm - pop bc ; B = h - pop hl - ld a, l - inc a - add a, c - ld l, a ; L = x + 1 + w - inc h ; H = y + 1 - call _gotoxy_arch_asm - call _cvline_arch_asm - - pop hl - pop de - pop bc - ret - -_ctk_conio_arch_asm_end:: diff --git a/platform/pc-6001/ctk/ctk-conio_arch-source.c b/platform/pc-6001/ctk/ctk-conio_arch-source.c deleted file mode 100644 index ea843e0da..000000000 --- a/platform/pc-6001/ctk/ctk-conio_arch-source.c +++ /dev/null @@ -1,395 +0,0 @@ -/* - * Copyright (c) 2007, Takahide Matsutsuka. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - */ - -/* - * \file - * This is an original source file for - * ctk-conio_arch.c and ctk-conio_arch-asm.S - * \author - * Takahide Matsutsuka - */ - - -#include "ctk/ctk.h" -#include "ctk/ctk-draw.h" -#include "contiki-conf.h" -#include "ctk/ctk_arch.h" -#include - -#ifndef NULL -#define NULL (void *)0 -#endif - -/*---------------------------------------------------------------------------*/ -static char cursx, cursy; -static unsigned char reversed; -static char cy1, cy2; - -unsigned char ctk_draw_windowtitle_height = 1; - -/*---------------------------------------------------------------------------*/ -#define revers(c) reversed = c -#define clip(y1, y2) cy1 = y1; cy2 = y2 -#define OFFSET(x, y) y * SCREEN_WIDTH + x - -/*---------------------------------------------------------------------------*/ -void cputc(char c) { - if (cursy >= cy1 && cursy <= cy2 - && cursy >= 0 && cursy <= SCREEN_HEIGHT - && cursx >= 0 && cursx < SCREEN_WIDTH) { - unsigned int offset = OFFSET(cursx, cursy); - *((char *) VRAM_CHAR + offset) = c; - *((char *) VRAM_ATTR + offset) = reversed ? COLOR_REVERSED : COLOR_NORMAL; - } - cursx++; -} - -/*---------------------------------------------------------------------------*/ -void cputs(char *str) { - while (*str != 0) { - cputc(*str); - str++; - } -} -/*---------------------------------------------------------------------------*/ -void cputsn(char *str, unsigned char len) { - while ((len > 0) && (*str != 0)) { - cputc(*str); - str++; - len--; - } -} -/*---------------------------------------------------------------------------*/ -void chline(unsigned char length) { - while (length > 0) { - cputc(CH_HOLILINE); - length--; - } -} -/*---------------------------------------------------------------------------*/ -/* #define cvline(l) while (l > 0) { cputc(CH_VERTLINE); */ -/* ++cursy; --cursx; l--; } */ - -void cvline(unsigned char length) { - while (length > 0) { - cputc(CH_VERTLINE); - ++cursy; - --cursx; - length--; - } -} -/*---------------------------------------------------------------------------*/ -void gotoxy(unsigned char x, unsigned char y) { - cursx = x; - cursy = y; -} -/*---------------------------------------------------------------------------*/ -void clearTo(char x) { - while (cursx < x) { - cputc(CH_SPACE); - } - cursx = x; -} - -/*---------------------------------------------------------------------------*/ -void ctk_draw_clear(unsigned char clipy1, unsigned char clipy2) { - while (clipy1 < clipy2) { - gotoxy(0, clipy1); - clearTo(SCREEN_WIDTH); - clipy1++; - } -} - -/*---------------------------------------------------------------------------*/ -void ctk_draw_init(void) { - clip(0, SCREEN_HEIGHT); - ctk_draw_clear(0, SCREEN_HEIGHT); -} -/*---------------------------------------------------------------------------*/ -/* - * w: widget - * x, y: screen position of client drawing area (left, top) - * clipx, clipy: screen position of client drawing area (right, bottom) - * clipy1, clipy2: min/max y position of screen - * focus: boolean - */ -void -draw_widget(struct ctk_widget *w, - unsigned char x, unsigned char y, - unsigned char focus) { - unsigned char xpos, ypos, xscroll; - unsigned char i, j; - char c, *text; -#if CTK_CONF_ICONS - unsigned char len; -#endif /* CTK_CONF_ICONS */ - - xpos = x + w->x; - ypos = y + w->y; - - revers(focus & CTK_FOCUS_WIDGET); - gotoxy(xpos, ypos); - - if (w->type == CTK_WIDGET_SEPARATOR) { - chline(w->w); - } else if (w->type == CTK_WIDGET_LABEL) { - text = w->widget.label.text; - for(i = 0; i < w->h; ++i) { - gotoxy(xpos, ypos); - cputsn(text, w->w); - clearTo(xpos + w->w); - ++ypos; - text += w->w; - } - } else if (w->type == CTK_WIDGET_BUTTON) { - cputc('['); - cputsn(w->widget.button.text, w->w); - cputc(']'); - } else if (w->type == CTK_WIDGET_HYPERLINK) { - cputsn(w->widget.hyperlink.text, w->w); - } else if (w->type == CTK_WIDGET_TEXTENTRY) { - text = w->widget.textentry.text; - xscroll = 0; - if(w->widget.textentry.xpos >= w->w - 1) { - xscroll = w->widget.textentry.xpos - w->w + 1; - } - for(j = 0; j < w->h; ++j) { - gotoxy(xpos, ypos); - if(w->widget.textentry.state == CTK_TEXTENTRY_EDIT && - w->widget.textentry.ypos == j) { - revers(0); - cputc('>'); - for(i = 0; i < w->w; ++i) { - c = text[i + xscroll]; - revers(i == w->widget.textentry.xpos - xscroll); - cputc((c == 0) ? CH_SPACE : c); - } - revers(0); - cputc('<'); - } else { - cputc(CH_VERTLINE); - cputsn(text, w->w); - clearTo(xpos + w->w + 1); - cputc(CH_VERTLINE); - } - ++ypos; - text += w->w; - } -#if CTK_CONF_ICONS - } else if (w->type == CTK_WIDGET_ICON) { - if(w->widget.icon.textmap != NULL) { - for(i = 0; i < 3; ++i) { - gotoxy(xpos, ypos); - cputc(w->widget.icon.textmap[0 + 3 * i]); - cputc(w->widget.icon.textmap[1 + 3 * i]); - cputc(w->widget.icon.textmap[2 + 3 * i]); - ++ypos; - } - x = xpos; - - len = strlen(w->widget.icon.title); - if(x + len >= SCREEN_WIDTH) { - x = SCREEN_WIDTH - len; - } - gotoxy(x, ypos); - cputs(w->widget.icon.title); - } -#endif /* CTK_CONF_ICONS */ - } - revers(0); - -} -/*---------------------------------------------------------------------------*/ -void -ctk_draw_widget(struct ctk_widget *w, - unsigned char focus, - unsigned char clipy1, - unsigned char clipy2) { - - struct ctk_window *win = w->window; - unsigned char posx, posy; - clip(clipy1, clipy2); - - posx = win->x + 1; - posy = win->y + 2; - - if(w == win->focused) { - focus |= CTK_FOCUS_WIDGET; - } - - draw_widget(w, posx, posy, focus); -} -/*---------------------------------------------------------------------------*/ -void -ctk_draw_clear_window(struct ctk_window *window, - unsigned char focus, - unsigned char clipy1, - unsigned char clipy2) { - - unsigned char i; - unsigned char x1, x2, y1, y2; - x1 = window->x + 1; - x2 = x1 + window->w; - y1 = window->y + 2; - y2 = y1 + window->h; - - for(i = y1; i < y2; ++i) { - gotoxy(x1, i); - clearTo(x2); - } -} -/*---------------------------------------------------------------------------*/ -void draw_window_sub(struct ctk_window *window, unsigned char focus) { - - unsigned char x, y; - unsigned char x1, y1, x2; - struct ctk_widget *w; - unsigned char wfocus; - - x = window->x; - y = window->y + 1; - - x1 = x + 1; - y1 = y + 1; - x2 = x1 + window->w; - - // |_ - gotoxy(x, y1); - cvline(window->h); - cputc(CH_LLCORNER); - chline(window->w); - cputc(CH_LRCORNER); - - // - - gotoxy(x, y); - cputc(CH_ULCORNER); - chline(window->w); - cputc(CH_URCORNER); - // | - gotoxy(x2, y1); - cvline(window->h); - - /* Draw inactive widgets. */ - for(w = window->inactive; w != NULL; w = w->next) { - draw_widget(w, x1, y1, focus); - } - - /* Draw active widgets. */ - for(w = window->active; w != NULL; w = w->next) { - wfocus = focus; - if(w == window->focused) { - wfocus |= CTK_FOCUS_WIDGET; - } - draw_widget(w, x1, y1, wfocus); - } -} -/*---------------------------------------------------------------------------*/ -void -ctk_draw_window(struct ctk_window *window, unsigned char focus, - unsigned char clipy1, unsigned char clipy2, unsigned char draw_borders) { - clip(clipy1, clipy2); - - focus = focus & CTK_FOCUS_WINDOW; - draw_window_sub(window, focus); -} -/*---------------------------------------------------------------------------*/ -void ctk_draw_dialog(struct ctk_window *dialog) { - clip(0, SCREEN_HEIGHT); - - ctk_draw_clear_window(dialog, 0, 0, SCREEN_HEIGHT); - draw_window_sub(dialog, CTK_FOCUS_DIALOG); -} -/*---------------------------------------------------------------------------*/ -#if CTK_CONF_MENUS -void draw_menu(struct ctk_menu *m, struct ctk_menu *open) { -#if CC_CONF_UNSIGNED_CHAR_BUGS - unsigned char x2; - unsigned int x, y; -#else - unsigned char x2; - unsigned char x, y; -#endif - x = cursx; - cputs(m->title); - cputc(CH_SPACE); - - if (m == open) { - x2 = cursx; - if(x + CTK_CONF_MENUWIDTH > SCREEN_WIDTH) { - x = SCREEN_WIDTH - CTK_CONF_MENUWIDTH; - } - - for(y = 0; y < m->nitems; y++) { - if(y == m->active) { - revers(0); - } - gotoxy(x, y + 1); - if(m->items[y].title[0] == '-') { - chline(CTK_CONF_MENUWIDTH); - } else { - cputs(m->items[y].title); - } - clearTo(x + CTK_CONF_MENUWIDTH); - revers(1); - } - gotoxy(x2, 0); - } -} -/*---------------------------------------------------------------------------*/ -void ctk_draw_menus(struct ctk_menus *menus) { - struct ctk_menu *m; - - clip(0, SCREEN_HEIGHT); - /* Draw menus */ - gotoxy(0, 0); - revers(1); - for(m = menus->menus->next; m != NULL; m = m->next) { - draw_menu(m, menus->open); - } - - clearTo(SCREEN_WIDTH - strlen(menus->desktopmenu->title) - 1); - - /* Draw desktopmenu */ - draw_menu(menus->desktopmenu, menus->open); - - revers(0); -} -#endif /* CTK_CONF_MENUS */ -/*---------------------------------------------------------------------------*/ -/* Returns width and height of screen. */ -unsigned char ctk_draw_width(void) { - return SCREEN_WIDTH; -} -unsigned char ctk_draw_height(void) { - return SCREEN_HEIGHT; -} - diff --git a/platform/pc-6001/ctk/ctk-conio_arch.c b/platform/pc-6001/ctk/ctk-conio_arch.c deleted file mode 100644 index 12cc833ba..000000000 --- a/platform/pc-6001/ctk/ctk-conio_arch.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2007, Takahide Matsutsuka. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - */ - -/* - * \file - * This is architecture-depend contiki toolkit for PC-6001 family. - * \author - * Takahide Matsutsuka - */ - - -#include "ctk/ctk.h" -#include "ctk/ctk-draw.h" -#include "contiki-conf.h" -#include "ctk/ctk_arch.h" -#include - -/*---------------------------------------------------------------------------*/ -/* - * Offset constants for assembler - */ -const uint8_t off_widget_x = offsetof(struct ctk_widget, x); -const uint8_t off_widget_y = offsetof(struct ctk_widget, y); -const uint8_t off_widget_w = offsetof(struct ctk_widget, w); -const uint8_t off_widget_h = offsetof(struct ctk_widget, h); -const uint8_t off_widget_type = offsetof(struct ctk_widget, type); -const uint8_t off_widget_window = offsetof(struct ctk_widget, window); - -const uint8_t off_widget_label_text = offsetof(struct ctk_widget, widget) + - offsetof(struct ctk_widget_label, text); -const uint8_t off_widget_button_text = offsetof(struct ctk_widget, widget) + - offsetof(struct ctk_widget_button, text); -const uint8_t off_widget_textentry_text = offsetof(struct ctk_widget, widget) + - offsetof(struct ctk_widget_textentry, text); -const uint8_t off_widget_textentry_xpos = offsetof(struct ctk_widget, widget) + - offsetof(struct ctk_widget_textentry, xpos); -const uint8_t off_widget_textentry_ypos = offsetof(struct ctk_widget, widget) + - offsetof(struct ctk_widget_textentry, ypos); -const uint8_t off_widget_textentry_state = offsetof(struct ctk_widget, widget) + - offsetof(struct ctk_widget_textentry, state); -#if CTK_CONF_HYPERLINK -const uint8_t off_widget_hyperlink_text = offsetof(struct ctk_widget, widget) + - offsetof(struct ctk_widget_hyperlink, text); -#endif /* CTK_CONF_HYPERLINK */ - -#if CTK_CONF_ICONS -const uint8_t off_widget_icon_title = offsetof(struct ctk_widget, widget) + - offsetof(struct ctk_widget_icon, title); -const uint8_t off_widget_icon_textmap = offsetof(struct ctk_widget, widget) + - offsetof(struct ctk_widget_icon, textmap); -#endif /* CTK_CONF_ICONS */ - -const uint8_t off_window_x = offsetof(struct ctk_window, x); -const uint8_t off_window_y = offsetof(struct ctk_window, y); -const uint8_t off_window_h = offsetof(struct ctk_window, h); -const uint8_t off_window_w = offsetof(struct ctk_window, w); -const uint8_t off_window_inactive = offsetof(struct ctk_window, inactive); -const uint8_t off_window_active = offsetof(struct ctk_window, active); -const uint8_t off_window_next = offsetof(struct ctk_window, next); -const uint8_t off_window_focused = offsetof(struct ctk_window, focused); - -#if CTK_CONF_MENUS -const uint8_t off_menu_title = offsetof(struct ctk_menu, title); -const uint8_t off_menu_active = offsetof(struct ctk_menu, active); -const uint8_t off_menu_nitems = offsetof(struct ctk_menu, nitems); -const uint8_t off_menu_items = offsetof(struct ctk_menu, items); -const uint8_t off_menu_next = offsetof(struct ctk_menu, next); -const uint8_t off_menuitem_title = offsetof(struct ctk_menuitem, title); -const uint8_t size_menuitem = sizeof(struct ctk_menuitem); -const uint8_t off_menus_open = offsetof(struct ctk_menus, open); -const uint8_t off_menus_menus = offsetof(struct ctk_menus, menus); -const uint8_t off_menus_desktopmenu = offsetof(struct ctk_menus, desktopmenu); -#endif - -/*---------------------------------------------------------------------------*/ diff --git a/platform/pc-6001/ctk/ctk_arch-def.h b/platform/pc-6001/ctk/ctk_arch-def.h deleted file mode 100644 index c55d88892..000000000 --- a/platform/pc-6001/ctk/ctk_arch-def.h +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright (c) 2007, Takahide Matsutsuka. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - */ - -/* - * \file - * ctk_arch-def.h - * Definitions of CTK for PC-6001 family, which consist of the following: - * - Configuraton for ctk main library. - * - Configuraton for ctk_arch library. - * This file is used in assembler file with precompilation, so - * NEVER include other than directives and comments. - * \author - * Takahide Matsutsuka - */ - -#ifndef __CTK_ARCH_DEF_H__ -#define __CTK_ARCH_DEF_H__ - -/* characters */ -#if defined(ARCH_PC6001) || defined(ARCH_PC6001MK2) -#define CH_VERTLINE 0x16 -#define CH_HOLILINE 0x17 -#define CH_ULCORNER 0x18 -#define CH_URCORNER 0x19 -#define CH_LLCORNER 0x1a -#define CH_LRCORNER 0x1b -#elif defined(ARCH_PC6001A) -#define CH_VERTLINE '|' -#define CH_HOLILINE '-' -#define CH_ULCORNER '/' -#define CH_URCORNER '\\' -#define CH_LLCORNER '\\' -#define CH_LRCORNER '/' -#else -#error invalid ARCH -#endif -#define CH_SPACE 0x20 - -/* screen properties */ -#if defined(ARCH_PC6001MK2) -#define VRAM_ATTR 0x4000 -#define VRAM_CHAR 0x4400 -#define SCREEN_WIDTH 40 -#define SCREEN_HEIGHT 20 -#define COLOR_NORMAL 0x0f -#define COLOR_REVERSED 0x70 -#elif (defined(ARCH_PC6001) || defined(ARCH_PC6001A)) && defined(MEMORY_16K) -#define VRAM_ATTR 0xc000 -#define VRAM_CHAR 0xc200 -#define SCREEN_WIDTH 32 -#define SCREEN_HEIGHT 16 -#define COLOR_NORMAL 0x20 -#define COLOR_REVERSED 0x21 -#elif (defined(ARCH_PC6001) || defined(ARCH_PC6001A)) && (defined(MEMORY_32K) || defined(MEMORY_ROM)) -#define VRAM_ATTR 0x8000 -#define VRAM_CHAR 0x8200 -#define SCREEN_WIDTH 32 -#define SCREEN_HEIGHT 16 -#define COLOR_NORMAL 0x20 -#define COLOR_REVERSED 0x21 -#else -#error Specify appropriate ARCH & MEMORY combination -#endif /* ARCH_PC6001MK2 */ - -/* key code */ -#define CH_F1 -16//0xf0 -#define CH_F2 -15//0xf1 -#define CH_F3 -14//0xf2 -#define CH_F4 -13//0xf3 -#define CH_F5 -12//0xf4 -#define CH_TAB 0x09 - -#define CH_CURS_UP 0x1e -#define CH_CURS_DOWN 0x1f -#define CH_CURS_LEFT 0x1d -#define CH_CURS_RIGHT 0x1c -#define CH_ENTER 0x0d -#define CH_ESC 0x1b -#define CH_STOP 0x03 -#define CH_DEL 0x08 - -/* Contiki toolkit options */ - -#if defined(CTK_CLIENT) || defined(CTK_SERVER) -/* If network is available, turn all options off by the memory reason */ -#define CTK_CONF_ICONS 0 -#define CTK_CONF_ICON_TEXTMAPS 0 -#define CTK_CONF_WINDOWS 1 -#define CTK_CONF_WINDOWCLOSE 0 -#define CTK_CONF_WINDOWMOVE 0 -#define CTK_CONF_MENUS 0 -#define CTK_CONF_HYPERLINK 0 -#elif defined(CTK_NOICON) -/* In the case of loader arch, we omit the icons by the memory reason */ -#define CTK_CONF_ICONS 0 -#define CTK_CONF_ICON_TEXTMAPS 0 -#define CTK_CONF_WINDOWS 1 -#define CTK_CONF_WINDOWCLOSE 1 -#define CTK_CONF_WINDOWMOVE 1 -#define CTK_CONF_MENUS 1 -#define CTK_CONF_HYPERLINK 1 -#else /* CTK_MINIMUM */ -/* Toggles support for desktop icons. */ -#define CTK_CONF_ICONS 1 -/* Define if text icon is used. */ -#define CTK_CONF_ICON_TEXTMAPS 1 -/* Toggles support for windows. */ -#define CTK_CONF_WINDOWS 1 -/* Toggles support for closable windows. */ -#define CTK_CONF_WINDOWCLOSE 1 -/* Toggles support for movable windows. */ -#define CTK_CONF_WINDOWMOVE 1 -/* Toggles support for menus. */ -#define CTK_CONF_MENUS 1 -/* Defines if hyperlink is supported. */ -#define CTK_CONF_HYPERLINK 1 -#endif /* CTK_MINIMUM */ - -/* Define if bitmap icon is used. */ -#define CTK_CONF_ICON_BITMAPS 0 -/* Defines the default width of a menu. */ -#define CTK_CONF_MENUWIDTH 16 -/* Defines if screen saver is supported. */ -#define CTK_CONF_SCREENSAVER 0 -/* Defines if mouse is supported. */ -#define CTK_CONF_MOUSE_SUPPORT 0 - -/* The maximum number of menu items in each menu. */ -#define CTK_CONF_MAXMENUITEMS 4 - -/* Key used to switch the frontmost window. */ -#define CTK_CONF_WINDOWSWITCH_KEY CH_F3 -/* Key used to move down a widget. */ -#define CTK_CONF_WIDGETDOWN_KEY CH_TAB -/* Key used to move up a widget. */ -#define CTK_CONF_WIDGETUP_KEY CH_F5 -/* Defines which key that is to be used for activating the menus */ -#define CTK_CONF_MENU_KEY CH_F1 - -#ifdef LIBCONIO_CONF_EXPORT -#define LIBCONIO_EXPORT LIBCONIO_CONF_EXPORT -#else /* LIBCONIO_CONF_EXPORT */ -#define LIBCONIO_EXPORT 0 -#endif /* LIBCONIO_CONF_EXPORT */ - -/* Imported symbols from ctk.h */ - -#define _CTK_FOCUS_NONE 0 -#define _CTK_FOCUS_WIDGET 1 -#define _CTK_FOCUS_WINDOW 2 -#define _CTK_FOCUS_DIALOG 4 - -#define _CTK_WIDGET_SEPARATOR 1 -#define _CTK_WIDGET_LABEL 2 -#define _CTK_WIDGET_BUTTON 3 -#define _CTK_WIDGET_HYPERLINK 4 -#define _CTK_WIDGET_TEXTENTRY 5 -#define _CTK_WIDGET_BITMAP 6 -#define _CTK_WIDGET_ICON 7 - -#define _CTK_TEXTENTRY_NORMAL 0 -#define _CTK_TEXTENTRY_EDIT 1 - -#endif /* __CTK_ARCH_DEF_H__ */ diff --git a/platform/pc-6001/ctk/ctk_arch.h b/platform/pc-6001/ctk/ctk_arch.h deleted file mode 100644 index d6e34057f..000000000 --- a/platform/pc-6001/ctk/ctk_arch.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2007, Takahide Matsutsuka. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - */ - -/* - * \file - * ctk_arch.h - * Archtecture specific definitions and library declarations. - * \author - * Takahide Matsutsuka - */ - -#ifndef __CTK_ARCH_H__ -#define __CTK_ARCH_H__ - -#include "ctk/ctk_arch-def.h" -#include "dev/getkey.h" -#include "dev/isprint_arch.h" - -#endif /* __CTK_ARCH_H__ */ diff --git a/platform/pc-6001/ctk/libconio_arch-asm.cS b/platform/pc-6001/ctk/libconio_arch-asm.cS deleted file mode 100644 index 3e30bdf0a..000000000 --- a/platform/pc-6001/ctk/libconio_arch-asm.cS +++ /dev/null @@ -1,382 +0,0 @@ -;;; -;;; -;;; libconio_arch-asm.hS -;;; -;;; Architecture depend libconio implementation. -;;; This assembler source contributes basically saving for speed and memory. -;;; -;;; @author Takahide Matsutsuka -;;; -;;; $Id: libconio_arch-asm.cS,v 1.2 2007/09/29 04:10:00 matsutsuka Exp $ -;;; - - ;; uses preprocessor to enable definitions -#include "ctk_arch-def.h" - - ;; export symbols -.if LIBCONIO_EXPORT - .globl _cputc_arch - .globl _cputs_arch - .globl _cputsn_arch - .globl _chline_arch - .globl _cvline_arch - .globl _gotoxy_arch - .globl _clearto_arch - .globl _revers_arch - .globl _clip_arch -.endif - .globl _wherex_arch - .globl _wherey_arch - - .area _DATA -_screen_cursor: - .ds 1 ; x - .ds 1 ; y -_screen_clips: - .ds 1 ; clip y1 - .ds 1 ; clip y2 -_screen_reversed: - .ds 1 - - .area _CODE - -_libconio_arch_asm_start:: - ;; --------------------------------- - ;; void cputc(char ch); - ;; Stack; retl reth ch - ;; AFBCDEHL____ - ;; return A=1 if output is succeeded, A=0 if not - ;; --------------------------------- -.if LIBCONIO_EXPORT -_cputc_arch: - ld hl, #2 - add hl, sp - ld a, (hl) -.endif ; LIBCONIO_EXPORT - ;; ------------ - ;; A = char - ;; AFBCDEHL____ - ;; ------------ -_cputc_arch_asm:: - push af - ld bc, (#_screen_cursor) ;B=y, C=x - ld de, (#_screen_clips) ;D=cy2, E=cy1 - ld a, b - cp a, e - jr c, _cputc_arch_ret_false ; if (cursy < cy1) - cp a, d - jr z, _cputc_arch_next1 - jr nc, _cputc_arch_ret_false ; if (cursy > cy2) -_cputc_arch_next1: - cp a, #SCREEN_HEIGHT ; cursy - SCREEN_HEIGHT - jr z, _cputc_arch_next2 - jr nc, _cputc_arch_ret_false ; if (cursy > SCREEN_HEIGHT) -_cputc_arch_next2: - ld a, c - cp a, #SCREEN_WIDTH ; cursx - SCREEN_WIDTH - jr nc, _cputc_arch_ret_false ; if (cursx >= SCREEN_WIDTH) - ;; calculate offset - ld a, b ; A=y - ld hl, #0 - ld de, #SCREEN_WIDTH -_cputc_arch_loop: - or a - jr z, _cputc_arch_calcx - add hl, de - dec a - jr _cputc_arch_loop -_cputc_arch_calcx: - ld d, #0 - ld e, c - add hl, de - - ;; putchar - pop af - ld de, #VRAM_CHAR - push hl - add hl, de - ld (hl), a - pop hl - ;; putattr - ld de, #VRAM_ATTR - add hl, de - ld a, (#_screen_reversed) - or a - jr z, _cputc_arch_normal - ld (hl), #COLOR_REVERSED - jr _cputc_arch_ret -_cputc_arch_normal: - ld (hl), #COLOR_NORMAL - ld a, #0x01 -_cputc_arch_ret: - ld hl, #_screen_cursor - inc (hl) - ret -_cputc_arch_ret_false: - pop af - xor a - jr _cputc_arch_ret - - ;; --------------------------------- - ;; void cputs_arch(char *str); - ;; Stack; retl reth strl strh - ;; AFB_DEHL____ - ;; return void - ;; --------------------------------- -.if 1 -_cputs_arch:: - ld hl, #2 - add hl, sp - ld e, (hl) - inc hl - ld d, (hl) -.endif ; LIBCONIO_EXPORT - - ;; ------------ - ;; DE = str - ;; AFB_DEHL____ - ;; ------------ -_cputs_arch_asm:: - ld b, #SCREEN_WIDTH ; max length - jr _cputsn_arch_asm ; take over B and DE - - ;; --------------------------------- - ;; void cputsn(char *str, unsigned char length); - ;; Stack; retl reth strl strh length - ;; AFB_DEHL____ - ;; return void - ;; --------------------------------- -.if LIBCONIO_EXPORT -_cputsn_arch: - ld hl, #2 - add hl, sp - ld e, (hl) - inc hl - ld d, (hl) - inc hl - ld b, (hl) -.endif ; LIBCONIO_EXPORT - - ;; ------------ - ;; B = nchars - ;; DE = str - ;; AFB_DEHL____ - ;; ------------ -_cputsn_arch_asm:: - ld a, (de) - or a - ret z - push bc - push de - call _cputc_arch_asm - pop de - pop bc - inc de - djnz _cputsn_arch_asm - ret - - ;; --------------------------------- - ;; void chline(unsigned char length); - ;; Stack; retl reth length - ;; AFB_DEHL____ - ;; return void - ;; --------------------------------- -.if LIBCONIO_EXPORT -_chline_arch: - ld hl, #2 - add hl, sp - ld b, (hl) - ;; ------------ - ;; B = length - ;; AFB_DEHL____ - ;; ------------ -.endif -_chline_arch_asm:: - ld a, #CH_HOLILINE - push bc - call _cputc_arch_asm - pop bc - djnz _chline_arch_asm - ret - - ;; --------------------------------- - ;; void cvline(unsigned char length); - ;; Stack; retl reth length - ;; AFB_DEHL____ - ;; return void - ;; --------------------------------- -.if LIBCONIO_EXPORT -_cvline_arch: - ld hl, #2 - add hl, sp - ld b, (hl) ; length -.endif ; LIBCONIO_EXPORT - ;; ------------ - ;; B = length - ;; AFB_DEHL____ - ;; ------------ -_cvline_arch_asm:: - ld hl, (#_screen_cursor) ; H=y, L=x -_cvline_arch_loop: - ld a, #CH_VERTLINE - push hl - push bc - call _cputc_arch_asm - pop bc - pop hl - inc h - ld (#_screen_cursor), hl - djnz _cvline_arch_loop - ret - - ;; --------------------------------- - ;; void gotoxy(unsigned char x, unsigned char y) - ;; Stack; retl reth x y - ;; _F__DEHL____ - ;; return void - ;; --------------------------------- -.if 1 -_gotoxy_arch:: - ld hl, #2 - add hl, sp - ld e, (hl) ; y - inc hl - ld d, (hl) ; x - ld l, e ; L=x - ld h, d ; H=y -.endif ; LIBCONIO_EXPORT - - ;; ------------ - ;; H = x, L = y - ;; ____________ - ;; ------------ -_gotoxy_arch_asm:: - ld (#_screen_cursor), hl - ret - - ;; --------------------------------- - ;; void clearto_arch(unsigned char to) - ;; Stack; retl reth to - ;; AFBCDEHL____ - ;; return void - ;; --------------------------------- -.if LIBCONIO_EXPORT -_clearto_arch: - ld hl, #2 - add hl, sp - ld a, (hl) -.endif ; LIBCONIO_EXPORT - ;; ------------ - ;; A = to - ;; AFBCDEHL____ - ;; ------------ -_clearto_arch_asm:: - ld hl, #_screen_cursor - cp (hl) ; to - cursx - ret z - ret c - push af - ld a, #CH_SPACE - call _cputc_arch_asm - or a - pop af - ret z - jr _clearto_arch_asm - - ;; --------------------------------- - ;; void revers_arch(unsigned char reverse) - ;; Stack; retl reth reverse - ;; A_____HL____ - ;; return void - ;; --------------------------------- -.if LIBCONIO_EXPORT -_revers_arch: - ld hl, #2 - add hl, sp - ld a, (hl) -.endif ; LIBCONIO_EXPORT - ;; A = reverse - ;; ____________ -_revers_arch_asm:: - ld (#_screen_reversed), a - ret - - ;; --------------------------------- - ;; void clip_arch(unsigned char clip1, unsigned char clip2) - ;; Stack; retl reth clip1 clip2 - ;; ____________ - ;; return void - ;; --------------------------------- -.if LIBCONIO_EXPORT -_clip_arch: - push af - push hl - push de - ld hl, #0x08 - add hl, sp - ld de, #_screen_clips - ld a, (hl) - ld (de), a - inc hl - inc de - ld a, (hl) - ld (de), a - pop de - pop hl - pop af - ret -.endif - ;; --------------------------------- - ;; L = clipy1, H = clipy2 - ;; ____________ - ;; --------------------------------- -_clip_arch_asm:: - ld (#_screen_clips), hl - ret - - ;; --------------------------------- - ;; unsigned char wherex_arch() - ;; Stack; retl reth - ;; A______L____ - ;; return x - ;; --------------------------------- -_wherex_arch: - ld a, (#_screen_cursor) - ld l, a - ret - - ;; --------------------------------- - ;; unsigned char wherey_arch() - ;; Stack; retl reth - ;; A______L____ - ;; return y - ;; --------------------------------- -_wherey_arch: - ld a, (#_screen_cursor + 1) - ld l, a - ret - -.if 0 -_newline_arch: - ld hl, #_screen_cursor - xor a - ld (hl), a - inc hl - ld a, (hl) - inc a - cp a, #SCREEN_HEIGHT - jr nc, _newline_arch_scroll - ld (hl), a - ret -_newline_arch_scroll: - ;; TODO: attr and specific impl - dec a - ld (hl), a - ld hl, #VRAM_CHAR + #SCREEN_WIDTH - ld de, #VRAM_CHAR - ld bc, #SCREEN_HEIGHT * #SCREEN_WIDTH - #SCREEN_WIDTH - ldir - ret -.endif - -_libconio_arch_asm_end:: diff --git a/platform/pc-6001/ctk/libconio_arch-small.cS b/platform/pc-6001/ctk/libconio_arch-small.cS deleted file mode 100644 index 1ff865faa..000000000 --- a/platform/pc-6001/ctk/libconio_arch-small.cS +++ /dev/null @@ -1,115 +0,0 @@ -;;; -;;; -;;; libconio_arch-small.hS -;;; -;;; Architecture depend libconio implementation. -;;; This assembler source contributes basically saving for speed and memory. -;;; -;;; @author Takahide Matsutsuka -;;; -;;; $Id: libconio_arch-small.cS,v 1.2 2007/11/28 09:38:21 matsutsuka Exp $ -;;; - - ;; uses preprocessor to enable definitions -#include "ctk_arch-def.h" - - ;; export symbols - .globl _clrscr_arch - .globl _libputc_arch - .globl _libputs_arch - - .area _DATA -_screen_offset:: - .ds 2 - - .area _CODE - -_libconio_arch_small_start:: - -_clrscr_arch: - ld hl, #0 - ld (#_screen_offset), hl - ld hl, #VRAM_CHAR - ld bc, #VRAM_CHAR + #SCREEN_HEIGHT * #SCREEN_WIDTH -_clrscr_arch_loop1: - ld (hl), #CH_SPACE - inc hl - ld a, h - cp b - jr nz, _clrscr_arch_loop1 - ld a, l - cp c - jr nz, _clrscr_arch_loop1 - ld hl, #VRAM_ATTR - ld bc, #VRAM_ATTR + #SCREEN_HEIGHT * #SCREEN_WIDTH -_clrscr_arch_loop2: - ld (hl), #COLOR_NORMAL - inc hl - ld a, h - cp b - jr nz, _clrscr_arch_loop2 - ld a, l - cp c - jr nz, _clrscr_arch_loop2 - ret - -_libputc_arch: - ld hl, #2 - add hl, sp - ld a, (hl) -_libputc_asm:: - push af - ld hl, (#_screen_offset) - ld bc, #SCREEN_HEIGHT * #SCREEN_WIDTH - ld a, b - cp h - jr nz, _libputc_arch_putc - ld a, c - cp l - jr z, _libputc_arch_scroll -_libputc_arch_putc: - ld bc, #VRAM_CHAR - add hl, bc - pop af - ld (hl), a - ld hl, #_screen_offset - inc (hl) - ret nz - inc hl - inc (hl) - ret -_libputc_arch_scroll: - push de - ld hl, #VRAM_CHAR + #SCREEN_WIDTH - ld de, #VRAM_CHAR - ld bc, #SCREEN_HEIGHT * #SCREEN_WIDTH - #SCREEN_WIDTH - push bc - push de - ldir - pop de - pop hl - push hl - ld (#_screen_offset), hl - ld b, #SCREEN_WIDTH - add hl, de -_libputc_arch_scroll_loop: - ld (hl), #CH_SPACE - inc hl - djnz _libputc_arch_scroll_loop - pop hl - pop de - jr _libputc_arch_putc - -_libputs_arch: - ld hl, #2 - add hl, sp - ld e, (hl) - inc hl - ld d, (hl) -_libputs_arch_loop: - ld a, (hl) - or a - ret z - call _libputc_asm - jr _libputs_arch_loop -_libconio_arch_small_end:: diff --git a/platform/pc-6001/ctk/libconio_arch-small.h b/platform/pc-6001/ctk/libconio_arch-small.h deleted file mode 100644 index 985a8dee4..000000000 --- a/platform/pc-6001/ctk/libconio_arch-small.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __LIBCONIO_ARCH_MSLL_H__ -#define __LIBCONIO_ARCH_MSLL_H__ -#include "contiki.h" - -void clrscr_arch(void); -void libputc_arch(unsigned char ch); -void libputs_arch(char* str); - -unsigned char wherex(void); -unsigned char wherey(void); -void gotoxy(unsigned char x, unsigned char y); - - -#endif /* __LIBCONIO_ARCH_MSLL_H__ */ diff --git a/platform/pc-6001/ctk/libconio_arch.h b/platform/pc-6001/ctk/libconio_arch.h deleted file mode 100644 index 7f3162ae0..000000000 --- a/platform/pc-6001/ctk/libconio_arch.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2007, Takahide Matsutsuka. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - */ - -/* - * \file - * This is architecture-depend contiki toolkit for PC-6001 family. - * \author - * Takahide Matsutsuka - */ - -#ifndef __LIBCONIO_ARCH_H__ -#define __LIBCONIO_ARCH_H__ - -/* The following functions are used by assembler only */ -#if LIBCONIO_EXPORT -void cputc_arch(char c); -void cputs_arch(char *str); -void cputsn_arch(char *str, unsigned char len); -void chline_arch(unsigned char length); -void cvline_arch(unsigned char length); -void clip_arch(unsigned char clip1, unsigned char clip2); -void clearto_arch(unsigned char to); -void revers_arch(unsigned char reversed); -void gotoxy_arch(unsigned char x, unsigned char y); -#endif /* LIBCONIO_CONF_EXPORT */ -unsigned char wherex_arch(); -unsigned char wherey_arch(); - -#endif /* __LIBCONIO_ARCH_H__ */ diff --git a/platform/pc-6001/dev/clock.S b/platform/pc-6001/dev/clock.S deleted file mode 100644 index 2ca70945b..000000000 --- a/platform/pc-6001/dev/clock.S +++ /dev/null @@ -1,34 +0,0 @@ -;;; -;;; -;;; clock.S -;;; -;;; retrieve tickcount from PC-6001's internal timer -;;; -;;; @author Takahide Matsutsuka -;;; -;;; $Id: clock.S,v 1.1 2007/09/11 12:12:59 matsutsuka Exp $ -;;; - .globl _clock_time - - .area _GSINIT - ;; --------------------------------- - ;; unsigned long clock_time(); - ;; __BCDEHL____ - ;; return long value as (DE, BC) - ;; --------------------------------- - ;; this function uses PC-6001's internal timer - ;; which counts up 2 per 1/512 sec. - .area _CODE -_clock_time: - ld hl, #0xfa28 - ld c, (hl) - inc hl - ld b, (hl) - inc hl - ld e, (hl) - inc hl - ld d, (hl) - ld l, c - ld h, b - - ret diff --git a/platform/pc-6001/dev/getkey.S b/platform/pc-6001/dev/getkey.S deleted file mode 100644 index 266dd7937..000000000 --- a/platform/pc-6001/dev/getkey.S +++ /dev/null @@ -1,74 +0,0 @@ -;;; -;;; -;;; getkey.S -;;; -;;; PC-6001 architecture-depend key fetch module -;;; -;;; @author Takahide Matsutsuka -;;; - - .globl _keyavail_arch - .globl _getkey_arch - .area _GSINIT - - .area _DATA - ;; unsigned char key; -_key: - .ds 1 - - .area _GSINIT - .area _CODE - - ;; --------------------------------- - ;; unsigned char keyavail_arch(); - ;; AFBC__HL____ - ;; a=getkey, l=getkey - ;; --------------------------------- -_keyavail_arch: - ld hl, #_key - ld a, (hl) - ;; if (key != 0) return 1; else goto _getch; - or a - jr z, _getch - ld l, #0x01 - ret - -_getch: - push hl - ;; A = (keybuf) - call #0x103a - pop hl - ;; if (keybuf != null) goto _getch_key - jr nz, _getch_key - ;; we do not have a keyin - xor a - jr _getch_got -_getch_key: - cp a, #0x14 - jr z, _getch - -_getch_got: - ;; key = getch() - ld (hl), a - ld l, a - ret - - - ;; --------------------------------- - ;; unsigned char getkey_arch(); - ;; AFBC__HL____ - ;; --------------------------------- -_getkey_arch: - ;; if (key == 0) keyavail_arch(); - ld hl, #_key - ld a, (hl) - or a - call z, _keyavail_arch - ;; if (key == 0) goto _havekey - or a - jr z, _havekey - ;; key = 0 - ld (hl), #0x00 -_havekey: - ld l, a - ret diff --git a/platform/pc-6001/dev/getkey.h b/platform/pc-6001/dev/getkey.h deleted file mode 100644 index b1dca4786..000000000 --- a/platform/pc-6001/dev/getkey.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2007, Takahide Matsutsuka. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/* - * \file - * A header file for machine depend key fetching functions. - * \author - * Takahide Matsutsuka - */ - -#ifndef __GETKEY_H__ -#define __GETKEY_H__ - -/* defined in getch.S */ -typedef char ctk_arch_key_t; -ctk_arch_key_t keyavail_arch(); -ctk_arch_key_t getkey_arch(); -#define CTK_ARCH_KEY_T -#define ctk_arch_getkey() getkey_arch() -#define ctk_arch_keyavail() keyavail_arch() - -#endif /* __GETKEY_H__ */ diff --git a/platform/pc-6001/dev/isprint_arch.S b/platform/pc-6001/dev/isprint_arch.S deleted file mode 100644 index 4ccf694f2..000000000 --- a/platform/pc-6001/dev/isprint_arch.S +++ /dev/null @@ -1,38 +0,0 @@ -;;; -;;; -;;; isprint-arch.S -;;; -;;; Architecture depend isprint function. -;;; -;;; @author Takahide Matsutsuka -;;; -;;; $Id: isprint_arch.S,v 1.1 2007/09/11 12:12:59 matsutsuka Exp $ -;;; - .globl _isprint_arch - .area _GSINIT - - ;; unsigned long clock_time(); - ;; return long value as (DE, BC) - - ;; this function is identify if a given - ;; character is printable on PC-6001 - .area _CODE -_isprint_arch: - ;; --------------------------------- - ;; char isprint (unsigned char ch); - ;; Stack; retl reth ch - ;; A_____HL____ - ;; return l - ;; --------------------------------- - ld hl, #2 - add hl, sp - ld a, (hl) - or a - jr z, #_isprint_arch_ret_false - cp #0xfe - jr nc, #_isprint_arch_ret_false - ld l, #1 - ret -_isprint_arch_ret_false: - ld l, #0 - ret diff --git a/platform/pc-6001/dev/isprint_arch.h b/platform/pc-6001/dev/isprint_arch.h deleted file mode 100644 index 90da5f101..000000000 --- a/platform/pc-6001/dev/isprint_arch.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2007, Takahide Matsutsuka. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/* - * \file - * A header file for machine depend isprint function. - * \author - * Takahide Matsutsuka - */ - -#ifndef __ISPRINT_ARCH_H__ -#define __ISPRINT_ARCH_H__ - -/* defined in isprint_arch.S */ -unsigned char isprint_arch(char ch); -#define ctk_arch_isprint(c) isprint_arch(c) - -#endif /* __ISPRINT_ARCH_H__ */ diff --git a/platform/pc-6001/dev/rs232-asm.S b/platform/pc-6001/dev/rs232-asm.S deleted file mode 100644 index 1cdfd0183..000000000 --- a/platform/pc-6001/dev/rs232-asm.S +++ /dev/null @@ -1,188 +0,0 @@ -;;; -;;; -;;; rs232-asm.S -;;; -;;; PC-6001 Architecture depend RS-232C implementation, -;;; uses a bunch of BIOS functions. -;;; -;;; @author Takahide Matsutsuka -;;; -;;; $Id: rs232-asm.S,v 1.3 2007/11/28 09:39:30 matsutsuka Exp $ -;;; - - ;; definitions of PC-6001 BIOS routines -_rs232c_initialize = 0x19bf -_buffer_out = 0x2627 -_char_input_sub = 0x2642 -_count_buffer = 0x26a2 -_rs232c_intr_vector = 0xfa04 -_subcpu_handshake_out = 0x0e8f -LOG = 0 -CTK = 0 - ;; export symbols - .globl _rs232_arch_writeb - .globl _rs232_arch_poll - .globl _rs232_arch_init - - .area _CODE - -.if LOG -_hex: - .ascii "0123456789ABCDEF" -.if CTK - .globl _cputc_arch_asm -.else - .globl _libputc_asm - .globl _screen_offset -.endif -_rs232_arch_putc: ; a = data - ld hl, #0 - ld (#_screen_offset), hl - push af - srl a - srl a - srl a - srl a - call _rs232_arch_putc_next1 - pop af - and a, #0x0f -_rs232_arch_putc_next1: - ld hl, #_hex -_rs232_arch_putc_loop: - or a - jr z, _rs232_arch_putc_next2 - inc hl - dec a - jr _rs232_arch_putc_loop -_rs232_arch_putc_next2: - ld a, (hl) -.if CTK - call _cputc_arch_asm -.else - call _libputc_asm -.endif - ret -.endif - - ;; --------------------------------- - ;; void rs232_writeb(uint8_t c) - ;; Stack; retl reth c - ;; AF__D_HL____ - ;; return void - ;; --------------------------------- -_rs232_arch_writeb: - ld hl, #2 - add hl, sp - ld d, (hl) -.if LOG - push de - ld a, #0x77 ; 'w' -.if CTK - call _cputc_arch_asm -.else - call _libputc_asm -.endif - pop de - ;; ld a, d - ;; push de - ;; call _rs232_arch_putc - ;; pop de -.endif -_rs232_arch_writeb_loop: - in a, (#0x81) - and a, #0x01 - cp #0x01 ; TxRDY? 0x01/0x81/0x85 - jr nz, _rs232_arch_writeb_loop - ld a, d - out (#0x80), a - ret - - ;; RS-232C interrupt routine - ;; receive a byte and put it into the buffer -_rs232_arch_intr: - push bc - push af - push de - push hl - in a, (#0x81) - and a, #0x02 ; RxRDY? - jr z, _rs232_arch_intr_next ; no input - in a, (#0x80) - ld e, a - ld a, #0x01 - call _buffer_out ; buffer output A=bufno, e=data -_rs232_arch_intr_next: - ld a, #0x0c - call _subcpu_handshake_out ; sub CPU handshake output A - call _rs232_arch_bufchk - pop hl - pop de - pop af - pop bc - ei - ret - -_rs232_arch_bufchk: - ld a, #0x01 - call _count_buffer ; count buffer available bytes -> A - cp #0x02 ; A >= 2? - ld a, #0x37 ; Rx enable - jr nc, _rs232_arch_bufchk_next ; buffer available bytes >= 2 - ld a, #0x33 ; Rx disable -_rs232_arch_bufchk_next: - out (#0x81),a ; buf available=0x37, buf full=0x33 - ret - - ;; --------------------------------- - ;; unsigned char rs232_arch_poll(unsigned char *stat); - ;; Stack; retl reth statl stath - ;; AFBCDEHL____ - ;; return input byte (*stat == 0 if no input) - ;; --------------------------------- -_rs232_arch_poll: - ld hl, #2 - add hl, sp - ld e, (hl) - inc hl - ld d, (hl) - ld a, #0x01 - ld (de), a - di - call _char_input_sub ; read from buffer - ei - push af - call _rs232_arch_bufchk ; buffer check - pop af - jr nz, _rs232_arch_poll_ret - xor a ; we have no data in the buffer - ld (de), a - jr _rs232_arch_poll_ret2 -_rs232_arch_poll_ret: -.if LOG - call _libputc_asm - ;; call _rs232_arch_putc -.endif -_rs232_arch_poll_ret2: - pop af - ld l, a - ret - - ;; --------------------------------- - ;; void rs232_init(unsigned long ubr); - ;; Stack; retl reth ubr1 ubr2 ubr3 ubr4 - ;; AFB_DEHL____ - ;; return void - ;; --------------------------------- -_rs232_arch_init: - ld hl, #_rs232_arch_intr - di - ld (#_rs232c_intr_vector), hl - ei - ;; S2 S1 PE P L2 L1 B2 B1 - ;; 0 1 0 0 1 1 1 1 - ;; 8-N-1 64x clock - ld b, #0x4f - call _rs232c_initialize - ld a, #0x37 - out (#0x81), a - ret diff --git a/platform/pc-6001/dev/rtimer-arch.h b/platform/pc-6001/dev/rtimer-arch.h deleted file mode 100644 index acc1aab84..000000000 --- a/platform/pc-6001/dev/rtimer-arch.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2007, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/* - * \file - * A configuration file of machine depend rtimer. - * \authort - * Takahide Matsutsuka - */ - - -#ifndef __RTIMER_ARCH_H__ -#define __RTIMER_ARCH_H__ - -#define RTIMER_ARCH_SECOND 1024 - -#endif /* __RTIMER_ARCH_H__ */ diff --git a/platform/pc-6001/loader/loader_arch.c b/platform/pc-6001/loader/loader_arch.c deleted file mode 100644 index 33184e0bf..000000000 --- a/platform/pc-6001/loader/loader_arch.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2007, Takahide Matsutsuka. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - */ - -/* - * \file - * loader-arch.c - * A machine-dependent implementation of program loader for PC-6001 family. - * \author - * Takahide Matsutsuka - */ - -#ifdef WITH_LOADER_ARCH -#include "contiki.h" -#include "loader.h" -#include "loader/mef.h" -#include "loader/loader_arch.h" - -unsigned char load_byte() { return 0; } - -struct dsc* -loader_arch_load_dsc(char *name) -{ - mef_load((unsigned char *) 0xc800); - log_message("loader_arch_load_dsc", name); -} -unsigned char -loader_arch_load(char *name, char *arg) -{ - log_message("loader_arch_load", name); - return LOADER_ERR_NOLOADER; -} -void -loader_arch_unload() -{ - log_message("loader_arch_unload", name); -} -void -loader_arch_unload_dsc(struct dsc *dsc) -{ - log_message("loader_arch_unload_dsc", name); -} - -#endif /* WITH_LOADER_ARCH */ diff --git a/platform/pc-6001/loader/loader_arch.h b/platform/pc-6001/loader/loader_arch.h deleted file mode 100644 index 44cf98535..000000000 --- a/platform/pc-6001/loader/loader_arch.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2007, Takahide Matsutsuka. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - */ - -/* - * \file - * loader-arch.h - * Definitions of machine-dependent loader for PC-6001 family. - * \author - * Takahide Matsutsuka - */ - -#ifndef __LOADER_ARCH_H__ -#define __LOADER_ARCH_H__ - -#ifdef WITH_LOADER_ARCH -#define LOADER_LOAD(name, arg) loader_arch_load(name, arg) -#define LOADER_UNLOAD() loader_arch_unload() -#define LOADER_LOAD_DSC(name) loader_arch_load_dsc(name) -#define LOADER_UNLOAD_DSC(dsc) loader_arch_unload_dsc(dsc) - - - -struct dsc *loader_arch_load_dsc(char *name); -unsigned char loader_arch_load(char *name, char *arg); -void loader_arch_unload(); -void loader_arch_unload_dsc(struct dsc *dsc); -#endif /* WITH_LOADER_ARCH */ - -#endif /* __LOADER_ARCH_H__ */ diff --git a/platform/redbee-dev/Makefile.redbee-dev b/platform/redbee-dev/Makefile.redbee-dev deleted file mode 100644 index 7c4f29230..000000000 --- a/platform/redbee-dev/Makefile.redbee-dev +++ /dev/null @@ -1,21 +0,0 @@ -# -*- makefile -*- - -CONTIKI_TARGET_DIRS = . dev apps net -CONTIKI_CORE=contiki-mc1322x-main -CONTIKI_TARGET_MAIN = ${CONTIKI_CORE}.o - -CONTIKI_TARGET_SOURCEFILES += contiki-mc1322x-main.c clock.c button-sensor.c sensors.c slip.c - -CONTIKIMC1322X=$(CONTIKI)/cpu/mc1322x -CONTIKIBOARD=. - -CONTIKI_PLAT_DEFS = - -MCU=arm7tdmi-s - -ifeq ($(UIP_CONF_IPV6),1) -CFLAGS += -DWITH_UIP6=1 -endif - -include $(CONTIKIMC1322X)/Makefile.mc1322x - diff --git a/platform/redbee-dev/button-sensor.c b/platform/redbee-dev/button-sensor.c deleted file mode 100644 index a1e080618..000000000 --- a/platform/redbee-dev/button-sensor.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2010, Mariano Alvira and other contributors - * to the MC1322x project (http://mc1322x.devl.org) and Contiki. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki OS. - * - */ - -#include "lib/sensors.h" -#include "dev/button-sensor.h" - -#include "mc1322x.h" - -#include - -const struct sensors_sensor button_sensor; - -static struct timer debouncetimer; -static int status(int type); - -void kbi4_isr(void) { - if(timer_expired(&debouncetimer)) { - timer_set(&debouncetimer, CLOCK_SECOND / 4); - sensors_changed(&button_sensor); - } - clear_kbi_evnt(4); -} - -static int -value(int type) -{ - return bit_is_set(gpio_data_get((0x1ULL << 26)), 26) || !timer_expired(&debouncetimer); -} - -static int -configure(int type, int c) -{ - switch (type) { - case SENSORS_ACTIVE: - if (c) { - if(!status(SENSORS_ACTIVE)) { - timer_set(&debouncetimer, 0); - enable_irq_kbi(4); - } - } else { - disable_irq_kbi(4); - } - return 1; - } - return 0; -} - -static int -status(int type) -{ - switch (type) { - case SENSORS_ACTIVE: - case SENSORS_READY: - return bit_is_set(*CRM_WU_CNTL, 20); /* check if kbi4 irq is enabled */ - } - return 0; -} - -SENSORS_SENSOR(button_sensor, BUTTON_SENSOR, - value, configure, status); diff --git a/platform/redbee-dev/contiki-conf.h b/platform/redbee-dev/contiki-conf.h deleted file mode 100644 index dceb1490d..000000000 --- a/platform/redbee-dev/contiki-conf.h +++ /dev/null @@ -1,240 +0,0 @@ -/* - * Copyright (c) 2010, Mariano Alvira and other contributors - * to the MC1322x project (http://mc1322x.devl.org) and Contiki. - * - * Copyright (c) 2006, Technical University of Munich - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - * @(#)$$ - */ - -/** - * \file - * Configuration for MC1322x hobby board based on - * Configuration for sample STK 501 Contiki kernel - * - * \author - * Originial by: - * Simon Barner - */ - -#ifndef __CONTIKI_CONF_H__ -#define __CONTIKI_CONF_H__ - -#include - -/* mc1322x files */ -#include "contiki-mc1322x-conf.h" -/* this is from cpu/mc1322x/board */ -#include "redbee-dev.h" - -/* Clock ticks per second */ -#define CLOCK_CONF_SECOND 100 -/* set to 1 to toggle the green led ever second */ -/* FIXME setting this will break the sensor button (and other gpio) */ -/* since leds_arch hits the entire gpio_data */ -#define BLINK_SECONDS 0 - -#define CCIF -#define CLIF - -/* Baud rate */ -#define BRMOD 9999 -/* 230400 bps, INC=767, MOD=9999, 24Mhz 16x samp */ -/* 115200 bps, INC=767, MOD=9999, 24Mhz 8x samp */ -#define BRINC 767 -/* 921600 bps, MOD=9999, 24Mhz 16x samp */ -//#define INC 3071 -#define SAMP UCON_SAMP_8X -//#define SAMP UCON_SAMP_16X - -#define uart_init uart1_init -#define dbg_putchar(x) uart1_putc(x) - -#define USE_FORMATTED_STDIO 1 -#define MACA_DEBUG 0 -#define CONTIKI_MACA_RAW_MODE 0 -#define USE_32KHZ_XTAL 0 - -#define BLOCKING_TX 0 - -/* end of mc1322x specific config. */ - -/* start of conitki config. */ - -/* Core rtimer.h defaults to 16 bit timer unless RTIMER_CLOCK_LT is defined */ -typedef unsigned long rtimer_clock_t; -#define RTIMER_CLOCK_LT(a,b) ((signed long)((a)-(b)) < 0) - -#define RIMEADDR_CONF_SIZE 8 - -/* EUI64 generation */ -/* Organizationally Unique Identifier */ -#define OUI 0xacde48 /* if IAB is defined then OUI = 0x0050C2 */ -#define IAB 0xA8C /* IAB 0xA8C for use on Redwire products only */ -//#undef IAB /* do not define an IAB if you are using a full OUI */ -//#define EXT_ID 0xdef123 /* lower 12-bits used if IAB is defined */ -#undef EXT_ID /* if an extention id is not defined then one will be generated randomly */ - -#define FLASH_BLANK_ADDR /* if defined then the generated rime address will flashed */ - -#if WITH_UIP6 -/* Network setup for IPv6 */ -#define NETSTACK_CONF_NETWORK sicslowpan_driver -#define NETSTACK_CONF_MAC nullmac_driver -/*#define NETSTACK_CONF_RDC contikimac_driver*/ /* contikimac for redbee hasn't been well tested */ -#define NETSTACK_CONF_RDC nullrdc_driver -#define NETSTACK_CONF_RADIO contiki_maca_driver -#define NETSTACK_CONF_FRAMER framer_802154 - -#define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8 -#define RIME_CONF_NO_POLITE_ANNOUCEMENTS 0 -#define CXMAC_CONF_ANNOUNCEMENTS 0 -#define XMAC_CONF_ANNOUNCEMENTS 0 - -#else /* WITH_UIP6 */ -/* Network setup for non-IPv6 (rime). */ - -#define NETSTACK_CONF_NETWORK rime_driver -#define NETSTACK_CONF_MAC csma_driver -#define NETSTACK_CONF_RDC sicslowmac_driver -#define NETSTACK_CONF_RADIO contiki_maca_driver -#define NETSTACK_CONF_FRAMER framer_802154 - -#define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8 - -#define COLLECT_CONF_ANNOUNCEMENTS 1 -#define RIME_CONF_NO_POLITE_ANNOUCEMENTS 0 -#define CXMAC_CONF_ANNOUNCEMENTS 0 -#define XMAC_CONF_ANNOUNCEMENTS 0 -#define CONTIKIMAC_CONF_ANNOUNCEMENTS 0 - -#define CONTIKIMAC_CONF_COMPOWER 0 -#define XMAC_CONF_COMPOWER 0 -#define CXMAC_CONF_COMPOWER 0 - -#define COLLECT_NBR_TABLE_CONF_MAX_NEIGHBORS 32 - -#endif /* WITH_UIP6 */ - -#define QUEUEBUF_CONF_NUM 16 - -#define PACKETBUF_CONF_ATTRS_INLINE 1 - -#ifndef RF_CHANNEL -#define RF_CHANNEL 26 -#endif /* RF_CHANNEL */ - -#define CONTIKIMAC_CONF_BROADCAST_RATE_LIMIT 0 - -#define IEEE802154_CONF_PANID 0xABCD - -#define PROFILE_CONF_ON 0 -#define ENERGEST_CONF_ON 0 - -#define AODV_COMPLIANCE -#define AODV_NUM_RT_ENTRIES 32 - -#define WITH_ASCII 1 - -#define PROCESS_CONF_NUMEVENTS 8 -#define PROCESS_CONF_STATS 1 - -#ifdef WITH_UIP6 - -#define RIMEADDR_CONF_SIZE 8 - -#define UIP_CONF_LL_802154 1 -#define UIP_CONF_LLH_LEN 0 - -#define UIP_CONF_ROUTER 1 -#define UIP_CONF_IPV6_RPL 1 - -#define NBR_TABLE_CONF_MAX_NEIGHBORS 30 -#define UIP_CONF_MAX_ROUTES 30 - -#define UIP_CONF_ND6_SEND_RA 0 -#define UIP_CONF_ND6_REACHABLE_TIME 600000 -#define UIP_CONF_ND6_RETRANS_TIMER 10000 - -#define UIP_CONF_IPV6 1 -#define UIP_CONF_IPV6_QUEUE_PKT 0 -#define UIP_CONF_IPV6_CHECKS 1 -#define UIP_CONF_IPV6_REASSEMBLY 0 -#define UIP_CONF_NETIF_MAX_ADDRESSES 3 -#define UIP_CONF_ND6_MAX_PREFIXES 3 -#define UIP_CONF_ND6_MAX_DEFROUTERS 2 -#define UIP_CONF_IP_FORWARD 0 -#define UIP_CONF_BUFFER_SIZE 1300 -#define SICSLOWPAN_CONF_FRAG 1 -#define SICSLOWPAN_CONF_MAXAGE 8 - -#define SICSLOWPAN_CONF_COMPRESSION_IPV6 0 -#define SICSLOWPAN_CONF_COMPRESSION_HC1 1 -#define SICSLOWPAN_CONF_COMPRESSION_HC01 2 -#define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_COMPRESSION_HC06 -#ifndef SICSLOWPAN_CONF_FRAG -#define SICSLOWPAN_CONF_FRAG 1 -#define SICSLOWPAN_CONF_MAXAGE 8 -#endif /* SICSLOWPAN_CONF_FRAG */ -#define SICSLOWPAN_CONF_CONVENTIONAL_MAC 1 -#define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 2 -#else /* WITH_UIP6 */ -#define UIP_CONF_IP_FORWARD 1 -#define UIP_CONF_BUFFER_SIZE 1300 -#endif /* WITH_UIP6 */ - -#define UIP_CONF_ICMP_DEST_UNREACH 1 - -#define UIP_CONF_DHCP_LIGHT -#define UIP_CONF_LLH_LEN 0 -#define UIP_CONF_RECEIVE_WINDOW 48 -#define UIP_CONF_TCP_MSS 48 -#define UIP_CONF_MAX_CONNECTIONS 4 -#define UIP_CONF_MAX_LISTENPORTS 8 -#define UIP_CONF_UDP_CONNS 12 -#define UIP_CONF_FWCACHE_SIZE 30 -#define UIP_CONF_BROADCAST 1 -#define UIP_ARCH_IPCHKSUM 1 -#define UIP_CONF_UDP 1 -#define UIP_CONF_UDP_CHECKSUMS 1 -#define UIP_CONF_PINGADDRCONF 0 -#define UIP_CONF_LOGGING 0 - -#define UIP_CONF_TCP_SPLIT 0 - -/* include the project config */ -/* PROJECT_CONF_H might be defined in the project Makefile */ -#ifdef PROJECT_CONF_H -#include PROJECT_CONF_H -#endif /* PROJECT_CONF_H */ - -#endif /* __CONTIKI_CONF_H__ */ diff --git a/platform/redbee-dev/contiki-mc1322x-main.c b/platform/redbee-dev/contiki-mc1322x-main.c deleted file mode 100644 index bab6fa482..000000000 --- a/platform/redbee-dev/contiki-mc1322x-main.c +++ /dev/null @@ -1,492 +0,0 @@ -/* - * Copyright (c) 2010, Mariano Alvira and other contributors - * to the MC1322x project (http://mc1322x.devl.org) and Contiki. - * - * Copyright (c) 2006, Technical University of Munich - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - * @(#)$$ - */ - -#include -#include -#include - -#include "contiki.h" - -#include "dev/leds.h" -#include "dev/serial-line.h" -#include "dev/slip.h" -#include "dev/xmem.h" -#include "dev/button-sensor.h" -#include "lib/random.h" -#include "net/netstack.h" -#include "net/mac/frame802154.h" - -#if WITH_UIP6 -#include "net/sicslowpan.h" -#include "net/uip-ds6.h" -#include "net/mac/sicslowmac.h" -#endif /* WITH_UIP6 */ - -#include "net/rime.h" - -#include "sys/autostart.h" - -/* from libmc1322x */ -#include "mc1322x.h" -#include "default_lowlevel.h" -#include "contiki-maca.h" -#include "contiki-uart.h" - -#define DEBUG 1 -#if DEBUG -#include -#define PRINTF(...) printf(__VA_ARGS__) -#define PRINT6ADDR(addr) PRINTF(" %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x ", ((uint8_t *)addr)[0], ((uint8_t *)addr)[1], ((uint8_t *)addr)[2], ((uint8_t *)addr)[3], ((uint8_t *)addr)[4], ((uint8_t *)addr)[5], ((uint8_t *)addr)[6], ((uint8_t *)addr)[7], ((uint8_t *)addr)[8], ((uint8_t *)addr)[9], ((uint8_t *)addr)[10], ((uint8_t *)addr)[11], ((uint8_t *)addr)[12], ((uint8_t *)addr)[13], ((uint8_t *)addr)[14], ((uint8_t *)addr)[15]) -#define PRINTLLADDR(lladdr) PRINTF(" %02x:%02x:%02x:%02x:%02x:%02x ",(lladdr)->addr[0], (lladdr)->addr[1], (lladdr)->addr[2], (lladdr)->addr[3],(lladdr)->addr[4], (lladdr)->addr[5]) -#else -#define PRINTF(...) -#define PRINT6ADDR(addr) -#define PRINTLLADDR(addr) -#endif - -#ifndef RIMEADDR_NVM -#define RIMEADDR_NVM 0x1E000 -#endif - -#ifndef RIMEADDR_NBYTES -#define RIMEADDR_NBYTES 8 -#endif - -#define PLATFORM_DEBUG 1 -#if PLATFORM_DEBUG -#define PRINTF(...) printf(__VA_ARGS__) -#else -#define PRINTF(...) -#endif - - -#if UIP_CONF_ROUTER - -#ifndef UIP_ROUTER_MODULE -#ifdef UIP_CONF_ROUTER_MODULE -#define UIP_ROUTER_MODULE UIP_CONF_ROUTER_MODULE -#else /* UIP_CONF_ROUTER_MODULE */ -#define UIP_ROUTER_MODULE rimeroute -#endif /* UIP_CONF_ROUTER_MODULE */ -#endif /* UIP_ROUTER_MODULE */ - -extern const struct uip_router UIP_ROUTER_MODULE; - -#endif /* UIP_CONF_ROUTER */ - -#if DCOSYNCH_CONF_ENABLED -static struct timer mgt_timer; -#endif - -#ifndef WITH_UIP -#define WITH_UIP 0 -#endif - -#if WITH_UIP -#include "net/uip.h" -#include "net/uip-fw.h" -#include "net/uip-fw-drv.h" -#include "net/uip-over-mesh.h" -static struct uip_fw_netif slipif = - {UIP_FW_NETIF(192,168,1,2, 255,255,255,255, slip_send)}; -static struct uip_fw_netif meshif = - {UIP_FW_NETIF(172,16,0,0, 255,255,0,0, uip_over_mesh_send)}; - -#endif /* WITH_UIP */ - -#define UIP_OVER_MESH_CHANNEL 8 -#if WITH_UIP -static uint8_t is_gateway; -#endif /* WITH_UIP */ - -/*---------------------------------------------------------------------------*/ -void uip_log(char *msg) { printf("%c",msg); } -/*---------------------------------------------------------------------------*/ -#ifndef RF_CHANNEL -#define RF_CHANNEL 26 -#endif -/*---------------------------------------------------------------------------*/ -#if WITH_UIP -static void -set_gateway(void) -{ - if(!is_gateway) { -// leds_on(LEDS_RED); - printf("%d.%d: making myself the IP network gateway.\n\n", - rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1]); - printf("IPv4 address of the gateway: %d.%d.%d.%d\n\n", - uip_ipaddr_to_quad(&uip_hostaddr)); - uip_over_mesh_set_gateway(&rimeaddr_node_addr); - uip_over_mesh_make_announced_gateway(); - is_gateway = 1; - } -} -#endif /* WITH_UIP */ -/*---------------------------------------------------------------------------*/ -static void -print_processes(struct process * const processes[]) -{ - /* const struct process * const * p = processes;*/ - printf("Starting"); - while(*processes != NULL) { - printf(" '%s'", (*processes)->name); - processes++; - } - printf("\n"); -} -/*--------------------------------------------------------------------------*/ - -SENSORS(&button_sensor); - -void -init_lowlevel(void) -{ - /* led direction init */ - set_bit(*GPIO_PAD_DIR0,8); - set_bit(*GPIO_PAD_DIR0,9); - set_bit(*GPIO_PAD_DIR0,10); - set_bit(*GPIO_PAD_DIR0,23); - set_bit(*GPIO_PAD_DIR0,24); - set_bit(*GPIO_PAD_DIR0,25); - - /* button init */ - /* set up kbi */ - enable_irq_kbi(4); - kbi_edge(4); - enable_ext_wu(4); -// kbi_pol_neg(7); -// kbi_pol_pos(7); -// gpio_sel0_pullup(29); -// gpio_pu0_disable(29); - - trim_xtal(); - - /* uart init */ - uart_init(BRINC, BRMOD, SAMP); - - default_vreg_init(); - - maca_init(); - - set_channel(RF_CHANNEL - 11); /* channel 11 */ - set_power(0x12); /* 0x12 is the highest, not documented */ - - /* control TX_ON with the radio */ - *GPIO_FUNC_SEL2 = (0x01 << ((44-16*2)*2)); - gpio_pad_dir_set( 1ULL << 44 ); - - enable_irq(CRM); - -#if USE_32KHZ_XTAL - enable_32khz_xtal(); -#else - cal_ring_osc(); -#endif - -#if USE_32KHZ_XTAL - *CRM_RTC_TIMEOUT = 32768 * 10; -#else - *CRM_RTC_TIMEOUT = cal_rtc_secs * 10; -#endif - - /* XXX debug */ - /* trigger periodic rtc int */ -// clear_rtc_wu_evt(); -// enable_rtc_wu(); -// enable_rtc_wu_irq(); -} - -#if RIMEADDR_SIZE == 1 -const rimeaddr_t addr_ff = { { 0xff } }; -#else /*RIMEADDR_SIZE == 2*/ -#if RIMEADDR_SIZE == 2 -const rimeaddr_t addr_ff = { { 0xff, 0xff } }; -#else /*RIMEADDR_SIZE == 2*/ -#if RIMEADDR_SIZE == 8 -const rimeaddr_t addr_ff = { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } }; -#endif /*RIMEADDR_SIZE == 8*/ -#endif /*RIMEADDR_SIZE == 2*/ -#endif /*RIMEADDR_SIZE == 1*/ - -void iab_to_eui64(rimeaddr_t *eui64, uint32_t oui, uint16_t iab, uint32_t ext) { - /* OUI for IABs */ - eui64->u8[0] = 0x00; - eui64->u8[1] = 0x50; - eui64->u8[2] = 0xc2; - - /* EUI64 field */ - eui64->u8[3] = 0xff; - eui64->u8[4] = 0xfe; - - /* IAB */ - eui64->u8[5] = (iab >> 4) & 0xff; - eui64->u8[6] = (iab & 0xf) << 4; - - /* EXT */ - eui64->u8[6] |= ((ext >> 8) & 0xf); - eui64->u8[7] = ext & 0xff; -} - -void oui_to_eui64(rimeaddr_t *eui64, uint32_t oui, uint32_t ext) { - /* OUI */ - eui64->u8[0] = (oui >> 16) & 0xff; - eui64->u8[1] = (oui >> 8) & 0xff; - eui64->u8[2] = oui & 0xff; - - /* EUI64 field */ - eui64->u8[3] = 0xff; - eui64->u8[4] = 0xfe; - - /* EXT */ - eui64->u8[5] = (ext >> 16) & 0xff; - eui64->u8[6] = (ext >> 8) & 0xff; - eui64->u8[7] = ext & 0xff; -} - -void -set_rimeaddr(rimeaddr_t *addr) -{ - nvmType_t type=0; - nvmErr_t err; - volatile uint8_t buf[RIMEADDR_NBYTES]; - rimeaddr_t eui64; - int i; - - err = nvm_detect(gNvmInternalInterface_c, &type); - - err = nvm_read(gNvmInternalInterface_c, type, (uint8_t *)buf, RIMEADDR_NVM, RIMEADDR_NBYTES); - - rimeaddr_copy(addr,&rimeaddr_null); - - for(i=0; iu8[i] = buf[i]; - } - - if (memcmp(addr, &addr_ff, RIMEADDR_CONF_SIZE)==0) { - - //set addr to EUI64 -#ifdef IAB - #ifdef EXT_ID - PRINTF("address in flash blank, setting to defined IAB and extension.\n\r"); - iab_to_eui64(&eui64, OUI, IAB, EXT_ID); - #else /* ifdef EXT_ID */ - PRINTF("address in flash blank, setting to defined IAB with a random extension.\n\r"); - iab_to_eui64(&eui64, OUI, IAB, *MACA_RANDOM & 0xfff); - #endif /* ifdef EXT_ID */ - -#else /* ifdef IAB */ - - #ifdef EXT_ID - PRINTF("address in flash blank, setting to defined OUI and extension.\n\r"); - oui_to_eui64(&eui64, OUI, EXT_ID); - #else /*ifdef EXT_ID */ - PRINTF("address in flash blank, setting to defined OUI with a random extension.\n\r"); - oui_to_eui64(&eui64, OUI, *MACA_RANDOM & 0xffffff); - #endif /*endif EXTID */ - -#endif /* ifdef IAB */ - - rimeaddr_copy(addr, &eui64); -#ifdef FLASH_BLANK_ADDR - PRINTF("flashing blank address\n\r"); - err = nvm_write(gNvmInternalInterface_c, type, &(eui64.u8), RIMEADDR_NVM, RIMEADDR_NBYTES); -#endif /* ifdef FLASH_BLANK_ADDR */ - } else { - PRINTF("loading rime address from flash.\n\r"); - } - - rimeaddr_set_node_addr(addr); -} - -int -main(void) -{ - volatile uint32_t i; - rimeaddr_t addr; - - /* Initialize hardware and */ - /* go into user mode */ - init_lowlevel(); - - /* Clock */ - clock_init(); - - /* Process subsystem */ - process_init(); - process_start(&etimer_process, NULL); - process_start(&contiki_maca_process, NULL); - - ctimer_init(); - - set_rimeaddr(&addr); - - printf("Rime started with address "); - for(i = 0; i < sizeof(addr.u8) - 1; i++) { - printf("%02X:", addr.u8[i]); - } - printf("%02X\n", addr.u8[i]); - - -#if WITH_UIP6 - memcpy(&uip_lladdr.addr, &addr.u8, sizeof(uip_lladdr.addr)); - /* Setup nullmac-like MAC for 802.15.4 */ -/* sicslowpan_init(sicslowmac_init(&cc2420_driver)); */ -/* printf(" %s channel %u\n", sicslowmac_driver.name, RF_CHANNEL); */ - - /* Setup X-MAC for 802.15.4 */ - queuebuf_init(); - NETSTACK_RDC.init(); - NETSTACK_MAC.init(); - NETSTACK_NETWORK.init(); - - printf("%s %s, channel check rate %lu Hz, radio channel %u\n", - NETSTACK_MAC.name, NETSTACK_RDC.name, - CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1: - NETSTACK_RDC.channel_check_interval()), - RF_CHANNEL); - - process_start(&tcpip_process, NULL); - - printf("Tentative link-local IPv6 address "); - { - int i, a; - for(a = 0; a < UIP_DS6_ADDR_NB; a++) { - if (uip_ds6_if.addr_list[a].isused) { - for(i = 0; i < 7; ++i) { - printf("%02x%02x:", - uip_ds6_if.addr_list[a].ipaddr.u8[i * 2], - uip_ds6_if.addr_list[a].ipaddr.u8[i * 2 + 1]); - } - printf("%02x%02x\n", - uip_ds6_if.addr_list[a].ipaddr.u8[14], - uip_ds6_if.addr_list[a].ipaddr.u8[15]); - } - } - } - - if(1) { - uip_ipaddr_t ipaddr; - int i; - uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0); - uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr); - uip_ds6_addr_add(&ipaddr, 0, ADDR_TENTATIVE); - printf("Tentative global IPv6 address "); - for(i = 0; i < 7; ++i) { - printf("%02x%02x:", - ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]); - } - printf("%02x%02x\n", - ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]); - } - - -#else /* WITH_UIP6 */ - - NETSTACK_RDC.init(); - NETSTACK_MAC.init(); - NETSTACK_NETWORK.init(); - - printf("%s %s, channel check rate %lu Hz, radio channel %u\n", - NETSTACK_MAC.name, NETSTACK_RDC.name, - CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0? 1: - NETSTACK_RDC.channel_check_interval()), - RF_CHANNEL); -#endif /* WITH_UIP6 */ - -#if TIMESYNCH_CONF_ENABLED - timesynch_init(); - timesynch_set_authority_level(rimeaddr_node_addr.u8[0]); -#endif /* TIMESYNCH_CONF_ENABLED */ - -#if WITH_UIP - process_start(&tcpip_process, NULL); - process_start(&uip_fw_process, NULL); /* Start IP output */ - process_start(&slip_process, NULL); - - slip_set_input_callback(set_gateway); - - { - uip_ipaddr_t hostaddr, netmask; - - uip_init(); - - uip_ipaddr(&hostaddr, 172,16, - rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1]); - uip_ipaddr(&netmask, 255,255,0,0); - uip_ipaddr_copy(&meshif.ipaddr, &hostaddr); - - uip_sethostaddr(&hostaddr); - uip_setnetmask(&netmask); - uip_over_mesh_set_net(&hostaddr, &netmask); - /* uip_fw_register(&slipif);*/ - uip_over_mesh_set_gateway_netif(&slipif); - uip_fw_default(&meshif); - uip_over_mesh_init(UIP_OVER_MESH_CHANNEL); - printf("uIP started with IP address %d.%d.%d.%d\n", - uip_ipaddr_to_quad(&hostaddr)); - } -#endif /* WITH_UIP */ - - process_start(&sensors_process, NULL); - - print_processes(autostart_processes); - autostart_start(autostart_processes); - - /* Main scheduler loop */ - while(1) { - check_maca(); - - /* TODO: replace this with a uart rx interrupt */ - if(uart1_input_handler != NULL) { - if(uart1_can_get()) { - uart1_input_handler(uart1_getc()); - } - } - - process_run(); - } - - return 0; -} - -/*---------------------------------------------------------------------------*/ -#if LOG_CONF_ENABLED -void -log_message(char *m1, char *m2) -{ - printf("%s%s\n", m1, m2); -} -#endif /* LOG_CONF_ENABLED */ diff --git a/platform/redbee-econotag/Makefile.redbee-econotag b/platform/redbee-econotag/Makefile.redbee-econotag deleted file mode 100644 index 4825b508b..000000000 --- a/platform/redbee-econotag/Makefile.redbee-econotag +++ /dev/null @@ -1,32 +0,0 @@ -# -*- makefile -*- - -define nl - - -endef - -ifndef ALLOW_OLD_PLATFORMS -${error $(nl)$(nl)**** This platform is old and will soon be removed **** $(nl)$(nl)\ -please use TARGET=econotag instead.$(nl)$(nl) \ - (or set ALLOW_OLD_PLATFORMS=1 to proceed)$(nl)$(nl) } -endif - -CONTIKI_TARGET_DIRS = . dev apps net -CONTIKI_CORE=contiki-mc1322x-main -CONTIKI_TARGET_MAIN = ${CONTIKI_CORE}.o - -CONTIKI_TARGET_SOURCEFILES += contiki-mc1322x-main.c clock.c button-sensor.c sensors.c slip.c light-sensor.c tmp102-sensor.c - -CONTIKIMC1322X=$(CONTIKI)/cpu/mc1322x -CONTIKIBOARD=. - -CONTIKI_PLAT_DEFS = - -MCU=arm7tdmi-s - -ifeq ($(UIP_CONF_IPV6),1) -CFLAGS += -DWITH_UIP6=1 -endif - -include $(CONTIKIMC1322X)/Makefile.mc1322x - diff --git a/platform/redbee-econotag/button-sensor.c b/platform/redbee-econotag/button-sensor.c deleted file mode 100644 index 24b9b63c1..000000000 --- a/platform/redbee-econotag/button-sensor.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2010, Mariano Alvira and other contributors - * to the MC1322x project (http://mc1322x.devl.org) and Contiki. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki OS. - * - */ - -#include "lib/sensors.h" -#include "dev/button-sensor.h" - -#include "mc1322x.h" - -#include - -const struct sensors_sensor button_sensor; - -static struct timer debouncetimer; -static int status(int type); - -void kbi4_isr(void) { - if(timer_expired(&debouncetimer)) { - timer_set(&debouncetimer, CLOCK_SECOND / 4); - sensors_changed(&button_sensor); - } - clear_kbi_evnt(4); -} - -static int -value(int type) -{ - return GPIO->DATA.GPIO_26 || !timer_expired(&debouncetimer); -} - -static int -configure(int type, int c) -{ - switch (type) { - case SENSORS_ACTIVE: - if (c) { - if(!status(SENSORS_ACTIVE)) { - timer_set(&debouncetimer, 0); - enable_irq_kbi(4); - } - } else { - disable_irq_kbi(4); - } - return 1; - } - return 0; -} - -static int -status(int type) -{ - switch (type) { - case SENSORS_ACTIVE: - case SENSORS_READY: - return bit_is_set(*CRM_WU_CNTL, 20); /* check if kbi4 irq is enabled */ - } - return 0; -} - -SENSORS_SENSOR(button_sensor, BUTTON_SENSOR, - value, configure, status); diff --git a/platform/redbee-econotag/contiki-conf.h b/platform/redbee-econotag/contiki-conf.h deleted file mode 100644 index 5cd8295dc..000000000 --- a/platform/redbee-econotag/contiki-conf.h +++ /dev/null @@ -1,258 +0,0 @@ -/* - * Copyright (c) 2010, Mariano Alvira and other contributors - * to the MC1322x project (http://mc1322x.devl.org) and Contiki. - * - * Copyright (c) 2006, Technical University of Munich - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - * @(#)$$ - */ - -/** - * \file - * Configuration for MC1322x hobby board based on - * Configuration for sample STK 501 Contiki kernel - * - * \author - * Originial by: - * Simon Barner - */ - -#ifndef __CONTIKI_CONF_H__ -#define __CONTIKI_CONF_H__ - -#include - -#define PLATFORM_NAME "Econotag" -#define PLATFORM_TYPE MC1322X -/* mc1322x files */ -#include "contiki-mc1322x-conf.h" -/* this is from cpu/mc1322x/board */ -#include "redbee-econotag.h" - -/* Clock ticks per second */ -#define CLOCK_CONF_SECOND 100 -/* set to 1 to toggle the green led ever second */ -/* FIXME setting this will break the sensor button (and other gpio) */ -/* since leds_arch hits the entire gpio_data */ -#define BLINK_SECONDS 0 -/* Set to 1 to sample an ADC channel every second, 9 second refresh */ -/* Set >1 to sample an ADC channel every tick, 90 msec refresh */ -#define CLOCK_CONF_SAMPLEADC 1 - -#define CCIF -#define CLIF - -/* Baud rate */ -#define BRMOD 9999 -/* 230400 bps, INC=767, MOD=9999, 24Mhz 16x samp */ -/* 115200 bps, INC=767, MOD=9999, 24Mhz 8x samp */ -#define BRINC 767 -/* 921600 bps, MOD=9999, 24Mhz 16x samp */ -//#define BRINC 3071 -#define SAMP UCON_SAMP_8X -//#define SAMP UCON_SAMP_16X - -#define CONSOLE_UART UART1 -#define CONSOLE_BAUD 115200 - -//#define uart_init uart1_init -#define dbg_putchar(x) uart1_putc(x) - -#define USE_FORMATTED_STDIO 1 -#define MACA_DEBUG 0 -#define CONTIKI_MACA_RAW_MODE 0 -#define USE_32KHZ_XTAL 0 - -#define BLOCKING_TX 1 -#define MACA_AUTOACK 1 -#define NULLRDC_CONF_802154_AUTOACK_HW 1 - -#define USE_WDT 0 - -#ifndef WDT_TIMEOUT -#define WDT_TIMEOUT 5000 /* watchdog timeout in ms */ -#endif - -/* end of mc1322x specific config. */ - -/* start of conitki config. */ -#define PLATFORM_HAS_LEDS 1 -#define PLATFORM_HAS_BUTTON 1 - -/* Core rtimer.h defaults to 16 bit timer unless RTIMER_CLOCK_LT is defined */ -typedef unsigned long rtimer_clock_t; -#define RTIMER_CLOCK_LT(a,b) ((signed long)((a)-(b)) < 0) - -#define RIMEADDR_CONF_SIZE 8 - -/* EUI64 generation */ -/* Organizationally Unique Identifier */ -#define OUI 0xacde48 /* if IAB is defined then OUI = 0x0050C2 */ -#define IAB 0xA8C /* IAB 0xA8C for use on Redwire products only */ -//#undef IAB /* do not define an IAB if you are using a full OUI */ -//#define EXT_ID 0xdef123 /* lower 12-bits used if IAB is defined */ -#undef EXT_ID /* if an extention id is not defined then one will be generated randomly */ - -#define FLASH_BLANK_ADDR /* if defined then the generated rime address will flashed */ - -#if WITH_UIP6 -/* Network setup for IPv6 */ -#define NETSTACK_CONF_NETWORK sicslowpan_driver -#define NETSTACK_CONF_MAC nullmac_driver -/*#define NETSTACK_CONF_RDC contikimac_driver*/ /* contikimac for redbee hasn't been well tested */ -#define NETSTACK_CONF_RDC nullrdc_driver -#define NETSTACK_CONF_RADIO contiki_maca_driver -#define NETSTACK_CONF_FRAMER framer_802154 - -#define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8 -#define RIME_CONF_NO_POLITE_ANNOUCEMENTS 0 -#define CXMAC_CONF_ANNOUNCEMENTS 0 -#define XMAC_CONF_ANNOUNCEMENTS 0 - -#else /* WITH_UIP6 */ -/* Network setup for non-IPv6 (rime). */ - -#define NETSTACK_CONF_NETWORK rime_driver -#define NETSTACK_CONF_MAC csma_driver -#define NETSTACK_CONF_RDC sicslowmac_driver -#define NETSTACK_CONF_RADIO contiki_maca_driver -#define NETSTACK_CONF_FRAMER framer_802154 - -#define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8 - -#define COLLECT_CONF_ANNOUNCEMENTS 1 -#define RIME_CONF_NO_POLITE_ANNOUCEMENTS 0 -#define CXMAC_CONF_ANNOUNCEMENTS 0 -#define XMAC_CONF_ANNOUNCEMENTS 0 -#define CONTIKIMAC_CONF_ANNOUNCEMENTS 0 - -#define CONTIKIMAC_CONF_COMPOWER 0 -#define XMAC_CONF_COMPOWER 0 -#define CXMAC_CONF_COMPOWER 0 - -#define COLLECT_NBR_TABLE_CONF_MAX_NEIGHBORS 32 - -#endif /* WITH_UIP6 */ - -#define QUEUEBUF_CONF_NUM 16 - -#define PACKETBUF_CONF_ATTRS_INLINE 1 - -#ifndef RF_CHANNEL -#define RF_CHANNEL 26 -#endif /* RF_CHANNEL */ - -#define CONTIKIMAC_CONF_BROADCAST_RATE_LIMIT 0 - -#define IEEE802154_CONF_PANID 0xABCD - -#define PROFILE_CONF_ON 0 -#define ENERGEST_CONF_ON 0 - -#define AODV_COMPLIANCE -#define AODV_NUM_RT_ENTRIES 32 - -#define WITH_ASCII 1 - -#define PROCESS_CONF_NUMEVENTS 8 -#define PROCESS_CONF_STATS 1 - -#ifdef WITH_UIP6 - -#define RIMEADDR_CONF_SIZE 8 - -#define UIP_CONF_LL_802154 1 -#define UIP_CONF_LLH_LEN 0 - -#define UIP_CONF_ROUTER 1 -#define UIP_CONF_IPV6_RPL 1 - -#define NBR_TABLE_CONF_MAX_NEIGHBORS 30 -#define UIP_CONF_MAX_ROUTES 30 - -#define UIP_CONF_ND6_SEND_RA 0 -#define UIP_CONF_ND6_REACHABLE_TIME 600000 -#define UIP_CONF_ND6_RETRANS_TIMER 10000 - -#define UIP_CONF_IPV6 1 -#define UIP_CONF_IPV6_QUEUE_PKT 0 -#define UIP_CONF_IPV6_CHECKS 1 -#define UIP_CONF_IPV6_REASSEMBLY 0 -#define UIP_CONF_NETIF_MAX_ADDRESSES 3 -#define UIP_CONF_ND6_MAX_PREFIXES 3 -#define UIP_CONF_ND6_MAX_DEFROUTERS 2 -#define UIP_CONF_IP_FORWARD 0 -#define UIP_CONF_BUFFER_SIZE 1300 -#define SICSLOWPAN_CONF_FRAG 1 -#define SICSLOWPAN_CONF_MAXAGE 8 - -#define SICSLOWPAN_CONF_COMPRESSION_IPV6 0 -#define SICSLOWPAN_CONF_COMPRESSION_HC1 1 -#define SICSLOWPAN_CONF_COMPRESSION_HC01 2 -#define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_COMPRESSION_HC06 -#ifndef SICSLOWPAN_CONF_FRAG -#define SICSLOWPAN_CONF_FRAG 1 -#define SICSLOWPAN_CONF_MAXAGE 8 -#endif /* SICSLOWPAN_CONF_FRAG */ -#define SICSLOWPAN_CONF_CONVENTIONAL_MAC 1 -#define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 2 -#else /* WITH_UIP6 */ -#define UIP_CONF_IP_FORWARD 1 -#define UIP_CONF_BUFFER_SIZE 1300 -#endif /* WITH_UIP6 */ - -#define UIP_CONF_ICMP_DEST_UNREACH 1 - -#define UIP_CONF_DHCP_LIGHT -#define UIP_CONF_LLH_LEN 0 -#define UIP_CONF_RECEIVE_WINDOW 300 -#define UIP_CONF_TCP_MSS 48 -#define UIP_CONF_MAX_CONNECTIONS 4 -#define UIP_CONF_MAX_LISTENPORTS 8 -#define UIP_CONF_UDP_CONNS 12 -#define UIP_CONF_FWCACHE_SIZE 30 -#define UIP_CONF_BROADCAST 1 -#define UIP_ARCH_IPCHKSUM 1 -#define UIP_CONF_UDP 1 -#define UIP_CONF_UDP_CHECKSUMS 1 -#define UIP_CONF_PINGADDRCONF 0 -#define UIP_CONF_LOGGING 0 - -#define UIP_CONF_TCP_SPLIT 0 - -/* include the project config */ -/* PROJECT_CONF_H might be defined in the project Makefile */ -#ifdef PROJECT_CONF_H -#include PROJECT_CONF_H -#endif /* PROJECT_CONF_H */ - -#endif /* __CONTIKI_CONF_H__ */ diff --git a/platform/redbee-econotag/contiki-mc1322x-main.c b/platform/redbee-econotag/contiki-mc1322x-main.c deleted file mode 100644 index e4c9c842b..000000000 --- a/platform/redbee-econotag/contiki-mc1322x-main.c +++ /dev/null @@ -1,677 +0,0 @@ -/* - * Copyright (c) 2010, Mariano Alvira and other contributors - * to the MC1322x project (http://mc1322x.devl.org) and Contiki. - * - * Copyright (c) 2006, Technical University of Munich - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - * @(#)$$ - */ - -#include -#include -#include - -#include "contiki.h" - -#include "dev/leds.h" -#include "dev/serial-line.h" -#include "dev/slip.h" -#include "dev/xmem.h" -#include "dev/button-sensor.h" -#include "lib/random.h" -#include "net/netstack.h" -#include "net/mac/frame802154.h" -#include "lib/include/mc1322x.h" - -#if WITH_UIP6 -#include "net/sicslowpan.h" -#include "net/uip-ds6.h" -#include "net/mac/sicslowmac.h" -#endif /* WITH_UIP6 */ - -#include "net/rime.h" - -#include "sys/autostart.h" - -/* from libmc1322x */ -#include "mc1322x.h" -#include "default_lowlevel.h" -#include "contiki-maca.h" -#include "contiki-uart.h" - -/* Get periodic prints from idle loop, from clock seconds or rtimer interrupts */ -/* Use of rtimer will conflict with other rtimer interrupts such as contikimac radio cycling */ -#define PERIODICPRINTS 0 -#if PERIODICPRINTS -//#define PINGS 64 -#define ROUTES 300 -#define STAMPS 60 -#define STACKMONITOR 600 -//#define HEAPMONITOR 60 -uint16_t clocktime; -#define TESTRTIMER 0 -#if TESTRTIMER -uint8_t rtimerflag=1; -struct rtimer rt; -void rtimercycle(void) {rtimerflag=1;} -#endif -#endif - -#define DEBUG 0 -#if DEBUG -#include -#define PRINTF(...) printf(__VA_ARGS__) -#define PRINT6ADDR(addr) PRINTF(" %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x ", ((uint8_t *)addr)[0], ((uint8_t *)addr)[1], ((uint8_t *)addr)[2], ((uint8_t *)addr)[3], ((uint8_t *)addr)[4], ((uint8_t *)addr)[5], ((uint8_t *)addr)[6], ((uint8_t *)addr)[7], ((uint8_t *)addr)[8], ((uint8_t *)addr)[9], ((uint8_t *)addr)[10], ((uint8_t *)addr)[11], ((uint8_t *)addr)[12], ((uint8_t *)addr)[13], ((uint8_t *)addr)[14], ((uint8_t *)addr)[15]) -#define PRINTLLADDR(lladdr) PRINTF(" %02x:%02x:%02x:%02x:%02x:%02x ",(lladdr)->addr[0], (lladdr)->addr[1], (lladdr)->addr[2], (lladdr)->addr[3],(lladdr)->addr[4], (lladdr)->addr[5]) -#else -#define PRINTF(...) -#define PRINT6ADDR(addr) -#define PRINTLLADDR(addr) -#endif - -#ifndef RIMEADDR_NVM -#define RIMEADDR_NVM 0x1E000 -#endif - -#ifndef RIMEADDR_NBYTES -#define RIMEADDR_NBYTES 8 -#endif - -#if UIP_CONF_ROUTER - -#ifndef UIP_ROUTER_MODULE -#ifdef UIP_CONF_ROUTER_MODULE -#define UIP_ROUTER_MODULE UIP_CONF_ROUTER_MODULE -#else /* UIP_CONF_ROUTER_MODULE */ -#define UIP_ROUTER_MODULE rimeroute -#endif /* UIP_CONF_ROUTER_MODULE */ -#endif /* UIP_ROUTER_MODULE */ - -extern const struct uip_router UIP_ROUTER_MODULE; - -#endif /* UIP_CONF_ROUTER */ - -#if DCOSYNCH_CONF_ENABLED -static struct timer mgt_timer; -#endif - -#ifndef WITH_UIP -#define WITH_UIP 0 -#endif - -#if WITH_UIP -#include "net/uip.h" -#include "net/uip-fw.h" -#include "net/uip-fw-drv.h" -#include "net/uip-over-mesh.h" -static struct uip_fw_netif slipif = - {UIP_FW_NETIF(192,168,1,2, 255,255,255,255, slip_send)}; -static struct uip_fw_netif meshif = - {UIP_FW_NETIF(172,16,0,0, 255,255,0,0, uip_over_mesh_send)}; - -#endif /* WITH_UIP */ - -#define UIP_OVER_MESH_CHANNEL 8 -#if WITH_UIP -static uint8_t is_gateway; -#endif /* WITH_UIP */ - -/*---------------------------------------------------------------------------*/ -void uip_log(char *msg) { printf("%c",msg); } -/*---------------------------------------------------------------------------*/ -#ifndef RF_CHANNEL -#define RF_CHANNEL 26 -#endif -/*---------------------------------------------------------------------------*/ -#if WITH_UIP -static void -set_gateway(void) -{ - if(!is_gateway) { - leds_on(LEDS_RED); - printf("%d.%d: making myself the IP network gateway.\n\n", - rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1]); - printf("IPv4 address of the gateway: %d.%d.%d.%d\n\n", - uip_ipaddr_to_quad(&uip_hostaddr)); - uip_over_mesh_set_gateway(&rimeaddr_node_addr); - uip_over_mesh_make_announced_gateway(); - is_gateway = 1; - } -} -#endif /* WITH_UIP */ -/*---------------------------------------------------------------------------*/ -static void -print_processes(struct process * const processes[]) -{ - /* const struct process * const * p = processes;*/ - printf("Starting"); - while(*processes != NULL) { - printf(" '%s'", (*processes)->name); - processes++; - } - printf("\n"); -} -/*--------------------------------------------------------------------------*/ - -SENSORS(&button_sensor); - -void -init_lowlevel(void) -{ - /* button init */ - /* set up kbi */ - enable_irq_kbi(4); - kbi_edge(4); - enable_ext_wu(4); -// kbi_pol_neg(7); -// kbi_pol_pos(7); -// gpio_sel0_pullup(29); -// gpio_pu0_disable(29); - - trim_xtal(); - - /* uart init */ - uart_init(UART1, 115200); - - default_vreg_init(); - - maca_init(); - - set_channel(RF_CHANNEL - 11); /* channel 11 */ - set_power(0x12); /* 0x12 is the highest, not documented */ - - enable_irq(CRM); - -#if USE_32KHZ_XTAL - enable_32khz_xtal(); -#else - cal_ring_osc(); -#endif - -#if USE_32KHZ_XTAL - *CRM_RTC_TIMEOUT = 32768 * 10; -#else - *CRM_RTC_TIMEOUT = cal_rtc_secs * 10; -#endif - -#if (USE_WDT == 1) - /* set the watchdog timer timeout to 1 sec */ - cop_timeout_ms(WDT_TIMEOUT); - /* enable the watchdog timer */ - CRM->COP_CNTLbits.COP_EN = 1; -#endif - - /* XXX debug */ - /* trigger periodic rtc int */ -// clear_rtc_wu_evt(); -// enable_rtc_wu(); -// enable_rtc_wu_irq(); -} - -#if RIMEADDR_SIZE == 1 -const rimeaddr_t addr_ff = { { 0xff } }; -#else /*RIMEADDR_SIZE == 2*/ -#if RIMEADDR_SIZE == 2 -const rimeaddr_t addr_ff = { { 0xff, 0xff } }; -#else /*RIMEADDR_SIZE == 2*/ -#if RIMEADDR_SIZE == 8 -const rimeaddr_t addr_ff = { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } }; -#endif /*RIMEADDR_SIZE == 8*/ -#endif /*RIMEADDR_SIZE == 2*/ -#endif /*RIMEADDR_SIZE == 1*/ - -void iab_to_eui64(rimeaddr_t *eui64, uint32_t oui, uint16_t iab, uint32_t ext) { - /* OUI for IABs */ - eui64->u8[0] = 0x00; - eui64->u8[1] = 0x50; - eui64->u8[2] = 0xc2; - - /* IAB */ - eui64->u8[3] = (iab >> 4) & 0xff; - eui64->u8[4] = (iab << 4) & 0xf0; - - /* EXT */ - - eui64->u8[4] |= (ext >> 24) & 0xf; - eui64->u8[5] = (ext >> 16) & 0xff; - eui64->u8[6] = (ext >> 8) & 0xff; - eui64->u8[7] = ext & 0xff; -} - -void oui_to_eui64(rimeaddr_t *eui64, uint32_t oui, uint64_t ext) { - /* OUI */ - eui64->u8[0] = (oui >> 16) & 0xff; - eui64->u8[1] = (oui >> 8) & 0xff; - eui64->u8[2] = oui & 0xff; - - /* EXT */ - eui64->u8[3] = (ext >> 32) & 0xff; - eui64->u8[4] = (ext >> 24) & 0xff; - eui64->u8[5] = (ext >> 16) & 0xff; - eui64->u8[6] = (ext >> 8) & 0xff; - eui64->u8[7] = ext & 0xff; -} - -extern unsigned short node_id; - -void -set_rimeaddr(rimeaddr_t *addr) -{ - nvmType_t type=0; - nvmErr_t err; - volatile uint8_t buf[RIMEADDR_NBYTES]; - rimeaddr_t eui64; - int i; - - err = nvm_detect(gNvmInternalInterface_c, &type); - - err = nvm_read(gNvmInternalInterface_c, type, (uint8_t *)buf, RIMEADDR_NVM, RIMEADDR_NBYTES); - - rimeaddr_copy(addr,&rimeaddr_null); - - for(i=0; iu8[i] = buf[i]; - } - - if (memcmp(addr, &addr_ff, RIMEADDR_CONF_SIZE)==0) { - - //set addr to EUI64 -#ifdef IAB - #ifdef EXT_ID - PRINTF("address in flash blank, setting to defined IAB and extension.\n\r"); - iab_to_eui64(&eui64, OUI, IAB, EXT_ID); - #else /* ifdef EXT_ID */ - PRINTF("address in flash blank, setting to defined IAB with a random extension.\n\r"); - iab_to_eui64(&eui64, OUI, IAB, *MACA_RANDOM); - #endif /* ifdef EXT_ID */ - -#else /* ifdef IAB */ - - #ifdef EXT_ID - PRINTF("address in flash blank, setting to defined OUI and extension.\n\r"); - oui_to_eui64(&eui64, OUI, EXT_ID); - #else /*ifdef EXT_ID */ - PRINTF("address in flash blank, setting to defined OUI with a random extension.\n\r"); - oui_to_eui64(&eui64, OUI, ((*MACA_RANDOM << 32) | *MACA_RANDOM)); - #endif /*endif EXTID */ - -#endif /* ifdef IAB */ - - rimeaddr_copy(addr, &eui64); -#ifdef FLASH_BLANK_ADDR - PRINTF("flashing blank address\n\r"); - err = nvm_write(gNvmInternalInterface_c, type, &(eui64.u8), RIMEADDR_NVM, RIMEADDR_NBYTES); -#endif /* ifdef FLASH_BLANK_ADDR */ - } else { - PRINTF("loading rime address from flash.\n\r"); - } - - node_id = (addr->u8[6] << 8 | addr->u8[7]); - rimeaddr_set_node_addr(addr); -} - -int -main(void) -{ - volatile uint32_t i; - rimeaddr_t addr; - - /* Initialize hardware and */ - /* go into user mode */ - init_lowlevel(); - -#if STACKMONITOR - /* Simple stack pointer highwater monitor. Checks for magic numbers in the main - * loop. In conjuction with PERIODICPRINTS, never-used stack will be printed - * every STACKMONITOR seconds. - */ -{ -extern uint32_t __und_stack_top__, __sys_stack_top__; -uint32_t p=(uint32_t)&__und_stack_top__; - do { - *(uint32_t *)p = 0x42424242; - p+=16; - } while (p<(uint32_t)&__sys_stack_top__-100); //don't overwrite our own stack -} -#endif -#if HEAPMONITOR - /* Simple heap pointer highwater monitor. Checks for magic numbers in the main - * loop. In conjuction with PERIODICPRINTS, never-used heap will be printed - * every HEAPMONITOR seconds. - * This routine assumes a linear FIFO heap as used by the printf _sbrk call. - */ -{ -extern uint32_t __heap_start__, __heap_end__; -uint32_t p=(uint32_t)&__heap_end__-4; - do { - *(uint32_t *)p = 0x42424242; - p-=4; - } while (p>=(uint32_t)&__heap_start__); -} -#endif - - /* Clock */ - clock_init(); - - /* LED driver */ - leds_init(); - - /* control TX_ON with the radio */ - GPIO->FUNC_SEL.GPIO_44 = 2; - GPIO->PAD_DIR.GPIO_44 = 1; - - /* Process subsystem */ - process_init(); - process_start(&etimer_process, NULL); - process_start(&contiki_maca_process, NULL); - - ctimer_init(); - - set_rimeaddr(&addr); - - printf("Rime started with address "); - for(i = 0; i < sizeof(addr.u8) - 1; i++) { - printf("%02X:", addr.u8[i]); - } - printf("%02X\n", addr.u8[i]); - - -#if WITH_UIP6 - memcpy(&uip_lladdr.addr, &addr.u8, sizeof(uip_lladdr.addr)); - /* Setup nullmac-like MAC for 802.15.4 */ -/* sicslowpan_init(sicslowmac_init(&cc2420_driver)); */ -/* printf(" %s channel %u\n", sicslowmac_driver.name, RF_CHANNEL); */ - - /* Setup X-MAC for 802.15.4 */ - queuebuf_init(); - NETSTACK_RDC.init(); - NETSTACK_MAC.init(); - NETSTACK_NETWORK.init(); - - printf("%s %s, channel check rate %lu Hz, radio channel %u\n", - NETSTACK_MAC.name, NETSTACK_RDC.name, - CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1: - NETSTACK_RDC.channel_check_interval()), - RF_CHANNEL); - - process_start(&tcpip_process, NULL); - - printf("Tentative link-local IPv6 address "); - { - int i, a; - for(a = 0; a < UIP_DS6_ADDR_NB; a++) { - if (uip_ds6_if.addr_list[a].isused) { - for(i = 0; i < 7; ++i) { - printf("%02x%02x:", - uip_ds6_if.addr_list[a].ipaddr.u8[i * 2], - uip_ds6_if.addr_list[a].ipaddr.u8[i * 2 + 1]); - } - printf("%02x%02x\n", - uip_ds6_if.addr_list[a].ipaddr.u8[14], - uip_ds6_if.addr_list[a].ipaddr.u8[15]); - } - } - } - - if(1) { - uip_ipaddr_t ipaddr; - int i; - uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0); - uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr); - uip_ds6_addr_add(&ipaddr, 0, ADDR_TENTATIVE); - printf("Tentative global IPv6 address "); - for(i = 0; i < 7; ++i) { - printf("%02x%02x:", - ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]); - } - printf("%02x%02x\n", - ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]); - } - - -#else /* WITH_UIP6 */ - - NETSTACK_RDC.init(); - NETSTACK_MAC.init(); - NETSTACK_NETWORK.init(); - - printf("%s %s, channel check rate %lu Hz, radio channel %u\n", - NETSTACK_MAC.name, NETSTACK_RDC.name, - CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0? 1: - NETSTACK_RDC.channel_check_interval()), - RF_CHANNEL); -#endif /* WITH_UIP6 */ - - *MACA_MACPANID = 0xcdab; /* this is the hardcoded contiki pan, register is PACKET order */ - *MACA_MAC16ADDR = 0xffff; /* short addressing isn't used, set this to 0xffff for now */ - - *MACA_MAC64HI = - addr.u8[0] << 24 | - addr.u8[1] << 16 | - addr.u8[2] << 8 | - addr.u8[3]; - *MACA_MAC64LO = - addr.u8[4] << 24 | - addr.u8[5] << 16 | - addr.u8[6] << 8 | - addr.u8[7]; - PRINTF("setting panid 0x%04x\n\r", *MACA_MACPANID); - PRINTF("setting short mac 0x%04x\n\r", *MACA_MAC16ADDR); - PRINTF("setting long mac 0x%08x_%08x\n\r", *MACA_MAC64HI, *MACA_MAC64LO); - -#if MACA_AUTOACK - set_prm_mode(AUTOACK); -#endif - -#if TIMESYNCH_CONF_ENABLED - timesynch_init(); - timesynch_set_authority_level(rimeaddr_node_addr.u8[0]); -#endif /* TIMESYNCH_CONF_ENABLED */ - -#if WITH_UIP - process_start(&tcpip_process, NULL); - process_start(&uip_fw_process, NULL); /* Start IP output */ - process_start(&slip_process, NULL); - - slip_set_input_callback(set_gateway); - - { - uip_ipaddr_t hostaddr, netmask; - - uip_init(); - - uip_ipaddr(&hostaddr, 172,16, - rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1]); - uip_ipaddr(&netmask, 255,255,0,0); - uip_ipaddr_copy(&meshif.ipaddr, &hostaddr); - - uip_sethostaddr(&hostaddr); - uip_setnetmask(&netmask); - uip_over_mesh_set_net(&hostaddr, &netmask); - /* uip_fw_register(&slipif);*/ - uip_over_mesh_set_gateway_netif(&slipif); - uip_fw_default(&meshif); - uip_over_mesh_init(UIP_OVER_MESH_CHANNEL); - printf("uIP started with IP address %d.%d.%d.%d\n", - uip_ipaddr_to_quad(&hostaddr)); - } -#endif /* WITH_UIP */ - - process_start(&sensors_process, NULL); - - print_processes(autostart_processes); - autostart_start(autostart_processes); - - /* Main scheduler loop */ - while(1) { - check_maca(); - -#if (USE_WDT == 1) - cop_service(); -#endif - - if(uart1_input_handler != NULL) { - if(uart1_can_get()) { - uart1_input_handler(uart1_getc()); - } - } - - process_run(); - -#if PERIODICPRINTS -#if TESTRTIMER -/* Timeout can be increased up to 8 seconds maximum. - * A one second cycle is convenient for triggering the various debug printouts. - * The triggers are staggered to avoid printing everything at once. - */ - if (rtimerflag) { - rtimer_set(&rt, RTIMER_NOW()+ RTIMER_ARCH_SECOND*1UL, 1,(void *) rtimercycle, NULL); - rtimerflag=0; -#else - if (clocktime!=clock_seconds()) { - clocktime=clock_seconds(); -#endif - -#if STAMPS -if ((clocktime%STAMPS)==0) { -#if ENERGEST_CONF_ON -#include "lib/print-stats.h" - print_stats(); -#elif RADIOSTATS -extern volatile unsigned long radioontime; - printf("\r%u(%u)s ",clocktime,radioontime); -#else - printf("%us\n",clocktime); -#endif - -} -#endif -#if TESTRTIMER - clocktime+=1; -#endif - -#if PINGS && UIP_CONF_IPV6 -extern void raven_ping6(void); -if ((clocktime%PINGS)==1) { - printf("**Ping\n"); - raven_ping6(); -} -#endif - -#if ROUTES && UIP_CONF_IPV6 -if ((clocktime%ROUTES)==2) { - -extern uip_ds6_netif_t uip_ds6_if; - - uint8_t i,j; - printf("\nAddresses [%u max]\n",UIP_DS6_ADDR_NB); - for (i=0;iipaddr); - printf("\n"); - j=0; - } - if (j) printf(" "); - PRINTF("\nRoutes [%u max]\n",UIP_DS6_ROUTE_NB); - { - uip_ds6_route_t *r; - PRINTF("\nRoutes [%u max]\n",UIP_DS6_ROUTE_NB); - j = 1; - for(r = uip_ds6_route_head(); - r != NULL; - r = uip_ds6_route_next(r)) { - ipaddr_add(&r->ipaddr); - PRINTF("/%u (via ", r->length); - ipaddr_add(uip_ds6_route_nexthop(r)); - PRINTF(") %lus\n", r->state.lifetime); - j = 0; - } - } - if (j) printf(" "); - printf("\n---------\n"); -} -#endif - -#if STACKMONITOR -if ((clocktime%STACKMONITOR)==3) { -extern uint32_t __und_stack_top__, __sys_stack_top__; -uint32_t p=(uint32_t)&__und_stack_top__; - do { - if (*(uint32_t *)p != 0x42424242) { - printf("Never-Used stack > %d bytes\n",p-(uint32_t)&__und_stack_top__); - break; - } - p+=16; - } while (p<(uint32_t)&__sys_stack_top__-100); -} -#endif -#if HEAPMONITOR -if ((clocktime%HEAPMONITOR)==4) { -extern uint32_t __heap_start__, __heap_end__; -uint32_t p=(uint32_t)&__heap_end__-4; - do { - if (*(uint32_t *)p != 0x42424242) { - break; - } - p-=4; - } while (p>=(uint32_t)&__heap_start__); - printf("Never-used heap >= %d bytes\n",(uint32_t)&__heap_end__-p-4); -#if 0 -#include -char *ptr=malloc(1); //allocates 16 bytes from the heap -printf("********Got pointer %x\n",ptr); -#endif -} -#endif - - } -#endif /* PERIODICPRINTS */ - } - - return 0; -} - -/*---------------------------------------------------------------------------*/ -#if LOG_CONF_ENABLED -void -log_message(char *m1, char *m2) -{ - printf("%s%s\n", m1, m2); -} -#endif /* LOG_CONF_ENABLED */ diff --git a/platform/redbee-econotag/dev/light-sensor.c b/platform/redbee-econotag/dev/light-sensor.c deleted file mode 100644 index 72994fd6a..000000000 --- a/platform/redbee-econotag/dev/light-sensor.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2011, Mariano Alvira and other contributors - * to the MC1322x project (http://mc1322x.devl.org) and Contiki. - * - * Copyright (c) 2005-2010, Swedish Institute of Computer Science - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -#include "contiki.h" -#include "lib/sensors.h" -#include "dev/light-sensor.h" - -#include - -/* Photodiode 1 (P64) on INCH_4 */ -/* Photodiode 2 (P65) on INCH_5 */ -#define INPUT_CHANNEL ((1 << INCH_4) | (1 << INCH_5)) -#define INPUT_REFERENCE SREF_0 -#define PHOTOSYNTHETIC_MEM ADC12MEM4 -#define TOTAL_SOLAR_MEM ADC12MEM5 - -const struct sensors_sensor light_sensor; - -/*---------------------------------------------------------------------------*/ -static int -value(int type) -{ - return 0; -} -/*---------------------------------------------------------------------------*/ -static int -status(int type) -{ - return 0; -} -/*---------------------------------------------------------------------------*/ -static int -configure(int type, int c) -{ - return 0; -} -/*---------------------------------------------------------------------------*/ -SENSORS_SENSOR(light_sensor, "Light", value, configure, status); diff --git a/platform/redbee-econotag/dev/light-sensor.h b/platform/redbee-econotag/dev/light-sensor.h deleted file mode 100644 index 52ade2767..000000000 --- a/platform/redbee-econotag/dev/light-sensor.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2010, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * ----------------------------------------------------------------- - * - * Author : Adam Dunkels, Joakim Eriksson, Niclas Finne - */ - -#ifndef __LIGHT_SENSOR_H__ -#define __LIGHT_SENSOR_H__ - -#include "lib/sensors.h" - -extern const struct sensors_sensor light_sensor; - -#define LIGHT_SENSOR_PHOTOSYNTHETIC 0 -#define LIGHT_SENSOR_TOTAL_SOLAR 1 - - -#endif /* __LIGHT-SENSOR_H__ */ diff --git a/platform/redbee-econotag/dev/tmp102-sensor.c b/platform/redbee-econotag/dev/tmp102-sensor.c deleted file mode 100644 index 53f0452a4..000000000 --- a/platform/redbee-econotag/dev/tmp102-sensor.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * An interface to the TI TMP102 temperature sensor - * 12 bit temperature reading, 0.5 deg. Celsius accuracy - * ----------------------------------------------------------------- - * - * Author : Hedde Bosman (heddebosman@incas3.eu) - */ - -#include "contiki.h" -#include "lib/sensors.h" -#include "dev/tmp102-sensor.h" - -#ifndef bool -#define bool uint8_t -#endif - -#ifndef false -#define false 0 -#endif - -#ifndef true -#define true 1 -#endif - - -static void set_configuration(uint8_t rate, bool precision) { - uint8_t tx_buf[] = {TMP102_REGISTER_CONFIGURATION, - 0, - (precision ? TMP102_CONF_EXTENDED_MODE : 0) | ((rate << 6) & TMP102_CONF_CONVERSION_RATE) - }; - - i2c_transmitinit(TMP102_ADDR, 3, tx_buf); -} - -/*---------------------------------------------------------------------------*/ -static int value(int type) { - uint8_t reg = TMP102_REGISTER_TEMPERATURE; - uint8_t temp[2]; - int16_t temperature = 0; - - /* transmit the register to start reading from */ - i2c_transmitinit(TMP102_ADDR, 1, ®); - while (!i2c_transferred()); // wait for data to arrive - - /* receive the data */ - i2c_receiveinit(TMP102_ADDR, 2, temp); - while (!i2c_transferred()); // wait for data to arrive - - // 12 bit normal mode - temperature = ((temp[0] <<8) | (temp[1])) >> 4; // lsb - - // 13 bit extended mode - //temperature = ((temp[0] <<8) | (temp[1])) >> 3; // lsb - - temperature = (100*temperature)/16; // in 100th of degrees - - return temperature; -} -/*---------------------------------------------------------------------------*/ -static int status(int type) { - switch (type) { - case SENSORS_ACTIVE: - case SENSORS_READY: - return 1; // fix? - break; - } - return 0; -} -/*---------------------------------------------------------------------------*/ -static int configure(int type, int c) { - switch (type) { - case SENSORS_ACTIVE: - if (c) { - // set active - set_configuration(1, false); // every 1 second, 12bit precision - } else { - // set inactive - } - return 1; - } - return 0; -} - - -/*---------------------------------------------------------------------------*/ -SENSORS_SENSOR(tmp102_sensor, "Temperature", value, configure, status); // register the functions - diff --git a/platform/redbee-econotag/dev/tmp102-sensor.h b/platform/redbee-econotag/dev/tmp102-sensor.h deleted file mode 100644 index 6d5bd2140..000000000 --- a/platform/redbee-econotag/dev/tmp102-sensor.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * An interface to the TI TMP102 temperature sensor - * 12 bit temperature reading, 0.5 deg. Celsius accuracy - * ----------------------------------------------------------------- - * - * Author : Hedde Bosman (heddebosman@incas3.eu) - */ - -#ifndef __TMP102_SENSOR_H__ -#define __TMP102_SENSOR_H__ - -#include "i2c.h" - -#include "lib/sensors.h" - -extern const struct sensors_sensor tmp102_sensor; - -#define TMP102_VALUE_TYPE_DEFAULT 0 - -#define TMP102_ADDR 0x48 // if A0 @ ground -//#define TMP102_ADDR 0x49 // if A0 @ V+ -//#define TMP102_ADDR 0x4A // if A0 @ SDA -//#define TMP102_ADDR 0x4B // if A0 @ SCL - -#define TMP102_REGISTER_TEMPERATURE 0x00 -#define TMP102_REGISTER_CONFIGURATION 0x01 -#define TMP102_REGISTERO_T_LOW 0x02 -#define TMP102_REGISTERO_T_HIGH 0x03 - - -#define TMP102_CONF_EXTENDED_MODE 0x10 -#define TMP102_CONF_ALERT 0x20 -#define TMP102_CONF_CONVERSION_RATE 0xC0 // 2 bits indicating conversion rate (0.25, 1, 4, 8 Hz) - -#define TMP102_CONF_SHUTDOWN_MODE 0x01 -#define TMP102_CONF_THERMOSTAT_MODE 0x02 // 0 = comparator mode, 1 = interrupt mode -#define TMP102_CONF_POLARITY 0x04 -#define TMP102_CONF_FAULT_QUEUE 0x18 // 2 bits indicating number of faults -#define TMP102_CONF_RESOLUTION 0x60 // 2 bits indicating resolution, default = b11 = 0x60 -#define TMP102_CONF_ONESHOT_READY 0x80 // - - -#endif - diff --git a/platform/sentilla-usb/Makefile.sentilla-usb b/platform/sentilla-usb/Makefile.sentilla-usb deleted file mode 100644 index c766dd8aa..000000000 --- a/platform/sentilla-usb/Makefile.sentilla-usb +++ /dev/null @@ -1,16 +0,0 @@ -# Use custom platform configuration -CFLAGS += -DPLATFORM_CONF_H=\"platform-sentilla-usb-conf.h\" - -# Some drivers such as ds2411.c only compile under platform sky -CFLAGS += -DCONTIKI_TARGET_SKY - -CONTIKI_TARGET_SOURCEFILES += contiki-sentilla-usb-platform.c \ - battery-sensor.c radio-sensor.c temperature-sensor.c - -include $(CONTIKI)/platform/sky/Makefile.common - -ifneq ($(TMOTE_BSL), 1) - ${warning No $(TMOTE_BSL_FILE) command for jcreate/sentilla-usb found. Please install this command in $(CONTIKI)/tools/sky} -endif - -CONTIKI_TARGET_DIRS += ${addprefix ../sky/,. dev apps} diff --git a/platform/sentilla-usb/contiki-sentilla-usb-platform.c b/platform/sentilla-usb/contiki-sentilla-usb-platform.c deleted file mode 100644 index f5ee8c134..000000000 --- a/platform/sentilla-usb/contiki-sentilla-usb-platform.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2010, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * \file - * Platform setup for the sentilla usb platform - * \author - * Niclas Finne - * Joakim Eriksson - */ - -#include "dev/radio-sensor.h" - -SENSORS(&radio_sensor); - -void -init_platform(void) -{ - process_start(&sensors_process, NULL); -} diff --git a/platform/sentilla-usb/leds-arch.c b/platform/sentilla-usb/leds-arch.c deleted file mode 100644 index 6430f76d6..000000000 --- a/platform/sentilla-usb/leds-arch.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2010, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * \file - * A leds implementation for the sentilla usb platform - * \author - * Adam Dunkels - * Niclas Finne - * Joakim Eriksson - */ - -#include "contiki-conf.h" -#include "dev/leds.h" - -/*---------------------------------------------------------------------------*/ -void -leds_arch_init(void) -{ - LEDS_PxDIR |= (LEDS_CONF_RED | LEDS_CONF_GREEN); - LEDS_PxOUT = (LEDS_CONF_RED | LEDS_CONF_GREEN); -} -/*---------------------------------------------------------------------------*/ -unsigned char -leds_arch_get(void) -{ - unsigned char leds; - leds = LEDS_PxOUT; - return ((leds & LEDS_CONF_RED) ? 0 : LEDS_RED) - | ((leds & LEDS_CONF_GREEN) ? 0 : LEDS_GREEN); -} -/*---------------------------------------------------------------------------*/ -void -leds_arch_set(unsigned char leds) -{ - LEDS_PxOUT = (LEDS_PxOUT & ~(LEDS_CONF_RED|LEDS_CONF_GREEN)) - | ((leds & LEDS_RED) ? 0 : LEDS_CONF_RED) - | ((leds & LEDS_GREEN) ? 0 : LEDS_CONF_GREEN); -} -/*---------------------------------------------------------------------------*/ diff --git a/platform/sentilla-usb/platform-sentilla-usb-conf.h b/platform/sentilla-usb/platform-sentilla-usb-conf.h deleted file mode 100644 index 579c654a3..000000000 --- a/platform/sentilla-usb/platform-sentilla-usb-conf.h +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Copyright (c) 2011, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/** - * \file - * Platform configuration for the Sentilla USB - * \author - * Niclas Finne - * Joakim Eriksson - */ - -#ifndef __PLATFORM_CONF_H__ -#define __PLATFORM_CONF_H__ - -/* - * Definitions below are dictated by the hardware and not really - * changeable! - */ -/* Platform TMOTE_SKY */ -#define TMOTE_SKY 1 - -#define PLATFORM_HAS_LEDS 1 -#define PLATFORM_HAS_BUTTON 0 - -/* CPU target speed in Hz */ -#define F_CPU 3900000uL /*2457600uL*/ - -/* Our clock resolution, this is the same as Unix HZ. */ -#define CLOCK_CONF_SECOND 128UL - -#define BAUD2UBR(baud) ((F_CPU/baud)) - -#define CCIF -#define CLIF - -#define HAVE_STDINT_H -#include "msp430def.h" - - -/* Types for clocks and uip_stats */ -typedef unsigned short uip_stats_t; -typedef unsigned long clock_time_t; -typedef unsigned long off_t; - -/* the low-level radio driver */ -#define NETSTACK_CONF_RADIO cc2420_driver - -/* LED ports */ -#define LEDS_PxDIR P5DIR -#define LEDS_PxOUT P5OUT -#define LEDS_CONF_RED 0x10 -#define LEDS_CONF_GREEN 0x20 -#define LEDS_CONF_YELLOW 0x40 - -/* DCO speed resynchronization for more robust UART, etc. */ -#ifndef DCOSYNCH_CONF_ENABLED -#define DCOSYNCH_CONF_ENABLED 1 -#endif /* DCOSYNCH_CONF_ENABLED */ -#ifndef DCOSYNCH_CONF_PERIOD -#define DCOSYNCH_CONF_PERIOD 30 -#endif /* DCOSYNCH_CONF_PERIOD */ - -#define ROM_ERASE_UNIT_SIZE 512 -#define XMEM_ERASE_UNIT_SIZE (64*1024L) - - -#define CFS_CONF_OFFSET_TYPE long - - -/* Use the first 64k of external flash for node configuration */ -#define NODE_ID_XMEM_OFFSET (0 * XMEM_ERASE_UNIT_SIZE) - -/* Use the second 64k of external flash for codeprop. */ -#define EEPROMFS_ADDR_CODEPROP (1 * XMEM_ERASE_UNIT_SIZE) - -#define CFS_XMEM_CONF_OFFSET (2 * XMEM_ERASE_UNIT_SIZE) -#define CFS_XMEM_CONF_SIZE (1 * XMEM_ERASE_UNIT_SIZE) - -#define CFS_RAM_CONF_SIZE 4096 - -/* - * SPI bus configuration for the TMote Sky. - */ - -/* SPI input/output registers. */ -#define SPI_TXBUF U0TXBUF -#define SPI_RXBUF U0RXBUF - - /* USART0 Tx ready? */ -#define SPI_WAITFOREOTx() while ((U0TCTL & TXEPT) == 0) - /* USART0 Rx ready? */ -#define SPI_WAITFOREORx() while ((IFG1 & URXIFG0) == 0) - /* USART0 Tx buffer ready? */ -#define SPI_WAITFORTxREADY() while ((IFG1 & UTXIFG0) == 0) - -#define SCK 1 /* P3.1 - Output: SPI Serial Clock (SCLK) */ -#define MOSI 2 /* P3.2 - Output: SPI Master out - slave in (MOSI) */ -#define MISO 3 /* P3.3 - Input: SPI Master in - slave out (MISO) */ - -/* - * SPI bus - M25P80 external flash configuration. - */ - -#define FLASH_PWR 3 /* P4.3 Output */ -#define FLASH_CS 4 /* P4.4 Output */ -#define FLASH_HOLD 7 /* P4.7 Output */ - -/* Enable/disable flash access to the SPI bus (active low). */ - -#define SPI_FLASH_ENABLE() ( P4OUT &= ~BV(FLASH_CS) ) -#define SPI_FLASH_DISABLE() ( P4OUT |= BV(FLASH_CS) ) - -#define SPI_FLASH_HOLD() ( P4OUT &= ~BV(FLASH_HOLD) ) -#define SPI_FLASH_UNHOLD() ( P4OUT |= BV(FLASH_HOLD) ) - -/* - * SPI bus - CC2420 pin configuration. - */ - -#define CC2420_CONF_SYMBOL_LOOP_COUNT 800 - -/* P1.0 - Input: FIFOP from CC2420 */ -#define CC2420_FIFOP_PORT(type) P1##type -#define CC2420_FIFOP_PIN 0 -/* P1.3 - Input: FIFO from CC2420 */ -#define CC2420_FIFO_PORT(type) P1##type -#define CC2420_FIFO_PIN 3 -/* P1.4 - Input: CCA from CC2420 */ -#define CC2420_CCA_PORT(type) P1##type -#define CC2420_CCA_PIN 4 -/* P4.1 - Input: SFD from CC2420 */ -#define CC2420_SFD_PORT(type) P4##type -#define CC2420_SFD_PIN 1 -/* P4.2 - Output: SPI Chip Select (CS_N) */ -#define CC2420_CSN_PORT(type) P4##type -#define CC2420_CSN_PIN 2 -/* P4.5 - Output: VREG_EN to CC2420 */ -#define CC2420_VREG_PORT(type) P4##type -#define CC2420_VREG_PIN 5 -/* P4.6 - Output: RESET_N to CC2420 */ -#define CC2420_RESET_PORT(type) P4##type -#define CC2420_RESET_PIN 6 - -#define CC2420_IRQ_VECTOR PORT1_VECTOR - -/* Pin status. */ -#define CC2420_FIFOP_IS_1 (!!(CC2420_FIFOP_PORT(IN) & BV(CC2420_FIFOP_PIN))) -#define CC2420_FIFO_IS_1 (!!(CC2420_FIFO_PORT(IN) & BV(CC2420_FIFO_PIN))) -#define CC2420_CCA_IS_1 (!!(CC2420_CCA_PORT(IN) & BV(CC2420_CCA_PIN))) -#define CC2420_SFD_IS_1 (!!(CC2420_SFD_PORT(IN) & BV(CC2420_SFD_PIN))) - -/* The CC2420 reset pin. */ -#define SET_RESET_INACTIVE() (CC2420_RESET_PORT(OUT) |= BV(CC2420_RESET_PIN)) -#define SET_RESET_ACTIVE() (CC2420_RESET_PORT(OUT) &= ~BV(CC2420_RESET_PIN)) - -/* CC2420 voltage regulator enable pin. */ -#define SET_VREG_ACTIVE() (CC2420_VREG_PORT(OUT) |= BV(CC2420_VREG_PIN)) -#define SET_VREG_INACTIVE() (CC2420_VREG_PORT(OUT) &= ~BV(CC2420_VREG_PIN)) - -/* CC2420 rising edge trigger for external interrupt 0 (FIFOP). */ -#define CC2420_FIFOP_INT_INIT() do { \ - CC2420_FIFOP_PORT(IES) &= ~BV(CC2420_FIFOP_PIN); \ - CC2420_CLEAR_FIFOP_INT(); \ - } while(0) - -/* FIFOP on external interrupt 0. */ -#define CC2420_ENABLE_FIFOP_INT() do {CC2420_FIFOP_PORT(IE) |= BV(CC2420_FIFOP_PIN);} while(0) -#define CC2420_DISABLE_FIFOP_INT() do {CC2420_FIFOP_PORT(IE) &= ~BV(CC2420_FIFOP_PIN);} while(0) -#define CC2420_CLEAR_FIFOP_INT() do {CC2420_FIFOP_PORT(IFG) &= ~BV(CC2420_FIFOP_PIN);} while(0) - -/* - * Enables/disables CC2420 access to the SPI bus (not the bus). - * (Chip Select) - */ - - /* ENABLE CSn (active low) */ -#define CC2420_SPI_ENABLE() (CC2420_CSN_PORT(OUT) &= ~BV(CC2420_CSN_PIN)) - /* DISABLE CSn (active low) */ -#define CC2420_SPI_DISABLE() (CC2420_CSN_PORT(OUT) |= BV(CC2420_CSN_PIN)) -#define CC2420_SPI_IS_ENABLED() ((CC2420_CSN_PORT(OUT) & BV(CC2420_CSN_PIN)) != BV(CC2420_CSN_PIN)) - -#endif /* __PLATFORM_CONF_H__ */ diff --git a/platform/stepper-robot/Makefile b/platform/stepper-robot/Makefile deleted file mode 100644 index beeb7adb3..000000000 --- a/platform/stepper-robot/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -TARGET=stepper-robot - -all: core - -core: - $(MAKE) core.$(TARGET) - -CONTIKI=../.. - -CORE=core-nosyms.$(TARGET) - -CONTIKI_TARGET_MAIN=contiki-main.c - -codeprop: $(CONTIKI)/tools/codeprop.c - cc -g -Wall $< -o $@ - -clean: stepper_robot_clean - -.PHONY: stepper_robot_clean - -stepper_robot_clean: - -rm codeprop - -include $(CONTIKI)/Makefile.include - diff --git a/platform/stepper-robot/Makefile.stepper-robot b/platform/stepper-robot/Makefile.stepper-robot deleted file mode 100644 index b74e6180d..000000000 --- a/platform/stepper-robot/Makefile.stepper-robot +++ /dev/null @@ -1,29 +0,0 @@ -STEPPER_ROBOT = leds.c leds-arch.c sam7s-spi.c stepper-process.c stepper.c stepper-interrupt.c stepper-move.c - -#CODEPROP_SOURCES = codeprop-otf.c ram-segments.c -UIPDRIVERS= cc2420.c cc2420-interrupt.c \ -cc2420-spi.c slip.c - -CONTIKI_TARGET_DIRS = . stepper - -# Master clock frequency -MCK=23961600 -CFLAGS+=-DAUTOSTART_ENABLE - -ifndef CONTIKI_TARGET_MAIN -CONTIKI_TARGET_MAIN = robot-main.c -endif - -CONTIKI_TARGET_SOURCEFILES += $(SENSORS) $(STEPPER_ROBOT) \ - $(CODEPROP_SOURCES) $(CONTIKI_TARGET_MAIN) - -# include $(CONTIKI)/platform/$(TARGET)/apps/Makefile.apps - -include $(CONTIKI)/cpu/arm/at91sam7s/Makefile.at91sam7s - -#contiki-$(TARGET).a: ${addprefix $(OBJECTDIR)/,symbols.o} - -ifndef BASE_IP -BASE_IP := 172.16.1.1 -endif - diff --git a/platform/stepper-robot/cc2420-interrupt.c b/platform/stepper-robot/cc2420-interrupt.c deleted file mode 100644 index 3b60711d8..000000000 --- a/platform/stepper-robot/cc2420-interrupt.c +++ /dev/null @@ -1,51 +0,0 @@ -#include -#include -#include -#include -#include -#include - -static void NACKEDFUNC -cc2420_fifop_interrupt (void) /* System Interrupt Handler */ -{ - ISR_STORE(); - ISR_ENABLE_NEST(); - cc2420_interrupt(); - ISR_DISABLE_NEST(); - *AT91C_AIC_EOICR = 0; /* End of Interrupt */ - ISR_RESTORE(); -} - -void -cc2420_interrupt_fifop_int_init(void) -{ - *AT91C_PIOA_ASR = AT91C_PA30_IRQ1; - *AT91C_PIOA_PDR = AT91C_PA30_IRQ1; - AT91C_AIC_SMR[AT91C_ID_IRQ1] = AT91C_AIC_SRCTYPE_POSITIVE_EDGE | 4; - AT91C_AIC_SVR[AT91C_ID_IRQ1] = (unsigned long)cc2420_fifop_interrupt; - /* *AT91C_AIC_IECR = (1 << AT91C_ID_IRQ1); */ -} - -#ifndef __MAKING_DEPS__ - -inline int splhigh(void) -{ - int save; -#ifndef __THUMBEL__ - asm("mrs %0, CPSR\n\torr r1,%0,#0x80\n\tmsr CPSR_c, r1" : "=r" (save)::"r1"); -#else -#error Must be compiled in ARM mode -#endif - return save; -} - -inline void splx(int saved) -{ -#ifndef __THUMBELL__ - asm("msr CPSR_c, %0" ::"r" (saved)); -#else -#error Must be compiled in ARM mode -#endif -} - -#endif /* __MAKING_DEPS__ */ diff --git a/platform/stepper-robot/cc2420-interrupt.h b/platform/stepper-robot/cc2420-interrupt.h deleted file mode 100644 index f36927850..000000000 --- a/platform/stepper-robot/cc2420-interrupt.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __CC2420_CORE_INTERRUPT_H__9499CTDNSK__ -#define __CC2420_CORE_INTERRUPT_H__9499CTDNSK__ - -void -cc2420_interrupt_fifop_int_init(void); -#endif /* __CC2420_CORE_INTERRUPT_H__9499CTDNSK__ */ diff --git a/platform/stepper-robot/cc2420-spi.c b/platform/stepper-robot/cc2420-spi.c deleted file mode 100644 index 04c5d6e17..000000000 --- a/platform/stepper-robot/cc2420-spi.c +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include -#include -#include - -#define SPI_SPEED 1000000 /* 1MHz clock*/ -#define SPI_DLYBCT 1 -#define SPI_DLYBS 20 - - -#ifndef BV -#define BV(b) (1<<(b)) -#endif - -void -cc2420_arch_init(void) -{ - spi_init(); - - AT91C_SPI_CSR[CC2420_DEFAULT_DEV] = - ((SPI_DLYBCT<<24) | (SPI_DLYBS<<16) | (((MCK+SPI_SPEED/2)/SPI_SPEED)<<8) - | AT91C_SPI_NCPHA | AT91C_SPI_BITS_8 | AT91C_SPI_CSAAT); -} diff --git a/platform/stepper-robot/contiki-conf.h b/platform/stepper-robot/contiki-conf.h deleted file mode 100644 index c457801af..000000000 --- a/platform/stepper-robot/contiki-conf.h +++ /dev/null @@ -1,98 +0,0 @@ -#ifndef __CONTIKI_CONF_H__CDBB4VIH3I__ -#define __CONTIKI_CONF_H__CDBB4VIH3I__ - -#include -#include -#include -#include - -#define CCIF -#define CLIF - -#define WITH_UIP 1 -#define WITH_ASCII 1 - -#define CLOCK_CONF_SECOND 100 - -/* These names are deprecated, use C99 names. */ -typedef uint8_t u8_t; -typedef uint16_t u16_t; -typedef uint32_t u32_t; -typedef int8_t s8_t; -typedef int16_t s16_t; -typedef int32_t s32_t; - -typedef unsigned int clock_time_t; -typedef unsigned int uip_stats_t; - -#ifndef BV -#define BV(x) (1<<(x)) -#endif - -/* SPI */ -#define SPI_TXBUF *AT91C_SPI_TDR - -#define SPI_RXBUF ((unsigned char)*AT91C_SPI_RDR) - -#define SPI_WAITFOREOTx() while ((*AT91C_SPI_SR & AT91C_SPI_TXEMPTY) == 0) - -#define SPI_WAITFOREORx() while ((*AT91C_SPI_SR & AT91C_SPI_RDRF) == 0) - -/* CC2420 control pins */ -/* LOOP count for waiting 20 symbols in the CC2420 code - same as MSP? */ -#define CC2420_CONF_SYMBOL_LOOP_COUNT 800 - - -#define FIFO_IS_1 (*AT91C_PIOA_PDSR & AT91C_PIO_PA2) -#define VREG_IS_1 1 /* Hardwired */ -#define FIFOP_IS_1 (*AT91C_PIOA_PDSR & AT91C_PIO_PA30) -#define SFD_IS_1 (*AT91C_PIOA_PDSR & AT91C_PIO_PA15) -#define CCA_IS_1 1 - -#define SET_RESET_INACTIVE() setreg(CC2420_MAIN, 0xf800); -#define SET_RESET_ACTIVE() setreg(CC2420_MAIN, 0x0000); - -#define SET_VREG_ACTIVE() -#define SET_VREG_INACTIVE() - -#define FIFOP_INT_INIT() cc2420_interrupt_fifop_int_init() -#define DISABLE_FIFOP_INT() (*AT91C_AIC_IDCR = (1 << AT91C_ID_IRQ1)) -#define ENABLE_FIFOP_INT() (*AT91C_AIC_IECR = (1 << AT91C_ID_IRQ1)) - -#define CC2420_DEFAULT_DEV 1 - -#define SPI_ENABLE() \ -do { \ -*AT91C_SPI_MR = ((*AT91C_SPI_MR & ~AT91C_SPI_PCS) \ - | ((~(1< -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "net/mac/nullmac.h" -#include "net/rime.h" - -#include "contiki-main.h" - -#ifndef RF_CHANNEL -#define RF_CHANNEL 15 -#endif - - -#if WITH_UIP -#include "net/uip.h" -#include "net/uip-fw.h" -#include "net/uip-fw-drv.h" -#include "net/uip-over-mesh.h" - - -static struct uip_fw_netif meshif = - {UIP_FW_NETIF(172,16,0,0, 255,255,0,0, uip_over_mesh_send)}; - -#define UIP_OVER_MESH_CHANNEL 9 - -uint8_t is_gateway = 0; -struct trickle_conn gateway_trickle; - -#endif /* WITH_UIP */ - -extern char __heap_end__; -extern char __heap_start__; - - -rimeaddr_t node_addr __attribute__((weak)) = {{0,2}}; - -/*--------------------------------------------------------------------------*/ -#if WITH_UIP - -/* Receive address of gateway */ - -static void -trickle_recv(struct trickle_conn *c) -{ - if (!is_gateway) { - struct gateway_msg *msg; - msg = rimebuf_dataptr(); - printf("%d.%d: gateway message: %d.%d\n", - rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1], - msg->gateway.u8[0], msg->gateway.u8[1]); - - uip_over_mesh_set_gateway(&msg->gateway); - } -} - -const static struct trickle_callbacks trickle_call = {trickle_recv}; - -/*---------------------------------------------------------------------------*/ -#endif - -#if 0 -/* Wathcdog is already disabled in startup code */ -static void -wdt_setup() -{ - -} -#endif - -static void -wdt_reset() -{ - *AT91C_WDTC_WDCR = (0xa5<<24) | AT91C_WDTC_WDRSTT; -} - -#if 0 -static uip_ipaddr_t gw_addr = {{172,16,0,1}}; -#endif - - -int -main() -{ - disableIRQ(); - disableFIQ(); - *AT91C_AIC_IDCR = 0xffffffff; - *AT91C_PMC_PCDR = 0xffffffff; - *AT91C_PMC_PCER = (1 << AT91C_ID_PIOA); - - dbg_setup_uart(); - printf("Initialising\n"); - leds_init(); - clock_init(); - process_init(); - process_start(&etimer_process, NULL); - - ctimer_init(); - - enableIRQ(); - - printf("Beginning CC2420 setup\n"); - cc2420_init(); - cc2420_set_pan_addr(0x2024, 0, NULL); - cc2420_set_channel(RF_CHANNEL); - rime_init(nullmac_init(&cc2420_driver)); - printf("CC2420 setup done\n"); - - rimeaddr_set_node_addr(&node_addr); - printf("Rime started with address %d.%d\n", node_addr.u8[0], node_addr.u8[1]); - - #if WITH_UIP - { - uip_ipaddr_t hostaddr, netmask; - - uip_init(); - - uip_ipaddr(&hostaddr, 172,16, - rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1]); - uip_ipaddr(&netmask, 255,255,0,0); - uip_ipaddr_copy(&meshif.ipaddr, &hostaddr); - printf("Host addr\n"); - uip_sethostaddr(&hostaddr); - uip_setnetmask(&netmask); - uip_over_mesh_set_net(&hostaddr, &netmask); - /* uip_fw_register(&slipif);*/ - /*uip_over_mesh_set_gateway_netif(&slipif);*/ - uip_fw_register(&meshif); - uip_fw_default(&meshif); - printf("Mesh init\n"); - uip_over_mesh_init(UIP_OVER_MESH_CHANNEL); - printf("uIP started with IP address %d.%d.%d.%d\n", - uip_ipaddr_to_quad(&hostaddr)); - } -#endif /* WITH_UIP */ - - - -#if WITH_UIP - process_start(&tcpip_process, NULL); - process_start(&uip_fw_process, NULL); /* Start IP output */ - - trickle_open(&gateway_trickle, CLOCK_SECOND * 4, GATEWAY_TRICKLE_CHANNEL, - &trickle_call); -#endif /* WITH_UIP */ - - printf("Heap size: %ld bytes\n", &__heap_end__ - (char*)sbrk(0)); - printf("Started\n"); - - /* procinit_init(); */ - - autostart_start(autostart_processes); - printf("Processes running\n"); - while(1) { - do { - /* Reset watchdog. */ - wdt_reset(); - } while(process_run() > 0); - /* Idle! */ - /* Stop processor clock */ - *AT91C_PMC_SCDR |= AT91C_PMC_PCK; - } - return 0; -} diff --git a/platform/stepper-robot/core.c b/platform/stepper-robot/core.c deleted file mode 100644 index 0ac8437a8..000000000 --- a/platform/stepper-robot/core.c +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include -#include -#include -#include -#include "codeprop-otf.h" -#include -#include - -PROCESS(blink_process, "LED blink process"); - -PROCESS_THREAD(blink_process, ev , data) -{ - static struct etimer timer; - PROCESS_BEGIN(); - etimer_set(&timer, CLOCK_SECOND/2); - while(1) { - PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_EXIT || - ev== PROCESS_EVENT_TIMER); - if (ev == PROCESS_EVENT_EXIT) break; - leds_invert(LEDS_RED); - etimer_reset(&timer); - } - PROCESS_END(); -} - -AUTOSTART_PROCESSES(&codeprop_process, &ram_segments_cleanup_process, &stepper_process,&blink_process); diff --git a/platform/stepper-robot/gateway/Makefile b/platform/stepper-robot/gateway/Makefile deleted file mode 100644 index fd867a7b4..000000000 --- a/platform/stepper-robot/gateway/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -CONTIKI=../../../../contiki-2.x/ -TARGET=stepper-robot - -MCK=23961600 -XSLTPROC=xsltproc - -CONTIKI_TARGET_MAIN=contiki-main.c - -all: gateway - -include $(CONTIKI)/Makefile.include diff --git a/platform/stepper-robot/gateway/gateway.c b/platform/stepper-robot/gateway/gateway.c deleted file mode 100644 index dd13f4186..000000000 --- a/platform/stepper-robot/gateway/gateway.c +++ /dev/null @@ -1,134 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "contiki-main.h" - -/* SLIP interface */ - -extern struct uip_fw_netif cc2420if; - -rimeaddr_t node_addr = {{0,129}}; - -static struct uip_fw_netif slipif = -{UIP_FW_NETIF(0,0,0,0, 255,255,255,255, slip_send)}; - -/* USB buffers */ -static unsigned char input_buffer[128]; -static unsigned char output_buffer[128]; -static unsigned char interrupt_buffer[16]; - -#define DEV_TO_HOST 0x81 -#define HOST_TO_DEV 0x02 - -#define GATEWAY_TRICKLE_CHANNEL 8 -void -slip_arch_init(unsigned long ubr) -{ -} - -void -slip_arch_writeb(unsigned char c) -{ - while(usb_send_data(DEV_TO_HOST, &c, 1) != 1); -} - -#if WITH_UIP - -static void -set_gateway(void) -{ - struct gateway_msg msg; - /* Make this node the gateway node, unless it already is the - gateway. */ - if(!is_gateway) { - leds_on(LEDS_RED); - printf("%d.%d: making myself the gateway\n", - rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1]); - uip_over_mesh_set_gateway(&rimeaddr_node_addr); - rimeaddr_copy(&(msg.gateway), &rimeaddr_node_addr); - rimebuf_copyfrom(&msg, sizeof(struct gateway_msg)); - trickle_send(&gateway_trickle); - is_gateway = 1; - } -} -#endif /* WITH_UIP */ - -PROCESS(gateway_process, "Gateway process"); - - -PROCESS_THREAD(gateway_process, ev , data) -{ - static struct etimer timer; - PROCESS_BEGIN(); - usb_set_user_process(process_current); - usb_setup(); - usb_cdc_acm_setup(); - - uip_fw_default(&slipif); - uip_over_mesh_set_gateway_netif(&slipif); - - process_start(&slip_process, NULL); - - set_gateway(); - - while(ev != PROCESS_EVENT_EXIT) { - PROCESS_WAIT_EVENT(); - if (ev == PROCESS_EVENT_TIMER) { - leds_toggle(LEDS_YELLOW); - /* printf("FIFOP: %d\n", FIFOP_IS_1); */ - etimer_restart(&timer); - } else if (ev == PROCESS_EVENT_MSG) { - const struct usb_user_msg * const msg = data; - switch(msg->type) { - case USB_USER_MSG_TYPE_CONFIG: - printf("User config\n"); - if (msg->data.config != 0) { - usb_setup_bulk_endpoint(DEV_TO_HOST, - input_buffer, sizeof(input_buffer)); - usb_setup_bulk_endpoint(HOST_TO_DEV, - output_buffer, sizeof(output_buffer)); - usb_setup_interrupt_endpoint(0x83,interrupt_buffer, - sizeof(interrupt_buffer)); - etimer_set(&timer, CLOCK_SECOND); - } else { - etimer_stop(&timer); - usb_disable_endpoint(DEV_TO_HOST); - usb_disable_endpoint(HOST_TO_DEV); - usb_disable_endpoint(0x83); - - } - break; - case USB_USER_MSG_TYPE_EP_OUT(2): - { - /*unsigned int len = msg->data.length; - printf("Received %d:\n", len); */ - { - unsigned char ch; - unsigned int xfer; - while((xfer = usb_recv_data(HOST_TO_DEV, &ch, 1)) > 0) { - /* printf(" %02x",ch); */ - if (slip_input_byte(ch)) break; - } - /* printf("\n"); */ - } - } - break; - } - - } - } - printf("USB test process exited\n"); - PROCESS_END(); -} - -AUTOSTART_PROCESSES(&gateway_process); diff --git a/platform/stepper-robot/leds-arch.c b/platform/stepper-robot/leds-arch.c deleted file mode 100644 index 8a51173fe..000000000 --- a/platform/stepper-robot/leds-arch.c +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include - -#define GREEN_PIN AT91C_PIO_PA3 -#define YELLOW_PIN AT91C_PIO_PA4 -#define RED_PIN AT91C_PIO_PA8 - -#define ALL_PINS (GREEN_PIN | YELLOW_PIN | RED_PIN) - -void -leds_arch_init(void) -{ - *AT91C_PIOA_PER = ALL_PINS; - *AT91C_PIOA_OER = ALL_PINS; - *AT91C_PIOA_MDER = ALL_PINS; - *AT91C_PIOA_SODR = ALL_PINS; -} - -unsigned char -leds_arch_get(void) -{ - unsigned char on = 0; - if (*AT91C_PIOA_ODSR & GREEN_PIN) on |= LEDS_GREEN; - if (*AT91C_PIOA_ODSR & YELLOW_PIN) on |= LEDS_YELLOW; - if (*AT91C_PIOA_ODSR & RED_PIN) on |= LEDS_RED; - return on; -} - -void -leds_arch_set(unsigned char leds) -{ - unsigned int set = 0; - if (leds & LEDS_GREEN) set |= GREEN_PIN; - if (leds & LEDS_YELLOW) set |= YELLOW_PIN; - if (leds & LEDS_RED) set |= RED_PIN; - *AT91C_PIOA_CODR = set; - *AT91C_PIOA_SODR = (~set) & ALL_PINS; -} diff --git a/platform/stepper-robot/robot-main.c b/platform/stepper-robot/robot-main.c deleted file mode 100644 index c57de8dc0..000000000 --- a/platform/stepper-robot/robot-main.c +++ /dev/null @@ -1,183 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "net/mac/nullmac.h" -#include "net/rime.h" - - -#ifndef RF_CHANNEL -#define RF_CHANNEL 15 -#endif - -#ifndef WITH_UIP -#define WITH_UIP 1 -#endif - -#if WITH_UIP -#include "net/uip.h" -#include "net/uip-fw.h" -#include "net/uip-fw-drv.h" -#include "net/uip-over-mesh.h" - -static struct uip_fw_netif meshif = - {UIP_FW_NETIF(172,16,0,0, 255,255,0,0, uip_over_mesh_send)}; - -#define UIP_OVER_MESH_CHANNEL 9 - -#endif /* WITH_UIP */ - -static rimeaddr_t node_addr = {{0,2}}; - -extern char __heap_end__; -extern char __heap_start__; - - -static const uint32_t stepper0_steps_acc[] = MICRO_STEP(0,3); -static const uint32_t stepper0_steps_run[] = MICRO_STEP(0,2); -static const uint32_t stepper0_steps_hold[] = MICRO_STEP(0,1); - -static const uint32_t stepper1_steps_acc[] = MICRO_STEP(1,3); -static const uint32_t stepper1_steps_run[] = MICRO_STEP(1,2); -static const uint32_t stepper1_steps_hold[] = MICRO_STEP(1,1); - -static StepperAccSeq seq_heap[40]; - -static void -init_seq_heap() -{ - unsigned int i; - for(i = 0; i < sizeof(seq_heap)/sizeof(seq_heap[0]); i++) { - seq_heap[i].next = NULL; - stepper_free_seq(&seq_heap[i]); - } -} - -static void -robot_stepper_init() -{ - init_seq_heap(); - stepper_init(AT91C_BASE_TC0, AT91C_ID_TC0); - *AT91C_PIOA_OER = STEPPER_INHIBIT; - *AT91C_PIOA_MDER = STEPPER_INHIBIT; /* | STEPPER0_IOMASK; */ - *AT91C_PIOA_CODR = STEPPER_INHIBIT; - stepper_init_io(1, STEPPER_IOMASK(0), stepper0_steps_acc, - stepper0_steps_run, stepper0_steps_hold, - (sizeof(stepper0_steps_run) / sizeof(stepper0_steps_run[0]))); - stepper_init_io(0, STEPPER_IOMASK(1), stepper1_steps_acc, - stepper1_steps_run, stepper1_steps_hold, - (sizeof(stepper1_steps_run) / sizeof(stepper1_steps_run[0])));} - - -#if 0 -/* Wathcdog is already disabled in startup code */ -static void -wdt_setup() -{ - -} -#endif - -static void -wdt_reset() -{ - *AT91C_WDTC_WDCR = (0xa5<<24) | AT91C_WDTC_WDRSTT; -} - -#if 0 -static uip_ipaddr_t gw_addr = {{172,16,0,1}}; -#endif - - -int -main() -{ - disableIRQ(); - disableFIQ(); - *AT91C_AIC_IDCR = 0xffffffff; - *AT91C_PMC_PCDR = 0xffffffff; - *AT91C_PMC_PCER = (1 << AT91C_ID_PIOA); - - dbg_setup_uart(); - printf("Initialising\n"); - leds_arch_init(); - clock_init(); - process_init(); - process_start(&etimer_process, NULL); - ctimer_init(); - - robot_stepper_init(); - - enableIRQ(); - - cc2420_init(); - cc2420_set_pan_addr(0x2024, 0, &uip_hostaddr.u16[1]); - cc2420_set_channel(RF_CHANNEL); - rime_init(nullmac_init(&cc2420_driver)); - printf("CC2420 setup done\n"); - - rimeaddr_set_node_addr(&node_addr); - - #if WITH_UIP - { - uip_ipaddr_t hostaddr, netmask; - - uip_init(); - - uip_ipaddr(&hostaddr, 172,16, - rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1]); - uip_ipaddr(&netmask, 255,255,0,0); - uip_ipaddr_copy(&meshif.ipaddr, &hostaddr); - printf("Host addr\n"); - uip_sethostaddr(&hostaddr); - uip_setnetmask(&netmask); - uip_over_mesh_set_net(&hostaddr, &netmask); - /* uip_fw_register(&slipif);*/ - /*uip_over_mesh_set_gateway_netif(&slipif);*/ - uip_fw_default(&meshif); - printf("Mesh init\n"); - uip_over_mesh_init(UIP_OVER_MESH_CHANNEL); - printf("uIP started with IP address %d.%d.%d.%d\n", - uip_ipaddr_to_quad(&hostaddr)); - } -#endif /* WITH_UIP */ - - -#if WITH_UIP - process_start(&tcpip_process, NULL); - process_start(&uip_fw_process, NULL); /* Start IP output */ -#endif /* WITH_UIP */ - - printf("Heap size: %ld bytes\n", &__heap_end__ - (char*)sbrk(0)); - printf("Started\n"); - - autostart_start(autostart_processes); - printf("Processes running\n"); - while(1) { - do { - /* Reset watchdog. */ - wdt_reset(); - } while(process_run() > 0); - /* Idle! */ - /* Stop processor clock */ - *AT91C_PMC_SCDR |= AT91C_PMC_PCK; - } - return 0; -} diff --git a/platform/stepper-robot/sam7s-spi.c b/platform/stepper-robot/sam7s-spi.c deleted file mode 100644 index b1ff7bd8c..000000000 --- a/platform/stepper-robot/sam7s-spi.c +++ /dev/null @@ -1,126 +0,0 @@ -#include -#include -#include -#include - -/* Prevents interrupts using SPI at inappropriate times */ -unsigned char spi_busy = 0; - -#define SPI_SPEED 1000000 /* 1MHz clock*/ -#define SPI_DLYBCT 1 -#define SPI_DLYBS 20 - -#define SPI_TRANSFER (AT91C_PA12_MISO | AT91C_PA13_MOSI | AT91C_PA14_SPCK) - -#define SPI_CS (AT91C_PA11_NPCS0 | AT91C_PA31_NPCS1) - -void -spi_init() -{ - static uint8_t initialised = 0; - if (!initialised) { - *AT91C_SPI_CR = AT91C_SPI_SPIDIS | AT91C_SPI_SWRST; - *AT91C_PMC_PCER = (1 << AT91C_ID_SPI); - *AT91C_PIOA_ASR = SPI_TRANSFER | SPI_CS; - *AT91C_PIOA_PDR = SPI_TRANSFER | SPI_CS; - *AT91C_PIOA_PPUER = AT91C_PA12_MISO | SPI_CS; - *AT91C_SPI_MR = (AT91C_SPI_MSTR | AT91C_SPI_PS_FIXED - | AT91C_SPI_MODFDIS | AT91C_SPI_PCS); - - /* It seems necessary to set the clock speed for chip select 0 - even if it's not used. */ - AT91C_SPI_CSR[0] = (MCK/SPI_SPEED)<<8; - - *AT91C_SPI_CR = AT91C_SPI_SPIEN; - initialised = 1; - } -} - -void -spi_init_chip_select(unsigned int chip, unsigned int speed, - unsigned int dlybct, - unsigned int dlybs, unsigned int phase, - unsigned int polarity) -{ - spi_init(); - - AT91C_SPI_CSR[chip] = - ((dlybct<<24) | (dlybs<<16) | (((MCK+speed/2)/speed)<<8) - | (phase?AT91C_SPI_NCPHA:0) | (polarity?AT91C_SPI_CPOL:0) - | AT91C_SPI_BITS_8 | AT91C_SPI_CSAAT); -} - -#if 0 -#define DBG_SEND dbg_blocking_putchar('>'); -#define DBG_RECV dbg_blocking_putchar('<'); -#else -#define DBG_SEND -#define DBG_RECV -#endif - -void -spi_transfer(unsigned int chip, const struct spi_block *block, unsigned int blocks) -{ - spi_busy = 1; - while(!(*AT91C_SPI_SR & AT91C_SPI_TXEMPTY)); /* wait unti previous transfer is done */ - - /* Clear any data left in the receiver */ - (void)*AT91C_SPI_RDR; - (void)*AT91C_SPI_RDR; - - /* Select chip */ - *AT91C_SPI_MR = ((*AT91C_SPI_MR & ~AT91C_SPI_PCS) - | ((~(1< 0) { - struct spi_block current = *block++; - if (current.send) { - if (current.receive) { - /* Send and receive */ - while(current.len-- > 0) { - while(!(*AT91C_SPI_SR & AT91C_SPI_TDRE)); - *AT91C_SPI_TDR = *current.send++; - DBG_SEND; - while(!(*AT91C_SPI_SR & AT91C_SPI_RDRF)); - *current.receive++ = *AT91C_SPI_RDR; - DBG_RECV; - } - } else { - /* Send only */ - while(current.len-- > 0) { - while(!(*AT91C_SPI_SR & AT91C_SPI_TDRE)); - *AT91C_SPI_TDR = *current.send++; - DBG_SEND; - while(!(*AT91C_SPI_SR & AT91C_SPI_RDRF)); - (void)*AT91C_SPI_RDR; - DBG_RECV; - } - } - } else { - if (current.receive) { - /* Receive only */ - while(current.len-- > 0) { - while(!(*AT91C_SPI_SR & AT91C_SPI_TDRE)); - *AT91C_SPI_TDR = 0; - DBG_SEND; - while(!(*AT91C_SPI_SR & AT91C_SPI_RDRF)); - *current.receive++ = *AT91C_SPI_RDR; - DBG_RECV; - } - } else { - /* Clock only */ - while(current.len-- > 0) { - while(!(*AT91C_SPI_SR & AT91C_SPI_TDRE)); - *AT91C_SPI_TDR = 0; - DBG_SEND; - while(!(*AT91C_SPI_SR & AT91C_SPI_RDRF)); - (void)*AT91C_SPI_RDR; - DBG_RECV; - } - } - } - } - *AT91C_SPI_CR = AT91C_SPI_LASTXFER; - - spi_busy = 0; -} diff --git a/platform/stepper-robot/sam7s-spi.h b/platform/stepper-robot/sam7s-spi.h deleted file mode 100644 index 7a2f41f67..000000000 --- a/platform/stepper-robot/sam7s-spi.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef __CORE_SPI_H__KBMMOKI6CG__ -#define __CORE_SPI_H__KBMMOKI6CG__ -#include - -void -spi_init(); - -#define SPI_POLARITY_INACTIVE_HIGH 1 -#define SPI_POLARITY_INACTIVE_LOW 1 - -#define SPI_PHASE_CHANGE_CAPTURE 0 -#define SPI_PHASE_CAPTURE_CHANGE 1 - -struct spi_block { - const uint8_t *send; /* NULL for receive only */ - uint8_t *receive; /* NULL for send only */ - uint16_t len; /* transfer length, non-zero */ -}; - -void -spi_transfer(unsigned int chip, const struct spi_block *block, unsigned int blocks); - -void -spi_init_chip_select(unsigned int chip, unsigned int speed, - unsigned int dlybct, - unsigned int dlybs, unsigned int phase, - unsigned int polarity); - -#endif /* __CORE_SPI_H__KBMMOKI6CG__ */ diff --git a/platform/stepper-robot/stepper-process.c b/platform/stepper-robot/stepper-process.c deleted file mode 100644 index b371bf834..000000000 --- a/platform/stepper-robot/stepper-process.c +++ /dev/null @@ -1,517 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#undef putchar - - -static unsigned int -parse_uint_hex(const char **pp, const char *end) -{ - unsigned int v = 0; - while(*pp < end) { - char ch; - if ((ch = **pp) >= '0' && ch <= '9') { - v = v* 16 + (ch - '0'); - } else if (ch >= 'A' && ch <= 'F') { - v = v* 16 + (ch - 'A') + 10; - } else break; - (*pp)++; - } - return v; -} - -static int -parse_int_hex(const char **pp, const char *end) -{ - if (*pp == end) return 0; - if (**pp == '-') { - (*pp)++; - return -parse_uint_hex(pp, end); - } else { - return parse_uint_hex(pp, end); - } -} - -static void -skip_white(const char **pp, const char *end) -{ - char ch; - while(*pp < end && ((ch = **pp) == ' ' || ch == '\t')) (*pp)++; -} - -static const char hex_chars[] = - {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; - -static void -format_uint_hex(char **str, char *end, unsigned int v) -{ - char buffer[10]; - char *p = buffer+10; - if (*str == end) return; - if (v == 0) { - *(*str)++ = '0'; - return; - } - while(v > 0) { - *--p = hex_chars[v&0xf]; - v >>= 4; - } - while((p < buffer+10) && (*str < end)) { - *(*str)++ = *p++; - } -} - -static void -format_int_hex(char **str, char *end, int v) -{ - if (v < 0) { - if (*str == end) return; - *(*str)++ = '-'; - v = -v; - } - format_uint_hex(str, end, v); -} - -static void -format_ull_hex(char **str, char *end, unsigned long long int v) -{ - char buffer[16]; - char *p = buffer+10; - if (*str == end) return; - if (v == 0) { - *(*str)++ = '0'; - return; - } - while(v > 0) { - *--p = hex_chars[v&0xf]; - v >>= 4; - } - while((p < buffer+10) && (*str < end)) { - *(*str)++ = *p++; - } -} -static void -format_ll_hex(char **str, char *end, long long v) -{ - if (v < 0) { - if (*str == end) return; - *(*str)++ = '-'; - v = -v; - } - format_ull_hex(str, end, v); -} - -typedef struct _ReplyBuffer ReplyBuffer; - -struct _ReplyBuffer -{ - char buffer[70]; /* Should be small enough to fit in one packet */ - char *write; -}; - -static ReplyBuffer tcp_reply; -static ReplyBuffer udp_reply; - -#define REPLY_BUFFER_END(reply) ((reply)->buffer+sizeof((reply)->buffer)) -#define REPLY_BUFFER_LEFT(reply) \ -((reply)->buffer+sizeof((reply)->buffer) - (reply)->write) - -static void -reply_char(ReplyBuffer *reply, char c) -{ - if (REPLY_BUFFER_LEFT(reply) > 0) { - *reply->write++ = c; - } -} - -static void -reply_str(ReplyBuffer *reply, char *str) -{ - while(reply->write < REPLY_BUFFER_END(reply) && *str != '\0') - *reply->write++ = *str++; -} - -static void -stepper_reply(ReplyBuffer *reply, StepperResult res) -{ - switch(res) { - case STEPPER_OK: - reply_str(reply, "OK"); - break; - case STEPPER_ERR_MEM: - reply_str(reply, "ERR MEM"); - break; - case STEPPER_ERR_TOO_LATE: - reply_str(reply, "ERR LATE"); - break; - case STEPPER_ERR_INDEX: /* Sholdn't happen here */ - reply_str(reply, "ERR INDEX"); - break; - default: - reply_str(reply, "ERR"); - } - reply_char(reply, '\n'); -} - -#define CHECK_INPUT_LEFT(x) \ -do {\ -if ((x) > inend - input_line) {reply_str(reply, "ERR\n");return 0;}\ -} while(0) - -static int -handle_line(const char *input_line, const char *inend, ReplyBuffer *reply) -{ - unsigned long when; -#if 0 - { - const char *p = input_line; - printf("Got line: '"); - while(p < inend) { - putchar(*p++); - } - printf("'\n"); - fsync(1); - } -#endif - skip_white(&input_line, inend); - CHECK_INPUT_LEFT(1); - if (*input_line == '#') { - input_line++; - reply_char(reply, '#'); - while (input_line < inend &&*input_line != ' ') { - reply_char(reply, *input_line++); - } - reply_char(reply, ' '); - } - skip_white(&input_line, inend); - - if (*input_line == '@') { - input_line++; - when = parse_uint_hex(&input_line, inend); - } else { - when = stepper_current_period() + 3; - } - skip_white(&input_line, inend); - CHECK_INPUT_LEFT(1); - if (input_line[0] == 'L' || input_line[0] == 'R') { - unsigned int stepper_index = (input_line[0] == 'R' ? 1 : 0); - CHECK_INPUT_LEFT(1); - input_line++; - if (input_line[0] == 'S') { - int speed; - input_line++; - if (input_line == inend) { - /* printf("Speed: %ld\n", - stepper_current_velocity(stepper_index)/VEL_SCALE);*/ - reply_char(reply, input_line[-2]); - reply_char(reply, 'S'); - format_int_hex(&reply->write, REPLY_BUFFER_END(reply), - stepper_current_velocity(stepper_index)/VEL_SCALE); - reply_char(reply, '\n'); - } else { - speed = parse_int_hex(&input_line, inend); - if (*input_line == ',') { - StepperResult res; - unsigned int acc; - input_line++; - acc = parse_uint_hex(&input_line, inend); - /* printf("Speed=%d, Acc=%u\n", speed, acc); */ - res = stepper_set_velocity(stepper_index, &when, - acc, speed*VEL_SCALE); - - stepper_reply(reply, res); - } else { - reply_str(reply, "ERR\n"); - } - } - } else if (input_line[0] == 'C') { - reply_char(reply, input_line[-1]); - reply_char(reply, 'C'); - format_ll_hex(&reply->write, REPLY_BUFFER_END(reply), - stepper_current_step(stepper_index)); - reply_char(reply, '\n'); - } else if (input_line[0] == 'M') { - unsigned int speed; - unsigned int acc; - int move; - input_line++; - speed = parse_uint_hex(&input_line, inend); - CHECK_INPUT_LEFT(1); - if (*input_line == ',') { - input_line++; - acc = parse_uint_hex(&input_line, inend); - if (*input_line == ',') { - StepperResult res; - input_line++; - move = parse_int_hex(&input_line, inend); - /*printf("Speed=%u, Acc=%u, Move=%d\n", speed, acc, move);*/ - res = stepper_move(stepper_index, &when, - acc,speed*VEL_SCALE,move*DIST_SCALE); - stepper_reply(reply, res); - } else { - reply_str(reply, "ERR\n"); - } - } else { - reply_str(reply, "ERR\n"); - } - } else { - reply_str(reply, "ERR\n"); - } - } else if (input_line[0] == 'E') { - STEPPER_ENABLE(); - printf("Stepper enabled\n"); - reply_str(reply, "OK\n"); - } else if (input_line[0] == 'D') { - STEPPER_DISABLE(); - printf("Stepper disabled\n"); - reply_str(reply, "OK\n"); - } else if (input_line[0] == 'p') { - reply_char(reply, 'p'); - format_int_hex(&reply->write, REPLY_BUFFER_END(reply), - cc2420_last_rssi); - reply_char(reply, ','); - format_uint_hex(&reply->write, REPLY_BUFFER_END(reply), - cc2420_last_correlation); - reply_char(reply, '\n'); - } else if (input_line[0] == 'T') { - reply_char(reply, 'T'); - format_int_hex(&reply->write, REPLY_BUFFER_END(reply), - stepper_current_period()); - reply_char(reply, '\n'); - } else if (input_line[0] == 'q') { - return 1; - } else { - reply_str(reply, "ERR\n"); - } - return 0; -} -static unsigned int transmit_len = 0; - -static void -send_reply() -{ - if (transmit_len == 0) { - transmit_len = tcp_reply.write - tcp_reply.buffer; - if (transmit_len > 0) { - /* printf("Sending len = %d\n", transmit_len); */ - uip_send(tcp_reply.buffer, transmit_len); - } - } -} - - -static void -handle_connection() -{ - static char exiting = 0; - static char line_buffer[100]; - static char *line_end; - if (uip_connected()) { - exiting = 0; - transmit_len = 0; - line_end = line_buffer; - tcp_reply.write = tcp_reply.buffer; - reply_str(&tcp_reply, "Ready\n"); - send_reply(); - } - if (uip_acked()) { - if (tcp_reply.write - tcp_reply.buffer > transmit_len) { - memmove(tcp_reply.buffer, tcp_reply.buffer + transmit_len, - tcp_reply.write - tcp_reply.buffer - transmit_len); - } - tcp_reply.write -= transmit_len; - /* printf("Acked: %d left\n", reply_buffer.write-reply_buffer.buffer); */ - transmit_len = 0; - if (exiting && tcp_reply.write == tcp_reply.buffer) { - uip_close(); - exiting = 0; - } - } - if (uip_newdata()) { - const char *read_pos = uip_appdata; - const char *read_end = read_pos + uip_len; - /* printf("Got data\n"); */ - while(read_pos < read_end) { - if (line_end == line_buffer+sizeof(line_buffer)) { - /* Buffer too small, just discard everything */ - line_end = line_buffer; - } - *line_end++ = *read_pos++; - if (line_end[-1] == '\n' || line_end[-1] == '\r' || line_end[-1] == ';'){ - if (line_end - 1 != line_buffer) { - if (handle_line(line_buffer, line_end - 1, &tcp_reply)) { - send_reply(); - /* Postpone closing if there's reply data left to be sent. */ - if (transmit_len == 0) - uip_close(); - else - exiting = 1; - break; - } - } - line_end = line_buffer; - } - } - send_reply(); - } - - if (uip_poll()) { - send_reply(); - } - if(uip_rexmit()) { - printf("Retransmit\n"); - if (transmit_len > 0) - uip_send(tcp_reply.buffer, transmit_len); - } - -} - -PROCESS(udp_stepper_process, "UDP stepper process"); - -PROCESS_THREAD(udp_stepper_process, ev, data) -{ - static struct etimer timer; - static struct uip_udp_conn *conn; - static char listening = 1; /* Listen for connections from anyone */ - static uip_ipaddr_t any; - PROCESS_EXITHANDLER(goto exit); - PROCESS_BEGIN(); - - printf("udp_stepper_process starting\n"); - - uip_ipaddr(&any, 0,0,0,0); - conn = udp_new(&any, UIP_HTONS(0), NULL); - if (!conn) goto exit; - uip_udp_bind(conn, UIP_HTONS(1010)); - etimer_set(&timer, CLOCK_SECOND*2); - while(1) { - PROCESS_YIELD(); - - if(ev == tcpip_event) { - if (uip_newdata()) { - struct uip_udpip_hdr *header = (struct uip_udpip_hdr *)uip_buf; - const char *line_start = uip_appdata; - const char *line_end = line_start; - const char *packet_end = line_start + uip_len; - udp_reply.write = udp_reply.buffer; - while(line_end < packet_end) { - if (*line_end == '\n' || *line_end == '\r' || *line_end == ';' ) { - if (line_end != line_start) { - handle_line(line_start, line_end, &udp_reply); - } - line_start = line_end+1; - } - line_end++; - } - /* Check if we are connected to a client, if not reconnect */ - if (listening) { - uip_udp_remove(conn); - conn = udp_new(&header->srcipaddr, header->srcport, &conn); - if (!conn) goto exit; - uip_udp_bind(conn, UIP_HTONS(1010)); - listening = 0; - } - etimer_reset(&timer); - tcpip_poll_udp(conn); - } else if (uip_poll()) { - if (data == &conn) { - uip_send(udp_reply.buffer, udp_reply.write - udp_reply.buffer); - /* printf("sent %ld\n", udp_reply.write - udp_reply.buffer); */ - } - } - } else if (ev == PROCESS_EVENT_TIMER) { - uip_udp_remove(conn); - conn = udp_new(&any, UIP_HTONS(0), NULL); - if (!conn) goto exit; - uip_udp_bind(conn, UIP_HTONS(1010)); - listening = 1; - } - } - - exit: - /* Contiki does automatic garbage collection of uIP state and we - * need not worry about that. */ - printf("udprecv_process exiting\n"); - PROCESS_END(); -} - -static const uint32_t stepper0_steps_acc[] = MICRO_STEP(0,3); -static const uint32_t stepper0_steps_run[] = MICRO_STEP(0,2); -static const uint32_t stepper0_steps_hold[] = MICRO_STEP(0,1); - -static const uint32_t stepper1_steps_acc[] = MICRO_STEP(1,3); -static const uint32_t stepper1_steps_run[] = MICRO_STEP(1,2); -static const uint32_t stepper1_steps_hold[] = MICRO_STEP(1,1); - -static StepperAccSeq seq_heap[40]; - -static void -init_seq_heap() -{ - unsigned int i; - for(i = 0; i < sizeof(seq_heap)/sizeof(seq_heap[0]); i++) { - seq_heap[i].next = NULL; - stepper_free_seq(&seq_heap[i]); - } -} - -static void -robot_stepper_init() -{ - disableIRQ(); - init_seq_heap(); - stepper_init(AT91C_BASE_TC0, AT91C_ID_TC0); - *AT91C_PIOA_OER = STEPPER_INHIBIT; - *AT91C_PIOA_MDER = STEPPER_INHIBIT; /* | STEPPER0_IOMASK; */ - *AT91C_PIOA_CODR = STEPPER_INHIBIT; - stepper_init_io(1, STEPPER_IOMASK(0), stepper0_steps_acc, - stepper0_steps_run, stepper0_steps_hold, - (sizeof(stepper0_steps_run) / sizeof(stepper0_steps_run[0]))); - stepper_init_io(0, STEPPER_IOMASK(1), stepper1_steps_acc, - stepper1_steps_run, stepper1_steps_hold, - (sizeof(stepper1_steps_run) / sizeof(stepper1_steps_run[0]))); - enableIRQ(); -} - - -PROCESS(stepper_process, "Stepper control process"); - -PROCESS_THREAD(stepper_process, ev, data) -{ - PROCESS_EXITHANDLER(goto exit); - PROCESS_BEGIN(); - robot_stepper_init(); - tcp_listen(UIP_HTONS(1010)); - - process_start(&udp_stepper_process, NULL); - printf("Stepper starting\n"); - - while(1) { - PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event); - if(uip_connected()) { - /* printf("connected\n"); */ - handle_connection(); /* Initialise parser */ - while(!(uip_aborted() || uip_closed() || uip_timedout())) { - PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event); - handle_connection(); - } - } - printf("disconnected\n"); - } - - exit: - /* Contiki does automatic garbage collection of uIP state and we - * need not worry about that. */ - printf("Stepper exiting\n"); - PROCESS_END(); -} - diff --git a/platform/stepper-robot/stepper-process.h b/platform/stepper-robot/stepper-process.h deleted file mode 100644 index fc396749a..000000000 --- a/platform/stepper-robot/stepper-process.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef __STEPPER_PROCESS_H__1OAHVG2XPP__ -#define __STEPPER_PROCESS_H__1OAHVG2XPP__ -#include - -PROCESS_NAME(stepper_process); - -#endif /* __STEPPER_PROCESS_H__1OAHVG2XPP__ */ diff --git a/platform/stepper-robot/stepper/stepper-interrupt.c b/platform/stepper-robot/stepper/stepper-interrupt.c deleted file mode 100644 index b89d8fabf..000000000 --- a/platform/stepper-robot/stepper/stepper-interrupt.c +++ /dev/null @@ -1,296 +0,0 @@ -#include -#include -#include -#include - - - -StepperContext stepper_context; - - -static void -do_step(StepperTimerStep *step) -{ - const uint32_t *io_steps; - StepperState *state = step->state; - - - if (step->power >= STEPPER_POWER_ACC) { - io_steps = state->acc_steps; - } else if (step->power >= STEPPER_POWER_RUN) { - io_steps = state->run_steps; - } else { - io_steps = state->hold_steps; - } - if (io_steps) { - if (step->direction == STEPPER_DIRECTION_FORWARD){ - state->step_count++; - /* dbg_putchar('+'); */ - if (++state->current_step == state->sequence_length) - state->current_step = 0; - } else { - state->step_count--; - /* dbg_putchar('-'); */ - if (state->current_step-- == 0) - state->current_step = state->sequence_length-1; - } - *AT91C_PIOA_ODSR = (*AT91C_PIOA_ODSR & ~state->io_mask) - | (io_steps[state->current_step] & state->io_mask); -#ifdef TIMING_ERRORS - { - long err = ((long)stepper_context.timer_channel->TC_CV - (long)step->time); - if (err >= (TIMER_FREQ/PPS/2)) { - err -= TIMER_FREQ/PPS; - } else if (err < -(TIMER_FREQ/PPS/2)) { - err += TIMER_FREQ/PPS; - } - if (err < state->err_min) state->err_min = err; - if (err > state->err_max) state->err_max = err; - } -#endif - } -} - -static void -set_hold(StepperState *state) { - *AT91C_PIOA_ODSR = (*AT91C_PIOA_ODSR & ~state->io_mask) - | (state->hold_steps[state->current_step] & state->io_mask); -} -static void -advance_step() -{ - StepperTimerStep *current =stepper_context.current_step; - AT91PS_TC timer = stepper_context.timer_channel; - unsigned int now = timer->TC_CV; - while (current && current->time <= now) { - do_step(current); - current = current->next; - if (!current) break; - timer->TC_RA = current->time; - now = timer->TC_CV; - } - stepper_context.current_step = current; -} - - -static inline int64_t -mulsu48_16(int64_t a, uint32_t b) -{ - return a*(int64_t)b; -} - -/* Find a solution for s = a*t*t +v * t in the interval [t_low, t_high[ */ -static unsigned long -solve_dist(long long s, long a, long long v, unsigned long t_low, unsigned long t_high) -{ - long long s_low = mulsu48_16((a*(long)t_low+ v), t_low); - long long s_high = mulsu48_16((a*(long)t_high + v), t_high); - if (s >= s_low && s <= s_high) { - while(t_low + 2 < t_high) { - unsigned long t = (t_high + t_low) / 2; - long long s_mid = mulsu48_16((a*(long)t + v), t); - if (s < s_mid) { - t_high = t; - s_high = s_mid; - } else { - t_low = t; - s_low = s_mid; - } - } - } else { - while(t_low + 1 < t_high) { - unsigned long t = (t_high + t_low) / 2; - long long s_mid = mulsu48_16((a*(long)t + v), t); - if (s > s_mid) { - t_high = t; - s_high = s_mid; - } else { - t_low = t; - s_low = s_mid; - } - } - } - return (t_high + t_low) / 2; -} - - -#define HEAP_SIZE 65 -static StepperTimerStep step_heap[2][HEAP_SIZE]; -static unsigned short heap_pos = 0; /* Next free position in heap */ -static unsigned char current_heap = 0; - -static StepperTimerStep * -allocate_step() -{ - if (heap_pos >= HEAP_SIZE) return NULL; - return &step_heap[current_heap][heap_pos++]; -} - -static void -switch_step_heap() -{ - current_heap ^= 1; - heap_pos = 0; -} - -StepperTimerStep ** -insert_step(StepperTimerStep **at, StepperState *state, - unsigned int time, uint8_t direction, uint8_t power) -{ - StepperTimerStep *new_step; - while(*at && (*at)->time <= time) { - at = &(*at)->next; - } - new_step = allocate_step(); - if (!new_step) return at; - new_step->next = *at; - new_step->state = state; - new_step->time = time; - new_step->direction = direction; - new_step->power = power; - *at = new_step; - /* dbg_putchar('!'); */ - return &new_step->next; -} - -/* Determine suitable power for the current state */ -static uint8_t -get_power(StepperState *state) -{ - if (state->acceleration != 0) return STEPPER_POWER_ACC; - if (state->velocity == 0) return STEPPER_POWER_HOLD; - return STEPPER_POWER_RUN; -} - -#define SQ(x) ((x)*(x)) -#define S_SCALING ((2LL*SQ((long long)TIMER_FREQ)) / DIST_SCALE ) -#define V_SCALING (2LL*TIMER_FREQ/VEL_SCALE) - - -static void -step_interval(StepperState *state) -{ - unsigned int i; - long long v = state->velocity * V_SCALING; - long long a = state->acceleration; - unsigned long t = 0; - StepperTimerStep **at = &stepper_context.steps; - if (state->n_steps >= 0) { - long long s = -state->step_frac * S_SCALING; - for (i = 0; i < state->n_steps; i++) { - s+= DIST_SCALE * S_SCALING; - t = solve_dist(s, a, v, t, TIMER_FREQ/PPS); - /* printf("F%ld\n", t); */ - at = insert_step(at, state, t, STEPPER_DIRECTION_FORWARD, get_power(state)); - } - } else { - long long s = (DIST_SCALE - state->step_frac) * S_SCALING; - for (i = 0; i < -state->n_steps; i++) { - s-= DIST_SCALE * S_SCALING; - t = solve_dist(s, a, v, t, TIMER_FREQ/PPS); - /* printf("B%ld\n", t); */ - at = insert_step(at, state, t, STEPPER_DIRECTION_BACKWARD, get_power(state)); - } - } -} -static void -setup_speed(StepperState *state) -{ - long steps; - long step_frac; - /* printf("%ld v= %ld s=%ld\n",stepper_context.period_count, */ -/* state->velocity, state->step_frac); */ - step_frac = (state->acceleration + 2 * state->velocity - + state->step_frac); - steps = step_frac / DIST_SCALE; - step_frac -= steps * DIST_SCALE; - if (step_frac <0) { - step_frac += DIST_SCALE; - steps--; - } - - /* printf("step_frac=%ld (%f) steps=%ld\n",step_frac, */ -/* (double)step_frac/(double)(DIST_SCALE), steps); */ - state->n_steps = steps; - step_interval(state); - state->velocity += state->acceleration; - state->step_frac = step_frac; - state->step_full += steps; -} - -static void -advance_period() -{ - unsigned int s; - StepperTimerStep *current =stepper_context.current_step; - /* Do any remaining step */ - while (current) { - do_step(current); - current = current->next; - } - /* Start from the beginning */ - stepper_context.current_step = stepper_context.steps; - stepper_context.steps = NULL; - if (stepper_context.current_step) { - stepper_context.timer_channel->TC_RA = stepper_context.current_step->time; - } else { - stepper_context.timer_channel->TC_RA = 0xffff; - } - /* In case there is a step very early in the period */ - advance_step(); - stepper_context.period_count++; - *AT91C_AIC_EOICR = 0; - for(s = 0; s < NUM_STEPPERS; s++) { - StepperState *state = &stepper_context.steppers[s]; - StepperAccSeq *acc_seq; - if (state->acceleration == 0 && state->velocity == 0) { - /* Set hold power if stationary */ - stepper_context.timer_channel->TC_IDR = AT91C_TC_CPCS | AT91C_TC_CPAS; - set_hold(state); - stepper_context.timer_channel->TC_IER = AT91C_TC_CPCS | AT91C_TC_CPAS; - } - while ((acc_seq = state->acceleration_sequence) - && acc_seq->period == stepper_context.period_count + 1) { - state->acceleration_sequence = acc_seq->next; - if (acc_seq->acceleration == STEPPER_ACC_INVALID) { - if (stepper_context.user_callback) { - stepper_context.user_callback(s, stepper_context.period_count); - } - } else { - state->acceleration = acc_seq->acceleration; - } - acc_seq->next = NULL; /* Only free this one */ - stepper_free_seq(acc_seq); - } - setup_speed(&stepper_context.steppers[s]); - } - /* Prepare heap for next period */ - switch_step_heap(); -} - -/* Here we have a proper stack frame and can use local variables */ -static void stepper_int_safe() __attribute((noinline)); -static void -stepper_int_safe() -{ - unsigned int status; - status = stepper_context.timer_channel->TC_SR; - if (status & AT91C_TC_CPAS) { - advance_step(); - /* dbg_putchar('*'); */ - } - if (status & AT91C_TC_CPCS) { - advance_period(); - } else { - *AT91C_AIC_EOICR = 0; /* End of Interrupt */ - } - -} - -void NACKEDFUNC stepper_timer_interrupt (void) { - ISR_STORE(); - ISR_ENABLE_NEST(); - stepper_int_safe(); - ISR_DISABLE_NEST(); - ISR_RESTORE(); -} diff --git a/platform/stepper-robot/stepper/stepper-interrupt.h b/platform/stepper-robot/stepper/stepper-interrupt.h deleted file mode 100644 index 1356004d7..000000000 --- a/platform/stepper-robot/stepper/stepper-interrupt.h +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef __STEPPER3_INTERRUPT_H__2MHD6D6PQ1__ -#define __STEPPER3_INTERRUPT_H__2MHD6D6PQ1__ - -#include - -/* Timer frequency */ -#define TIMER_FREQ 748800 - -typedef struct _StepperContext StepperContext; -typedef struct _StepperState StepperState; -typedef struct _StepperTimerStep StepperTimerStep; - -#define MAX_STEPS_PER_PERIOD 40 -#define NUM_STEPPERS 2 - -#define STEPPER_MAX_VELOCITY 4000 -#define STEPPER_MAX_ACCELRATION 4000 - - -#define TIMING_ERRORS - -struct _StepperState -{ - long step_count; - uint32_t io_mask; - const uint32_t *acc_steps; /* Stepping sequence when accelerating */ - const uint32_t *run_steps; /* Stepping sequence when running */ - const uint32_t *hold_steps; /* Stepping sequence when stationary */ - uint8_t current_step; /* in stepping sequence */ - uint8_t sequence_length; - - long velocity; /* steps/second * PPS */ - long acceleration; /* steps/second^2 */ - long step_full; /* steps, same as step_count at period boundaries */ - long step_frac; /* (steps * PPS^2 * 2) % steps * PPS^2 */ - - long n_steps; /* full steps to move during this period */ - - StepperAccSeq *acceleration_sequence; - -#ifdef TIMING_ERRORS - long err_max; - long err_min; -#endif -}; - -#define STEPPER_POWER_ACC 30 -#define STEPPER_POWER_RUN 20 -#define STEPPER_POWER_HOLD 10 -#define STEPPER_POWER_OFF 0 - -#define STEPPER_DIRECTION_NONE 0 -#define STEPPER_DIRECTION_FORWARD 1 -#define STEPPER_DIRECTION_BACKWARD 2 - -struct _StepperTimerStep -{ - StepperTimerStep *next; - StepperState *state; - uint16_t time; - uint8_t direction; - uint8_t power; -}; - - -struct _StepperContext -{ - unsigned int flags; - unsigned long period_count; - AT91PS_TC timer_channel; - StepperState steppers[NUM_STEPPERS]; - StepperTimerStep *steps; - StepperTimerStep *current_step; - StepperUserCallback user_callback; -}; - -extern StepperContext stepper_context; -#endif /* __STEPPER3_INTERRUPT_H__2MHD6D6PQ1__ */ - -void stepper_timer_interrupt(void); diff --git a/platform/stepper-robot/stepper/stepper-move.c b/platform/stepper-robot/stepper/stepper-move.c deleted file mode 100644 index 8fe6df631..000000000 --- a/platform/stepper-robot/stepper/stepper-move.c +++ /dev/null @@ -1,193 +0,0 @@ -#include -#include -#include -#include - -#if 0 -#define PRINTF(...) printf(__VA_ARGS__) -#else -#define PRINTF(...) do {} while (0) -#endif - -static unsigned int -isqrt(unsigned long x) -{ - unsigned int r; - unsigned int b2 = 0x40000000; - unsigned int b = 0x8000; - while(x < b2) { - b2 >>= 2; - b >>= 1; - } - if (b == 0) return 0; - r = b; - b >>= 1; - while(b > 0) { - r += b; - unsigned int t = r*r; - if (t > x) { - r -= b; - } - b >>=1; - } - return r; -} - -#define ACC_FIRST_UP 0 -#define ACC_K1_UP 1 -#define ACC_LAST_UP 2 -#define ACC_TOP 3 -#define ACC_FIRST_DOWN 4 -#define ACC_K1_DOWN 5 -#define ACC_LAST_DOWN 6 -#define ACC_END 7 - -typedef struct _AccDiff AccDiff; -struct _AccDiff -{ - long diff; - unsigned long pos; -}; - - -static inline long -base_acc(unsigned long t,unsigned long n, unsigned long l, unsigned long a_max) -{ - long a; - if (t >= n) { - if (t >= n+l) { - a = -a_max; - } else { - a = 0; - } - } else { - a = a_max; - } - return a; -} - -static AccDiff acc[ACC_END+1]; -StepperResult -stepper_move(unsigned int stepper_index, unsigned long *periodp, - unsigned long a_max,unsigned long v_max, long s_end) -{ - unsigned long start_period = *periodp; - unsigned long s; - unsigned long ds; - unsigned long l; - unsigned long da0; - unsigned long k1 = 0; - unsigned long n = (v_max+a_max-1)/a_max; - unsigned long a_speed_adj = v_max - (n-1)*a_max; - unsigned long s_res; - long d; - if (s_end >= 0) { - s_res = s_end/2; - } else { - s_res = (-s_end)/2; - } - d = s_res - (long)a_max*(n*n-1) - (long)a_speed_adj; - - acc[ACC_END].diff = 0; - acc[ACC_END].pos = UINT_MAX; - if (d < 0) { - l = 0; - n = isqrt(s_res/a_max); - if (n*(unsigned long long)n*a_max < s_res) n++; - a_speed_adj = a_max; - acc[ACC_LAST_UP].diff=0; - acc[ACC_FIRST_DOWN].diff=0; - } else { - l = (d+v_max-1)/v_max; - acc[ACC_LAST_UP].diff= a_speed_adj - a_max; - acc[ACC_FIRST_DOWN].diff= a_max - a_speed_adj; - } - acc[ACC_LAST_UP].pos = n-1; - acc[ACC_FIRST_DOWN].pos = n+l; - - s = a_max*(n*n-1) + a_speed_adj + l * (a_max*(n-1) + a_speed_adj); - ds = s-s_res; - - da0 = ds/(2*n+l-1); - acc[ACC_FIRST_UP].diff = -da0; - acc[ACC_LAST_DOWN].diff = da0; - acc[ACC_FIRST_UP].pos = 0; - acc[ACC_LAST_DOWN].pos = 2*n+l-1; - ds -= da0*(2*n+l-1); - - acc[ACC_K1_UP].diff = 0; - acc[ACC_K1_DOWN].diff = 0; - acc[ACC_K1_UP].pos = 0; - acc[ACC_K1_DOWN].pos = 2*n+l-1; - - acc[ACC_TOP].diff = 0; - acc[ACC_TOP].pos = n; - - if (ds > 0) { - k1 = (2*n+l -ds)/2; - if (k1 < n) { - - acc[ACC_K1_UP].diff = -1; - acc[ACC_K1_DOWN].diff = 1; - acc[ACC_K1_UP].pos = k1; - acc[ACC_K1_DOWN].pos = 2*n+l-1 - k1; - ds -= (2*(n-k1)+l-1); - } - if (ds > 0) { - acc[ACC_LAST_UP].diff--; - acc[ACC_TOP].diff = 1; - acc[ACC_TOP].pos = n+ds-1; - } - } -#if 0 - { - unsigned int k; - PRINTF("n=%ld l=%ld a_max=%ld v_max=%ld s_res=%ld\n", - n,l ,a_max, v_max, s_res); - for (k = 0; k < 7; k++) { - PRINTF(" %ld@%ld", acc[k].diff, acc[k].pos); - } - PRINTF("\n"); - } -#endif - { - StepperResult res; - unsigned int k; - unsigned long t = 0; - long da = 0; - long a_prev = ULONG_MAX; - for (k = 0; k < ACC_END; k++) { - long a; - da += acc[k].diff; - if (acc[k].pos != acc[k+1].pos) { /* Next position is different */ - if (t != acc[k].pos) { - a = base_acc(t,n,l,a_max); - if (s_end < 0) a = -a; - if (a_prev != a) { - res = stepper_add_acc(stepper_index, t+start_period, a); - if (res != STEPPER_OK) return res; - PRINTF("%d: %ld@%ld\n", stepper_index, a, t+start_period); - a_prev = a; - } - t = acc[k].pos; - } - a = da + base_acc(t,n,l,a_max); - if (s_end < 0) a = -a; - if (a_prev != a) { - res = stepper_add_acc(stepper_index, t+start_period, a); - if (res != STEPPER_OK) return res; - PRINTF("%d: %ld@%ld\n", stepper_index, a, t+start_period); - a_prev = a; - } - t++; - da = 0; - } - } - res = stepper_add_acc(stepper_index, t+start_period, 0); - PRINTF("%d: %d@%ld\n", stepper_index, 0, t+start_period); - if (res != STEPPER_OK) return res; - *periodp += t; - } - return STEPPER_OK; -} - diff --git a/platform/stepper-robot/stepper/stepper-move.h b/platform/stepper-robot/stepper/stepper-move.h deleted file mode 100644 index 5bea1cd3f..000000000 --- a/platform/stepper-robot/stepper/stepper-move.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __STEPPER_MOVE_H__9UFUHMYMYS__ -#define __STEPPER_MOVE_H__9UFUHMYMYS__ - -StepperResult -stepper_move(unsigned int stepper_index, unsigned long *periodp, - unsigned long a_max,unsigned long v_max, long s_end); - -#endif /* __STEPPER_MOVE_H__9UFUHMYMYS__ */ diff --git a/platform/stepper-robot/stepper/stepper-steps.h b/platform/stepper-robot/stepper/stepper-steps.h deleted file mode 100644 index 35f778454..000000000 --- a/platform/stepper-robot/stepper/stepper-steps.h +++ /dev/null @@ -1,103 +0,0 @@ -#include - -#ifndef MAX -#define MIN(a,b) (((a) > (b)) ? (b) : (a)) -#endif - -/* Pins for stepper 0 */ -#define STEPPER0_I00 AT91C_PIO_PA17 -#define STEPPER0_I01 AT91C_PIO_PA18 -#define STEPPER0_PHASE0 AT91C_PIO_PA19 - -#define STEPPER0_I10 AT91C_PIO_PA21 -#define STEPPER0_I11 AT91C_PIO_PA22 -#define STEPPER0_PHASE1 AT91C_PIO_PA23 - -/* Pins for stepper 1 */ -#define STEPPER1_I00 AT91C_PIO_PA24 -#define STEPPER1_I01 AT91C_PIO_PA25 -#define STEPPER1_PHASE0 AT91C_PIO_PA26 - -#define STEPPER1_I10 AT91C_PIO_PA27 -#define STEPPER1_I11 AT91C_PIO_PA28 -#define STEPPER1_PHASE1 AT91C_PIO_PA29 - -/* Common pins */ -#define STEPPER_INHIBIT AT91C_PIO_PA7 - - -#define STEPPER_IOMASK(s) (STEPPER##s##_I00 | STEPPER##s##_I01 | STEPPER##s##_PHASE0 \ - | STEPPER##s##_I10 | STEPPER##s##_I11 | STEPPER##s##_PHASE1) -#define STEPPER_PHASE(s,p,l) ((((l) < 2) ? (STEPPER##s##_I##p##1) : 0) | (((l) & 1) ? 0 : (STEPPER##s##_I##p##0))) - -#define STEPPER_STEP(s, l0, l1) (\ -((l0 >= 0) ? STEPPER_PHASE(s,0, l0):(STEPPER_PHASE(s,0, -(l0))|STEPPER##s##_PHASE0)) | \ -((l1 >= 0) ? STEPPER_PHASE(s,1, l1):(STEPPER_PHASE(s,1,-(l1))|STEPPER##s##_PHASE1))) - - -#define FULL_STEP_BOTH(s,l) {\ - STEPPER_STEP(s,(l),(l)), \ - STEPPER_STEP(s,(l),-(l)), \ - STEPPER_STEP(s,-(l),-(l)), \ - STEPPER_STEP(s,-(l),(l))} - - -#define FULL_STEP_SINGLE(s,l) {\ - STEPPER_STEP(s,0,(l)), \ - STEPPER_STEP(s,(l),0), \ - STEPPER_STEP(s,0,-(l)), \ - STEPPER_STEP(s,-(l),0)} - -#define HALF_STEP(s,l) {\ - STEPPER_STEP(s,0,(l)), \ - STEPPER_STEP(s,(l),(l)), \ - STEPPER_STEP(s,(l),0), \ - STEPPER_STEP(s,(l),-(l)), \ - STEPPER_STEP(s,0,-(l)), \ - STEPPER_STEP(s,-(l),-(l)), \ - STEPPER_STEP(s,-(l),0), \ - STEPPER_STEP(s,-(l),(l))} - - -#define MINI_STEP(s,l) {\ - STEPPER_STEP(s,0,(l)), \ - STEPPER_STEP(s,1,MIN((l),2)), \ - STEPPER_STEP(s,MIN((l),2),1), \ - STEPPER_STEP(s,(l),0), \ - STEPPER_STEP(s,MIN((l),2),-1), \ - STEPPER_STEP(s,1,-MIN((l),2)), \ - STEPPER_STEP(s,0,-(l)), \ - STEPPER_STEP(s,-1,-MIN((l),2)), \ - STEPPER_STEP(s,-MIN((l),2),-1), \ - STEPPER_STEP(s,-(l),0), \ - STEPPER_STEP(s,-MIN((l),2),1), \ - STEPPER_STEP(s,-1,MIN((l),2))} - -#define MICRO_STEP(s,l) {\ - STEPPER_STEP(s,0,(l)), \ - STEPPER_STEP(s,1,(l)), \ - STEPPER_STEP(s,MIN((l),2),(l)), \ - STEPPER_STEP(s,(l),(l)), \ - STEPPER_STEP(s,(l),MIN((l),2)), \ - STEPPER_STEP(s,(l),1), \ - STEPPER_STEP(s,(l),0), \ - STEPPER_STEP(s,(l),-1), \ - STEPPER_STEP(s,(l),-MIN((l),2)), \ - STEPPER_STEP(s,(l),-(l)), \ - STEPPER_STEP(s,MIN((l),2),-(l)), \ - STEPPER_STEP(s,1,-(l)), \ - STEPPER_STEP(s,0,-(l)), \ - STEPPER_STEP(s,-1,-(l)), \ - STEPPER_STEP(s,-MIN((l),2),-(l)), \ - STEPPER_STEP(s,-(l),-(l)), \ - STEPPER_STEP(s,-(l),-MIN((l),2)), \ - STEPPER_STEP(s,-(l),-1), \ - STEPPER_STEP(s,-(l),0), \ - STEPPER_STEP(s,-(l),1), \ - STEPPER_STEP(s,-(l),MIN((l),2)), \ - STEPPER_STEP(s,-(l),(l)), \ - STEPPER_STEP(s,-MIN((l),2),(l)), \ - STEPPER_STEP(s,-1,(l))} - -#define STEPPER_ENABLE() (*AT91C_PIOA_SODR = STEPPER_INHIBIT) -#define STEPPER_DISABLE() (*AT91C_PIOA_CODR = STEPPER_INHIBIT) diff --git a/platform/stepper-robot/stepper/stepper.c b/platform/stepper-robot/stepper/stepper.c deleted file mode 100644 index 9f6f3c00d..000000000 --- a/platform/stepper-robot/stepper/stepper.c +++ /dev/null @@ -1,360 +0,0 @@ -#include -#include - -#ifndef NUL -#define NULL 0 -#endif - -static StepperAccSeq *free_seq = NULL; - -StepperAccSeq * -stepper_allocate_seq() -{ - StepperAccSeq *seq; - if (!free_seq) return NULL; - stepper_context.timer_channel->TC_IDR = AT91C_TC_CPCS | AT91C_TC_CPAS; - seq = free_seq; - free_seq = seq->next; - stepper_context.timer_channel->TC_IER = AT91C_TC_CPCS | AT91C_TC_CPAS; - return seq; -} - - -void -stepper_free_seq(StepperAccSeq *seq) -{ - StepperAccSeq *s; - if (!seq) return; - s = seq; - stepper_context.timer_channel->TC_IDR = AT91C_TC_CPCS | AT91C_TC_CPAS; - while(s->next) s = s->next; - s->next = free_seq; - free_seq = seq; - stepper_context.timer_channel->TC_IER = AT91C_TC_CPCS | AT91C_TC_CPAS; -} - -static void -stepper_state_init(StepperState *stepper) -{ - stepper->step_count = 0; - stepper->io_mask = 0; - stepper->acc_steps = NULL; - stepper->run_steps = NULL; - stepper->hold_steps = NULL; - stepper->current_step = 0; - stepper->sequence_length = 0; - - stepper->velocity = 0; - stepper->acceleration = 0; - stepper->step_full = 0; - stepper->step_frac = 0; - stepper->n_steps = 0; - -#ifdef TIMING_ERRORS - stepper->err_min = TIMER_FREQ; - stepper->err_max = -TIMER_FREQ; -#endif - -} - -void -stepper_init(AT91PS_TC timer, unsigned int id) -{ - unsigned int s; - stepper_context.flags = 0; - stepper_context.timer_channel = timer; - stepper_context.steps = NULL; - stepper_context.current_step = NULL; - stepper_context.period_count = 0; - stepper_context.user_callback = NULL; - - for (s = 0; s < NUM_STEPPERS; s++) { - stepper_state_init(&stepper_context.steppers[s]); - } - timer->TC_CMR = (AT91C_TC_WAVE | AT91C_TC_WAVESEL_UP_AUTO - | AT91C_TC_CLKS_TIMER_DIV3_CLOCK); - timer->TC_RC = TIMER_FREQ / PPS; - timer->TC_RA = 0xffff; - timer->TC_IER = AT91C_TC_CPCS | AT91C_TC_CPAS; - *AT91C_PMC_PCER = (1 << id); - - AT91C_AIC_SMR[id] = AT91C_AIC_SRCTYPE_INT_POSITIVE_EDGE | 7; - AT91C_AIC_SVR[id] = (unsigned long)stepper_timer_interrupt; - *AT91C_AIC_IECR = (1 << id); - timer->TC_CCR = AT91C_TC_CLKEN | AT91C_TC_SWTRG; -} - -void -stepper_init_io(unsigned int stepper_index, uint32_t mask, - const uint32_t *acc, const uint32_t *run, - const uint32_t *hold, unsigned int nsteps) -{ - StepperState *state; - if (stepper_index >= NUM_STEPPERS) return; - state = &stepper_context.steppers[stepper_index]; - - stepper_context.timer_channel->TC_IDR = AT91C_TC_CPCS | AT91C_TC_CPAS; - - state->io_mask = mask; - state->acc_steps = acc; - state->run_steps = run; - state->hold_steps = hold; - state->current_step = 0; - state->sequence_length = nsteps; - *AT91C_PIOA_OWER = mask; - *AT91C_PIOA_MDDR = mask; - - *AT91C_PIOA_ODSR = ((*AT91C_PIOA_ODSR & ~mask) - | (state->hold_steps[0] & mask)); - stepper_context.timer_channel->TC_IER = AT91C_TC_CPCS | AT91C_TC_CPAS; - *AT91C_PIOA_OER = mask; -} - -/** - Append an acceleration sequence - - Truncates the current acceleration sequence at the insertion time - and appends the new sequence at that position.. The insertion time - is the time of the first element of the new sequence. The - truncation takes place after any elements with the acceleration set - to STEPPER_ACC_INVALID (user callbacks) that has the same time as - the insertion time. All other elements with the same time is - replaced. - - \param stepper_index Index of the stepper the sequence is intended for. - \param new_seq A linked list of sequence elements to append. - */ -StepperResult -stepper_add_acc_seq(unsigned int stepper_index, StepperAccSeq *new_seq) -{ - StepperResult res = STEPPER_ERR_TOO_LATE; - StepperAccSeq **seqp; - StepperState *state; - if (stepper_index >= NUM_STEPPERS) return STEPPER_ERR_INDEX; - state = &stepper_context.steppers[stepper_index]; - stepper_context.timer_channel->TC_IDR = AT91C_TC_CPCS | AT91C_TC_CPAS; - seqp = &state->acceleration_sequence; - while(*seqp && ((*seqp)->period < new_seq->period || ((*seqp)->period == new_seq->period && (*seqp)->acceleration == STEPPER_ACC_INVALID))) { - seqp = &(*seqp)->next; - } - if (new_seq->period > stepper_context.period_count + 1) { - /* Replace tail of sequence */ - if (*seqp) stepper_free_seq(*seqp); - *seqp = new_seq; - res = STEPPER_OK; - } - stepper_context.timer_channel->TC_IER = AT91C_TC_CPCS | AT91C_TC_CPAS; - return res; -} - -/** - Insert a callback mark - - Inserts a callback mark at the indicated period. This will cause - the callback procedure to be called just before that period, - usually near the beginning of the previous period. Does not - truncate the current sequence. - - \param stepper_index Index of the stepper the callbak is intended for. - \param period When the callback should be invoked - - \sa stepper_set_callback_proc -*/ - -StepperResult -stepper_insert_callback(unsigned int stepper_index, unsigned int period) -{ - StepperResult res = STEPPER_ERR_TOO_LATE; - StepperAccSeq **seqp; - StepperState *state; - if (stepper_index >= NUM_STEPPERS) return STEPPER_ERR_INDEX; - state = &stepper_context.steppers[stepper_index]; - stepper_context.timer_channel->TC_IDR = AT91C_TC_CPCS | AT91C_TC_CPAS; - seqp = &state->acceleration_sequence; - while(*seqp && (*seqp)->period < period) { - seqp = &(*seqp)->next; - } - if (period > stepper_context.period_count + 1) { - StepperAccSeq *new_seq = stepper_allocate_seq(); - if (!new_seq) { - res = STEPPER_ERR_MEM; - } else { - new_seq->next = *seqp; - *seqp = new_seq; - new_seq->period = period; - new_seq->acceleration = STEPPER_ACC_INVALID; - res = STEPPER_OK; - } - } - stepper_context.timer_channel->TC_IER = AT91C_TC_CPCS | AT91C_TC_CPAS; - return res; -} - -StepperResult -stepper_add_acc(unsigned int stepper_index, unsigned int period, long acc) -{ - StepperAccSeq *seq = stepper_allocate_seq(); - /* printf("stepper_add_acc: %d %d %ld\n", stepper_index, period, acc); */ - if (!seq) return STEPPER_ERR_MEM; - seq->next = NULL; - seq->period = period; - seq->acceleration = acc; - return stepper_add_acc_seq(stepper_index, seq); -} - -void -stepper_set_callback_proc(StepperUserCallback callback) -{ - stepper_context.user_callback = callback; -} - -unsigned long -stepper_current_period() -{ - return stepper_context.period_count; -} - -long -stepper_current_step(unsigned int stepper_index) -{ - StepperState *state = &stepper_context.steppers[stepper_index]; - return state->step_count; -} - -long long -stepper_step_frac(unsigned int stepper_index) -{ - long long s; - StepperState *state = &stepper_context.steppers[stepper_index]; - stepper_context.timer_channel->TC_IDR = AT91C_TC_CPCS | AT91C_TC_CPAS; - s = state->step_full * DIST_SCALE + state->step_frac; - stepper_context.timer_channel->TC_IER = AT91C_TC_CPCS | AT91C_TC_CPAS; - return s; -} - -long -stepper_current_velocity(unsigned int stepper_index) -{ - StepperState *state = &stepper_context.steppers[stepper_index]; - return state->velocity; -} - -/* Calculate the speed at given current given the current acceleration - sequence. */ -unsigned long -stepper_velocity(unsigned int stepper_index, unsigned long period) -{ - long a; - long v; - unsigned long t; - StepperState *state; - StepperAccSeq *seq; - state = &stepper_context.steppers[stepper_index]; - - stepper_context.timer_channel->TC_IDR = AT91C_TC_CPCS | AT91C_TC_CPAS; - seq = state->acceleration_sequence; - a = state->acceleration; - v = state->velocity; - t = stepper_context.period_count + 2; - - while(seq && seq->period < period) { - v += a * (seq->period - t); - t = seq->period; - a = seq->acceleration; - seq = seq->next; - } - stepper_context.timer_channel->TC_IER = AT91C_TC_CPCS | AT91C_TC_CPAS; - v += a * (period - t); - return v; -} - -/** - Calculate the speed and position at specified period given the - current acceleration sequence. - - \param stepper_index Index of the stepper the callbak is intended for. - \param period The period to calculate for - \param Speed return - \param Position return. In fractional steps - -*/ -StepperResult -stepper_state_at(unsigned int stepper_index, unsigned long period, - long *velocity, long long *position) -{ - long a; - long v; - long long s; - unsigned long t; - long dt; - StepperState *state; - StepperAccSeq *seq; - state = &stepper_context.steppers[stepper_index]; - - stepper_context.timer_channel->TC_IDR = AT91C_TC_CPCS | AT91C_TC_CPAS; - if (period < stepper_context.period_count + 2) { - stepper_context.timer_channel->TC_IER = AT91C_TC_CPCS | AT91C_TC_CPAS; - return STEPPER_ERR_TOO_LATE; - } - seq = state->acceleration_sequence; - a = state->acceleration; - v = state->velocity; - t = stepper_context.period_count + 2; - s = state->step_full * (long long)DIST_SCALE + state->step_frac; - while(seq && seq->period < period) { - dt = seq->period - t; - s += (a * (long long)dt + 2 * v) * dt; - v += a * (seq->period - t); - t = seq->period; - a = seq->acceleration; - seq = seq->next; - } - stepper_context.timer_channel->TC_IER = AT91C_TC_CPCS | AT91C_TC_CPAS; - dt = period - t; - *position = s + (a * (long long)dt + (DIST_SCALE/VEL_SCALE) * v) * dt; - *velocity = v + a * dt; - - return STEPPER_OK; -} - - -StepperResult -stepper_set_velocity(unsigned int stepper_index, unsigned long *periodp, - unsigned long max_acc, long final_speed) -{ - long start_period = *periodp; - long v = stepper_velocity(stepper_index, start_period); - /* printf("%ld @ %ld\n", v, start_period); */ - if (final_speed == v) { - return stepper_add_acc(stepper_index, start_period, 0); - } else { - StepperResult res; - long a = (final_speed > v) ? max_acc : -max_acc; - long t = ((long)(final_speed - v)) / a; - long diff = (final_speed - v) - t * a; - if (t > 0) { - res = stepper_add_acc(stepper_index, start_period, a); - if (res != STEPPER_OK) return res; - } - if (diff) { - res = stepper_add_acc(stepper_index, start_period+t, diff); - if (res != STEPPER_OK) return res; - t++; - } - *periodp = start_period+t; - return stepper_add_acc(stepper_index, start_period+t, 0); - } -} - -#ifdef TIMING_ERRORS -void -stepper_timing_errors(unsigned int stepper_index, long *min, long *max) -{ - StepperState *state; - state = &stepper_context.steppers[stepper_index]; - *min = state->err_min; - *max = state->err_max; - state->err_max = -TIMER_FREQ; - state->err_min = TIMER_FREQ; -} -#endif diff --git a/platform/stepper-robot/stepper/stepper.h b/platform/stepper-robot/stepper/stepper.h deleted file mode 100644 index 6e067641c..000000000 --- a/platform/stepper-robot/stepper/stepper.h +++ /dev/null @@ -1,98 +0,0 @@ -#ifndef __STEPPER_H__JPA916UOFT__ -#define __STEPPER_H__JPA916UOFT__ - -#include -#include -#include - -/* Define periods/second */ -#define PPS 128 - -/* Scaling factor for distance */ -#define DIST_SCALE (2 * PPS * PPS) - -/* Scaling factor for velocity */ -#define VEL_SCALE PPS - -typedef struct _StepperAccSeq StepperAccSeq; -struct _StepperAccSeq -{ - StepperAccSeq *next; - unsigned long period; - long acceleration; -}; - -#define STEPPER_ACC_INVALID LONG_MAX - -#define STEPPER_MAX_VELOCITY 4000 -#define STEPPER_MAX_ACCELRATION 4000 - -typedef void (*StepperUserCallback)(unsigned int stepper_index, - unsigned long period); - - -typedef unsigned int StepperResult; -#define STEPPER_OK 0 -#define STEPPER_ERR_MEM 1 -#define STEPPER_ERR_TOO_LATE 2 -#define STEPPER_ERR_INDEX 3 - -void -stepper_init(AT91PS_TC timer, unsigned int id); - -void -stepper_init_io(unsigned int stepper_index, uint32_t mask, - const uint32_t *acc, const uint32_t *run, - const uint32_t *hold, unsigned int nsteps); - -/* Returns true if the new sequence was actually added or false - if the index is illegal or the first step in the sequence is too soon */ - -StepperResult -stepper_add_acc_seq(unsigned int stepper_index, StepperAccSeq *new_seq); - -StepperResult -stepper_add_acc(unsigned int stepper_index, unsigned int period, long acc); - -StepperResult -stepper_insert_callback(unsigned int stepper_index, unsigned int period); - -void -stepper_set_callback_proc(StepperUserCallback callback); - -unsigned long -stepper_current_period(); - -long -stepper_current_step(unsigned int stepper_index); - -long long -stepper_step_frac(unsigned int stepper_index); - -long -stepper_current_velocity(unsigned int stepper_index); - -unsigned long -stepper_velocity(unsigned int stepper_index, unsigned long period); - -StepperResult -stepper_state_at(unsigned int stepper_index, unsigned long period, - long *velocity, long long *position); - -StepperResult -stepper_set_velocity(unsigned int stepper_index, unsigned long *periodp, - unsigned long max_acc, long final_speed); - -StepperAccSeq * -stepper_allocate_seq(); - -void -stepper_free_seq(StepperAccSeq *seq); - -#ifdef TIMING_ERRORS - -void -stepper_timing_errors(unsigned int stepper_index, long *min, long *max); -#endif - -#endif /* __STEPPER_H__JPA916UOFT__ */ diff --git a/platform/stepper-robot/sys-tst.c b/platform/stepper-robot/sys-tst.c deleted file mode 100644 index d8b7e6d88..000000000 --- a/platform/stepper-robot/sys-tst.c +++ /dev/null @@ -1,80 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -volatile const char * volatile input_line = NULL; -volatile unsigned int input_line_len = 0; - -static void -recv_input(const char *str, unsigned int len) -{ - /* Assume that the line is handled before any new characters is written - to the buffer */ - input_line = str; - input_line_len = len; -} -PROCESS(blink_process, "LED blink process"); - -PROCESS_THREAD(blink_process, ev , data) -{ - static struct etimer timer; - PROCESS_BEGIN(); - etimer_set(&timer, CLOCK_SECOND/2); - while(1) { - PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_EXIT || - ev== PROCESS_EVENT_TIMER); - if (ev == PROCESS_EVENT_EXIT) break; - leds_invert(LEDS_RED); -#if 0 - { - DISABLE_FIFOP_INT(); - printf("FSMSTATE: %04x",cc2420_getreg(CC2420_FSMSTATE)); - ENABLE_FIFOP_INT(); - if (SFD_IS_1) printf(" SFD"); - if (FIFO_IS_1) printf(" FIFO"); - if (FIFOP_IS_1) printf(" FIFOP"); - putchar('\n'); - } -#endif - etimer_reset(&timer); - } - printf("Ended process\n"); - PROCESS_END(); -} -PROCINIT(&etimer_process, &blink_process); -int -main() -{ - disableIRQ(); - disableFIQ(); - *AT91C_AIC_IDCR = 0xffffffff; - *AT91C_PMC_PCDR = 0xffffffff; - *AT91C_PMC_PCER = (1 << AT91C_ID_PIOA); - - dbg_setup_uart(); - printf("Initialising\n"); - dbg_set_input_handler(recv_input); - leds_arch_init(); - clock_init(); - - process_init(); - printf("Started\n"); - - procinit_init(); - enableIRQ(); - printf("Processes running\n"); - while(1) { - do { - /* Reset watchdog. */ - } while(process_run() > 0); - /* Idle! */ - /* Stop processor clock */ - *AT91C_PMC_SCDR |= AT91C_PMC_PCK; - } - return 0; -} diff --git a/platform/stepper-robot/usb-main.c b/platform/stepper-robot/usb-main.c deleted file mode 100644 index cf10c1f11..000000000 --- a/platform/stepper-robot/usb-main.c +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -unsigned int idle_count = 0; - -int -main() -{ - dbg_setup_uart(); - printf("Initialising\n"); - - clock_init(); - process_init(); - process_start(&etimer_process, NULL); - autostart_start(autostart_processes); - printf("Processes running\n"); - while(1) { - do { - } while(process_run() > 0); - idle_count++; - /* Idle! */ - /* Stop processor clock */ - *AT91C_PMC_SCDR |= AT91C_PMC_PCK; - } - return 0; -} diff --git a/platform/stepper-robot/usb-msc/Makefile b/platform/stepper-robot/usb-msc/Makefile deleted file mode 100644 index 83ad96b17..000000000 --- a/platform/stepper-robot/usb-msc/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -TARGET=stepper-robot - -all: usbmsctst - - -CONTIKI=../../.. - -CONTIKI_TARGET_MAIN=usb-main.c - -PROJECT_SOURCEFILES = - -USB_MASS_STORAGE_CLASS=1 - - -clean: stepper_robot_clean - -.PHONY: stepper_robot_clean - -stepper_robot_clean: - -include $(CONTIKI)/Makefile.include diff --git a/platform/stepper-robot/usb-msc/usbmsctst.c b/platform/stepper-robot/usb-msc/usbmsctst.c deleted file mode 100644 index 1746744ca..000000000 --- a/platform/stepper-robot/usb-msc/usbmsctst.c +++ /dev/null @@ -1,40 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -PROCESS(usb_masstest_process, "USB massstorage test process"); - -#if 0 -extern unsigned int idle_count; -#endif - -PROCESS_THREAD(usb_masstest_process, ev , data) -{ - static unsigned int last_count; - PROCESS_BEGIN(); - static struct etimer timer; - usb_msc_bulk_setup(); - etimer_set(&timer, CLOCK_SECOND); -#if 0 - last_count = idle_count; -#endif - while(1) { - PROCESS_WAIT_EVENT(); - if (ev == PROCESS_EVENT_TIMER) { -#if 0 - printf("Idle count: %d\n", idle_count - last_count); - last_count = idle_count; -#endif - etimer_reset(&timer); - } - } - PROCESS_END(); -} - - -AUTOSTART_PROCESSES(&usb_masstest_process); diff --git a/platform/stk500/Makefile b/platform/stk500/Makefile deleted file mode 100644 index 3e1094a59..000000000 --- a/platform/stk500/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -all: contiki-stk500-main.out -upload: contiki-stk500-main.u - -CONTIKI=../.. -TARGET=stk500 - -include $(CONTIKI)/Makefile.include diff --git a/platform/stk500/Makefile.stk500 b/platform/stk500/Makefile.stk500 deleted file mode 100644 index 3d8fdc645..000000000 --- a/platform/stk500/Makefile.stk500 +++ /dev/null @@ -1,19 +0,0 @@ -CONTIKI_TARGET_DIRS = . dev apps loader -CONTIKI_TARGET_MAIN = contiki-stk500-main.o - -CONTIKI_SOURCEFILES += rs232.c contiki-stk500-main.c - -CONTIKI_NO_NET=1 -CONTIKIAVR=$(CONTIKI)/cpu/avr -CONTIKIBOARD=. - -//MCU=atmega8 -MCU=atmega8515 -//MCU=atmega644 -//MCU=atmega328p -//MCU=atmega16 -//MCU=atmega32 - -CONTIKI_PLAT_DEFS = -DF_CPU=8000000UL -DAUTO_CRC_PADDING=2 - -include $(CONTIKIAVR)/Makefile.avr diff --git a/platform/stk500/contiki-conf.h b/platform/stk500/contiki-conf.h deleted file mode 100644 index 6bb4a00a8..000000000 --- a/platform/stk500/contiki-conf.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef __CONTIKI_CONF_H__ -#define __CONTIKI_CONF_H__ - -#include - -/* Platform name, type, and MCU clock rate */ -#define PLATFORM_NAME "STK500" -#define PLATFORM_TYPE STK500 -#ifndef F_CPU -#define F_CPU 8000000UL -#endif - -#define CCIF -#define CLIF - -/* The AVR tick interrupt usually is done with an 8 bit counter around 128 Hz. - * 125 Hz needs slightly more overhead during the interrupt, as does a 32 bit - * clock_time_t. - */ - /* Clock ticks per second */ -#define CLOCK_CONF_SECOND 125 -#if 1 -/* 16 bit counter overflows every ~10 minutes */ -typedef unsigned short clock_time_t; -#define CLOCK_LT(a,b) ((signed short)((a)-(b)) < 0) -#define INFINITE_TIME 0xffff -#define RIME_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME INFINITE_TIME/CLOCK_CONF_SECOND /* Default uses 600 */ -#define COLLECT_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME INFINITE_TIME/CLOCK_CONF_SECOND /* Default uses 600 */ -#else -typedef unsigned long clock_time_t; -#define CLOCK_LT(a,b) ((signed long)((a)-(b)) < 0) -#define INFINITE_TIME 0xffffffff -#endif -/* These routines are not part of the contiki core but can be enabled in cpu/avr/clock.c */ -void clock_delay_msec(uint16_t howlong); -void clock_adjust_ticks(clock_time_t howmany); - -#define SLIP_PORT 0 - -#if UIP_CONF_IPV6 -#define RIMEADDR_CONF_SIZE 8 -#define UIP_CONF_ICMP6 1 -#define UIP_CONF_UDP 1 -#define UIP_CONF_TCP 1 -//#define UIP_CONF_IPV6_RPL 0 - -/* See uip-ds6.h */ -#define NBR_TABLE_CONF_MAX_NEIGHBORS 20 -#define UIP_CONF_DS6_DEFRT_NBU 2 -#define UIP_CONF_DS6_PREFIX_NBU 3 -#define UIP_CONF_MAX_ROUTES 20 -#define UIP_CONF_DS6_ADDR_NBU 3 -#define UIP_CONF_DS6_MADDR_NBU 0 -#define UIP_CONF_DS6_AADDR_NBU 0 - -#define NETSTACK_CONF_NETWORK sicslowpan_driver -#define NETSTACK_CONF_MAC nullmac_driver -#define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_COMPRESSION_HC06 -#define NETSTACK_CONF_RDC sicslowmac_driver -#define NETSTACK_CONF_FRAMER framer_802154 -#define NETSTACK_CONF_RADIO rf230_driver -#define CHANNEL_802_15_4 26 -/* AUTOACK receive mode gives better rssi measurements, even if ACK is never requested */ -#define RF230_CONF_AUTOACK 1 -/* Request 802.15.4 ACK on all packets sent (else autoretry). This is primarily for testing. */ -#define SICSLOWPAN_CONF_ACK_ALL 0 -/* Number of auto retry attempts 0-15 (0 implies don't use extended TX_ARET_ON mode with CCA) */ -#define RF230_CONF_AUTORETRIES 2 -#define SICSLOWPAN_CONF_FRAG 1 -/* Most browsers reissue GETs after 3 seconds which stops fragment reassembly so a longer MAXAGE does no good */ -#define SICSLOWPAN_CONF_MAXAGE 3 -/* How long to wait before terminating an idle TCP connection. Smaller to allow faster sleep. Default is 120 seconds */ -#define UIP_CONF_WAIT_TIMEOUT 5 - -#else -/* ip4 should build but is largely untested */ -#define RIMEADDR_CONF_SIZE 2 -#define NETSTACK_CONF_NETWORK rime_driver -#endif /* UIP_CONF_IPV6 */ - -typedef unsigned short uip_stats_t; - -/* These names are deprecated, use C99 names. */ -typedef uint8_t u8_t; -typedef int8_t s8_t; -typedef uint16_t u16_t; -typedef int16_t s16_t; -typedef uint32_t u32_t; -typedef int32_t s32_t; - -#endif /* __CONTIKI_CONF_H__ */ diff --git a/platform/stk500/contiki-stk500-main.c b/platform/stk500/contiki-stk500-main.c deleted file mode 100644 index 54169f19e..000000000 --- a/platform/stk500/contiki-stk500-main.c +++ /dev/null @@ -1,236 +0,0 @@ - -/* Copyright (c) 2008, Daniel Willmann - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This file is part of the Contiki OS - * - * - */ - -#include "contiki.h" -#include "dev/rs232.h" - -#include -#include -#include -#include - -#define PRINTA(FORMAT,args...) printf_P(PSTR(FORMAT),##args) -#define DEBUG 0 -#if DEBUG -#define PRINTD PRINTA -#else -#define PRINTD(...) -#endif - -/* Test rtimers, also stack monitor and time stamps */ -#define TESTRTIMER 1 -#if TESTRTIMER -#define STAMPS 30 -#define STACKMONITOR 128 - -uint8_t rtimerflag=1; -uint16_t rtime; -struct rtimer rt; -void rtimercycle(void) {rtimerflag=1;} -#endif /* TESTRTIMER */ - -#if defined (__AVR_ATmega8__) -FUSES = - { - .low = 0xe0, - .high = 0xd9, - }; -#elif defined (__AVR_ATmega16__) -FUSES = - { - .low = 0xe0, - .high = 0x99, - }; -#elif defined (__AVR_ATmega644__) -FUSES = - { - .low = 0xe0, - .high = 0x99, - .extended = 0xff, - }; - -//MCU=atmega8515 -//MCU=atmega328p -//MCU=atmega32 -#endif - - -PROCESS(led_process, "LED process"); -PROCESS_THREAD(led_process, ev, data) -{ - static struct etimer etimer; - - PROCESS_BEGIN(); - while (1) { - PRINTD("LED1\r\n"); - PORTB |= (1< %d bytes\n",p-(uint16_t)&__bss_end); - break; - } - p+=4; - } while (p - * - * @(#)$$ - */ -#include "contiki-stk501.h" - -void -init_lowlevel(void) -{ - /* Configure default slip port with 115200 baud */ - rs232_init(RS232_PORT_0, USART_BAUD_115200, USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8); - - /* Second rs232 port for debugging */ - rs232_init(RS232_PORT_1, USART_BAUD_9600, USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8); - - /* Redirect stdout to second port */ - rs232_redirect_stdout (RS232_PORT_1); -} diff --git a/platform/stk501/contiki-stk501-default-init-net.c b/platform/stk501/contiki-stk501-default-init-net.c deleted file mode 100644 index 037edfb07..000000000 --- a/platform/stk501/contiki-stk501-default-init-net.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2006, Technical University of Munich - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - * Author: Simon Barner - * - * @(#)$$ - */ - -#include "contiki-stk501.h" - -#if UIP_CONF_IPV6 -#warning ********Explcit IPV4 code bypassed*********** -#else - -static struct uip_fw_netif slipif = - {UIP_FW_NETIF(10,100,0,0, 255,255,0,0, slip_send)}; -#endif - -void -init_net(void) -{ -#if !UIP_CONF_IPV6 - uip_ipaddr_t hostaddr; - - rs232_set_input (SLIP_PORT, slip_input_byte); - process_start(&slip_process, NULL); - - uip_ipaddr(&hostaddr, 10, 100, 0, 2); - uip_sethostaddr(&hostaddr); - - uip_fw_register(&slipif); - // uip_fw_default(&slipif); -#endif /* UIP_CONF_IPV6 */ -} diff --git a/platform/stk501/contiki-stk501-main.c b/platform/stk501/contiki-stk501-main.c deleted file mode 100644 index 3223bbfae..000000000 --- a/platform/stk501/contiki-stk501-main.c +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) 2006, Technical University of Munich - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - * @(#)$$ - */ - -/** - * \file - * Sample Contiki kernel for STK 501 development board - * - * \author - * Simon Barner -#include -#include "net/uip_arp.h" - -#include "contiki-stk501.h" -//#include "../core/cfs/cfs-eeprom.h" -#include "cfs/cfs.h" -#include "dev/eeprom.h" -#include "lib/mmem.h" -#include "loader/symbols-def.h" -#include "loader/symtab.h" -#include "../apps/codeprop/codeprop.h" -#include "sys/mt.h" - -/* Uncomment to enable demonstration of multi-threading libary */ -/* #define MT_DEMO */ - -#define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args) - -//TODO: What happened to cfs_eeprom_process? -//PROCINIT(&etimer_process, &tcpip_process, &uip_fw_process, &cfs_eeprom_process); -#if UIP_CONF_IPV6 -PROCINIT(&etimer_process, &tcpip_process); -#else -PROCINIT(&etimer_process, &tcpip_process, &uip_fw_process); -#endif - -#ifdef MT_DEMO -static struct mt_thread threads[3]; - -static -void thread_handler1 (void* data) { - while (1) { - PRINTF ("Thread 1. Data: 0x%x, %d\n", data, *(uint8_t*)data ); - mt_yield (); - } -} - -static -void thread_handler2 (void* data) { - while (1) { - PRINTF ("Thread 2. Data: 0x%x, %d\n", data, *(uint8_t*)data ); - mt_yield (); - } -} -#endif - -PROCESS(contiki_stk501_main_init_process, "Contiki STK501 init process"); -PROCESS_THREAD(contiki_stk501_main_init_process, ev, data) -{ - PROCESS_BEGIN(); - - /* Network support (uIP) */ - init_net(); - - /* Initalize heap allocator */ - mmem_init (); - - /* Code propagator */ - /* TODO: The core elfloader-avr.c has 16/32 bit pointer problems so this won't build */ -//process_start(&codeprop_process, NULL); - - /* Multi-threading support */ -#ifdef MT_DEMO - mt_init (); -#endif - - PROCESS_END(); -} - -#ifdef MT_DEMO -static uint8_t d1=1, d2=2, d3=3; -#endif - -int -main(void) -{ - /* - * GCC depends on register r1 set to 0. - */ - asm volatile ("clr r1"); - - /* Initialize hardware */ - init_lowlevel(); - - /* Clock */ - clock_init(); - - /* Process subsystem */ - process_init(); - - /* Register initial processes */ - procinit_init(); - - /* Perform rest of initializations */ - process_start(&contiki_stk501_main_init_process, NULL); - - PRINTF("Initialized.\n"); - -#ifdef MT_DEMO - mt_start (&threads[0], thread_handler1, &d1); - mt_start (&threads[1], thread_handler2, &d2); - mt_start (&threads[2], thread_handler2, &d3); - - uint8_t i; -#endif - - /* Main scheduler loop */ - while(1) { - - process_run(); - -#ifdef MT_DEMO - for (i=0; i<3; ++i) { - mt_exec (&threads[i]); - } -#endif - } - - return 0; -} diff --git a/platform/stk501/contiki-stk501.h b/platform/stk501/contiki-stk501.h deleted file mode 100644 index 17a2bc98d..000000000 --- a/platform/stk501/contiki-stk501.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2006, Technical University of Munich - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - * @(#)$$ - */ - -/** - * \file - * Sample Contiki kernel for STK 501 development board - * - * \author - * Simon Barner - */ -#include -#include "dev/rs232.h" -#include "contiki.h" - -PROCESS(test_process1, "Test process"); -PROCESS_THREAD(test_process1, ev, data) -{ - static struct etimer etimer; - - PROCESS_BEGIN(); - - rs232_print (RS232_PORT_1, "test_process 1 starting\n"); - - while(1) { - etimer_set(&etimer, CLOCK_SECOND); - PROCESS_WAIT_UNTIL(etimer_expired(&etimer)); - rs232_print (RS232_PORT_1, "Tick\n"); - etimer_set(&etimer, CLOCK_SECOND); - PROCESS_WAIT_UNTIL(etimer_expired(&etimer)); - rs232_print (RS232_PORT_1, "Tack\n"); - } - - PROCESS_END(); -} - -const struct process *autostart_processes[] = {&test_process1}; diff --git a/regression-tests/01-compile-base/Makefile b/regression-tests/01-compile-base/Makefile index f3f736f82..a0e572144 100644 --- a/regression-tests/01-compile-base/Makefile +++ b/regression-tests/01-compile-base/Makefile @@ -3,7 +3,6 @@ TOOLSDIR=../../tools EXAMPLES = \ hello-world/avr-raven \ -hello-world/esb \ hello-world/exp5438 \ hello-world/micaz \ hello-world/minimal-net \ diff --git a/regression-tests/02-hello-world/04-hello-world-esb.csc b/regression-tests/02-hello-world/04-hello-world-esb.csc deleted file mode 100644 index a0152058a..000000000 --- a/regression-tests/02-hello-world/04-hello-world-esb.csc +++ /dev/null @@ -1,83 +0,0 @@ - - - - Hello World (ESB) - generated - 1000000 - - org.contikios.cooja.radiomediums.UDGM - 50.0 - 100.0 - 1.0 - 1.0 - - - 40000 - - - org.contikios.cooja.mspmote.ESBMoteType - esb1 - ESB Mote Type #esb1 - [CONTIKI_DIR]/examples/hello-world/hello-world.c - make hello-world.esb TARGET=esb - [CONTIKI_DIR]/examples/hello-world/hello-world.esb - org.contikios.cooja.interfaces.Position - org.contikios.cooja.interfaces.RimeAddress - org.contikios.cooja.interfaces.IPAddress - org.contikios.cooja.mspmote.interfaces.MspSerial - org.contikios.cooja.mspmote.interfaces.MspClock - org.contikios.cooja.mspmote.interfaces.ESBLED - org.contikios.cooja.mspmote.interfaces.ESBButton - org.contikios.cooja.mspmote.interfaces.MspMoteID - org.contikios.cooja.mspmote.interfaces.TR1001Radio - org.contikios.cooja.interfaces.Mote2MoteRelations - org.contikios.cooja.interfaces.MoteAttributes - - - - - org.contikios.cooja.interfaces.Position - 57.296459690977144 - 73.20759478605089 - 0.0 - - - org.contikios.cooja.mspmote.interfaces.MspMoteID - 1 - - esb1 - - - - org.contikios.cooja.plugins.LogListener - - - - 623 - 1 - 270 - 29 - 256 - - - org.contikios.cooja.plugins.ScriptRunner - - [CONFIG_DIR]/hello-world.js - true - - 600 - 0 - 453 - 337 - 25 - - - org.contikios.cooja.plugins.SimControl - 280 - 2 - 160 - 20 - 23 - - -