from Cam Marshall original modbus

Dependencies:   mbed

Fork of Modbus by Cam Marshall

Committer:
stanley1228
Date:
Sun Apr 09 19:05:17 2017 +0800
Revision:
9:0fb2f20a1451
Parent:
8:924d128c1722
1.Changge to baudrate 460800 ok
2.Test 921600 failed

Who changed what in which revision?

UserRevisionLine numberNew contents of line
cam 0:0453a0a7e500 1 /*
cam 0:0453a0a7e500 2 * FreeModbus Libary: BARE Port
cam 0:0453a0a7e500 3 * Copyright (C) 2006 Christian Walter <wolti@sil.at>
cam 0:0453a0a7e500 4 *
cam 0:0453a0a7e500 5 * This library is free software; you can redistribute it and/or
cam 0:0453a0a7e500 6 * modify it under the terms of the GNU Lesser General Public
cam 0:0453a0a7e500 7 * License as published by the Free Software Foundation; either
cam 0:0453a0a7e500 8 * version 2.1 of the License, or (at your option) any later version.
cam 0:0453a0a7e500 9 *
cam 0:0453a0a7e500 10 * This library is distributed in the hope that it will be useful,
cam 0:0453a0a7e500 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cam 0:0453a0a7e500 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
cam 0:0453a0a7e500 13 * Lesser General Public License for more details.
cam 0:0453a0a7e500 14 *
cam 0:0453a0a7e500 15 * You should have received a copy of the GNU Lesser General Public
cam 0:0453a0a7e500 16 * License along with this library; if not, write to the Free Software
cam 0:0453a0a7e500 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
cam 0:0453a0a7e500 18 *
cam 0:0453a0a7e500 19 * File: $Id: porttimer.c,v 1.1 2006/08/22 21:35:13 wolti Exp $
cam 0:0453a0a7e500 20 */
cam 0:0453a0a7e500 21
cam 0:0453a0a7e500 22 /* ----------------------- System includes ----------------------------------*/
cam 0:0453a0a7e500 23 #include "mbed.h" // Cam
cam 0:0453a0a7e500 24
cam 0:0453a0a7e500 25 /* ----------------------- Platform includes --------------------------------*/
cam 0:0453a0a7e500 26 #include "port.h"
cam 0:0453a0a7e500 27
cam 0:0453a0a7e500 28 /* ----------------------- Modbus includes ----------------------------------*/
cam 0:0453a0a7e500 29 #include "mb.h"
cam 0:0453a0a7e500 30 #include "mbport.h"
stanley1228 5:c712a10c9414 31 extern DigitalOut testD8; //stanley
cam 0:0453a0a7e500 32 /* ----------------------- static functions ---------------------------------*/
cam 0:0453a0a7e500 33 static void prvvTIMERExpiredISR( void );
cam 0:0453a0a7e500 34
cam 0:0453a0a7e500 35 /* ----------------------- System Variables ---------------------------------*/
cam 0:0453a0a7e500 36 Timeout toMBUS; // Cam - mbed timeout
cam 0:0453a0a7e500 37 static ULONG usInterval; // Cam - timeout interval in microseconds
cam 0:0453a0a7e500 38
cam 0:0453a0a7e500 39 /* ----------------------- Start implementation -----------------------------*/
cam 0:0453a0a7e500 40 BOOL
cam 0:0453a0a7e500 41 xMBPortTimersInit( USHORT usTim1Timerout50us )
cam 0:0453a0a7e500 42 {
stanley1228 5:c712a10c9414 43 usInterval = 50 * usTim1Timerout50us;
cam 0:0453a0a7e500 44 return TRUE;
cam 0:0453a0a7e500 45 }
cam 0:0453a0a7e500 46
cam 0:0453a0a7e500 47
cam 0:0453a0a7e500 48 /*inline*/ void
cam 0:0453a0a7e500 49 vMBPortTimersEnable( )
cam 0:0453a0a7e500 50 {
cam 0:0453a0a7e500 51 /* Enable the timer with the timeout passed to xMBPortTimersInit( ) */
cam 0:0453a0a7e500 52
cam 0:0453a0a7e500 53 // Cam - firstly detach from any existing timeout
cam 0:0453a0a7e500 54 toMBUS.detach();
cam 0:0453a0a7e500 55 // Cam - now attach the timeout to the prvvTIMERExpiredISR routine
cam 0:0453a0a7e500 56 toMBUS.attach_us(&prvvTIMERExpiredISR, usInterval);
cam 0:0453a0a7e500 57 }
cam 0:0453a0a7e500 58
cam 0:0453a0a7e500 59 /*inline*/ void
cam 0:0453a0a7e500 60 vMBPortTimersDisable( )
cam 0:0453a0a7e500 61 {
cam 0:0453a0a7e500 62 /* Disable any pending timers. */
cam 0:0453a0a7e500 63
cam 0:0453a0a7e500 64 // Cam - disable further interrupts by detaching
cam 0:0453a0a7e500 65 toMBUS.detach();
cam 0:0453a0a7e500 66 }
cam 0:0453a0a7e500 67
cam 0:0453a0a7e500 68 /* Create an ISR which is called whenever the timer has expired. This function
cam 0:0453a0a7e500 69 * must then call pxMBPortCBTimerExpired( ) to notify the protocol stack that
cam 0:0453a0a7e500 70 * the timer has expired.
cam 0:0453a0a7e500 71 */
cam 0:0453a0a7e500 72 static void prvvTIMERExpiredISR( void )
cam 0:0453a0a7e500 73 {
stanley1228 5:c712a10c9414 74
stanley1228 5:c712a10c9414 75 (void)pxMBPortCBTimerExpired( );
cam 0:0453a0a7e500 76 // Cam - disable further interrupts by detaching
cam 0:0453a0a7e500 77 toMBUS.detach();
cam 0:0453a0a7e500 78 }
cam 0:0453a0a7e500 79