diff --git a/platform/avr-rcb/Makefile.avr-rcb b/platform/avr-rcb/Makefile.avr-rcb new file mode 100644 index 000000000..d9b2f5b88 --- /dev/null +++ b/platform/avr-rcb/Makefile.avr-rcb @@ -0,0 +1,38 @@ +CONTIKI_TARGET_DIRS = . rf230 apps net loader +CONTIKI_CORE=contiki-rcb-main +CONTIKI_TARGET_MAIN = ${CONTIKI_CORE}.o + +CONTIKI_TARGET_SOURCEFILES += rs232.c cfs-eeprom.c eeprom.c random.c \ + mmem.c contiki-rcb-main.c + +CONTIKIAVR=$(CONTIKI)/cpu/avr +CONTIKIBOARD=. + +CONTIKI_PLAT_DEFS = -DF_CPU=8000000UL -DAUTO_CRC_PADDING=2 + +MCU=atmega1281 +AVRDUDE_PROGRAMMER=jtag2 + +# For usb devices, you may either use PORT=usb, or (e.g. if you have more than one +# programmer connected) you can use the following trick to find out the serial number: +# +# The example is for an JTAGICE mkII used to program an ATmega128: +# avrdude -v -P usb:xxxx -c jtag2 -p atmega128 +AVRDUDE_PORT=usb:00B000000D79 + + +# Additional avrdude options +# Verify off +AVRDUDE_OPTIONS=-V + + +include $(CONTIKIAVR)/Makefile.avr + +# Source for AT86RF230 +include $(CONTIKI)/cpu/avr/radio/rf230/Makefile.rf230 + +# Source for Atmel/Cisco 802.15.4'ish MAC +include $(CONTIKI)/cpu/avr/radio/mac/Makefile.mac + +# Source for IEEE 802.15.4 manager interface +include $(CONTIKI)/cpu/avr/radio/ieee-manager/Makefile.ieee-manager diff --git a/platform/avr-rcb/contiki-conf.h b/platform/avr-rcb/contiki-conf.h new file mode 100644 index 000000000..84fde83f9 --- /dev/null +++ b/platform/avr-rcb/contiki-conf.h @@ -0,0 +1,126 @@ +/* + * 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 RCB_REVISION RCB_B + +/* Clock ticks per second */ +#define CLOCK_CONF_SECOND 125 + +/* 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 + +#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 0 + +#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-rcb/contiki-rcb-main.c b/platform/avr-rcb/contiki-rcb-main.c new file mode 100644 index 000000000..4cd1b6ba4 --- /dev/null +++ b/platform/avr-rcb/contiki-rcb-main.c @@ -0,0 +1,151 @@ +/* + * 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 + +#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 = 0xe2, + .high = 0x99, + .extended = 0xff, + }; + +PROCESS(rcb_leds, "RCB leds process"); + +PROCINIT(&etimer_process, &mac_process, &tcpip_process, &rcb_leds); + +/* Put default MAC address in EEPROM */ +uint8_t mac_address[8] EEMEM = {0x02, 0x11, 0x22, 0xff, 0xfe, 0x33, 0x44, 0x55}; + +#define LED1 (1< + */ +#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};