Contiki 2.6

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.2 2007/03/25 17:20:43 adamdunkels 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 
00053 #define RS232_19200 1
00054 #define RS232_38400 2
00055 #define RS232_57600 3
00056 #define RS232_115200 4
00057 
00058 /**
00059  * \brief      Initialize the RS232 module
00060  *
00061  *             This function is called from the boot up code to
00062  *             initalize the RS232 module.
00063  */
00064 void rs232_init(void);
00065 
00066 /**
00067  * \brief      Set an input handler for incoming RS232 data
00068  * \param f    A pointer to a byte input handler
00069  *
00070  *             This function sets the input handler for incoming RS232
00071  *             data. The input handler function is called for every
00072  *             incoming data byte. The function is called from the
00073  *             RS232 interrupt handler, so care must be taken when
00074  *             implementing the input handler to avoid race
00075  *             conditions.
00076  *
00077  *             The return value of the input handler affects the sleep
00078  *             mode of the CPU: if the input handler returns non-zero
00079  *             (true), the CPU is awakened to let other processing
00080  *             take place. If the input handler returns zero, the CPU
00081  *             is kept sleeping.
00082  */
00083 void rs232_set_input(int (* f)(unsigned char));
00084 
00085 /**
00086  * \brief      Configure the speed of the RS232 hardware
00087  * \param speed The speed
00088  *
00089  *             This function configures the speed of the RS232
00090  *             hardware. The allowed parameters are RS232_19200,
00091  *             RS232_38400, RS232_57600, and RS232_115200.
00092  */
00093 void rs232_set_speed(unsigned char speed);
00094 
00095 /**
00096  * \brief      Print a text string on RS232
00097  * \param str  A pointer to the string that is to be printed
00098  *
00099  *             This function prints a string to RS232. The string must
00100  *             be terminated by a null byte. The RS232 module must be
00101  *             correctly initalized and configured for this function
00102  *             to work.
00103  */
00104 void rs232_print(char *str);
00105 
00106 /**
00107  * \brief      Print a character on RS232
00108  * \param c    The character to be printed
00109  *
00110  *             This function prints a character to RS232. The RS232
00111  *             module must be correctly initalized and configured for
00112  *             this function to work.
00113  */
00114 void rs232_send(char c);
00115 
00116 #endif /* __RS232_H__ */
00117 
00118 /** @} */
00119 /** @} */