Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
mbport.h
00001 /* 00002 * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. 00003 * Copyright (c) 2006 Christian Walter <wolti@sil.at> 00004 * All rights reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions 00008 * are met: 00009 * 1. Redistributions of source code must retain the above copyright 00010 * notice, this list of conditions and the following disclaimer. 00011 * 2. Redistributions in binary form must reproduce the above copyright 00012 * notice, this list of conditions and the following disclaimer in the 00013 * documentation and/or other materials provided with the distribution. 00014 * 3. The name of the author may not be used to endorse or promote products 00015 * derived from this software without specific prior written permission. 00016 * 00017 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 00018 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00019 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00020 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 00021 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 00022 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00023 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00024 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00025 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 00026 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00027 * 00028 * File: $Id: mbport.h,v 1.17 2006/12/07 22:10:34 wolti Exp $ 00029 */ 00030 00031 #ifndef _MB_PORT_H 00032 #define _MB_PORT_H 00033 00034 #ifdef __cplusplus 00035 PR_BEGIN_EXTERN_C 00036 #endif 00037 00038 /* ----------------------- Type definitions ---------------------------------*/ 00039 00040 typedef enum 00041 { 00042 EV_READY, /*!< Startup finished. */ 00043 EV_FRAME_RECEIVED, /*!< Frame received. */ 00044 EV_EXECUTE, /*!< Execute function. */ 00045 EV_FRAME_SENT /*!< Frame sent. */ 00046 } eMBEventType; 00047 00048 /*! \ingroup modbus 00049 * \brief Parity used for characters in serial mode. 00050 * 00051 * The parity which should be applied to the characters sent over the serial 00052 * link. Please note that this values are actually passed to the porting 00053 * layer and therefore not all parity modes might be available. 00054 */ 00055 typedef enum 00056 { 00057 MB_PAR_NONE , /*!< No parity. */ 00058 MB_PAR_ODD , /*!< Odd parity. */ 00059 MB_PAR_EVEN /*!< Even parity. */ 00060 } eMBParity; 00061 00062 /* ----------------------- Supporting functions -----------------------------*/ 00063 BOOL xMBPortEventInit( void ); 00064 00065 BOOL xMBPortEventPost( eMBEventType eEvent ); 00066 00067 BOOL xMBPortEventGet( /*@out@ */ eMBEventType * eEvent ); 00068 00069 /* ----------------------- Serial port functions ----------------------------*/ 00070 00071 BOOL xMBPortSerialInit( UCHAR ucPort, ULONG ulBaudRate, 00072 UCHAR ucDataBits, eMBParity eParity ); 00073 00074 void vMBPortClose( void ); 00075 00076 void xMBPortSerialClose( void ); 00077 00078 void vMBPortSerialEnable( BOOL xRxEnable, BOOL xTxEnable ); 00079 00080 INLINE BOOL xMBPortSerialGetByte( CHAR * pucByte ); 00081 00082 INLINE BOOL xMBPortSerialPutByte( CHAR ucByte ); 00083 00084 /* ----------------------- Timers functions ---------------------------------*/ 00085 BOOL xMBPortTimersInit( USHORT usTimeOut50us ); 00086 00087 void xMBPortTimersClose( void ); 00088 00089 INLINE void vMBPortTimersEnable( void ); 00090 00091 INLINE void vMBPortTimersDisable( void ); 00092 00093 /* ----------------------- Callback for the protocol stack ------------------*/ 00094 00095 /*! 00096 * \brief Callback function for the porting layer when a new byte is 00097 * available. 00098 * 00099 * Depending upon the mode this callback function is used by the RTU or 00100 * ASCII transmission layers. In any case a call to xMBPortSerialGetByte() 00101 * must immediately return a new character. 00102 * 00103 * \return <code>TRUE</code> if a event was posted to the queue because 00104 * a new byte was received. The port implementation should wake up the 00105 * tasks which are currently blocked on the eventqueue. 00106 */ 00107 extern BOOL( *pxMBFrameCBByteReceived ) ( void ); 00108 00109 extern BOOL( *pxMBFrameCBTransmitterEmpty ) ( void ); 00110 00111 extern BOOL( *pxMBPortCBTimerExpired ) ( void ); 00112 00113 /* ----------------------- TCP port functions -------------------------------*/ 00114 BOOL xMBTCPPortInit( USHORT usTCPPort ); 00115 00116 void vMBTCPPortClose( void ); 00117 00118 void vMBTCPPortDisable( void ); 00119 00120 BOOL xMBTCPPortGetRequest( UCHAR **ppucMBTCPFrame, USHORT * usTCPLength ); 00121 00122 BOOL xMBTCPPortSendResponse( const UCHAR *pucMBTCPFrame, USHORT usTCPLength ); 00123 00124 #ifdef __cplusplus 00125 PR_END_EXTERN_C 00126 #endif 00127 #endif
Generated on Sun Jul 17 2022 02:04:12 by
1.7.2