master/canopen.h
author Florian Pose <fp@igh-essen.com>
Thu, 28 Feb 2008 11:07:40 +0000
changeset 837 133528cfd528
parent 831 ded9519c8d6e
permissions -rw-r--r--
NEWS.
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/******************************************************************************
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
 *  $Id$
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
 *  Copyright (C) 2006  Florian Pose, Ingenieurgemeinschaft IgH
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
 *
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
 *  This file is part of the IgH EtherCAT Master.
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
 *
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
 *  The IgH EtherCAT Master is free software; you can redistribute it
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
 *  and/or modify it under the terms of the GNU General Public License
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
 *  as published by the Free Software Foundation; either version 2 of the
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
 *  License, or (at your option) any later version.
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
 *
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
 *  The IgH EtherCAT Master is distributed in the hope that it will be
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
 *  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
 *  GNU General Public License for more details.
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
 *
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
 *  You should have received a copy of the GNU General Public License
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
 *  along with the IgH EtherCAT Master; if not, write to the Free Software
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
 *
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
 *  The right to use EtherCAT Technology is granted and comes free of
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
 *  charge under condition of compatibility of product made by
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
 *  Licensee. People intending to distribute/sell products based on the
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
 *  code, have to sign an agreement to guarantee that products using
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
 *  software based on IgH EtherCAT master stay compatible with the actual
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
 *  EtherCAT specification (which are released themselves as an open
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
 *  standard) as the (only) precondition to have the right to use EtherCAT
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
 *  Technology, IP and trade marks.
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
 *
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
 *****************************************************************************/
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
/**
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
   \file
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
   EtherCAT CANopen structures.
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
*/
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
/*****************************************************************************/
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
#ifndef _EC_CANOPEN_H_
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
#define _EC_CANOPEN_H_
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
#include <linux/list.h>
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
#include <linux/kobject.h>
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
#include "globals.h"
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
#include "slave.h"
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
/*****************************************************************************/
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
831
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
    52
/** CANopen Sdo.
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
    53
 */
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
    54
struct ec_sdo {
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
    struct kobject kobj; /**< kobject */
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
    struct list_head list; /**< list item */
430
74754f45d5fa Implemented SDO reading via Sysfs.
Florian Pose <fp@igh-essen.com>
parents: 409
diff changeset
    57
    ec_slave_t *slave; /**< parent slave */
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
    58
    uint16_t index; /**< Sdo index */
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
    uint8_t object_code; /**< object code */
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
    60
    char *name; /**< Sdo name */
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
    uint8_t subindices; /**< subindices */
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
    struct list_head entries; /**< entry list */
740
68d83b45dfa2 Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents: 739
diff changeset
    63
};
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
/*****************************************************************************/
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
831
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
    67
/** CANopen Sdo entry.
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
    68
 */
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
    69
typedef struct {
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
    struct kobject kobj; /**< kobject */
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
    struct list_head list; /**< list item */
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
    72
    ec_sdo_t *sdo; /**< parent Sdo */
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
    uint8_t subindex; /**< entry subindex */
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
    uint16_t data_type; /**< entry data type */
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
    uint16_t bit_length; /**< entry length in bit */
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
    char *description; /**< entry description */
831
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
    77
} ec_sdo_entry_t;
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
/*****************************************************************************/
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
831
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
    81
/** CANopen Sdo configuration data.
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
    82
 */
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
    83
typedef struct {
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
    struct list_head list; /**< list item */
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
    85
    uint16_t index; /**< Sdo index */
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
    86
    uint8_t subindex; /**< Sdo subindex */
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
    87
    uint8_t *data; /**< pointer to Sdo data */
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
    88
    size_t size; /**< size of Sdo data */
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
}
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
ec_sdo_data_t;
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    91
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    92
/*****************************************************************************/
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    93
430
74754f45d5fa Implemented SDO reading via Sysfs.
Florian Pose <fp@igh-essen.com>
parents: 409
diff changeset
    94
/**
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
    95
   CANopen Sdo request.
430
74754f45d5fa Implemented SDO reading via Sysfs.
Florian Pose <fp@igh-essen.com>
parents: 409
diff changeset
    96
*/
74754f45d5fa Implemented SDO reading via Sysfs.
Florian Pose <fp@igh-essen.com>
parents: 409
diff changeset
    97
831
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
    98
typedef struct {
646
fbbd4e54e031 Implemented SDO reading with wait queues.
Florian Pose <fp@igh-essen.com>
parents: 448
diff changeset
    99
    struct list_head list; /**< list item */
831
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   100
    ec_slave_t *slave; /**< Slave owning the Sdo. */
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   101
    uint16_t index; /**< Sdo index. */
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   102
    uint8_t subindex; /**< Sdo subindex. */
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
   103
    uint8_t *data; /**< pointer to Sdo data */
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
   104
    size_t size; /**< size of Sdo data */
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
   105
    ec_request_state_t state; /**< Sdo request state */
831
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   106
} ec_sdo_request_t;
430
74754f45d5fa Implemented SDO reading via Sysfs.
Florian Pose <fp@igh-essen.com>
parents: 409
diff changeset
   107
74754f45d5fa Implemented SDO reading via Sysfs.
Florian Pose <fp@igh-essen.com>
parents: 409
diff changeset
   108
/*****************************************************************************/
74754f45d5fa Implemented SDO reading via Sysfs.
Florian Pose <fp@igh-essen.com>
parents: 409
diff changeset
   109
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   110
int ec_sdo_init(ec_sdo_t *, uint16_t, ec_slave_t *);
448
e4b76dc7910c FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents: 430
diff changeset
   111
void ec_sdo_destroy(ec_sdo_t *);
740
68d83b45dfa2 Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents: 739
diff changeset
   112
ec_sdo_entry_t *ec_sdo_get_entry(ec_sdo_t *, uint8_t);
448
e4b76dc7910c FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents: 430
diff changeset
   113
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   114
int ec_sdo_entry_init(ec_sdo_entry_t *, uint8_t, ec_sdo_t *);
448
e4b76dc7910c FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents: 430
diff changeset
   115
void ec_sdo_entry_destroy(ec_sdo_entry_t *);
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
831
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   117
void ec_sdo_request_init_read(ec_sdo_request_t *, ec_slave_t *, uint16_t,
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   118
        uint8_t);
739
4a02162a6301 Removed 'sdo' field from ec_sdo_request_t; Exported
Florian Pose <fp@igh-essen.com>
parents: 646
diff changeset
   119
void ec_sdo_request_clear(ec_sdo_request_t *);
4a02162a6301 Removed 'sdo' field from ec_sdo_request_t; Exported
Florian Pose <fp@igh-essen.com>
parents: 646
diff changeset
   120
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   121
/*****************************************************************************/
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   122
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   123
#endif