2009-09-08 10:59:29 +02:00
|
|
|
/*
|
|
|
|
* 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>
|
2010-09-20 20:07:25 +02:00
|
|
|
#include <avr/pgmspace.h>
|
2009-09-08 10:59:29 +02:00
|
|
|
|
|
|
|
#include "contiki.h"
|
|
|
|
#include "contiki-lib.h"
|
2010-09-20 20:07:25 +02:00
|
|
|
#include "net/rime.h"
|
2009-09-08 10:59:29 +02:00
|
|
|
#include "dev/leds.h"
|
|
|
|
#include "dev/rs232.h"
|
|
|
|
#include "dev/watchdog.h"
|
2010-09-20 20:07:25 +02:00
|
|
|
#include "dev/slip.h"
|
2009-09-08 10:59:29 +02:00
|
|
|
|
2010-09-20 20:07:25 +02:00
|
|
|
#include "init-net.h"
|
|
|
|
#include "dev/ds2401.h"
|
2012-11-20 19:57:20 +01:00
|
|
|
#include "sys/node-id.h"
|
2009-09-08 10:59:29 +02:00
|
|
|
|
2010-09-20 20:07:25 +02:00
|
|
|
/*---------------------------------------------------------------------------*/
|
2009-09-08 10:59:29 +02:00
|
|
|
void
|
|
|
|
init_usart(void)
|
|
|
|
{
|
2009-10-22 17:48:20 +02:00
|
|
|
/* First rs232 port for debugging */
|
2009-09-08 10:59:29 +02:00
|
|
|
rs232_init(RS232_PORT_0, USART_BAUD_115200,
|
|
|
|
USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);
|
|
|
|
|
2010-09-20 20:07:25 +02:00
|
|
|
#if WITH_UIP || WITH_UIP6
|
2012-04-09 21:49:53 +02:00
|
|
|
// slip_arch_init(USART_BAUD_115200);
|
|
|
|
rs232_redirect_stdout(RS232_PORT_0);
|
2010-09-20 20:07:25 +02:00
|
|
|
#else
|
2009-09-08 10:59:29 +02:00
|
|
|
rs232_redirect_stdout(RS232_PORT_0);
|
2010-09-20 20:07:25 +02:00
|
|
|
#endif /* WITH_UIP */
|
2009-09-08 10:59:29 +02:00
|
|
|
|
|
|
|
}
|
2010-09-20 20:07:25 +02:00
|
|
|
/*---------------------------------------------------------------------------*/
|
2009-09-08 10:59:29 +02:00
|
|
|
int
|
|
|
|
main(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
leds_init();
|
|
|
|
|
2009-09-13 23:42:43 +02:00
|
|
|
leds_on(LEDS_RED);
|
2009-09-08 10:59:29 +02:00
|
|
|
|
|
|
|
/* Initialize USART */
|
|
|
|
init_usart();
|
|
|
|
|
|
|
|
/* Clock */
|
|
|
|
clock_init();
|
|
|
|
|
2009-09-13 23:42:43 +02:00
|
|
|
leds_on(LEDS_GREEN);
|
|
|
|
|
|
|
|
ds2401_init();
|
2010-09-20 20:07:25 +02:00
|
|
|
|
|
|
|
node_id_restore();
|
2009-09-13 23:42:43 +02:00
|
|
|
|
2010-09-20 20:07:25 +02:00
|
|
|
random_init(ds2401_id[0] + node_id);
|
2009-09-08 10:59:29 +02:00
|
|
|
|
|
|
|
rtimer_init();
|
|
|
|
|
|
|
|
/* Process subsystem */
|
|
|
|
process_init();
|
|
|
|
|
|
|
|
process_start(&etimer_process, NULL);
|
|
|
|
|
|
|
|
ctimer_init();
|
|
|
|
|
2009-09-13 23:42:43 +02:00
|
|
|
leds_on(LEDS_YELLOW);
|
2012-04-09 21:49:53 +02:00
|
|
|
|
2009-09-08 10:59:29 +02:00
|
|
|
init_net();
|
2009-09-24 08:53:35 +02:00
|
|
|
|
2010-09-20 20:07:25 +02:00
|
|
|
printf_P(PSTR(CONTIKI_VERSION_STRING " started. Node id %u\n"), node_id);
|
2009-09-08 10:59:29 +02:00
|
|
|
|
|
|
|
leds_off(LEDS_ALL);
|
|
|
|
|
|
|
|
/* Autostart processes */
|
|
|
|
autostart_start(autostart_processes);
|
|
|
|
|
|
|
|
/* Main scheduler loop */
|
|
|
|
do {
|
|
|
|
|
|
|
|
process_run();
|
|
|
|
|
|
|
|
}while(1);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|