Contiki 2.5
ethernut-main.c
1 
2 /* Copyright (c) 2005, Swedish Institute of Computer Science
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following
12  * disclaimer in the documentation and/or other materials provided
13  * with the distribution.
14  * 3. The name of the author may not be used to endorse or promote
15  * products derived from this software without specific prior
16  * written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
19  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
24  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  *
30  * This file is part of the Contiki OS
31  *
32  * $Id: ethernut-main.c,v 1.4 2010/12/03 21:39:33 dak664 Exp $
33  *
34  */
35 
36 #include "contiki.h"
37 #include "contiki-net.h"
38 #include "dev/serial-line.h"
39 #include "dev/slip.h"
40 #include "dev/rs232.h"
41 
42 #include <avr/interrupt.h>
43 /*static void setup_xram(void) __attribute__ ((naked)) \
44  __attribute__ ((section (".init1")));
45 
46 static void
47 setup_xram(void)
48 {
49  outp(BV(SRE) | BV(SRW), MCUCR);
50 }*/
51 
52 static struct uip_fw_netif slipif =
53  {UIP_FW_NETIF(0,0,0,0, 0,0,0,0, slip_send)};
54 
55 PROCESS(serial_test, "Serial test");
56 
57 PROCESS_THREAD(serial_test, ev, data)
58 {
59  PROCESS_BEGIN();
60 
61  while(1) {
62  PROCESS_WAIT_EVENT_UNTIL(ev == serial_line_event_message);
63  rs232_print(RS232_PORT_0, data);
64  }
65  PROCESS_END();
66 }
67 
68 PROCINIT(&etimer_process, &serial_line_process, &slip_process,
69  &uip_fw_process);
70 
71 int
72 main(void)
73 {
74  uip_ipaddr_t addr;
75 
76  clock_init();
77  rs232_init(RS232_PORT_0, USART_BAUD_57600,USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);
78  rs232_set_input(RS232_PORT_0, slip_input_byte);
79 
80  sei();
81 
82  /* Initialize drivers and event kernal */
83  process_init();
84 
85  uip_ipaddr(&addr, 172,16,0,2);
86  uip_sethostaddr(&addr);
87 
88  procinit_init();
89  autostart_start(autostart_processes);
90  uip_fw_default(&slipif);
91 
92  rs232_print_p(RS232_PORT_0, PSTR("Initialized\n"));
93 
94  while(1) {
95  process_run();
96  }
97 
98  return 0;
99 }