master/sync.h
author Florian Pose <fp@igh-essen.com>
Thu, 04 Oct 2007 08:09:41 +0000
changeset 762 15214036c72a
parent 748 6c8801bd547f
child 792 3778920f61e4
permissions -rw-r--r--
Store PDO mapping source in sync manager.
628
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/******************************************************************************
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
 *  $Id$
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
 *  Copyright (C) 2006  Florian Pose, Ingenieurgemeinschaft IgH
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
 *
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
 *  This file is part of the IgH EtherCAT Master.
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
 *
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
 *  The IgH EtherCAT Master is free software; you can redistribute it
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
 *  and/or modify it under the terms of the GNU General Public License
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
 *  as published by the Free Software Foundation; either version 2 of the
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
 *  License, or (at your option) any later version.
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
 *
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
 *  The IgH EtherCAT Master is distributed in the hope that it will be
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
 *  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
 *  GNU General Public License for more details.
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
 *
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
 *  You should have received a copy of the GNU General Public License
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
 *  along with the IgH EtherCAT Master; if not, write to the Free Software
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
 *
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
 *  The right to use EtherCAT Technology is granted and comes free of
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
 *  charge under condition of compatibility of product made by
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
 *  Licensee. People intending to distribute/sell products based on the
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
 *  code, have to sign an agreement to guarantee that products using
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
 *  software based on IgH EtherCAT master stay compatible with the actual
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
 *  EtherCAT specification (which are released themselves as an open
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
 *  standard) as the (only) precondition to have the right to use EtherCAT
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
 *  Technology, IP and trade marks.
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
 *
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
 *****************************************************************************/
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
/**
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
   \file
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
   EtherCAT sync manager.
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
*/
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
/*****************************************************************************/
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
#ifndef _EC_SYNC_H_
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
#define _EC_SYNC_H_
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
#include <linux/list.h>
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
#include "../include/ecrt.h"
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
#include "globals.h"
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
/*****************************************************************************/
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
629
84a64efca00d Moved a few constants to the files they are needed in.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
    51
/** size of a sync manager configuration page */
84a64efca00d Moved a few constants to the files they are needed in.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
    52
#define EC_SYNC_SIZE 8
84a64efca00d Moved a few constants to the files they are needed in.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
    53
84a64efca00d Moved a few constants to the files they are needed in.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
    54
/*****************************************************************************/
84a64efca00d Moved a few constants to the files they are needed in.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
    55
628
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
/**
762
15214036c72a Store PDO mapping source in sync manager.
Florian Pose <fp@igh-essen.com>
parents: 748
diff changeset
    57
 * EtherCAT sync manager PDO mapping information source.
15214036c72a Store PDO mapping source in sync manager.
Florian Pose <fp@igh-essen.com>
parents: 748
diff changeset
    58
 */
15214036c72a Store PDO mapping source in sync manager.
Florian Pose <fp@igh-essen.com>
parents: 748
diff changeset
    59
15214036c72a Store PDO mapping source in sync manager.
Florian Pose <fp@igh-essen.com>
parents: 748
diff changeset
    60
typedef enum {
15214036c72a Store PDO mapping source in sync manager.
Florian Pose <fp@igh-essen.com>
parents: 748
diff changeset
    61
    EC_SYNC_MAPPING_NONE, /**< No PDO mapping information */
15214036c72a Store PDO mapping source in sync manager.
Florian Pose <fp@igh-essen.com>
parents: 748
diff changeset
    62
    EC_SYNC_MAPPING_SII, /**< PDO mapping information from SII */
15214036c72a Store PDO mapping source in sync manager.
Florian Pose <fp@igh-essen.com>
parents: 748
diff changeset
    63
    EC_SYNC_MAPPING_COE /**< PDO mapping information from CoE dictionary */
15214036c72a Store PDO mapping source in sync manager.
Florian Pose <fp@igh-essen.com>
parents: 748
diff changeset
    64
}
15214036c72a Store PDO mapping source in sync manager.
Florian Pose <fp@igh-essen.com>
parents: 748
diff changeset
    65
ec_sync_mapping_source_t;
15214036c72a Store PDO mapping source in sync manager.
Florian Pose <fp@igh-essen.com>
parents: 748
diff changeset
    66
15214036c72a Store PDO mapping source in sync manager.
Florian Pose <fp@igh-essen.com>
parents: 748
diff changeset
    67
/*****************************************************************************/
15214036c72a Store PDO mapping source in sync manager.
Florian Pose <fp@igh-essen.com>
parents: 748
diff changeset
    68
15214036c72a Store PDO mapping source in sync manager.
Florian Pose <fp@igh-essen.com>
parents: 748
diff changeset
    69
/**
628
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
 * Sync manager.
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
 */
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
typedef struct
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
{
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 629
diff changeset
    75
    ec_slave_t *slave; /**< slave, the sync manager belongs to */
628
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
    unsigned int index; /**< sync manager index */
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
    uint16_t physical_start_address; /**< physical start address */
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
    uint16_t length; /**< data length in bytes */
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
    uint8_t control_register; /**< control register value */
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
    uint8_t enable; /**< enable bit */
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 629
diff changeset
    82
    uint16_t est_length; /**< used to calculate the length via PDO ranges */
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 629
diff changeset
    83
    struct list_head pdos; /**< list of mapped PDOs */
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 629
diff changeset
    84
    unsigned int alt_mapping; /**< alternative mapping configured */
762
15214036c72a Store PDO mapping source in sync manager.
Florian Pose <fp@igh-essen.com>
parents: 748
diff changeset
    85
    ec_sync_mapping_source_t mapping_source; /**< pdo mapping source */
628
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
}
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    87
ec_sync_t;
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
/*****************************************************************************/
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 629
diff changeset
    91
void ec_sync_init(ec_sync_t *, ec_slave_t *, unsigned int);
628
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    92
void ec_sync_clear(ec_sync_t *);
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    93
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 629
diff changeset
    94
uint16_t ec_sync_size(const ec_sync_t *);
628
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
void ec_sync_config(const ec_sync_t *, uint8_t *);
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 629
diff changeset
    97
int ec_sync_add_pdo(ec_sync_t *, const ec_pdo_t *);
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 629
diff changeset
    98
void ec_sync_clear_pdos(ec_sync_t *);
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 629
diff changeset
    99
748
6c8801bd547f Added ec_sync_get_pdo_type().
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   100
ec_pdo_type_t ec_sync_get_pdo_type(const ec_sync_t *);
6c8801bd547f Added ec_sync_get_pdo_type().
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   101
628
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   102
/*****************************************************************************/
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   103
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   104
#endif