diff --git a/cpu/avr/dev/rs232.h b/cpu/avr/dev/rs232.h index 276ae6b31..b8491e93a 100644 --- a/cpu/avr/dev/rs232.h +++ b/cpu/avr/dev/rs232.h @@ -31,7 +31,7 @@ * Author: Adam Dunkels * Simon Barner * - * @(#)$Id: rs232.h,v 1.4 2008/11/09 15:39:49 c_oflynn Exp $ + * @(#)$Id: rs232.h,v 1.5 2008/11/29 15:55:02 c_oflynn Exp $ */ #ifndef __RS232_H__ @@ -42,6 +42,8 @@ #if defined (__AVR_ATmega128__) #include "dev/rs232_atmega128.h" +#elif defined (__AVR_ATmega1281__) +#include "dev/rs232_atmega1281.h" #elif defined (__AVR_ATmega1284P__) #include "dev/rs232_atmega1284.h" #elif defined (__AVR_AT90USB1287__) diff --git a/cpu/avr/dev/usb/rndis/rndis_task.c b/cpu/avr/dev/usb/rndis/rndis_task.c index 49531a6bf..93f64c78b 100644 --- a/cpu/avr/dev/usb/rndis/rndis_task.c +++ b/cpu/avr/dev/usb/rndis/rndis_task.c @@ -129,6 +129,7 @@ PROCESS_THREAD(rndis_process, ev, data_proc) /* Device is Enumerated but RNDIS not loading. We might have a system that does not support IAD (winXP). If so count the timeout then switch to just network interface. */ +#if 0 if (usb_mode == rndis_debug) { //If we have timed out, detach if (iad_fail_timeout == IAD_TIMEOUT_DETACH) { @@ -189,6 +190,7 @@ PROCESS_THREAD(rndis_process, ev, data_proc) rndis_fail_timeout = 0; } }//usb_mode == rnids_only +#endif if(rndis_state == rndis_data_initialized) //Enumeration processs OK ? diff --git a/cpu/avr/radio/rf230/hal.h b/cpu/avr/radio/rf230/hal.h index 8bc2c9520..b2a2d19c7 100644 --- a/cpu/avr/radio/rf230/hal.h +++ b/cpu/avr/radio/rf230/hal.h @@ -47,7 +47,7 @@ * \file * \brief This file contains low-level radio driver code. * - * $Id: hal.h,v 1.3 2008/11/09 15:39:49 c_oflynn Exp $ + * $Id: hal.h,v 1.4 2008/11/29 15:55:02 c_oflynn Exp $ */ #ifndef HAL_AVR_H @@ -70,9 +70,17 @@ * \{ */ /* Define all possible revisions here */ +// RAVEN_D : Raven kit with LCD display +// RAVENUSB_C : used for USB key or Raven card +// RCB_B : RZ200 kit from Atmel based on 1281V +// ZIGBIT : Zigbit module from Meshnetics #define RAVEN_D 0 #define RAVENUSB_C 1 -#define RCB_B 2 +#define RCB_B 2 +#define ZIGBIT 3 + + + #if RCB_REVISION == RCB_B /* 1281 rcb */ @@ -93,8 +101,29 @@ # define TICKTIMER 3 # define HAS_SPARE_TIMER -#elif RAVEN_REVISION == RAVEN_D +#elif HARWARE_REVISION == ZIGBIT +/* 1281V Zigbit */ +# define SSPORT B +# define SSPIN (0x00) +# define SPIPORT B +# define MOSIPIN (0x02) +# define MISOPIN (0x03) +# define SCKPIN (0x01) +# define RSTPORT A +# define RSTPIN (0x07) +# define IRQPORT E +# define IRQPIN (0x05) +# define SLPTRPORT B +# define SLPTRPIN (0x04) +# define TXCWPORT B +# define TXCWPIN (0x07) +# define USART 1 +# define USARTVECT USART1_RX_vect +//# define TICKTIMER 3 +//# define HAS_SPARE_TIMER // Not used + +#elif RAVEN_REVISION == RAVEN_D /* 1284 raven */ # define SSPORT B # define SSPIN (0x04) @@ -117,7 +146,6 @@ # define HAS_SPARE_TIMER #elif RAVEN_REVISION == RAVENUSB_C - /* 1287USB raven */ # define SSPORT B # define SSPIN (0x00) @@ -141,7 +169,7 @@ #else -#error "RAVEN platform undefined in hal.h" +#error "Platform undefined in hal.h" #endif @@ -245,10 +273,16 @@ #error "Clock speed not supported." #endif - +#if HARWARE_REVISION == ZIGBIT +// IRQ E5 for Zigbit example +#define RADIO_VECT INT5_vect +#define HAL_ENABLE_RADIO_INTERRUPT( ) { ( EIMSK |= ( 1 << INT5 ) ) ; EICRB |= 0x0C ; PORTE &= ~(1< +#include +#include +#include + +#include "lib/mmem.h" +#include "loader/symbols-def.h" +#include "loader/symtab.h" +#include +#include "mac.h" +#include "sicslowmac.h" +#include "sicslowpan.h" +#include "ieee-15-4-manager.h" + +#include "contiki.h" +#include "contiki-net.h" +#include "contiki-lib.h" + +#include "dev/rs232.h" +#include "dev/serial.h" +#include "dev/slip.h" + +#include "sicslowmac.h" + +FUSES = + { + .low = (FUSE_CKSEL0 & FUSE_CKSEL2 & FUSE_CKSEL3 & FUSE_SUT0), // 0xe2, + .high = (FUSE_BOOTSZ0 /*& FUSE_BOOTSZ1*/ & FUSE_SPIEN & FUSE_JTAGEN), //0x9D, + .extended = 0xff, + }; + + +PROCINIT(&etimer_process, &mac_process, &tcpip_process ); +/* Put default MAC address in EEPROM */ +uint8_t mac_address[8] EEMEM = {0x02, 0x11, 0x22, 0xff, 0xfe, 0x33, 0x44, 0x55}; + + +void +init_lowlevel(void) +{ + + /* Second rs232 port for debugging */ + rs232_init(RS232_PORT_1, USART_BAUD_115200, + USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8); + + /* Redirect stdout to second port */ + rs232_redirect_stdout(RS232_PORT_1); +} + + +int +main(void) +{ + //calibrate_rc_osc_32k(); //CO: Had to comment this out + + /* Initialize hardware */ + init_lowlevel(); + + /* Clock */ + clock_init(); + + + /* Process subsystem */ + process_init(); + + /* Register initial processes */ + procinit_init(); + + /* Autostart processes */ + autostart_start(autostart_processes); + + printf_P(PSTR("\n********BOOTING CONTIKI*********\n")); + + printf_P(PSTR("System online.\n")); + + /* Main scheduler loop */ + while(1) { + process_run(); + } + + return 0; +} diff --git a/platform/avr-zigbit/contiki-avr-zigbit.h b/platform/avr-zigbit/contiki-avr-zigbit.h new file mode 100644 index 000000000..36617a14b --- /dev/null +++ b/platform/avr-zigbit/contiki-avr-zigbit.h @@ -0,0 +1,58 @@ +/* + * 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 Zigbit module + * + * \author + * Frederic Thepaut + */ + +#ifndef __CONTIKI_AVR_ZIGBIT_H__ +#define __CONTIKI_AVR_ZIGBIT_H__ + +#include "contiki.h" +#include "contiki-net.h" +#include "contiki-lib.h" + +#include "dev/rs232.h" + +#include "dev/serial.h" +#include "dev/slip.h" + +void init_lowlevel(void); +void init_net(void); + + +#endif /* #ifndef __CONTIKI_AVR_ZIGBIT_H__ */ diff --git a/platform/avr-zigbit/contiki-conf.h b/platform/avr-zigbit/contiki-conf.h new file mode 100644 index 000000000..c1ef019ca --- /dev/null +++ b/platform/avr-zigbit/contiki-conf.h @@ -0,0 +1,134 @@ +/* + * 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 sample STK 501 Contiki kernel + * + * \author + * Simon Barner + +typedef int32_t s32_t; + +/* + * MCU and clock rate + */ +#define MCU_MHZ 8 +#define PLATFORM PLATFORM_AVR +#define HARWARE_REVISION ZIGBIT + +/* Clock ticks per second */ +#define CLOCK_CONF_SECOND 125 + +/* Maximum time interval (used for timers) */ +#define INFINITE_TIME 0xffff + +/* COM port to be used for SLIP connection */ +#define SLIP_PORT RS232_PORT_0 + +/* Pre-allocated memory for loadable modules heap space (in bytes)*/ +#define MMEM_CONF_SIZE 256 + +/* Use the following address for code received via the codeprop + * facility + */ +#define EEPROMFS_ADDR_CODEPROP 0x8000 + +#define CCIF +#define CLIF + +#define RIMEADDR_CONF_SIZE 8 +#define RIMEBUF_CONF_HDR_SIZE 0 + +/* 0 for IPv6, or 1 for HC1, 2 for HC01 */ +#define SICSLOWPAN_CONF_COMPRESSION_IPV6 0 +#define SICSLOWPAN_CONF_COMPRESSION_HC1 1 +#define SICSLOWPAN_CONF_COMPRESSION_HC01 2 + +//FTH081105 +#define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_CONF_COMPRESSION_HC01 +#define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 2 +#define SICSLOWPAN_CONF_FRAG 1 + +#define SICSLOWPAN_CONF_MAXAGE 5 + +#define UIP_CONF_LL_802154 1 +#define UIP_CONF_LLH_LEN 14 + +#define UIP_CONF_MAX_CONNECTIONS 2 +#define UIP_CONF_MAX_LISTENPORTS 2 +#define UIP_CONF_UDP_CONNS 2 + +#define UIP_CONF_IP_FORWARD 0 +#define UIP_CONF_FWCACHE_SIZE 0 + +#define UIP_CONF_IPV6 1 +#define UIP_CONF_IPV6_CHECKS 1 + + +#define UIP_CONF_IPV6_QUEUE_PKT 0 + + +#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_NEIGHBORS 4 +#define UIP_CONF_ND6_MAX_DEFROUTERS 2 +#define UIP_CONF_ICMP6 1 + +#define UIP_CONF_UDP 1 +#define UIP_CONF_UDP_CHECKSUMS 1 + +#define UIP_CONF_TCP 1 +#define UIP_CONF_TCP_SPLIT 1 + + +typedef unsigned short clock_time_t; +typedef unsigned char u8_t; +typedef unsigned short u16_t; +typedef unsigned long u32_t; +typedef unsigned short uip_stats_t; +typedef unsigned long off_t; + +void clock_delay(unsigned int us2); +void clock_wait(int ms10); +void clock_set_seconds(unsigned long s); +unsigned long clock_seconds(void); + +#endif /* __CONTIKI_CONF_H__ */ diff --git a/platform/avr-zigbit/loadable_prg.c b/platform/avr-zigbit/loadable_prg.c new file mode 100644 index 000000000..ff4674689 --- /dev/null +++ b/platform/avr-zigbit/loadable_prg.c @@ -0,0 +1,68 @@ +/* + * 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 loadable module + * + * \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(); +} + + +CLIF struct process * const autostart_processes[] = {&test_process1};