Project

General

Profile

Statistics
| Branch: | Revision:

root / toolbox / freemodbus / port / portevent.c @ ae250f1a

History | View | Annotate | Download (1.72 KB)

1
/*
2
 * FreeModbus Libary: ATMega168 Port
3
 * Copyright (C) 2006 Christian Walter <wolti@sil.at>
4
 *
5
 * This library is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU Lesser General Public
7
 * License as published by the Free Software Foundation; either
8
 * version 2.1 of the License, or (at your option) any later version.
9
 *
10
 * This library is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 * Lesser General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Lesser General Public
16
 * License along with this library; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 *
19
 * File: $Id: portevent.c,v 1.2 2006/05/14 21:55:01 wolti Exp $
20
 */
21

    
22
/* ----------------------- Modbus includes ----------------------------------*/
23
#include "mb.h"
24
#include "mbport.h"
25

    
26
/* ----------------------- Variables ----------------------------------------*/
27
static eMBEventType eQueuedEvent;
28
static BOOL     xEventInQueue;
29

    
30
/* ----------------------- Start implementation -----------------------------*/
31
BOOL
32
xMBPortEventInit( void )
33
{
34
    xEventInQueue = FALSE;
35
    return TRUE;
36
}
37

    
38
BOOL
39
xMBPortEventPost( eMBEventType eEvent )
40
{
41
    xEventInQueue = TRUE;
42
    eQueuedEvent = eEvent;
43
    return TRUE;
44
}
45

    
46
BOOL
47
xMBPortEventGet( eMBEventType * eEvent )
48
{
49
    BOOL            xEventHappened = FALSE;
50

    
51
    if( xEventInQueue )
52
    {
53
        *eEvent = eQueuedEvent;
54
        xEventInQueue = FALSE;
55
        xEventHappened = TRUE;
56
    }
57
    return xEventHappened;
58
}