IgH EtherCAT Master
1.6.2
sdo.c
Go to the documentation of this file.
1
/*****************************************************************************
2
*
3
* Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH
4
*
5
* This file is part of the IgH EtherCAT Master.
6
*
7
* The IgH EtherCAT Master is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License version 2, as
9
* published by the Free Software Foundation.
10
*
11
* The IgH EtherCAT Master is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
14
* Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License along
17
* with the IgH EtherCAT Master; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
*
20
****************************************************************************/
21
27
/****************************************************************************/
28
29
#include <linux/slab.h>
30
31
#include "
master.h
"
32
33
#include "
sdo.h
"
34
35
/****************************************************************************/
36
39
void
ec_sdo_init
(
40
ec_sdo_t
*sdo,
41
ec_slave_t
*slave,
42
uint16_t index
43
)
44
{
45
sdo->
slave
= slave;
46
sdo->
index
= index;
47
sdo->
object_code
= 0x00;
48
sdo->
name
= NULL;
49
sdo->
max_subindex
= 0;
50
INIT_LIST_HEAD(&sdo->
entries
);
51
}
52
53
/****************************************************************************/
54
59
void
ec_sdo_clear
(
60
ec_sdo_t
*sdo
61
)
62
{
63
ec_sdo_entry_t
*entry, *next;
64
65
// free all entries
66
list_for_each_entry_safe(entry, next, &sdo->
entries
, list) {
67
list_del(&entry->
list
);
68
ec_sdo_entry_clear
(entry);
69
kfree(entry);
70
}
71
72
if
(sdo->
name
)
73
kfree(sdo->
name
);
74
}
75
76
/****************************************************************************/
77
83
ec_sdo_entry_t
*
ec_sdo_get_entry
(
84
ec_sdo_t
*sdo,
85
uint8_t subindex
86
)
87
{
88
ec_sdo_entry_t
*entry;
89
90
list_for_each_entry(entry, &sdo->
entries
, list) {
91
if
(entry->
subindex
!= subindex)
92
continue
;
93
return
entry;
94
}
95
96
return
NULL;
97
}
98
99
/****************************************************************************/
100
108
const
ec_sdo_entry_t
*
ec_sdo_get_entry_const
(
109
const
ec_sdo_t
*sdo,
110
uint8_t subindex
111
)
112
{
113
const
ec_sdo_entry_t
*entry;
114
115
list_for_each_entry(entry, &sdo->
entries
, list) {
116
if
(entry->
subindex
!= subindex)
117
continue
;
118
return
entry;
119
}
120
121
return
NULL;
122
}
123
124
/****************************************************************************/
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:108
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:83
ec_sdo_entry_t
CANopen SDO entry.
Definition:
sdo_entry.h:46
ec_sdo
CANopen SDO.
Definition:
sdo.h:41
ec_sdo::index
uint16_t index
SDO index.
Definition:
sdo.h:44
ec_sdo::slave
ec_slave_t * slave
Parent slave.
Definition:
sdo.h:43
ec_sdo_entry_t::list
struct list_head list
List item.
Definition:
sdo_entry.h:47
master.h
EtherCAT master structure.
ec_sdo::object_code
uint8_t object_code
Object code.
Definition:
sdo.h:45
ec_slave
EtherCAT slave.
Definition:
slave.h:168
ec_sdo::name
char * name
SDO name.
Definition:
sdo.h:46
ec_sdo_entry_clear
void ec_sdo_entry_clear(ec_sdo_entry_t *entry)
Destructor.
Definition:
sdo_entry.c:60
ec_sdo_init
void ec_sdo_init(ec_sdo_t *sdo, ec_slave_t *slave, uint16_t index)
Constructor.
Definition:
sdo.c:39
ec_sdo::entries
struct list_head entries
List of entries.
Definition:
sdo.h:48
ec_sdo::max_subindex
uint8_t max_subindex
Maximum subindex.
Definition:
sdo.h:47
ec_sdo_clear
void ec_sdo_clear(ec_sdo_t *sdo)
SDO destructor.
Definition:
sdo.c:59
sdo.h
EtherCAT CANopen SDO structure.
ec_sdo_entry_t::subindex
uint8_t subindex
Subindex.
Definition:
sdo_entry.h:49
Documentation automatically created by
. - IgH EtherCAT Master developed by
Ingenieurgemeinschaft IgH GmbH
. All rights reserved.