modified for nuc472

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

Fork of Modbus by Matthew Waddilove

Committer:
wclin
Date:
Fri Oct 06 02:54:27 2017 +0000
Revision:
7:be466464a18c
Parent:
2:6ee56c002f64
Support M487 board.

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"
wclin 2:6ee56c002f64 25 #include "mbed.h"
giryan 0:274eb57e1df3 26
giryan 0:274eb57e1df3 27 /* ----------------------- Variables ----------------------------------------*/
wclin 2:6ee56c002f64 28 static volatile eMBEventType eQueuedEvent;
wclin 2:6ee56c002f64 29 static volatile BOOL xEventInQueue;
giryan 0:274eb57e1df3 30
giryan 0:274eb57e1df3 31 /* ----------------------- Start implementation -----------------------------*/
giryan 0:274eb57e1df3 32 BOOL
giryan 0:274eb57e1df3 33 xMBPortEventInit( void )
giryan 0:274eb57e1df3 34 {
giryan 0:274eb57e1df3 35 xEventInQueue = FALSE;
giryan 0:274eb57e1df3 36 return TRUE;
giryan 0:274eb57e1df3 37 }
giryan 0:274eb57e1df3 38
giryan 0:274eb57e1df3 39 BOOL
giryan 0:274eb57e1df3 40 xMBPortEventPost( eMBEventType eEvent )
giryan 0:274eb57e1df3 41 {
giryan 0:274eb57e1df3 42 xEventInQueue = TRUE;
giryan 0:274eb57e1df3 43 eQueuedEvent = eEvent;
giryan 0:274eb57e1df3 44 return TRUE;
giryan 0:274eb57e1df3 45 }
giryan 0:274eb57e1df3 46
giryan 0:274eb57e1df3 47 BOOL
giryan 0:274eb57e1df3 48 xMBPortEventGet( eMBEventType * eEvent )
giryan 0:274eb57e1df3 49 {
giryan 0:274eb57e1df3 50 BOOL xEventHappened = FALSE;
giryan 0:274eb57e1df3 51
giryan 0:274eb57e1df3 52 if( xEventInQueue )
giryan 0:274eb57e1df3 53 {
giryan 0:274eb57e1df3 54 *eEvent = eQueuedEvent;
giryan 0:274eb57e1df3 55 xEventInQueue = FALSE;
giryan 0:274eb57e1df3 56 xEventHappened = TRUE;
wclin 2:6ee56c002f64 57 //printf("[%s %d] %x\r\n", __func__, __LINE__, *eEvent );
giryan 0:274eb57e1df3 58 }
giryan 0:274eb57e1df3 59 return xEventHappened;
giryan 0:274eb57e1df3 60 }