slip-uart1.c

00001 /*
00002  * Copyright (c) 2006, Swedish Institute of Computer Science
00003  * Copyright (c) 2010, Mariano Alvira <mar@devl.org> and other contributors
00004  * to the MC1322x project (http://mc1322x.devl.org) and Contiki.
00005  *
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions
00010  * are met:
00011  * 1. Redistributions of source code must retain the above copyright
00012  *    notice, this list of conditions and the following disclaimer.
00013  * 2. Redistributions in binary form must reproduce the above copyright
00014  *    notice, this list of conditions and the following disclaimer in the
00015  *    documentation and/or other materials provided with the distribution.
00016  * 3. Neither the name of the Institute nor the names of its contributors
00017  *    may be used to endorse or promote products derived from this software
00018  *    without specific prior written permission.
00019  *
00020  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
00021  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00022  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00023  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
00024  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00025  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00026  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00027  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00028  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00029  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00030  * SUCH DAMAGE.
00031  *
00032  * This file is part of the Contiki OS.
00033  *
00034  *
00035  */
00036 
00037 /*
00038  * Machine dependent mc1322x SLIP routines for UART1.
00039  */
00040 
00041 #include "contiki.h"
00042 #include "dev/slip.h"
00043 
00044 #include "mc1322x.h"
00045 
00046 /*---------------------------------------------------------------------------*/
00047 void
00048 slip_arch_writeb(unsigned char c)
00049 {
00050   uart1_putc(c);
00051 }
00052 /*---------------------------------------------------------------------------*/
00053 /*
00054  * The serial line is used to transfer IP packets using slip. To make
00055  * it possible to send debug output over the same line we send debug
00056  * output as slip frames (i.e delimeted by SLIP_END).
00057  *
00058  */
00059 /*---------------------------------------------------------------------------*/
00060 #if WITH_UIP
00061 int
00062 putchar(int c)
00063 {
00064 #define SLIP_END 0300
00065   static char debug_frame = 0;
00066 
00067   if (!debug_frame) {           /* Start of debug output */
00068     slip_arch_writeb(SLIP_END);
00069     slip_arch_writeb('\r');     /* Type debug line == '\r' */
00070     debug_frame = 1;
00071   }
00072 
00073   slip_arch_writeb((char)c);
00074   
00075   /*
00076    * Line buffered output, a newline marks the end of debug output and
00077    * implicitly flushes debug output.
00078    */
00079   if (c == '\n') {
00080     slip_arch_writeb(SLIP_END);
00081     debug_frame = 0;
00082   }
00083 
00084   return c;
00085 }
00086 #endif
00087 /*---------------------------------------------------------------------------*/
00088 /**
00089  * Initalize the RS232 port and the SLIP driver.
00090  *
00091  */
00092 void
00093 slip_arch_init(unsigned long ubr)
00094 {
00095   uart1_set_input(slip_input_byte);
00096 }
00097 /*---------------------------------------------------------------------------*/

Generated on Mon Apr 11 14:23:38 2011 for Contiki 2.5 by  doxygen 1.6.1