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.5 2010/12/03 21:39:33 dak664 Exp $
33  *
34  */
35 
36 #include "contiki.h"
37 #include "contiki-net.h"
38 
39 #include "dev/rs232.h"
40 #include "dev/rtl8019-drv.h"
41 
42 #include <avr/interrupt.h>
43 #include <avr/io.h>
44 #include <avr/pgmspace.h>
45 
46 PROCINIT(&etimer_process, &tcpip_process, &rtl8019_process);
47 
48 static const struct uip_eth_addr ethaddr = {{0x00,0x06,0x98,0x01,0x02,0x29}};
49 
50 int
51 main(void)
52 {
53  uip_ipaddr_t addr;
54 
55  /*
56  * GCC depends on register r1 set to 0.
57  */
58  asm volatile ("clr r1");
59 
60  /*
61  * No interrupts used.
62  */
63  cli();
64 
65  /*
66  * Enable external data and address
67  * bus.
68  */
69  MCUCR = _BV(SRE) | _BV(SRW);
70 
71  clock_init();
72  rs232_init(RS232_PORT_0, USART_BAUD_57600,USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);
73 
74  sei();
75 
76 
77  process_init();
78 
79  uip_ipaddr(&addr, 193,10,67,152);
80  uip_sethostaddr(&addr);
81 
82  uip_setethaddr(ethaddr);
83 
84  procinit_init();
85 
86  autostart_start(autostart_processes);
87 
88  rs232_print(RS232_PORT_0, "Initialized\n");
89 
90  while(1) {
91  process_run();
92  }
93 
94  return 0;
95 }
96 
97 int
98 putchar(int c)
99 {
100  rs232_send(RS232_PORT_0, c);
101  return c;
102 }