contiki-rcb-main.c
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include <avr/pgmspace.h>
00035 #include <avr/fuse.h>
00036 #include <avr/eeprom.h>
00037 #include <stdio.h>
00038
00039 #include "lib/mmem.h"
00040 #include "loader/symbols-def.h"
00041 #include "loader/symtab.h"
00042
00043 #if RF230BB //radio driver using contiki core mac
00044 #include "radio/rf230bb/rf230bb.h"
00045 #include "net/mac/frame802154.h"
00046 #include "net/mac/framer-802154.h"
00047 #include "net/sicslowpan.h"
00048 #else //radio driver using Atmel/Cisco 802.15.4'ish MAC
00049 #include <stdbool.h>
00050 #include "mac.h"
00051 #include "sicslowmac.h"
00052 #include "sicslowpan.h"
00053 #include "ieee-15-4-manager.h"
00054 #endif
00055
00056 #include "contiki.h"
00057 #include "contiki-net.h"
00058 #include "contiki-lib.h"
00059
00060 #include "dev/rs232.h"
00061 #include "dev/serial-line.h"
00062 #include "dev/slip.h"
00063
00064
00065 #include "sicslowmac.h"
00066
00067 FUSES =
00068 {
00069 .low = 0xe2,
00070 .high = 0x99,
00071 .extended = 0xff,
00072 };
00073
00074 PROCESS(rcb_leds, "RCB leds process");
00075
00076 #if RF230BB
00077 PROCINIT(&etimer_process, &tcpip_process, &rcb_leds);
00078 #else
00079 PROCINIT(&etimer_process, &mac_process, &tcpip_process, &rcb_leds);
00080 #endif
00081
00082
00083 uint8_t mac_address[8] EEMEM = {0x02, 0x11, 0x22, 0xff, 0xfe, 0x33, 0x44, 0x55};
00084
00085 #define LED1 (1<<PE2)
00086 #define LED2 (1<<PE3)
00087 #define LED3 (1<<PE4)
00088
00089 #define LEDOff(x) (PORTE |= (x))
00090 #define LEDOn(x) (PORTE &= ~(x))
00091
00092
00093 void
00094 init_lowlevel(void)
00095 {
00096
00097 rs232_init(RS232_PORT_1, USART_BAUD_57600,
00098 USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);
00099
00100
00101 rs232_redirect_stdout(RS232_PORT_1);
00102
00103 DDRE |= LED1 | LED2 | LED3;
00104 }
00105
00106
00107 static struct etimer et;
00108 PROCESS_THREAD(rcb_leds, ev, data)
00109 {
00110 u8_t error;
00111
00112 PROCESS_BEGIN();
00113
00114 if((error = icmp6_new(NULL)) == 0) {
00115 while(1) {
00116 PROCESS_YIELD();
00117
00118 #if UIP_CONF_IPV6
00119 if (ev == ICMP6_ECHO_REQUEST) {
00120 #else
00121 if (1) {
00122 #endif
00123 LEDOn(LED2);
00124 etimer_set(&et, CLOCK_SECOND/10);
00125 } else {
00126 LEDOff(LED2);
00127 }
00128 }
00129 }
00130 PROCESS_END();
00131 }
00132
00133
00134 int
00135 main(void)
00136 {
00137
00138
00139
00140 init_lowlevel();
00141
00142
00143 clock_init();
00144
00145 LEDOff(LED1 | LED2);
00146
00147
00148 process_init();
00149
00150
00151 procinit_init();
00152
00153
00154 autostart_start(autostart_processes);
00155
00156 printf_P(PSTR("\n********BOOTING CONTIKI*********\n"));
00157
00158 printf_P(PSTR("System online.\n"));
00159
00160
00161 while(1) {
00162 process_run();
00163 }
00164
00165 return 0;
00166 }