Contiki 2.6

msb430-slip-arch.c

00001 #include "dev/msb430-uart1.h"
00002 #include "dev/rs232.h"
00003 #include "sys/clock.h"
00004 #include "dev/slip.h"
00005 
00006 
00007 void
00008 slip_arch_writeb(unsigned char c)
00009 {
00010   rs232_send(c);
00011 }
00012 /*---------------------------------------------------------------------------*/
00013 
00014 /*
00015  * The serial line is used to transfer IP packets using slip. To make
00016  * it possible to send debug output over the same line we send debug
00017  * output as slip frames (i.e delimeted by SLIP_END).
00018  *
00019  */
00020 int
00021 putchar(int c)
00022 {
00023 #define SLIP_END 0300
00024   static char debug_frame = 0;
00025 
00026   if(!debug_frame) {            /* Start of debug output */
00027     slip_arch_writeb(SLIP_END);
00028     slip_arch_writeb('\r');     /* Type debug line == '\r' */
00029     debug_frame = 1;
00030   }
00031 
00032   slip_arch_writeb((char)c);
00033   
00034   /*
00035    * Line buffered output, a newline marks the end of debug output and
00036    * implicitly flushes debug output.
00037    */
00038   if(c == '\n') {
00039     slip_arch_writeb(SLIP_END);
00040     debug_frame = 0;
00041   }
00042 
00043   clock_delay(100);
00044 
00045   return c;
00046 }
00047 
00048 /**
00049  * Initalize the RS232 port and the SLIP driver.
00050  *
00051  */
00052 void
00053 slip_arch_init(unsigned long ubr)
00054 {
00055   rs232_set_input(slip_input_byte);
00056 }