373a8c32b2
git-svn-id: file:///srv/dev-disk-by-uuid-17e88007-4d0c-45e0-8757-cacfcc458630/repositories/svn/Diplomarbeit@55 9fe90eed-be63-e94b-8204-d34ff4c2ff93
126 lines
4.2 KiB
C
126 lines
4.2 KiB
C
/* ---------------------------------------------------------------------------
|
|
* serial.h - v0.1 (c) 2007 Micro-key bv
|
|
* ---------------------------------------------------------------------------
|
|
* Micro-key bv
|
|
* Industrieweg 28, 9804 TG Noordhorn
|
|
* Postbus 92, 9800 AB Zuidhorn
|
|
* The Netherlands
|
|
* Tel: +31 594 503020
|
|
* Fax: +31 594 505825
|
|
* Email: support@microkey.nl
|
|
* Web: www.microkey.nl
|
|
* ---------------------------------------------------------------------------
|
|
* Description: RS232 interface.
|
|
* ---------------------------------------------------------------------------
|
|
* Version(s): 0.1, 10-09-2007, Marcel Mulder.
|
|
* Creation.
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
#ifndef __SERIAL_H__
|
|
#define __SERIAL_H__
|
|
|
|
/** \file serial.h
|
|
\brief RS232 (UART) interface.
|
|
*/
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
* System include files.
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
* Application include files.
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
#include "sys_config.h"
|
|
#include "lpc23xx.h"
|
|
#include "types.h"
|
|
#include "uart.h"
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
* Constant and macro definitions.
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
* Type definitions.
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
typedef enum
|
|
{
|
|
COM1, /**< First RS232 port*/
|
|
COM2 /**< Second RS232 port*/
|
|
} t_serial_devices;
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
* Variable declarations.
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
* Function declarations.
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
/** \brief Initialize of serial interface.*/
|
|
void serInit (
|
|
t_serial_devices device,
|
|
UINT16 baudrate, /**< baudrate: B1200, B9600, B19200, B38400, B57600, B115200*/
|
|
UINT8 mode, /**< mode: UART_8N1, UART_7N1, UART_8N2, UART_7N2, UART_8E1,
|
|
UART_7E1, UART_8E2, UART_7E2, UART_8O1, UART_7O1,
|
|
UART_8O2, UART_7O2 */
|
|
UINT8 fmode /**< fmode: UART_FIFO_OFF, UART_FIFO_1, UART_FIFO_4, UART_FIFO_8,
|
|
UART_FIFO_14*/
|
|
);
|
|
|
|
/** \brief Write data of a certain length to a serial port.*/
|
|
void serWrite (
|
|
t_serial_devices device,
|
|
UINT16 length, /**< Lengh of data in bytes */
|
|
UINT8 * data /**< Pointer to data */
|
|
);
|
|
|
|
/** \brief Reads data from serial port.
|
|
\retval Lengt of received data in bytes*/
|
|
UINT16 serRead (
|
|
t_serial_devices device,
|
|
UINT8 * data /**< Pointer to data */
|
|
);
|
|
|
|
/** \brief Get byte from serial port.
|
|
\retval bool Returns true if there was data */
|
|
BOOLEAN serGet(
|
|
t_serial_devices device,
|
|
UINT8 * byte /**< Pointer to byte to return data*/
|
|
);
|
|
|
|
/** \brief Send byte to serial port. */
|
|
void serPut(
|
|
t_serial_devices device,
|
|
UINT8 value /**< Byte to send*/
|
|
);
|
|
|
|
/** \brief Flush serial port buffers. */
|
|
void serFlush(
|
|
t_serial_devices device
|
|
);
|
|
|
|
/** \brief Check if receive buffers is empty.
|
|
\retval bool Returns true if recieve buffer is empty */
|
|
BOOLEAN serEmpty(
|
|
t_serial_devices device
|
|
);
|
|
|
|
/** \brief Enables handshaking to use serial-port with an external modem
|
|
* When enabled the CTS/RTS lines are used for communication with external modem.
|
|
* The ModemControl is only supported by COM2
|
|
* \retval OK Modem control was altered succesfull
|
|
* \retval ERROR Modem control couldn't be altered (COM1 doesn't support modem control
|
|
*/
|
|
RESULT serSetModemControl(
|
|
t_serial_devices device, /**< COM1 or COM2 */
|
|
BOOLEAN enable /**< Enable/disable modem control */
|
|
);
|
|
|
|
#endif /* __SERIAL_H__ */
|