IgH EtherCAT Master
1.5.3
sdo.c
Go to the documentation of this file.
1
/******************************************************************************
2
*
3
* $Id$
4
*
5
* Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH
6
*
7
* This file is part of the IgH EtherCAT Master.
8
*
9
* The IgH EtherCAT Master is free software; you can redistribute it and/or
10
* modify it under the terms of the GNU General Public License version 2, as
11
* published by the Free Software Foundation.
12
*
13
* The IgH EtherCAT Master is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
16
* Public License for more details.
17
*
18
* You should have received a copy of the GNU General Public License along
19
* with the IgH EtherCAT Master; if not, write to the Free Software
20
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
*
22
* ---
23
*
24
* The license mentioned above concerns the source code only. Using the
25
* EtherCAT technology and brand is only permitted in compliance with the
26
* industrial property and similar rights of Beckhoff Automation GmbH.
27
*
28
*****************************************************************************/
29
35
/*****************************************************************************/
36
37
#include <linux/slab.h>
38
39
#include "
master.h
"
40
41
#include "
sdo.h
"
42
43
/*****************************************************************************/
44
47
void
ec_sdo_init
(
48
ec_sdo_t
*sdo,
49
ec_slave_t
*slave,
50
uint16_t index
51
)
52
{
53
sdo->
slave
= slave;
54
sdo->
index
= index;
55
sdo->
object_code
= 0x00;
56
sdo->
name
= NULL;
57
sdo->
max_subindex
= 0;
58
INIT_LIST_HEAD(&sdo->
entries
);
59
}
60
61
/*****************************************************************************/
62
67
void
ec_sdo_clear
(
68
ec_sdo_t
*sdo
69
)
70
{
71
ec_sdo_entry_t
*entry, *next;
72
73
// free all entries
74
list_for_each_entry_safe(entry, next, &sdo->
entries
, list) {
75
list_del(&entry->
list
);
76
ec_sdo_entry_clear
(entry);
77
kfree(entry);
78
}
79
80
if
(sdo->
name
)
81
kfree(sdo->
name
);
82
}
83
84
/*****************************************************************************/
85
91
ec_sdo_entry_t
*
ec_sdo_get_entry
(
92
ec_sdo_t
*sdo,
93
uint8_t subindex
94
)
95
{
96
ec_sdo_entry_t
*entry;
97
98
list_for_each_entry(entry, &sdo->
entries
, list) {
99
if
(entry->
subindex
!= subindex)
100
continue
;
101
return
entry;
102
}
103
104
return
NULL;
105
}
106
107
/*****************************************************************************/
108
116
const
ec_sdo_entry_t
*
ec_sdo_get_entry_const
(
117
const
ec_sdo_t
*sdo,
118
uint8_t subindex
119
)
120
{
121
const
ec_sdo_entry_t
*entry;
122
123
list_for_each_entry(entry, &sdo->
entries
, list) {
124
if
(entry->
subindex
!= subindex)
125
continue
;
126
return
entry;
127
}
128
129
return
NULL;
130
}
131
132
/*****************************************************************************/
ec_sdo_get_entry_const
const ec_sdo_entry_t * ec_sdo_get_entry_const(const ec_sdo_t *sdo, uint8_t subindex)
Get an SDO entry from an SDO via its subindex.
Definition:
sdo.c:116
ec_sdo_get_entry
ec_sdo_entry_t * ec_sdo_get_entry(ec_sdo_t *sdo, uint8_t subindex)
Get an SDO entry from an SDO via its subindex.
Definition:
sdo.c:91
ec_sdo_entry_t
CANopen SDO entry.
Definition:
sdo_entry.h:54
ec_sdo
CANopen SDO.
Definition:
sdo.h:49
ec_sdo::index
uint16_t index
SDO index.
Definition:
sdo.h:52
ec_sdo::slave
ec_slave_t * slave
Parent slave.
Definition:
sdo.h:51
ec_sdo_entry_t::list
struct list_head list
List item.
Definition:
sdo_entry.h:55
master.h
EtherCAT master structure.
ec_sdo::object_code
uint8_t object_code
Object code.
Definition:
sdo.h:53
ec_slave
EtherCAT slave.
Definition:
slave.h:176
ec_sdo::name
char * name
SDO name.
Definition:
sdo.h:54
ec_sdo_entry_clear
void ec_sdo_entry_clear(ec_sdo_entry_t *entry)
Destructor.
Definition:
sdo_entry.c:68
ec_sdo_init
void ec_sdo_init(ec_sdo_t *sdo, ec_slave_t *slave, uint16_t index)
Constructor.
Definition:
sdo.c:47
ec_sdo::entries
struct list_head entries
List of entries.
Definition:
sdo.h:56
ec_sdo::max_subindex
uint8_t max_subindex
Maximum subindex.
Definition:
sdo.h:55
ec_sdo_clear
void ec_sdo_clear(ec_sdo_t *sdo)
SDO destructor.
Definition:
sdo.c:67
sdo.h
EtherCAT CANopen SDO structure.
ec_sdo_entry_t::subindex
uint8_t subindex
Subindex.
Definition:
sdo_entry.h:57
Documentation automatically createt on Fri Jun 7 2024 11:28:45 by
. - IgH EtherCAT Master developed by
Ingenieurgemeinschaft IgH GmbH
. All rights reserved.