Nuvoton / Modbus

Dependents:   NuMaker-mbed-modbus-sample NuMaker_NuWicam_Lite NuMaker-mbed-modbus-sample

Fork of Modbus by Wayne Lin

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers portevent.cpp Source File

portevent.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: portevent.c,v 1.1 2006/08/22 21:35:13 wolti Exp $
00020  */
00021 
00022 /* ----------------------- Modbus includes ----------------------------------*/
00023 #include "mb.h"
00024 #include "mbport.h"
00025 #include "mbed.h"
00026 
00027 /* ----------------------- Variables ----------------------------------------*/
00028 static volatile eMBEventType eQueuedEvent;
00029 static volatile BOOL         xEventInQueue;
00030 
00031 /* ----------------------- Start implementation -----------------------------*/
00032 BOOL
00033 xMBPortEventInit( void )
00034 {
00035     xEventInQueue = FALSE;
00036     return TRUE;
00037 }
00038 
00039 BOOL
00040 xMBPortEventPost( eMBEventType eEvent )
00041 {
00042     xEventInQueue = TRUE;
00043     eQueuedEvent = eEvent;
00044     return TRUE;
00045 }
00046 
00047 BOOL
00048 xMBPortEventGet( eMBEventType * eEvent )
00049 {
00050     BOOL    xEventHappened = FALSE;
00051 
00052     if( xEventInQueue )
00053     {
00054         *eEvent = eQueuedEvent;
00055         xEventInQueue = FALSE;
00056         xEventHappened = TRUE;
00057         //printf("[%s %d] %x\r\n", __func__, __LINE__, *eEvent );    
00058     }
00059     return xEventHappened;
00060 }