/* --------------------------------------------------------------------------- * bus.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: RS485 interface. * --------------------------------------------------------------------------- * Version(s): 0.1, 10-09-2007, Marcel Mulder. * Creation. * --------------------------------------------------------------------------- */ #ifndef __BUS_H__ #define __BUS_H__ /** \file bus.h \brief RS485 (UART) interface. */ /* --------------------------------------------------------------------------- * System include files. * --------------------------------------------------------------------------- */ #include "BpPort.h" /* --------------------------------------------------------------------------- * Application include files. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Constant and macro definitions. * --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- * Type definitions. * --------------------------------------------------------------------------- */ typedef enum { BUS1, /**< First RS485 port*/ BUS2 /**< Second RS485 port*/ } t_bus_devices; /* --------------------------------------------------------------------------- * Variable declarations. * --------------------------------------------------------------------------- */ int bus1Handle; int bus2Handle; /* --------------------------------------------------------------------------- * Function declarations. * --------------------------------------------------------------------------- */ /** \brief Initialize of serial bus interface.*/ void busInit ( t_bus_devices device ); /** \brief Write data of a certain length to a serial bus.*/ void busWrite ( t_bus_devices device, UINT16 length, /**< Lengh of data in bytes */ UINT8 * data /**< Pointer to data */ ); /** \brief Reads data from serial bus. \retval Lengt of received data in bytes*/ UINT16 busRead ( t_bus_devices device, UINT8 * data /**< Pointer to data */ ); /** \brief Get byte from serial bus. \retval bool Returns true if there was data */ BOOLEAN busGet( t_bus_devices device, UINT8 * byte /**< Pointer to byte to return data*/ ); /** \brief Send byte to serial bus. */ void busPut( t_bus_devices device, UINT8 value /**< Byte to send*/ ); /** \brief Flush serial bus buffers. */ void busFlush( t_bus_devices device ); /** \brief Check if receive buffers is empty. \retval bool Returns true if recieve buffer is empty */ BOOLEAN busEmpty( t_bus_devices device ); #endif /* __BUS_H__ */