📄 porttimer.c
字号:
/* * FreeModbus Libary: Win32 Port * Copyright (C) 2006 Christian Walter <wolti@sil.at> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * File: $Id: porttimer.c,v 1.3 2006/06/18 13:00:30 wolti Exp $ *//* ----------------------- Platform includes --------------------------------*/#include "port.h"/* ----------------------- Modbus includes ----------------------------------*/#include "mb.h"#include "mbport.h"/* ----------------------- Defines ------------------------------------------*//* ----------------------- Static variables ---------------------------------*/DWORD dwTimeOut;BOOL bTimeoutEnable;DWORD dwTimeLast;extern HANDLE g_hSerial;/* ----------------------- Start implementation -----------------------------*/BOOLxMBPortTimersInit( USHORT usTim1Timerout50us ){ dwTimeOut = usTim1Timerout50us / 20U; if( dwTimeOut == 0 ) dwTimeOut = 1; return xMBPortSerialSetTimeout( dwTimeOut );}voidxMBPortTimersClose( ){ /* Does not use any hardware resources. */}voidvMBPortTimerPoll( ){ /* Timers are called from the serial layer because we have no high * res timer in Win32. */ if( bTimeoutEnable ) { DWORD dwTimeCurrent = GetTickCount( ); if( ( dwTimeCurrent - dwTimeLast ) > dwTimeOut ) { bTimeoutEnable = FALSE; ( void )pxMBPortCBTimerExpired( ); } }}voidvMBPortTimersEnable( ){ bTimeoutEnable = TRUE; dwTimeLast = GetTickCount( );}voidvMBPortTimersDisable( ){ bTimeoutEnable = FALSE;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -