mirror of
https://github.com/armink/FreeModbus_Slave-Master-RTT-STM32.git
synced 2025-01-26 08:17:10 +08:00
a5528950d0
2、【修改】FreeModbus的port文件夹下相关文件的命名方式,从机保留FreeModbus原有的文件,主机则在文件名后面增加“_m”以区分,尽量保证FreeModbus源码的统一性; 3、【增加】FreeModbus主机初始化、使能、失能及定时器状态机相关方法,定时器超时状态机还需要后期完善,发送状态机及接收状态机还未实现; Signed-off-by: armink <armink.ztl@gmail.com>
59 lines
1.7 KiB
C
59 lines
1.7 KiB
C
/*
|
|
* FreeModbus Libary: STM32 Port
|
|
* Copyright (C) 2013 Armink <armink.ztl@gmail.com>
|
|
*
|
|
* 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: portevent.c,v 1.60 2013/08/13 15:07:05 Armink add Master Functions, $
|
|
*/
|
|
|
|
/* ----------------------- Modbus includes ----------------------------------*/
|
|
#include "mb.h"
|
|
#include "mbport.h"
|
|
|
|
/* ----------------------- Variables ----------------------------------------*/
|
|
static eMBEventType eQueuedEvent;
|
|
static BOOL xEventInQueue;
|
|
|
|
/* ----------------------- Start implementation -----------------------------*/
|
|
BOOL
|
|
xMBPortEventInit( void )
|
|
{
|
|
xEventInQueue = FALSE;
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL
|
|
xMBPortEventPost( eMBEventType eEvent )
|
|
{
|
|
xEventInQueue = TRUE;
|
|
eQueuedEvent = eEvent;
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL
|
|
xMBPortEventGet( eMBEventType * eEvent )
|
|
{
|
|
BOOL xEventHappened = FALSE;
|
|
|
|
if( xEventInQueue )
|
|
{
|
|
*eEvent = eQueuedEvent;
|
|
xEventInQueue = FALSE;
|
|
xEventHappened = TRUE;
|
|
}
|
|
return xEventHappened;
|
|
}
|