fork frdm kl25z slave
Embed:
(wiki syntax)
Show/hide line numbers
porttimer.cpp
00001 /* 00002 * FreeModbus Libary: BARE Port 00003 * Copyright (C) 2006 Christian Walter <wolti@sil.at> 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00018 * 00019 * File: $Id: porttimer.c,v 1.1 2006/08/22 21:35:13 wolti Exp $ 00020 */ 00021 00022 /* ----------------------- System includes ----------------------------------*/ 00023 #include "mbed.h" // Cam 00024 00025 /* ----------------------- Platform includes --------------------------------*/ 00026 #include "port.h" 00027 00028 /* ----------------------- Modbus includes ----------------------------------*/ 00029 #include "mb.h" 00030 #include "mbport.h" 00031 00032 /* ----------------------- static functions ---------------------------------*/ 00033 static void prvvTIMERExpiredISR( void ); 00034 00035 /* ----------------------- System Variables ---------------------------------*/ 00036 Timeout toMBUS; // Cam - mbed timeout 00037 static ULONG usInterval; // Cam - timeout interval in microseconds 00038 00039 /* ----------------------- Start implementation -----------------------------*/ 00040 BOOL 00041 xMBPortTimersInit( USHORT usTim1Timerout50us ) 00042 { 00043 usInterval = 50 * usTim1Timerout50us; 00044 return TRUE; 00045 } 00046 00047 00048 /*inline*/ void 00049 vMBPortTimersEnable( ) 00050 { 00051 /* Enable the timer with the timeout passed to xMBPortTimersInit( ) */ 00052 00053 // Cam - firstly detach from any existing timeout 00054 toMBUS.detach(); 00055 // Cam - now attach the timeout to the prvvTIMERExpiredISR routine 00056 toMBUS.attach_us(&prvvTIMERExpiredISR, usInterval); 00057 } 00058 00059 /*inline*/ void 00060 vMBPortTimersDisable( ) 00061 { 00062 /* Disable any pending timers. */ 00063 00064 // Cam - disable further interrupts by detaching 00065 toMBUS.detach(); 00066 } 00067 00068 /* Create an ISR which is called whenever the timer has expired. This function 00069 * must then call pxMBPortCBTimerExpired( ) to notify the protocol stack that 00070 * the timer has expired. 00071 */ 00072 static void prvvTIMERExpiredISR( void ) 00073 { 00074 ( void )pxMBPortCBTimerExpired( ); 00075 // Cam - disable further interrupts by detaching 00076 toMBUS.detach(); 00077 } 00078
Generated on Fri Jul 15 2022 08:22:19 by 1.7.2