Modified version of ModbusTCP

Dependencies:   EthernetNetIf mbed

Committer:
paleskyjp
Date:
Thu Mar 15 15:28:14 2012 +0000
Revision:
3:d7d7c67f21fa
Parent:
0:62be54b8975d
eMBRegCoilsCB was corrected.
(Implementation of writing single coil was wrong.)

Who changed what in which revision?

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