1.original from Cam Marshall 2.use for F446RE Test 3.use the interrupt method of uart 4.not change to RTOS yet

Dependents:   RoboticArm Modbus_Gripper_Test

Committer:
stanley1228
Date:
Fri Mar 31 01:47:35 2017 +0000
Revision:
0:aefcdfe9ca2f
1.change the file in "port" folder to F446RE use

Who changed what in which revision?

UserRevisionLine numberNew contents of line
stanley1228 0:aefcdfe9ca2f 1 /*
stanley1228 0:aefcdfe9ca2f 2 * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
stanley1228 0:aefcdfe9ca2f 3 * Copyright (c) 2006 Christian Walter <wolti@sil.at>
stanley1228 0:aefcdfe9ca2f 4 * All rights reserved.
stanley1228 0:aefcdfe9ca2f 5 *
stanley1228 0:aefcdfe9ca2f 6 * Redistribution and use in source and binary forms, with or without
stanley1228 0:aefcdfe9ca2f 7 * modification, are permitted provided that the following conditions
stanley1228 0:aefcdfe9ca2f 8 * are met:
stanley1228 0:aefcdfe9ca2f 9 * 1. Redistributions of source code must retain the above copyright
stanley1228 0:aefcdfe9ca2f 10 * notice, this list of conditions and the following disclaimer.
stanley1228 0:aefcdfe9ca2f 11 * 2. Redistributions in binary form must reproduce the above copyright
stanley1228 0:aefcdfe9ca2f 12 * notice, this list of conditions and the following disclaimer in the
stanley1228 0:aefcdfe9ca2f 13 * documentation and/or other materials provided with the distribution.
stanley1228 0:aefcdfe9ca2f 14 * 3. The name of the author may not be used to endorse or promote products
stanley1228 0:aefcdfe9ca2f 15 * derived from this software without specific prior written permission.
stanley1228 0:aefcdfe9ca2f 16 *
stanley1228 0:aefcdfe9ca2f 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
stanley1228 0:aefcdfe9ca2f 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
stanley1228 0:aefcdfe9ca2f 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
stanley1228 0:aefcdfe9ca2f 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
stanley1228 0:aefcdfe9ca2f 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
stanley1228 0:aefcdfe9ca2f 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
stanley1228 0:aefcdfe9ca2f 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
stanley1228 0:aefcdfe9ca2f 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
stanley1228 0:aefcdfe9ca2f 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
stanley1228 0:aefcdfe9ca2f 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
stanley1228 0:aefcdfe9ca2f 27 *
stanley1228 0:aefcdfe9ca2f 28 * File: $Id: mbport.h,v 1.17 2006/12/07 22:10:34 wolti Exp $
stanley1228 0:aefcdfe9ca2f 29 */
stanley1228 0:aefcdfe9ca2f 30
stanley1228 0:aefcdfe9ca2f 31 #ifndef _MB_PORT_H
stanley1228 0:aefcdfe9ca2f 32 #define _MB_PORT_H
stanley1228 0:aefcdfe9ca2f 33
stanley1228 0:aefcdfe9ca2f 34 #ifdef __cplusplus
stanley1228 0:aefcdfe9ca2f 35 PR_BEGIN_EXTERN_C
stanley1228 0:aefcdfe9ca2f 36 #endif
stanley1228 0:aefcdfe9ca2f 37
stanley1228 0:aefcdfe9ca2f 38 /* ----------------------- Type definitions ---------------------------------*/
stanley1228 0:aefcdfe9ca2f 39
stanley1228 0:aefcdfe9ca2f 40 typedef enum
stanley1228 0:aefcdfe9ca2f 41 {
stanley1228 0:aefcdfe9ca2f 42 EV_READY, /*!< Startup finished. */
stanley1228 0:aefcdfe9ca2f 43 EV_FRAME_RECEIVED, /*!< Frame received. */
stanley1228 0:aefcdfe9ca2f 44 EV_EXECUTE, /*!< Execute function. */
stanley1228 0:aefcdfe9ca2f 45 EV_FRAME_SENT /*!< Frame sent. */
stanley1228 0:aefcdfe9ca2f 46 } eMBEventType;
stanley1228 0:aefcdfe9ca2f 47
stanley1228 0:aefcdfe9ca2f 48 /*! \ingroup modbus
stanley1228 0:aefcdfe9ca2f 49 * \brief Parity used for characters in serial mode.
stanley1228 0:aefcdfe9ca2f 50 *
stanley1228 0:aefcdfe9ca2f 51 * The parity which should be applied to the characters sent over the serial
stanley1228 0:aefcdfe9ca2f 52 * link. Please note that this values are actually passed to the porting
stanley1228 0:aefcdfe9ca2f 53 * layer and therefore not all parity modes might be available.
stanley1228 0:aefcdfe9ca2f 54 */
stanley1228 0:aefcdfe9ca2f 55 typedef enum
stanley1228 0:aefcdfe9ca2f 56 {
stanley1228 0:aefcdfe9ca2f 57 MB_PAR_NONE, /*!< No parity. */
stanley1228 0:aefcdfe9ca2f 58 MB_PAR_ODD, /*!< Odd parity. */
stanley1228 0:aefcdfe9ca2f 59 MB_PAR_EVEN /*!< Even parity. */
stanley1228 0:aefcdfe9ca2f 60 } eMBParity;
stanley1228 0:aefcdfe9ca2f 61
stanley1228 0:aefcdfe9ca2f 62 /* ----------------------- Supporting functions -----------------------------*/
stanley1228 0:aefcdfe9ca2f 63 BOOL xMBPortEventInit( void );
stanley1228 0:aefcdfe9ca2f 64
stanley1228 0:aefcdfe9ca2f 65 BOOL xMBPortEventPost( eMBEventType eEvent );
stanley1228 0:aefcdfe9ca2f 66
stanley1228 0:aefcdfe9ca2f 67 BOOL xMBPortEventGet( /*@out@ */ eMBEventType * eEvent );
stanley1228 0:aefcdfe9ca2f 68
stanley1228 0:aefcdfe9ca2f 69 /* ----------------------- Serial port functions ----------------------------*/
stanley1228 0:aefcdfe9ca2f 70
stanley1228 0:aefcdfe9ca2f 71 BOOL xMBPortSerialInit( UCHAR ucPort, ULONG ulBaudRate,
stanley1228 0:aefcdfe9ca2f 72 UCHAR ucDataBits, eMBParity eParity );
stanley1228 0:aefcdfe9ca2f 73
stanley1228 0:aefcdfe9ca2f 74 void vMBPortClose( void );
stanley1228 0:aefcdfe9ca2f 75
stanley1228 0:aefcdfe9ca2f 76 void xMBPortSerialClose( void );
stanley1228 0:aefcdfe9ca2f 77
stanley1228 0:aefcdfe9ca2f 78 void vMBPortSerialEnable( BOOL xRxEnable, BOOL xTxEnable );
stanley1228 0:aefcdfe9ca2f 79
stanley1228 0:aefcdfe9ca2f 80 INLINE BOOL xMBPortSerialGetByte( CHAR * pucByte );
stanley1228 0:aefcdfe9ca2f 81
stanley1228 0:aefcdfe9ca2f 82 INLINE BOOL xMBPortSerialPutByte( CHAR ucByte );
stanley1228 0:aefcdfe9ca2f 83
stanley1228 0:aefcdfe9ca2f 84 /* ----------------------- Timers functions ---------------------------------*/
stanley1228 0:aefcdfe9ca2f 85 BOOL xMBPortTimersInit( USHORT usTimeOut50us );
stanley1228 0:aefcdfe9ca2f 86
stanley1228 0:aefcdfe9ca2f 87 void xMBPortTimersClose( void );
stanley1228 0:aefcdfe9ca2f 88
stanley1228 0:aefcdfe9ca2f 89 INLINE void vMBPortTimersEnable( void );
stanley1228 0:aefcdfe9ca2f 90
stanley1228 0:aefcdfe9ca2f 91 INLINE void vMBPortTimersDisable( void );
stanley1228 0:aefcdfe9ca2f 92
stanley1228 0:aefcdfe9ca2f 93 /* ----------------------- Callback for the protocol stack ------------------*/
stanley1228 0:aefcdfe9ca2f 94
stanley1228 0:aefcdfe9ca2f 95 /*!
stanley1228 0:aefcdfe9ca2f 96 * \brief Callback function for the porting layer when a new byte is
stanley1228 0:aefcdfe9ca2f 97 * available.
stanley1228 0:aefcdfe9ca2f 98 *
stanley1228 0:aefcdfe9ca2f 99 * Depending upon the mode this callback function is used by the RTU or
stanley1228 0:aefcdfe9ca2f 100 * ASCII transmission layers. In any case a call to xMBPortSerialGetByte()
stanley1228 0:aefcdfe9ca2f 101 * must immediately return a new character.
stanley1228 0:aefcdfe9ca2f 102 *
stanley1228 0:aefcdfe9ca2f 103 * \return <code>TRUE</code> if a event was posted to the queue because
stanley1228 0:aefcdfe9ca2f 104 * a new byte was received. The port implementation should wake up the
stanley1228 0:aefcdfe9ca2f 105 * tasks which are currently blocked on the eventqueue.
stanley1228 0:aefcdfe9ca2f 106 */
stanley1228 0:aefcdfe9ca2f 107 extern BOOL( *pxMBFrameCBByteReceived ) ( void );
stanley1228 0:aefcdfe9ca2f 108
stanley1228 0:aefcdfe9ca2f 109 extern BOOL( *pxMBFrameCBTransmitterEmpty ) ( void );
stanley1228 0:aefcdfe9ca2f 110
stanley1228 0:aefcdfe9ca2f 111 extern BOOL( *pxMBPortCBTimerExpired ) ( void );
stanley1228 0:aefcdfe9ca2f 112
stanley1228 0:aefcdfe9ca2f 113 /* ----------------------- TCP port functions -------------------------------*/
stanley1228 0:aefcdfe9ca2f 114 BOOL xMBTCPPortInit( USHORT usTCPPort );
stanley1228 0:aefcdfe9ca2f 115
stanley1228 0:aefcdfe9ca2f 116 void vMBTCPPortClose( void );
stanley1228 0:aefcdfe9ca2f 117
stanley1228 0:aefcdfe9ca2f 118 void vMBTCPPortDisable( void );
stanley1228 0:aefcdfe9ca2f 119
stanley1228 0:aefcdfe9ca2f 120 BOOL xMBTCPPortGetRequest( UCHAR **ppucMBTCPFrame, USHORT * usTCPLength );
stanley1228 0:aefcdfe9ca2f 121
stanley1228 0:aefcdfe9ca2f 122 BOOL xMBTCPPortSendResponse( const UCHAR *pucMBTCPFrame, USHORT usTCPLength );
stanley1228 0:aefcdfe9ca2f 123
stanley1228 0:aefcdfe9ca2f 124 #ifdef __cplusplus
stanley1228 0:aefcdfe9ca2f 125 PR_END_EXTERN_C
stanley1228 0:aefcdfe9ca2f 126 #endif
stanley1228 0:aefcdfe9ca2f 127 #endif