merge iris and micaz

This commit is contained in:
HATATANI Shinta 2011-07-17 10:36:35 +09:00
parent e6d5ff2f18
commit 3c168cc395
6 changed files with 97 additions and 15 deletions

View File

@ -5,22 +5,43 @@ CONTIKI_TARGET_MAIN = ${CONTIKI_CORE}.o
SENSOR_BOARD_SOURCEFILES = mts300.c
CONTIKI_TARGET_SOURCEFILES += adc.c rs232.c cfs-eeprom.c contiki-micaz-main.c \
leds-arch.c cc2420.c init-net.c node-id.c \
clock.c spi.c cc2420-arch.c rtimer-arch.c ds2401.c \
leds-arch.c init-net.c node-id.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=.
# MicaZ runs on Clock rate 7.3728 MHz
CONTIKI_PLAT_DEFS = -DF_CPU=7372800UL -DAUTO_CRC_PADDING=2
MCU=atmega128
ifeq ($(SUBTARGET),)
SUBTARGET=MICAZ
endif
CFLAGS += -DSUBTARGET=$(SUBTARGET)
include $(CONTIKIAVR)/Makefile.avr
ifeq ($(SUBTARGET),MICAZ)
CONTIKI_TARGET_SOURCEFILES += cc2420.c cc2420-arch.c clock-micaz.c
# MicaZ runs on Clock rate 7.3728 MHz
CONTIKI_PLAT_DEFS = -DF_CPU=7372800UL -DAUTO_CRC_PADDING=2
MCU=atmega128
endif
ifeq ($(SUBTARGET),IRIS)
CONTIKI_TARGET_SOURCEFILES += clock.c
# IRIS runs on Clock rate 8 MHz
CONTIKI_PLAT_DEFS = -DF_CPU=8000000UL -DAUTO_CRC_PADDING=2 #-DUSART_BAUD_115200
MCU=atmega1281
include $(CONTIKIAVR)/radio/Makefile.radio
endif
AVRDUDE_OPTIONS=-V
AVRDUDE_PROGRAMMER=mib510
#AVRDUDE_PROGRAMMER=jtag2
#AVRDUDE_PORT=usb
AVRDUDE_PORT=$(PORT)
%.od: %.$(TARGET)
avr-objdump -zhD $< > $@
@ -40,7 +61,8 @@ endif
ifeq ($(PORT), )
ifndef WINDIR
PORT = /dev/ttyS0
#PORT = /dev/ttyS0
PORT = /dev/ttyUSB0
else
PORT = COM1
endif
@ -53,3 +75,7 @@ ifneq ($(strip $(HAVE_PRGBOARD_FILE)), )
include $(PRGBOARD_FILE)
endif
ifdef UIP_CONF_IPV6
CFLAGS += -DWITH_UIP6=1
endif

View File

@ -55,7 +55,11 @@
#define NETSTACK_CONF_RDC nullrdc_driver
#define NETSTACK_CONF_FRAMER framer_802154
#if SUBTARGET == MICAZ
#define CC2420_CONF_AUTOACK 1
#elif SUBTARGET == IRIS
#define RF230_CONF_AUTOACK 1
#endif
#define MAC_CONF_CHANNEL_CHECK_RATE 8
#define RIME_CONF_NO_POLITE_ANNOUCEMENTS 0
#define CXMAC_CONF_ANNOUNCEMENTS 0
@ -69,7 +73,11 @@
#define NETSTACK_CONF_RDC cxmac_driver
#define NETSTACK_CONF_FRAMER framer_802154
#if SUBTARGET == MICAZ
#define CC2420_CONF_AUTOACK 1
#elif SUBTARGET == IRIS
#define RF230_CONF_AUTOACK 1
#endif
#define MAC_CONF_CHANNEL_CHECK_RATE 8
#define COLLECT_CONF_ANNOUNCEMENTS 1
@ -158,15 +166,19 @@
#endif
#define TIMESYNCH_CONF_ENABLED 1
#define CC2420_CONF_TIMESTAMPS 1
#if SUBTARGET == MICAZ
#define CC2420_CONF_TIMESTAMPS 0
#define CC2420_CONF_SYMBOL_LOOP_COUNT 500
#elif SUBTARGET == IRIS
#define RF230_CONF_TIMESTAMPS 0
#define RF230_CONF_SYMBOL_LOOP_COUNT 500
#endif
#define WITH_NULLMAC 0
#define CCIF
#define CLIF
/* The process names are not used to save RAM */
#define PROCESS_CONF_NO_PROCESS_NAMES 1
#define UIP_CONF_ICMP_DEST_UNREACH 1
@ -198,4 +210,8 @@ void clock_wait(int ms10);
void clock_set_seconds(unsigned long s);
unsigned long clock_seconds(void);
#ifdef PROJECT_CONF_H
#include PROJECT_CONF_H
#endif /* PROJECT_CONF_H */
#endif /* __CONTIKI_CONF_H__ */

View File

@ -51,6 +51,7 @@
#include "dev/watchdog.h"
#include "dev/slip.h"
#include "dev/serial-line.h"
#include "init-net.h"
#include "dev/ds2401.h"
#include "node-id.h"
@ -105,6 +106,11 @@ main(void)
leds_on(LEDS_YELLOW);
init_net();
#if !WITH_UIP && !WITH_UIP6
rs232_set_input(RS232_PORT_0, serial_line_input_byte);
serial_line_init();
#endif
printf_P(PSTR(CONTIKI_VERSION_STRING " started. Node id %u\n"), node_id);

View File

@ -43,12 +43,22 @@
#include <avr/pgmspace.h>
#include "contiki.h"
#include "dev/cc2420.h"
#include "dev/rs232.h"
#include "dev/slip.h"
#include "dev/leds.h"
#include "net/netstack.h"
#include "net/mac/frame802154.h"
#if SUBTARGET == MICAZ
#include "dev/cc2420.h"
#define INIT_NET_INIT cc2420_init
#define INIT_NET_SET_PAN_ADDR cc2420_set_pan_addr
#define INIT_NET_SET_CHANNEL cc2420_set_channel
#elif SUBTARGET == IRIS
#include "rf230bb.h"
#define INIT_NET_INIT rf230_init
#define INIT_NET_SET_PAN_ADDR rf230_set_pan_addr
#define INIT_NET_SET_CHANNEL rf230_set_channel
#endif
#include "dev/ds2401.h"
#include "node-id.h"
@ -124,7 +134,7 @@ init_net(void)
{
set_rime_addr();
cc2420_init();
INIT_NET_INIT();
{
uint8_t longaddr[8];
uint16_t shortaddr;
@ -137,9 +147,9 @@ init_net(void)
longaddr[0], longaddr[1], longaddr[2], longaddr[3],
longaddr[4], longaddr[5], longaddr[6], longaddr[7]);
cc2420_set_pan_addr(IEEE802154_PANID, shortaddr, longaddr);
INIT_NET_SET_PAN_ADDR(IEEE802154_PANID, shortaddr, longaddr);
}
cc2420_set_channel(RF_CHANNEL);
INIT_NET_SET_CHANNEL(RF_CHANNEL);
#if WITH_UIP6

View File

@ -40,17 +40,32 @@
#ifndef __PLATFORM_CONF_H__
#define __PLATFORM_CONF_H__
#define MICAZ 1
#define IRIS 2
#ifndef SUBTARGET
# define SUBTARGET MICAZ
#endif
/*
* Definitions below are dictated by the hardware and not really
* changeable!
*/
#define PLATFORM PLATFORM_AVR
#if SUBTARGET == IRIS
#define HARWARE_REVISION IRIS
#endif
/*
* MCU and clock rate.
* MICAZ runs on 7.3728 MHz clock.
* IRIS runs on 8 MHz clock.
*/
#if SUBTARGET == MICAZ
#define MCU_MHZ 7
#elif SUBTARGET == IRIS
#define MCU_MHZ 8
#endif
/* Clock ticks per second */
#define CLOCK_CONF_SECOND 128
@ -77,7 +92,11 @@
#define EEPROM_NODE_ID_START 0x00
#if SUBTARGET == MICAZ
#define NETSTACK_CONF_RADIO cc2420_driver
#elif SUBTARGET == IRIS
#define NETSTACK_CONF_RADIO rf230_driver
#endif
/*
@ -113,6 +132,7 @@
#define SPI_FLASH_HOLD() ( P4OUT &= ~BV(FLASH_HOLD) )
#define SPI_FLASH_UNHOLD() ( P4OUT |= BV(FLASH_HOLD) )
#if SUBTARGET == MICAZ
/*
* SPI bus - CC2420 pin configuration.
*/
@ -128,7 +148,6 @@
#define CCA 6
#define SFD 4
#define CSN 0
#define VREG_EN 5
#define RESET_N 6
@ -192,4 +211,9 @@
#define CC2420_SPI_ENABLE() (PORTB &= ~BV(CSN)) /* ENABLE CSn (active low) */
#define CC2420_SPI_DISABLE() (PORTB |= BV(CSN)) /* DISABLE CSn (active low) */
#endif /* SUBTARGET == MICAZ */
/* In iris, only CSN is necessary */
#define CSN 0
#endif /* __PLATFORM_CONF_H__ */