master/coe_emerg_ring.c
author Florian Pose <fp@igh-essen.com>
Wed, 05 Dec 2012 11:47:07 +0100
branchstable-1.5
changeset 2471 fc64a4b1ec1a
parent 2438 9c3e629a220c
child 2522 ec403cf308eb
permissions -rw-r--r--
Fixed __e1000_maybe_stop_tx().
2438
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/******************************************************************************
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
 *  $Id$
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
 *  Copyright (C) 2012  Florian Pose, Ingenieurgemeinschaft IgH
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
 *
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
 *  This file is part of the IgH EtherCAT Master.
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
 *
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
 *  The IgH EtherCAT Master is free software; you can redistribute it and/or
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
 *  modify it under the terms of the GNU General Public License version 2, as
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
 *  published by the Free Software Foundation.
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
 *
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
 *  The IgH EtherCAT Master is distributed in the hope that it will be useful,
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
 *  Public License for more details.
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
 *
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
 *  You should have received a copy of the GNU General Public License along
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
 *  with the IgH EtherCAT Master; if not, write to the Free Software
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
 *
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
 *  ---
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
 *
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
 *  The license mentioned above concerns the source code only. Using the
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
 *  EtherCAT technology and brand is only permitted in compliance with the
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
 *  industrial property and similar rights of Beckhoff Automation GmbH.
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
 *
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
 *  vim: expandtab
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
 *
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
 *****************************************************************************/
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
/**
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
   \file
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
   EtherCAT CoE emergency ring buffer methods.
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
*/
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
/*****************************************************************************/
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
#include <linux/slab.h>
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
#include "coe_emerg_ring.h"
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
/*****************************************************************************/
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
/** Emergency ring buffer constructor.
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
 */
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
void ec_coe_emerg_ring_init(
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
        ec_coe_emerg_ring_t *ring, /**< Emergency ring. */
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
        ec_slave_config_t *sc /**< Slave configuration. */
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
        )
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
{
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
    ring->sc = sc;
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
    ring->msgs = NULL;
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
    ring->size = 0;
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
    ring->read_index = 0;
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
    ring->write_index = 0;
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
    ring->overruns = 0;
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
}
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
/*****************************************************************************/
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
/** Emergency ring buffer destructor.
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
 */
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
void ec_coe_emerg_ring_clear(
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
        ec_coe_emerg_ring_t *ring /**< Emergency ring. */
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
        )
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
{
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
    if (ring->msgs) {
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
        kfree(ring->msgs);
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
    }
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
}
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
/*****************************************************************************/
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
/** Set the ring size.
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
 */
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
int ec_coe_emerg_ring_size(
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
        ec_coe_emerg_ring_t *ring, /**< Emergency ring. */
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
        size_t size /**< Maximum number of messages in the ring. */
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
        )
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
{
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
    ring->size = 0;
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
    if (size < 0) {
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
        size = 0;
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
    }
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    87
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
    ring->read_index = ring->write_index = 0;
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
    if (ring->msgs) {
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    91
        kfree(ring->msgs);
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    92
    }
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    93
    ring->msgs = NULL;
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    94
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
    if (size == 0) {
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
        return 0;
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
    }
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    98
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    99
    ring->msgs = kmalloc(sizeof(ec_coe_emerg_msg_t) * (size + 1), GFP_KERNEL);
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   100
    if (!ring->msgs) {
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   101
        return -ENOMEM;
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   102
    }
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   103
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   104
    ring->size = size;
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   105
    return 0;
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   106
}
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   107
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   108
/*****************************************************************************/
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   109
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   110
/** Add a new emergency message.
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   111
 */
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   112
void ec_coe_emerg_ring_push(
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   113
        ec_coe_emerg_ring_t *ring, /**< Emergency ring. */
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   114
        const u8 *msg /**< Emergency message. */
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   115
        )
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
{
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   117
    if (!ring->size ||
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   118
            (ring->write_index + 1) % (ring->size + 1) == ring->read_index) {
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   119
        ring->overruns++;
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   120
        return;
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   121
    }
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   122
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   123
    memcpy(ring->msgs[ring->write_index].data, msg,
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   124
            EC_COE_EMERGENCY_MSG_SIZE);
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   125
    ring->write_index = (ring->write_index + 1) % (ring->size + 1);
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   126
}
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   127
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   128
/*****************************************************************************/
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   129
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   130
/** Remove an emergency message from the ring.
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   131
 */
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   132
int ec_coe_emerg_ring_pop(
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   133
        ec_coe_emerg_ring_t *ring, /**< Emergency ring. */
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   134
        u8 *msg /**< Memory to store the emergency message. */
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   135
        )
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   136
{
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   137
    if (ring->read_index == ring->write_index) {
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   138
        return -ENOENT;
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   139
    }
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   140
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   141
    memcpy(msg, ring->msgs[ring->read_index].data, EC_COE_EMERGENCY_MSG_SIZE);
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   142
    ring->read_index = (ring->read_index + 1) % (ring->size + 1);
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   143
    return 0;
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   144
}
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   145
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   146
/*****************************************************************************/
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   147
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   148
/** Clear the ring.
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   149
 */
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   150
int ec_coe_emerg_ring_clear_ring(
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   151
        ec_coe_emerg_ring_t *ring /**< Emergency ring. */
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   152
        )
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   153
{
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   154
    ring->read_index = ring->write_index;
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   155
    ring->overruns = 0;
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   156
    return 0;
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   157
}
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   158
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   159
/*****************************************************************************/
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   160
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   161
/** Read the number of overruns.
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   162
 */
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   163
int ec_coe_emerg_ring_overruns(
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   164
        ec_coe_emerg_ring_t *ring /**< Emergency ring. */
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   165
        )
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   166
{
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   167
    return ring->overruns;
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   168
}
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   169
9c3e629a220c Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   170
/*****************************************************************************/