/*
Copyright 2007, Freie Universitaet Berlin. All rights reserved.

These sources were developed at the Freie Universität Berlin, Computer
Systems and Telematics group.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

- Neither the name of Freie Universitaet Berlin (FUB) nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

This software is provided by FUB and the contributors on an "as is"
basis, without any representations or warranties of any kind, express
or implied including, but not limited to, representations or
warranties of non-infringement, merchantability or fitness for a
particular purpose. In no event shall FUB or contributors be liable
for any direct, indirect, incidental, special, exemplary, or
consequential damages (including, but not limited to, procurement of
substitute goods or services; loss of use, data, or profits; or
business interruption) however caused and on any theory of liability,
whether in contract, strict liability, or tort (including negligence
or otherwise) arising in any way out of the use of this software, even
if advised of the possibility of such damage.

This implementation was developed by the CST group at the FUB.

For documentation and questions please use the web site
http://scatterweb.mi.fu-berlin.de and the mailinglist
scatterweb@lists.spline.inf.fu-berlin.de (subscription via the Website).
Berlin, 2007
*/

/**
 * @file ScatterWeb.Comm.h
 * @ingroup kernel
 * @brief The ScatterWeb.Comm consists all of the fuctions that constitute
 * the serial architecture.
 *
 *
 * @version       $Rev: 273 $
 * @since         1.0
 */

#ifndef ScatterWeb_Comm
#define ScatterWeb_Comm

/**
 * @brief	Available baudrate configurations for RS232 communication
 */
enum comm_bps {
	BPS_2400       = 0,
	BPS_4800       = 1,
	BPS_9600       = 2,
	BPS_14400      = 3,
	BPS_19200      = 4,
	BPS_38400      = 5,
	BPS_57600      = 6,
	BPS_115200     = 7
};

/**
 * @brief		Set speed for RS232 communication
 * @param		bps		see enum comm_bps for available baudrates
 * @return      <code>True</code> always.
 */
bool Comm_setSpeed(enum comm_bps bps);

/**
 @brief		Initializes the RS232 module.

 @return	<code>True</code> always.

 @since		1.0
 */
bool Comm_init();

/**
 * @brief		Write one byte to the RS232 interface
 * @param[in]	data	one byte of data
 *
 * @note		No data is written if UART is not in RS232 mode
 */
int Comm_writer(int data);

/**
 * @brief		Write a number of bytes to the RS232 interface
 * @param[in]	data	Pointer to byte array to send
 * @param[in]	n		Number of bytes to send
 *
 * @note		No data is written if UART is not in RS232 mode
 */
void Comm_writeChars(const char* data, const int n);

/**
 * Sends bytes of data
 *
 * @param fmt     function
 * @param ...     list of parameters
 * @return        <code>True</code> always.
 * @since         1.0
 */
bool Comm_printf(const char *fmt, ...);

/*
 @brief	This member supports the ScatterWeb infrastructure and is not intended to be used directly from your code.

 @since	1.0
 */
void Comm_clear();

#endif
