rs232.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2005, Swedish Institute of Computer Science
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  * 3. Neither the name of the Institute nor the names of its contributors
00014  *    may be used to endorse or promote products derived from this software
00015  *    without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
00018  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
00021  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00022  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00023  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00024  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00025  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00026  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00027  * SUCH DAMAGE.
00028  *
00029  * This file is part of the Contiki operating system.
00030  *
00031  * @(#)$Id: rs232.h,v 1.6 2009/06/29 12:46:50 nvt-se Exp $
00032  */
00033 
00034 /** \addtogroup esb
00035  * @{ */
00036 
00037 /**
00038  * \defgroup esbrs232 ESB RS232
00039  *
00040  * @{
00041  */
00042 
00043 /**
00044  * \file
00045  * Header file for MSP430 RS232 driver.
00046  * \author Adam Dunkels <adam@sics.se>
00047  *
00048  */
00049 #ifndef __RS232_H__
00050 #define __RS232_H__
00051 
00052 #include "dev/msb430-uart1.h"
00053 
00054 enum rs232_speed {
00055         RS232_9600  =   0,
00056         RS232_19200 =   1,
00057         RS232_38400 =   2,
00058         RS232_57600 =   3,
00059         RS232_115200 =  4
00060 };
00061 
00062 /**
00063  * \brief      Initialize the RS232 module
00064  *
00065  *             This function is called from the boot up code to
00066  *             initalize the RS232 module.
00067  */
00068 void rs232_init(void);
00069 
00070 /**
00071  * \brief      Set an input handler for incoming RS232 data
00072  * \param f    A pointer to a byte input handler
00073  *
00074  *             This function sets the input handler for incoming RS232
00075  *             data. The input handler function is called for every
00076  *             incoming data byte. The function is called from the
00077  *             RS232 interrupt handler, so care must be taken when
00078  *             implementing the input handler to avoid race
00079  *             conditions.
00080  *
00081  *             The return value of the input handler affects the sleep
00082  *             mode of the CPU: if the input handler returns non-zero
00083  *             (true), the CPU is awakened to let other processing
00084  *             take place. If the input handler returns zero, the CPU
00085  *             is kept sleeping.
00086  */
00087 void rs232_set_input(uart_handler_t f);
00088 
00089 /**
00090  * \brief      Configure the speed of the RS232 hardware
00091  * \param speed The speed
00092  *
00093  *             This function configures the speed of the RS232
00094  *             hardware. The allowed parameters are RS232_9600,
00095  *             RS232_19200, RS232_38400, RS232_57600, and RS232_115200.
00096  */
00097 void rs232_set_speed(enum rs232_speed speed);
00098 
00099 /**
00100  * \brief      Print a text string on RS232
00101  * \param str  A pointer to the string that is to be printed
00102  *
00103  *             This function prints a string to RS232. The string must
00104  *             be terminated by a null byte. The RS232 module must be
00105  *             correctly initalized and configured for this function
00106  *             to work.
00107  */
00108 void rs232_print(char *text);
00109 
00110 /**
00111  * \brief      Print a character on RS232
00112  * \param c    The character to be printed
00113  *
00114  *             This function prints a character to RS232. The RS232
00115  *             module must be correctly initalized and configured for
00116  *             this function to work.
00117  */
00118 void rs232_send(char c);
00119 
00120 #endif /* __RS232_H__ */
00121 
00122 /** @} */
00123 /** @} */

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