⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 portevent.c

📁 freemodbus-v019.zip 是v0.19版本的代码
💻 C
字号:
/* * FreeModbus Libary: lwIP 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: portevent.c,v 1.1 2006/08/30 23:18:07 wolti Exp $ *//* ----------------------- System includes ----------------------------------*/#include "assert.h"/* ----------------------- lwIP ---------------------------------------------*/#include "lwip/api.h"#include "lwip/sys.h"/* ----------------------- Modbus includes ----------------------------------*/#include "mb.h"/* ----------------------- Defines ------------------------------------------*/#define MB_POLL_CYCLETIME       100     /* Poll cycle time is 100ms *//* ----------------------- Static variables ---------------------------------*/static sys_mbox_t xMailBox = SYS_MBOX_NULL;static eMBEventType eMailBoxEvent;/* ----------------------- Start implementation -----------------------------*/BOOLxMBPortEventInit( void ){    eMailBoxEvent = EV_READY;    xMailBox = sys_mbox_new(  );    return xMailBox != SYS_MBOX_NULL ? TRUE : FALSE;}voidvMBPortEventClose( void ){    if( xMailBox != SYS_MBOX_NULL )    {        sys_mbox_free( xMailBox );    }}BOOLxMBPortEventPost( eMBEventType eEvent ){    eMailBoxEvent = eEvent;    sys_mbox_post( xMailBox, &eMailBoxEvent );    return TRUE;}BOOLxMBPortEventGet( eMBEventType * eEvent ){    void           *peMailBoxEvent;    BOOL            xEventHappend = FALSE;    u32_t           uiTimeSpent;    uiTimeSpent = sys_arch_mbox_fetch( xMailBox, &peMailBoxEvent, MB_POLL_CYCLETIME );    if( uiTimeSpent != SYS_ARCH_TIMEOUT )    {        *eEvent = *( eMBEventType * ) peMailBoxEvent;        eMailBoxEvent = EV_READY;        xEventHappend = TRUE;    }    return xEventHappend;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -