Merge pull request #713 from adamdunkels/pr/drop-iris

Remove the unmaintained iris platform
This commit is contained in:
Nicolas Tsiftes 2014-06-13 12:57:52 +02:00
commit 4c5fa6ff5d
23 changed files with 0 additions and 2144 deletions

View File

@ -1,57 +0,0 @@
CONTIKI_TARGET_DIRS = . dev dev/sensors
CONTIKI_CORE=contiki-iris
CONTIKI_TARGET_MAIN = ${CONTIKI_CORE}.o
SENSOR_BOARD_SOURCEFILES = mts300.c
CONTIKI_TARGET_SOURCEFILES += adc.c rs232.c cfs-eeprom.c contiki-iris-main.c \
leds-arch.c init-net.c node-id.c \
clock.c spi.c rtimer-arch.c ds2401.c \
battery-sensor.c slip.c slip_uart0.c
CONTIKI_TARGET_SOURCEFILES += $(SENSOR_BOARD_SOURCEFILES)
CONTIKIAVR=$(CONTIKI)/cpu/avr
CONTIKIBOARD=.
# IRIS runs on Clock rate 8 MHz
CONTIKI_PLAT_DEFS = -DF_CPU=8000000UL -DAUTO_CRC_PADDING=2 #-DUSART_BAUD_115200
MCU=atmega1281
AVRDUDE_OPTIONS=-V
AVRDUDE_PROGRAMMER=mib510
#AVRDUDE_PROGRAMMER=jtag2
#AVRDUDE_PORT=usb
AVRDUDE_PORT=$(PORT)
include $(CONTIKIAVR)/Makefile.avr
%.od: %.$(TARGET)
avr-objdump -zhD $< > $@
ifeq ($(PRGBOARD), )
PRGBOARD = mib510
endif
ifeq ($(PORT), )
ifeq ($(HOST_OS), Windows)
PORT = COM1
else
PORT = /dev/ttyUSB0
endif
endif
PRGBOARD_FILE = $(CONTIKI)/platform/$(TARGET)/buildscripts/Makefile.$(PRGBOARD)
HAVE_PRGBOARD_FILE = $(wildcard $(PRGBOARD_FILE))
ifneq ($(strip $(HAVE_PRGBOARD_FILE)), )
include $(PRGBOARD_FILE)
endif
include $(CONTIKIAVR)/radio/Makefile.radio
ifeq ($(UIP_CONF_IPV6),1)
CFLAGS += -DWITH_UIP6=1
endif

View File

@ -1,5 +0,0 @@
CONTIKI = ../../..
all: battery-monitor
include $(CONTIKI)/Makefile.include

View File

@ -1,34 +0,0 @@
#include "contiki.h"
#include "dev/battery-sensor.h"
#include "lib/sensors.h"
#include <stdio.h> /* For printf() */
/*---------------------------------------------------------------------------*/
PROCESS(battery_monitor_process, "Battery Voltage Monitor");
AUTOSTART_PROCESSES(&battery_monitor_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(battery_monitor_process, ev, data)
{
static struct etimer et;
PROCESS_BEGIN();
SENSORS_ACTIVATE(battery_sensor);
while(1) {
etimer_set(&et, CLOCK_SECOND * 2);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
/*
* Battery voltage calculation formula
*
* V(Battery Voltage) = v(Voltage Reference) * 1024 / ADC
*
* Where:
* v = 1.223
*
*/
printf("ADC value : %d\n", battery_sensor.value(0));
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -1,5 +0,0 @@
CONTIKI = ../../../..
all: accel-test light-test magnet-test mic-test
include $(CONTIKI)/Makefile.include

View File

@ -1,59 +0,0 @@
/*
* Copyright (c) 2009, University of Colombo School of Computing
* 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 <stdio.h>
#include "contiki.h"
#include "dev/sensors/mts300.h"
/*---------------------------------------------------------------------------*/
PROCESS(test_accel_process, "Accel test");
AUTOSTART_PROCESSES(&test_accel_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(test_accel_process, ev, data)
{
static struct etimer et;
PROCESS_BEGIN();
while(1) {
printf("AccX : %d\n",get_accx());
printf("AccY : %d\n",get_accy());
etimer_set(&et, CLOCK_SECOND / 2);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -1,60 +0,0 @@
/*
* Copyright (c) 2009, University of Colombo School of Computing
* 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/sensors/mts300.h"
#include <stdio.h>
/*---------------------------------------------------------------------------*/
PROCESS(test_light_process, "light test");
AUTOSTART_PROCESSES(&test_light_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(test_light_process, ev, data)
{
static struct etimer et;
PROCESS_BEGIN();
while(1) {
printf("Light : %d\n",get_light());
printf("Temp : %d\n",get_temp());
etimer_set(&et, CLOCK_SECOND / 2);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -1,61 +0,0 @@
/*
* Copyright (c) 2009, University of Colombo School of Computing
* 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/sensors/mts300.h"
#include <stdio.h>
/*---------------------------------------------------------------------------*/
PROCESS(test_sounder_process, "Sounder test");
AUTOSTART_PROCESSES(&test_sounder_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(test_sounder_process, ev, data)
{
static struct etimer et;
PROCESS_BEGIN();
while(1) {
sounder_on();
etimer_set(&et, 1);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
sounder_off();
etimer_set(&et, 1);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -1,58 +0,0 @@
/*
* Copyright (c) 2009, University of Colombo School of Computing
* 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/sensors/mts300.h"
#include <stdio.h>
/*---------------------------------------------------------------------------*/
PROCESS(test_mic_process, "Mic test");
AUTOSTART_PROCESSES(&test_mic_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(test_mic_process, ev, data)
{
static struct etimer et;
PROCESS_BEGIN();
while(1) {
printf("Mic : %d\n",get_mic());
etimer_set(&et, CLOCK_SECOND / 8);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
;
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -1,197 +0,0 @@
/*
* Copyright (c) 2009, University of Colombo School of Computing
* 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 MICAz platform.
*
* \author
* Kasun Hewage <kasun.ch@gmail.com>
*/
#ifndef CONTIKI_CONF_H_
#define CONTIKI_CONF_H_
#define HAVE_STDINT_H
#include "avrdef.h"
#include "platform-conf.h"
#if WITH_UIP6
/* Network setup for IPv6 */
#define NETSTACK_CONF_NETWORK sicslowpan_driver
#define NETSTACK_CONF_MAC csma_driver
#define NETSTACK_CONF_RDC nullrdc_driver
#define NETSTACK_CONF_FRAMER framer_802154
#define RF230_CONF_AUTOACK 1
#define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8
#define RIME_CONF_NO_POLITE_ANNOUCEMENTS 0
#define CXMAC_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 cxmac_driver
#define NETSTACK_CONF_FRAMER framer_802154
#define RF230_CONF_AUTOACK 1
#define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8
#define COLLECT_CONF_ANNOUNCEMENTS 1
#define RIME_CONF_NO_POLITE_ANNOUCEMENTS 1
#define CXMAC_CONF_ANNOUNCEMENTS 0
#define CXMAC_CONF_COMPOWER 1
#define CONTIKIMAC_CONF_ANNOUNCEMENTS 0
#define CONTIKIMAC_CONF_COMPOWER 1
#define COLLECT_NBR_TABLE_CONF_MAX_NEIGHBORS 32
#endif /* WITH_UIP6 */
#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 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 LINKADDR_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
/* configure number of neighbors and routes */
#define NBR_TABLE_CONF_MAX_NEIGHBORS 5
#define UIP_CONF_MAX_ROUTES 5
#define RPL_CONF_MAX_PARENTS 4
#define NBR_TABLE_CONF_MAX_NEIGHBORS 8
#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 240
#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 128
#endif /* WITH_UIP6 */
#define UIP_CONF_ICMP_DEST_UNREACH 1
#if !WITH_UIP && !WITH_UIP6
#define QUEUEBUF_CONF_NUM 8
#else
#define QUEUEBUF_CONF_NUM 4
#endif
#define TIMESYNCH_CONF_ENABLED 1
#define RF230_CONF_TIMESTAMPS 0
#define RF230_CONF_SYMBOL_LOOP_COUNT 500
#define WITH_NULLMAC 0
#define CCIF
#define CLIF
/* The process names are not used to save RAM */
#define PROCESS_CONF_NO_PROCESS_NAMES 0
#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 15
#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
typedef unsigned short uip_stats_t;
typedef unsigned long off_t;
#ifdef PROJECT_CONF_H
#include PROJECT_CONF_H
#endif /* PROJECT_CONF_H */
#endif /* CONTIKI_CONF_H_ */

View File

@ -1,125 +0,0 @@
/*
* Copyright (c) 2009, University of Colombo School of Computing
* 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 file of the MICAz port.
*
* \author
* Kasun Hewage <kasun.ch@gmail.com>
*/
#include <stdio.h>
#include <avr/pgmspace.h>
#include "contiki.h"
#include "contiki-lib.h"
#include "net/rime/rime.h"
#include "dev/leds.h"
#include "dev/rs232.h"
#include "dev/watchdog.h"
#include "dev/slip.h"
#include "init-net.h"
#include "dev/ds2401.h"
#include "sys/node-id.h"
/*---------------------------------------------------------------------------*/
void
init_usart(void)
{
/* First rs232 port for debugging */
rs232_init(RS232_PORT_0, USART_BAUD_115200,
USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);
#if WITH_UIP || WITH_UIP6
slip_arch_init(USART_BAUD_115200);
#else
rs232_redirect_stdout(RS232_PORT_0);
#endif /* WITH_UIP */
}
/*---------------------------------------------------------------------------*/
int
main(void)
{
leds_init();
leds_on(LEDS_RED);
/* Initialize USART */
init_usart();
/* Clock */
clock_init();
leds_on(LEDS_GREEN);
ds2401_init();
node_id_restore();
random_init(ds2401_id[0] + node_id);
rtimer_init();
/* Process subsystem */
process_init();
process_start(&etimer_process, NULL);
ctimer_init();
leds_on(LEDS_YELLOW);
init_net();
printf_P(PSTR(CONTIKI_VERSION_STRING " started. Node id %u\n"), node_id);
leds_off(LEDS_ALL);
/* Autostart processes */
autostart_start(autostart_processes);
mmem_init();
/* Main scheduler loop */
do {
process_run();
}while(1);
return 0;
}

View File

@ -1,76 +0,0 @@
/*
* Copyright (c) 2010, University of Colombo School of Computing
* 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 <avr/io.h>
#include "dev/adc.h"
/*---------------------------------------------------------------------------*/
void
adc_init()
{
ADMUX = 0;
/* AVCC with external capacitor at AREF pin. */
ADMUX |= _BV(REFS0);
/* Disable ADC interrupts. */
ADCSRA &= ~( _BV(ADIE) | _BV(ADIF) );
/* Set ADC prescaler to 64 and clear interrupt flag. */
ADCSRA |= _BV(ADPS2) | _BV(ADPS1) | _BV(ADIE);
}
/*---------------------------------------------------------------------------*/
/* Poll based approach. The interrupt based adc is currently not used.
The ADC result is right adjusted. First 8 bits(from left) are in ADCL and
other two bits are in ADCH. See Atmega128 datasheet page 228. */
uint16_t
get_adc(int channel)
{
uint16_t reading;
ADMUX |= (channel & 0x1F);
/* Disable ADC interrupts. */
ADCSRA &= ~_BV(ADIE);
/* Clear previous interrupts. */
ADCSRA |= _BV(ADIF);
/* Enable ADC and start conversion. */
ADCSRA |= _BV(ADEN) | _BV(ADSC);
/* Wait until conversion is completed. */
while ( ADCSRA & _BV(ADSC) );
/* Get first 8 bits. */
reading = ADCL;
/* Get last two bits. */
reading |= (ADCH & 3) << 8;
/* Disable ADC. */
ADCSRA &= ~_BV(ADEN);
return reading;
}
/*---------------------------------------------------------------------------*/

View File

@ -1,40 +0,0 @@
/*
* Copyright (c) 2010, University of Colombo School of Computing
* 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();
uint16_t get_adc(int channel);
#endif /* ADC_H_ */

View File

@ -1,244 +0,0 @@
/*
* Copyright (c) 2009, University of Colombo School of Computing
* 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.
*
*/
/*
* Device driver for the Dallas Semiconductor DS2401 chip. Heavily
* based on the application note 126 "1-Wire Communications Through
* Software".
*
* http://www.maxim-ic.com/appnotes.cfm/appnote_number/126
*/
/*
* For now we stuff in Crossbow Technology, Inc's unique OUI.
* 00:1A:4C Crossbow Technology, Inc
*
* The EUI-64 is a concatenation of the 24-bit OUI value assigned by
* the IEEE Registration Authority and a 40-bit extension identifier
* assigned by the organization with that OUI assignment.
*/
#include <avr/io.h>
#include <string.h>
#include "contiki.h"
#include "ds2401.h"
unsigned char ds2401_id[8];
/* 1-wire is at PortA.4 */
#define SERIAL_ID_PIN_READ PINA
#define SERIAL_ID_PIN_MASK _BV(4)
#define SERIAL_ID_PxOUT PORTA
#define SERIAL_ID_PxDIR DDRA
#define SET_PIN_INPUT() (SERIAL_ID_PxDIR &= ~SERIAL_ID_PIN_MASK)
#define SET_PIN_OUTPUT() (SERIAL_ID_PxDIR |= SERIAL_ID_PIN_MASK)
#define OUTP_0() (SERIAL_ID_PxOUT &= ~SERIAL_ID_PIN_MASK)
#define OUTP_1() (SERIAL_ID_PxOUT |= SERIAL_ID_PIN_MASK)
#define PIN_INIT() do{ \
SET_PIN_INPUT(); \
OUTP_0(); \
} while(0)
/* Drive the one wire interface low */
#define OW_DRIVE() do { \
SET_PIN_OUTPUT(); \
OUTP_0(); \
} while (0)
/* Release the one wire by turning on the internal pull-up. */
#define OW_RELEASE() do { \
SET_PIN_INPUT(); \
OUTP_1(); \
} while (0)
/* Read one bit. */
#define INP() (SERIAL_ID_PIN_READ & SERIAL_ID_PIN_MASK)
/*
* Delay times in us.
*/
#define tA 6 /* min-5, recommended-6, max-15 */
#define tB 64 /* min-59, recommended-64, max-N/A */
#define tC 60 /* min-60, recommended-60, max-120 */
#define tD 10 /* min-5.3, recommended-10, max-N/A */
#define tE 9 /* min-0.3, recommended-9, max-9.3 */
#define tF 55 /* min-50, recommended-55, max-N/A */
#define tG 0 /* min-0, recommended-0, max-0 */
#define tH 480 /* min-480, recommended-480, max-640 */
#define tI 70 /* min-60.3, recommended-70, max-75.3 */
#define tJ 410 /* min-410, recommended-410, max-N/A */
/*---------------------------------------------------------------------------*/
/*
* The delay caused by calling the delay_loop is given by the following
* formula.
* delay(us) = (4n + 1)/XTAL
* where n is the number of iterations and XTAL is the clock frequency(in MHz).
* TODO: Moving the delay_loop to dev/clock.c
*/
static void
delay_loop(uint16_t __count)
{
asm volatile ("1: sbiw %0,1" "\n\t"
"brne 1b"
: "=w" (__count)
: "0" (__count)
);
}
/*---------------------------------------------------------------------------*/
/*
* This macro relies on the compiler doing the arithmetic during compile time
* for the needed iterations.!!
* In MICAz, XTAL = 7.3728 MHz
*/
#define udelay(u) delay_loop(((7.3728F * u)-1)/4)
/*---------------------------------------------------------------------------*/
static uint8_t
reset(void)
{
uint8_t result;
OW_DRIVE();
udelay(500); /* 480 < tH < 640 */
OW_RELEASE(); /* Releases the bus */
udelay(tI);
result = INP();
udelay(tJ);
return result;
}
/*---------------------------------------------------------------------------*/
static void
write_byte(uint8_t byte)
{
uint8_t i = 7;
do {
if (byte & 0x01) {
OW_DRIVE();
udelay(tA);
OW_RELEASE(); /* Releases the bus */
udelay(tB);
} else {
OW_DRIVE();
udelay(tC);
OW_RELEASE(); /* Releases the bus */
udelay(tD);
}
if (i == 0)
return;
i--;
byte >>= 1;
} while (1);
}
/*---------------------------------------------------------------------------*/
static unsigned
read_byte(void)
{
unsigned result = 0;
int i = 7;
do {
OW_DRIVE();
udelay(tA);
OW_RELEASE(); /* Releases the bus */
udelay(tE);
if (INP())
result |= 0x80; /* LSbit first */
udelay(tF);
if (i == 0)
return result;
i--;
result >>= 1;
} while (1);
}
/*---------------------------------------------------------------------------*/
/* Polynomial ^8 + ^5 + ^4 + 1 */
static unsigned
crc8_add(unsigned acc, unsigned byte)
{
int i;
acc ^= byte;
for (i = 0; i < 8; i++)
if (acc & 1)
acc = (acc >> 1) ^ 0x8c;
else
acc >>= 1;
return acc;
}
/*---------------------------------------------------------------------------*/
int
ds2401_init()
{
int i;
uint8_t volatile sreg;
unsigned family, crc, acc;
PIN_INIT();
sreg = SREG; /* Save status register before disabling interrupts. */
cli(); /* Disable interrupts. */
if (reset() == 0) {
write_byte(0x33); /* Read ROM command. */
family = read_byte();
for (i = 7; i >= 2; i--) {
ds2401_id[i] = read_byte();
}
crc = read_byte();
SREG = sreg; /* Enable interrupts. */
if(family != 0x01) {
goto fail;
}
acc = crc8_add(0x0, family);
for (i = 7; i >= 2; i--) {
acc = crc8_add(acc, ds2401_id[i]);
}
if (acc == crc) {
/* 00:1A:4C OUI for Crossbow Technology, Inc. */
ds2401_id[0] = 0x00;
ds2401_id[1] = 0x1A;
ds2401_id[2] = 0x4C;
return 1; /* Success! */
}
} else {
SREG = sreg; /* Enable interrupts. */
}
fail:
memset(ds2401_id, 0x0, sizeof(ds2401_id));
return 0; /* Fail! */
}
/*---------------------------------------------------------------------------*/

View File

@ -1,39 +0,0 @@
/*
* Copyright (c) 2009, University of Colombo School of Computing
* 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 DS2401_H
#define DS2401_H
extern unsigned char ds2401_id[8];
extern int ds2401_init();
#endif /* DS2401_H */

View File

@ -1,67 +0,0 @@
/*
* Copyright (c) 2009, University of Colombo School of Computing
* 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
* LED architecture of the MICAz port.
* \author
* Kasun Hewage <kasun.ch@gmail.com>
*/
#include "contiki-conf.h"
#include "dev/leds.h"
#include <avr/io.h>
/*---------------------------------------------------------------------------*/
void leds_arch_init(void)
{
LEDS_PxDIR |= (LEDS_CONF_RED | LEDS_CONF_GREEN | LEDS_CONF_YELLOW);
LEDS_PxOUT |= (LEDS_CONF_RED | LEDS_CONF_GREEN | LEDS_CONF_YELLOW);
}
/*---------------------------------------------------------------------------*/
unsigned char leds_arch_get(void)
{
return ((LEDS_PxOUT & LEDS_CONF_RED) ? 0 : LEDS_RED)
| ((LEDS_PxOUT & LEDS_CONF_GREEN) ? 0 : LEDS_GREEN)
| ((LEDS_PxOUT & LEDS_CONF_YELLOW) ? 0 : LEDS_YELLOW);
}
/*---------------------------------------------------------------------------*/
void leds_arch_set(unsigned char leds)
{
LEDS_PxOUT = (LEDS_PxOUT & ~(LEDS_CONF_RED|LEDS_CONF_GREEN|LEDS_CONF_YELLOW))
| ((leds & LEDS_RED) ? 0 : LEDS_CONF_RED)
| ((leds & LEDS_GREEN) ? 0 : LEDS_CONF_GREEN)
| ((leds & LEDS_YELLOW) ? 0 : LEDS_CONF_YELLOW);
}
/*---------------------------------------------------------------------------*/

View File

@ -1,103 +0,0 @@
/*
* Copyright (c) 2010, University of Colombo School of Computing.
* 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
* Battery sensor driver.
* \author
* Kasun Hewage <kasun.ch@gmail.com>
*/
#include <avr/io.h>
#include "dev/battery-sensor.h"
#include "dev/adc.h"
#define BAT_MONITOR_PORT PORTF
#define BAT_MONITOR_PIN_MASK _BV(1)
#define BAT_MONITOR_PORT_DDR DDRF
#define BAT_MONITOR_ADC_CHANNEL 30
const struct sensors_sensor battery_sensor;
static uint8_t active;
/*---------------------------------------------------------------------------*/
static void
activate(void)
{
/* This assumes that some other sensor system already did setup the ADC */
adc_init();
/* Enable battery sensor. */
BAT_MONITOR_PORT |= BAT_MONITOR_PIN_MASK;
BAT_MONITOR_PORT_DDR |= BAT_MONITOR_PIN_MASK;
active = 1;
}
/*---------------------------------------------------------------------------*/
static void
deactivate(void)
{
active = 0;
}
/*---------------------------------------------------------------------------*/
static int
value(int type)
{
return get_adc(BAT_MONITOR_ADC_CHANNEL);
}
/*---------------------------------------------------------------------------*/
static int
configure(int type, int c)
{
switch(type) {
case SENSORS_ACTIVE:
if (c) {
activate();
} else {
deactivate();
}
}
return 0;
}
/*---------------------------------------------------------------------------*/
static int
status(int type)
{
switch (type) {
case SENSORS_ACTIVE:
case SENSORS_READY:
return active;
}
return 0;
}
/*---------------------------------------------------------------------------*/
SENSORS_SENSOR(battery_sensor, BATTERY_SENSOR,
value, configure, status);

View File

@ -1,221 +0,0 @@
/*
* Copyright (c) 2009, University of Colombo School of Computing
* 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
* Device drivers implementation for MTS300 sensor board.
* \author
* Kasun Hewage <kasun.ch@gmail.com>
*/
#include "mts300.h"
/*---------------------------------------------------------------------------*/
void
sounder_on()
{ SOUNDER_DDR |= SOUNDER_MASK;
SOUNDER_PORT &= ~SOUNDER_MASK;
SOUNDER_PORT |= SOUNDER_MASK;
}
/*---------------------------------------------------------------------------*/
void
sounder_off()
{
SOUNDER_PORT &= ~(SOUNDER_MASK);
SOUNDER_DDR &= ~(SOUNDER_MASK);
}
/*---------------------------------------------------------------------------*/
void
adc_init()
{
ADMUX = 0;
/* AVCC with external capacitor at AREF pin. */
//ADMUX |= _BV(REFS0)
/* Disable ADC interrupts. */
ADCSRA &= ~( _BV(ADIE) | _BV(ADIF) );
/* Set ADC prescaler to 64 and clear interrupt flag. */
ADCSRA |= _BV(ADPS2) | _BV(ADPS1) | _BV(ADIE);
}
/*---------------------------------------------------------------------------*/
/* Poll based approach. The interrupt based adc is currently not used.
The ADC result is right adjusted. First 8 bits(from left) are in ADCL and
other two bits are in ADCH. See Atmega128 datasheet page 228. */
uint16_t
get_adc(int channel)
{
uint16_t reading;
ADMUX |= (channel & 0x1F);
/* Disable ADC interrupts. */
ADCSRA &= ~_BV(ADIE);
/* Clear previous interrupts. */
ADCSRA |= _BV(ADIF);
/* Enable ADC and start conversion. */
ADCSRA |= _BV(ADEN) | _BV(ADSC);
/* Wait until conversion is completed. */
while ( ADCSRA & _BV(ADSC) );
/* Get first 8 bits. */
reading = ADCL;
/* Get last two bits. */
reading |= (ADCH & 3) << 8;
/* Disable ADC. */
ADCSRA &= ~_BV(ADEN);
return reading;
}
/*---------------------------------------------------------------------------*/
uint16_t
get_light()
{
uint16_t reading;
/* Enable light sensor. */
LIGHT_PORT |= LIGHT_PIN_MASK;
LIGHT_PORT_DDR |= LIGHT_PIN_MASK;
/* Disable temperature sensor. */
TEMP_PORT_DDR &= ~TEMP_PIN_MASK;
TEMP_PORT &= ~TEMP_PIN_MASK;
/* Read ADC. */
reading = get_adc(LIGHT_ADC_CHANNEL);
/* Disable light sensor. */
LIGHT_PORT &= ~LIGHT_PIN_MASK;
LIGHT_PORT_DDR &= ~LIGHT_PIN_MASK;
return reading;
}
/*---------------------------------------------------------------------------*/
uint16_t
get_temp()
{
uint16_t reading;
/* Disable light sensor. */
LIGHT_PORT &= ~LIGHT_PIN_MASK;
LIGHT_PORT_DDR &= ~LIGHT_PIN_MASK;
/* Enable temperature sensor. */
TEMP_PORT_DDR |= TEMP_PIN_MASK;
TEMP_PORT |= TEMP_PIN_MASK;
/* Read ADC. */
reading = get_adc(TEMP_ADC_CHANNEL);
/* Disable temperature sensor. */
TEMP_PORT_DDR &= ~TEMP_PIN_MASK;
TEMP_PORT &= ~TEMP_PIN_MASK;
return reading;
}
/*---------------------------------------------------------------------------*/
uint16_t
get_accx()
{
uint16_t reading;
/* Enable accelerometer. */
ACCEL_PORT_DDR |= ACCEL_PIN_MASK;
ACCEL_PORT |= ACCEL_PIN_MASK;
/* Read ADC. */
reading = get_adc(ACCELX_ADC_CHANNEL);
/* Enable accelerometer. */
ACCEL_PORT_DDR &= ~ACCEL_PIN_MASK;
ACCEL_PORT &= ~ACCEL_PIN_MASK;
return reading;
}
/*---------------------------------------------------------------------------*/
uint16_t
get_accy()
{
uint16_t reading;
/* Enable accelerometer. */
ACCEL_PORT_DDR |= ACCEL_PIN_MASK;
ACCEL_PORT |= ACCEL_PIN_MASK;
/* Read ADC. */
reading = get_adc(ACCELY_ADC_CHANNEL);
/* Enable accelerometer. */
ACCEL_PORT_DDR &= ~ACCEL_PIN_MASK;
ACCEL_PORT &= ~ACCEL_PIN_MASK;
return reading;
}
/*---------------------------------------------------------------------------*/
uint16_t
get_magx()
{
uint16_t reading;
/* Enable magnetometer. */
MAGNET_PORT_DDR |= MAGNET_PIN_MASK;
MAGNET_PORT |= MAGNET_PIN_MASK;
/* Read ADC. */
reading = get_adc(MAGNETX_ADC_CHANNEL);
/* Enable magnetometer. */
MAGNET_PORT_DDR &= ~MAGNET_PIN_MASK;
MAGNET_PORT &= ~MAGNET_PIN_MASK;
return reading;
}
/*---------------------------------------------------------------------------*/
uint16_t
get_magy()
{
uint16_t reading;
/* Enable magnetometer. */
MAGNET_PORT_DDR |= MAGNET_PIN_MASK;
MAGNET_PORT |= MAGNET_PIN_MASK;
/* Read ADC. */
reading = get_adc(MAGNETY_ADC_CHANNEL);
/* Enable magnetometer. */
MAGNET_PORT_DDR &= ~MAGNET_PIN_MASK;
MAGNET_PORT &= ~MAGNET_PIN_MASK;
return reading;
}
/*---------------------------------------------------------------------------*/
uint16_t
get_mic()
{
uint16_t reading;
/* Enable mic. */
MIC_PORT_DDR |= MIC_PIN_MASK;
MIC_PORT |= MIC_PIN_MASK;
/* Read ADC. */
reading = get_adc(MIC_ADC_CHANNEL);
/* Enable mic. */
MIC_PORT_DDR &= ~MIC_PIN_MASK;
MIC_PORT &= ~MIC_PIN_MASK;
return reading;
}
/*---------------------------------------------------------------------------*/

View File

@ -1,112 +0,0 @@
/*
* Copyright (c) 2009, University of Colombo School of Computing
* 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
* Device drivers header file for MTS300 sensor board.
* \author
* Kasun Hewage <kasun.ch@gmail.com>
*/
#ifndef MTS300_H_
#define MTS300_H_
#include <avr/io.h>
#include "contiki-conf.h"
#define SOUNDER_PORT PORTC
#define SOUNDER_MASK _BV(2)
#define SOUNDER_DDR DDRC
/* MTS300CA and MTS310CA, the light sensor power is controlled
* by setting signal INT1(PORTE pin 5).
* Both light and thermistor use the same ADC channel.
*/
#define LIGHT_PORT_DDR DDRE
#define LIGHT_PORT PORTE
#define LIGHT_PIN_MASK _BV(5)
#define LIGHT_ADC_CHANNEL 1
/* MTS300CA and MTS310CA, the thermistor power is controlled
* by setting signal INT2(PORTE pin 6).
* Both light and thermistor use the same ADC channel.
*/
#define TEMP_PORT_DDR DDRE
#define TEMP_PORT PORTE
#define TEMP_PIN_MASK _BV(6)
#define TEMP_ADC_CHANNEL 1
/* Power is controlled to the accelerometer by setting signal
* PW4(PORTC pin 4), and the analog data is sampled on ADC3 and ADC4.
*/
#define ACCEL_PORT_DDR DDRC
#define ACCEL_PORT PORTC
#define ACCEL_PIN_MASK _BV(4)
#define ACCELX_ADC_CHANNEL 3
#define ACCELY_ADC_CHANNEL 4
/* Power is controlled to the magnetometer by setting signal
* PW5(PORTC pin 5), and the analog data is sampled on ADC5 and ADC6.
*/
#define MAGNET_PORT_DDR DDRC
#define MAGNET_PORT PORTC
#define MAGNET_PIN_MASK _BV(5)
#define MAGNETX_ADC_CHANNEL 5
#define MAGNETY_ADC_CHANNEL 6
#define MIC_PORT_DDR DDRC
#define MIC_PORT PORTC
#define MIC_PIN_MASK _BV(3)
#define MIC_ADC_CHANNEL 2
void sounder_on();
void sounder_off();
uint16_t get_light();
uint16_t get_temp();
uint16_t get_accx();
uint16_t get_accy();
uint16_t get_magx();
uint16_t get_magy();
uint16_t get_mic();
void mts300_init();
#endif /* MTS300_H_ */

View File

@ -1,93 +0,0 @@
/*
* Copyright (c) 2010, University of Colombo School of Computing
* 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
* Machine dependent AVR SLIP routines for UART0.
* \author
* Kasun Hewage <kasun.ch@gmail.com>
*/
#include <stdio.h>
#include "contiki.h"
#include "dev/rs232.h"
#include "slip.h"
/*---------------------------------------------------------------------------*/
static int
slip_putchar(char c, FILE *stream)
{
#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((unsigned 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;
}
return c;
}
/*---------------------------------------------------------------------------*/
static FILE slip_stdout = FDEV_SETUP_STREAM(slip_putchar, NULL,
_FDEV_SETUP_WRITE);
/*---------------------------------------------------------------------------*/
void
slip_arch_init(unsigned long ubr)
{
rs232_set_input(RS232_PORT_0, slip_input_byte);
stdout = &slip_stdout;
}
/*---------------------------------------------------------------------------*/
/*
XXX:
Currently, the following function is in cpu/avr/dev/rs232.c file. this
should be moved to here from there hence this is a platform specific slip
related function.
void
slip_arch_writeb(unsigned char c)
{
rs232_send(RS232_PORT_0, c);
}
*/

View File

@ -1,245 +0,0 @@
/*
* Copyright (c) 2010, University of Colombo School of Computing
* 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
* Network initialization for the MICAz port.
* \author
* Kasun Hewage <kasun.ch@gmail.com>
*/
#include <stdio.h>
#include <string.h>
#include <avr/pgmspace.h>
#include "contiki.h"
#include "rf230bb.h"
#include "dev/rs232.h"
#include "dev/slip.h"
#include "dev/leds.h"
#include "net/netstack.h"
#include "net/mac/frame802154.h"
#include "dev/ds2401.h"
#include "sys/node-id.h"
#if WITH_UIP6
#include "net/ipv6/uip-ds6.h"
#endif /* WITH_UIP6 */
#if WITH_UIP
#include "net/ip/uip.h"
#include "net/ipv4/uip-fw.h"
#include "net/uip-fw-drv.h"
#include "net/ipv4/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)};
static uint8_t is_gateway;
#endif /* WITH_UIP */
#define UIP_OVER_MESH_CHANNEL 8
/*---------------------------------------------------------------------------*/
static void
set_rime_addr(void)
{
linkaddr_t addr;
int i;
memset(&addr, 0, sizeof(linkaddr_t));
#if UIP_CONF_IPV6
memcpy(addr.u8, ds2401_id, sizeof(addr.u8));
#else
if(node_id == 0) {
for(i = 0; i < sizeof(linkaddr_t); ++i) {
addr.u8[i] = ds2401_id[7 - i];
}
} else {
addr.u8[0] = node_id & 0xff;
addr.u8[1] = node_id >> 8;
}
#endif
linkaddr_set_node_addr(&addr);
printf_P(PSTR("Rime started with address "));
for(i = 0; i < sizeof(addr.u8) - 1; i++) {
printf_P(PSTR("%d."), addr.u8[i]);
}
printf_P(PSTR("%d\n"), addr.u8[i]);
}
/*--------------------------------------------------------------------------*/
#if WITH_UIP
static void
set_gateway(void)
{
if(!is_gateway) {
leds_on(LEDS_RED);
printf_P(PSTR("%d.%d: making myself the IP network gateway.\n\n"),
linkaddr_node_addr.u8[0], linkaddr_node_addr.u8[1]);
printf_P(PSTR("IPv4 address of the gateway: %d.%d.%d.%d\n\n"),
uip_ipaddr_to_quad(&uip_hostaddr));
uip_over_mesh_set_gateway(&linkaddr_node_addr);
uip_over_mesh_make_announced_gateway();
is_gateway = 1;
}
}
#endif /* WITH_UIP */
/*---------------------------------------------------------------------------*/
void
init_net(void)
{
set_rime_addr();
NETSTACK_RADIO.init();
{
uint8_t longaddr[8];
uint16_t shortaddr;
shortaddr = (linkaddr_node_addr.u8[0] << 8) +
linkaddr_node_addr.u8[1];
memset(longaddr, 0, sizeof(longaddr));
linkaddr_copy((linkaddr_t *)&longaddr, &linkaddr_node_addr);
printf_P(PSTR("MAC %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n"),
longaddr[0], longaddr[1], longaddr[2], longaddr[3],
longaddr[4], longaddr[5], longaddr[6], longaddr[7]);
rf230_set_pan_addr(IEEE802154_PANID, shortaddr, longaddr);
}
rf230_set_channel(RF_CHANNEL);
#if WITH_UIP6
memcpy(&uip_lladdr.addr, ds2401_id, 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_P(PSTR("%s %s, channel check rate %d Hz, radio channel %d\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_P(PSTR("Tentative link-local IPv6 address "));
{
uip_ds6_addr_t *lladdr;
int i;
lladdr = uip_ds6_get_link_local(-1);
for(i = 0; i < 7; ++i) {
printf_P(PSTR("%02x%02x:"), lladdr->ipaddr.u8[i * 2],
lladdr->ipaddr.u8[i * 2 + 1]);
}
printf_P(PSTR("%02x%02x\n"), lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);
}
if(!UIP_CONF_IPV6_RPL) {
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_P(PSTR("Tentative global IPv6 address "));
for(i = 0; i < 7; ++i) {
printf_P(PSTR("%02x%02x:"),
ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]);
}
printf_P(PSTR("%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_P(PSTR("%s %s, channel check rate %d Hz, radio channel %d\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 WITH_UIP
uip_ipaddr_t hostaddr, netmask;
uip_init();
uip_fw_init();
process_start(&tcpip_process, NULL);
process_start(&slip_process, NULL);
process_start(&uip_fw_process, NULL);
slip_set_input_callback(set_gateway);
/* Construct ip address from four bytes. */
uip_ipaddr(&hostaddr, 172, 16, linkaddr_node_addr.u8[0],
linkaddr_node_addr.u8[1]);
/* Construct netmask from four bytes. */
uip_ipaddr(&netmask, 255,255,0,0);
uip_ipaddr_copy(&meshif.ipaddr, &hostaddr);
/* Set the IP address for this host. */
uip_sethostaddr(&hostaddr);
/* Set the netmask for this host. */
uip_setnetmask(&netmask);
uip_over_mesh_set_net(&hostaddr, &netmask);
/* Register slip interface with forwarding module. */
//uip_fw_register(&slipif);
uip_over_mesh_set_gateway_netif(&slipif);
/* Set slip interface to be a default forwarding interface . */
uip_fw_default(&meshif);
uip_over_mesh_init(UIP_OVER_MESH_CHANNEL);
printf_P(PSTR("uIP started with IP address %d.%d.%d.%d\n"),
uip_ipaddr_to_quad(&hostaddr));
#endif /* WITH_UIP */
}
/*---------------------------------------------------------------------------*/

View File

@ -1,46 +0,0 @@
/*
* Copyright (c) 2010, University of Colombo School of Computing
* 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
* Network initialization for the MICAz port.
* \author
* Kasun Hewage <kasun.ch@gmail.com>
*/
#ifndef INIT_NET_H_
#define INIT_NET_H_
void init_net(void);
#endif /* INIT_NET_H_ */

View File

@ -1,63 +0,0 @@
/*
* Copyright (c) 2009, University of Colombo School of Computing
* 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"
uint16_t node_id = 0;
/*---------------------------------------------------------------------------*/
void
node_id_restore(void)
{
uint16_t newid[2];
uint8_t volatile sreg;
sreg = SREG; /* Save status register before disabling interrupts. */
cli(); /* Disable interrupts. */
eeprom_read(EEPROM_NODE_ID_START, (unsigned char *)newid, sizeof(newid));
node_id = (newid[0] == 0xdead) ? newid[1] : 0;
SREG = sreg; /* Enable interrupts. */
}
/*---------------------------------------------------------------------------*/
void
node_id_burn(uint16_t id)
{
uint16_t buffer[2] = { 0xdead, id };
uint8_t volatile sreg;
sreg = SREG; /* Save status register before disabling interrupts. */
cli(); /* Disable interrupts. */
eeprom_write(EEPROM_NODE_ID_START, (unsigned char *)buffer, sizeof(buffer));
SREG = sreg; /* Enable interrupts. */
}
/*---------------------------------------------------------------------------*/

View File

@ -1,134 +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 <nfi@sics.se>
* Joakim Eriksson <joakime@sics.se>
*/
#ifndef PLATFORM_CONF_H_
#define PLATFORM_CONF_H_
/*
* Definitions below are dictated by the hardware and not really
* changeable!
*/
/* Platform name, type, and MCU clock rate */
#define PLATFORM_NAME "Iris"
#define PLATFORM_TYPE IRIS
#ifndef F_CPU
#define F_CPU 8000000UL
#endif
/* 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 128
#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);
/* LED ports */
#define LEDS_PxDIR DDRA // port direction register
#define LEDS_PxOUT PORTA // port register
#define LEDS_CONF_RED 0x04 //red led
#define LEDS_CONF_GREEN 0x02 // green led
#define LEDS_CONF_YELLOW 0x01 // yellow led
/* 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 EEPROM_NODE_ID_START 0x00
#define NETSTACK_CONF_RADIO rf230_driver
/*
* SPI bus configuration for the TMote Sky.
*/
/* SPI input/output registers. */
#define SPI_TXBUF SPDR
#define SPI_RXBUF SPDR
#define BV(bitno) _BV(bitno)
#define SPI_WAITFOREOTx() do { while (!(SPSR & BV(SPIF))); } while (0)
#define SPI_WAITFOREORx() do { while (!(SPSR & BV(SPIF))); } while (0)
#define SCK 1 /* - Output: SPI Serial Clock (SCLK) - ATMEGA128 PORTB, PIN1 */
#define MOSI 2 /* - Output: SPI Master out - slave in (MOSI) - ATMEGA128 PORTB, PIN2 */
#define MISO 3 /* - Input: SPI Master in - slave out (MISO) - ATMEGA128 PORTB, PIN3 */
/*
* 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) )
#define CSN 0
#endif /* PLATFORM_CONF_H_ */