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
include/mbproto.h@0:aefcdfe9ca2f, 2017-03-31 (annotated)
- 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?
User | Revision | Line number | New 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: mbproto.h,v 1.14 2006/12/07 22:10:34 wolti Exp $ |
stanley1228 | 0:aefcdfe9ca2f | 29 | */ |
stanley1228 | 0:aefcdfe9ca2f | 30 | |
stanley1228 | 0:aefcdfe9ca2f | 31 | #ifndef _MB_PROTO_H |
stanley1228 | 0:aefcdfe9ca2f | 32 | #define _MB_PROTO_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 | /* ----------------------- Defines ------------------------------------------*/ |
stanley1228 | 0:aefcdfe9ca2f | 38 | #define MB_ADDRESS_BROADCAST ( 0 ) /*! Modbus broadcast address. */ |
stanley1228 | 0:aefcdfe9ca2f | 39 | #define MB_ADDRESS_MIN ( 1 ) /*! Smallest possible slave address. */ |
stanley1228 | 0:aefcdfe9ca2f | 40 | #define MB_ADDRESS_MAX ( 247 ) /*! Biggest possible slave address. */ |
stanley1228 | 0:aefcdfe9ca2f | 41 | #define MB_FUNC_NONE ( 0 ) |
stanley1228 | 0:aefcdfe9ca2f | 42 | #define MB_FUNC_READ_COILS ( 1 ) |
stanley1228 | 0:aefcdfe9ca2f | 43 | #define MB_FUNC_READ_DISCRETE_INPUTS ( 2 ) |
stanley1228 | 0:aefcdfe9ca2f | 44 | #define MB_FUNC_WRITE_SINGLE_COIL ( 5 ) |
stanley1228 | 0:aefcdfe9ca2f | 45 | #define MB_FUNC_WRITE_MULTIPLE_COILS ( 15 ) |
stanley1228 | 0:aefcdfe9ca2f | 46 | #define MB_FUNC_READ_HOLDING_REGISTER ( 3 ) |
stanley1228 | 0:aefcdfe9ca2f | 47 | #define MB_FUNC_READ_INPUT_REGISTER ( 4 ) |
stanley1228 | 0:aefcdfe9ca2f | 48 | #define MB_FUNC_WRITE_REGISTER ( 6 ) |
stanley1228 | 0:aefcdfe9ca2f | 49 | #define MB_FUNC_WRITE_MULTIPLE_REGISTERS ( 16 ) |
stanley1228 | 0:aefcdfe9ca2f | 50 | #define MB_FUNC_READWRITE_MULTIPLE_REGISTERS ( 23 ) |
stanley1228 | 0:aefcdfe9ca2f | 51 | #define MB_FUNC_DIAG_READ_EXCEPTION ( 7 ) |
stanley1228 | 0:aefcdfe9ca2f | 52 | #define MB_FUNC_DIAG_DIAGNOSTIC ( 8 ) |
stanley1228 | 0:aefcdfe9ca2f | 53 | #define MB_FUNC_DIAG_GET_COM_EVENT_CNT ( 11 ) |
stanley1228 | 0:aefcdfe9ca2f | 54 | #define MB_FUNC_DIAG_GET_COM_EVENT_LOG ( 12 ) |
stanley1228 | 0:aefcdfe9ca2f | 55 | #define MB_FUNC_OTHER_REPORT_SLAVEID ( 17 ) |
stanley1228 | 0:aefcdfe9ca2f | 56 | #define MB_FUNC_ERROR ( 128 ) |
stanley1228 | 0:aefcdfe9ca2f | 57 | /* ----------------------- Type definitions ---------------------------------*/ |
stanley1228 | 0:aefcdfe9ca2f | 58 | typedef enum |
stanley1228 | 0:aefcdfe9ca2f | 59 | { |
stanley1228 | 0:aefcdfe9ca2f | 60 | MB_EX_NONE = 0x00, |
stanley1228 | 0:aefcdfe9ca2f | 61 | MB_EX_ILLEGAL_FUNCTION = 0x01, |
stanley1228 | 0:aefcdfe9ca2f | 62 | MB_EX_ILLEGAL_DATA_ADDRESS = 0x02, |
stanley1228 | 0:aefcdfe9ca2f | 63 | MB_EX_ILLEGAL_DATA_VALUE = 0x03, |
stanley1228 | 0:aefcdfe9ca2f | 64 | MB_EX_SLAVE_DEVICE_FAILURE = 0x04, |
stanley1228 | 0:aefcdfe9ca2f | 65 | MB_EX_ACKNOWLEDGE = 0x05, |
stanley1228 | 0:aefcdfe9ca2f | 66 | MB_EX_SLAVE_BUSY = 0x06, |
stanley1228 | 0:aefcdfe9ca2f | 67 | MB_EX_MEMORY_PARITY_ERROR = 0x08, |
stanley1228 | 0:aefcdfe9ca2f | 68 | MB_EX_GATEWAY_PATH_FAILED = 0x0A, |
stanley1228 | 0:aefcdfe9ca2f | 69 | MB_EX_GATEWAY_TGT_FAILED = 0x0B |
stanley1228 | 0:aefcdfe9ca2f | 70 | } eMBException; |
stanley1228 | 0:aefcdfe9ca2f | 71 | |
stanley1228 | 0:aefcdfe9ca2f | 72 | typedef eMBException( *pxMBFunctionHandler ) ( UCHAR * pucFrame, USHORT * pusLength ); |
stanley1228 | 0:aefcdfe9ca2f | 73 | |
stanley1228 | 0:aefcdfe9ca2f | 74 | typedef struct |
stanley1228 | 0:aefcdfe9ca2f | 75 | { |
stanley1228 | 0:aefcdfe9ca2f | 76 | UCHAR ucFunctionCode; |
stanley1228 | 0:aefcdfe9ca2f | 77 | pxMBFunctionHandler pxHandler; |
stanley1228 | 0:aefcdfe9ca2f | 78 | } xMBFunctionHandler; |
stanley1228 | 0:aefcdfe9ca2f | 79 | |
stanley1228 | 0:aefcdfe9ca2f | 80 | #ifdef __cplusplus |
stanley1228 | 0:aefcdfe9ca2f | 81 | PR_END_EXTERN_C |
stanley1228 | 0:aefcdfe9ca2f | 82 | #endif |
stanley1228 | 0:aefcdfe9ca2f | 83 | #endif |