modified for nuc472

Dependents:   modbus-over-rs485-sample NTOUEE-mbed-modbus-RTU NuMaker_NuWicam_Lite

Fork of Modbus by Matthew Waddilove

Committer:
giryan
Date:
Sun Aug 22 16:34:20 2010 +0000
Revision:
0:274eb57e1df3
Child:
2:6ee56c002f64

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
giryan 0:274eb57e1df3 1 /*
giryan 0:274eb57e1df3 2 * FreeModbus Libary: BARE Port
giryan 0:274eb57e1df3 3 * Copyright (C) 2006 Christian Walter <wolti@sil.at>
giryan 0:274eb57e1df3 4 *
giryan 0:274eb57e1df3 5 * This library is free software; you can redistribute it and/or
giryan 0:274eb57e1df3 6 * modify it under the terms of the GNU Lesser General Public
giryan 0:274eb57e1df3 7 * License as published by the Free Software Foundation; either
giryan 0:274eb57e1df3 8 * version 2.1 of the License, or (at your option) any later version.
giryan 0:274eb57e1df3 9 *
giryan 0:274eb57e1df3 10 * This library is distributed in the hope that it will be useful,
giryan 0:274eb57e1df3 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
giryan 0:274eb57e1df3 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
giryan 0:274eb57e1df3 13 * Lesser General Public License for more details.
giryan 0:274eb57e1df3 14 *
giryan 0:274eb57e1df3 15 * You should have received a copy of the GNU Lesser General Public
giryan 0:274eb57e1df3 16 * License along with this library; if not, write to the Free Software
giryan 0:274eb57e1df3 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
giryan 0:274eb57e1df3 18 *
giryan 0:274eb57e1df3 19 * File: $Id: portevent.c,v 1.1 2006/08/22 21:35:13 wolti Exp $
giryan 0:274eb57e1df3 20 */
giryan 0:274eb57e1df3 21
giryan 0:274eb57e1df3 22 /* ----------------------- Modbus includes ----------------------------------*/
giryan 0:274eb57e1df3 23 #include "mb.h"
giryan 0:274eb57e1df3 24 #include "mbport.h"
giryan 0:274eb57e1df3 25
giryan 0:274eb57e1df3 26 /* ----------------------- Variables ----------------------------------------*/
giryan 0:274eb57e1df3 27 static eMBEventType eQueuedEvent;
giryan 0:274eb57e1df3 28 static BOOL xEventInQueue;
giryan 0:274eb57e1df3 29
giryan 0:274eb57e1df3 30 /* ----------------------- Start implementation -----------------------------*/
giryan 0:274eb57e1df3 31 BOOL
giryan 0:274eb57e1df3 32 xMBPortEventInit( void )
giryan 0:274eb57e1df3 33 {
giryan 0:274eb57e1df3 34 xEventInQueue = FALSE;
giryan 0:274eb57e1df3 35 return TRUE;
giryan 0:274eb57e1df3 36 }
giryan 0:274eb57e1df3 37
giryan 0:274eb57e1df3 38 BOOL
giryan 0:274eb57e1df3 39 xMBPortEventPost( eMBEventType eEvent )
giryan 0:274eb57e1df3 40 {
giryan 0:274eb57e1df3 41 xEventInQueue = TRUE;
giryan 0:274eb57e1df3 42 eQueuedEvent = eEvent;
giryan 0:274eb57e1df3 43 return TRUE;
giryan 0:274eb57e1df3 44 }
giryan 0:274eb57e1df3 45
giryan 0:274eb57e1df3 46 BOOL
giryan 0:274eb57e1df3 47 xMBPortEventGet( eMBEventType * eEvent )
giryan 0:274eb57e1df3 48 {
giryan 0:274eb57e1df3 49 BOOL xEventHappened = FALSE;
giryan 0:274eb57e1df3 50
giryan 0:274eb57e1df3 51 if( xEventInQueue )
giryan 0:274eb57e1df3 52 {
giryan 0:274eb57e1df3 53 *eEvent = eQueuedEvent;
giryan 0:274eb57e1df3 54 xEventInQueue = FALSE;
giryan 0:274eb57e1df3 55 xEventHappened = TRUE;
giryan 0:274eb57e1df3 56 }
giryan 0:274eb57e1df3 57 return xEventHappened;
giryan 0:274eb57e1df3 58 }