libethercat - an embeddable realtime EtherCAT-master library
Communicate with EtherCAT slaves attached to a Network interface.
Loading...
Searching...
No Matches
eeprom.h
Go to the documentation of this file.
1
14/*
15 * This file is part of libethercat.
16 *
17 * libethercat is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU Lesser General Public
19 * License as published by the Free Software Foundation; either
20 * version 3 of the License, or (at your option) any later version.
21 *
22 * libethercat is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 * Lesser General Public License for more details.
26 *
27 * You should have received a copy of the GNU Lesser General Public
28 * License along with libethercat (LICENSE.LGPL-V3); if not, write
29 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
30 * Floor, Boston, MA 02110-1301, USA.
31 *
32 * Please note that the use of the EtherCAT technology, the EtherCAT
33 * brand name and the EtherCAT logo is only permitted if the property
34 * rights of Beckhoff Automation GmbH are observed. For further
35 * information please contact Beckhoff Automation GmbH & Co. KG,
36 * Hülshorstweg 20, D-33415 Verl, Germany (www.beckhoff.com) or the
37 * EtherCAT Technology Group, Ostendstraße 196, D-90482 Nuremberg,
38 * Germany (ETG, www.ethercat.org).
39 *
40 */
41
42#ifndef LIBETHERCAT_EEPROM_H
43#define LIBETHERCAT_EEPROM_H
44
45#include <libosal/queue.h>
46#include <libosal/types.h>
47
48#include "libethercat/common.h"
49
57//------------------ Category General ---------------
58
59typedef struct PACKED ec_eeprom_cat_general {
60 osal_uint8_t group_idx;
61 osal_uint8_t img_idx;
62 osal_uint8_t order_idx;
63 osal_uint8_t name_idx;
64 osal_uint8_t physical_layer;
65 osal_uint8_t can_open;
66 osal_uint8_t file_access;
67 osal_uint8_t ethernet;
68 osal_uint8_t soe_channels;
69 osal_uint8_t ds402_channels;
70 osal_uint8_t sysman_class;
71 osal_uint8_t flags;
72 osal_uint16_t current_on_ebus;
73} ec_eeprom_cat_general_t;
74
75//------------------ Category PDO -------------------
76
77typedef struct PACKED ec_eeprom_cat_pdo_entry {
78 osal_uint16_t entry_index;
79 osal_uint8_t sub_index;
80 osal_uint8_t entry_name_idx;
81 osal_uint8_t data_type;
82 osal_uint8_t bit_len;
83 osal_uint16_t flags;
84} ec_eeprom_cat_pdo_entry_t;
85
86typedef struct ec_eeprom_cat_pdo {
87 struct PACKED {
88 osal_uint16_t pdo_index;
89 osal_uint8_t n_entry;
90 osal_uint8_t sm_nr;
91 osal_uint8_t dc_sync;
92 osal_uint8_t name_idx;
93 osal_uint16_t flags;
94
95#define EC_EEPROM_CAT_PDO_LEN (osal_size_t)8u
96 };
97
98 ec_eeprom_cat_pdo_entry_t entries[LEC_MAX_EEPROM_CAT_PDO_ENTRIES];
100
104
106TAILQ_HEAD(ec_eeprom_cat_pdo_queue, ec_eeprom_cat_pdo);
107
108//------------------ Category SM --------------------
109
111typedef struct PACKED ec_eeprom_cat_sm {
112 osal_uint16_t adr;
113 osal_uint16_t len;
114 osal_uint8_t ctrl_reg;
115 osal_uint8_t status_reg;
116 osal_uint8_t activate;
117 osal_uint8_t pdi_ctrl;
119
120//------------------ Category DC --------------------
121
123typedef struct PACKED ec_eeprom_cat_dc {
124 osal_uint32_t cycle_time_0;
125 osal_uint32_t shift_time_0;
126 osal_uint32_t shift_time_1;
127 osal_int16_t sync_1_cycle_factor;
128 osal_uint16_t assign_active;
129 osal_int16_t sync_0_cycle_factor;
130 osal_uint8_t name_idx;
131 osal_uint8_t desc_idx;
132 osal_uint8_t reserved[4];
133#define EC_EEPROM_CAT_DC_LEN (osal_size_t)25u
135
136//------------------ Category FMMU ------------------
137
139typedef struct PACKED ec_eeprom_cat_fmmu {
140 osal_uint8_t type;
142
143typedef struct eeprom_info {
145
146 osal_uint32_t vendor_id;
147 osal_uint32_t product_code;
148 osal_uint16_t mbx_supported;
149
150 osal_uint16_t mbx_receive_offset;
151 osal_uint16_t mbx_receive_size;
152 osal_uint16_t mbx_send_offset;
153 osal_uint16_t mbx_send_size;
154
156 osal_uint16_t boot_mbx_receive_size;
157 osal_uint16_t boot_mbx_send_offset;
158 osal_uint16_t boot_mbx_send_size;
159
160 ec_eeprom_cat_general_t general;
161
162 osal_uint8_t strings_cnt;
164
165 osal_uint8_t sms_cnt;
167
168 osal_uint8_t fmmus_cnt;
170
172 struct ec_eeprom_cat_pdo_queue free_pdo_queue;
173
174 struct ec_eeprom_cat_pdo_queue txpdos;
175 struct ec_eeprom_cat_pdo_queue rxpdos;
176
177 osal_uint8_t dcs_cnt;
180
181#define EC_EEPROM_MBX_AOE (0x01u)
182#define EC_EEPROM_MBX_EOE (0x02u)
183#define EC_EEPROM_MBX_COE (0x04u)
184#define EC_EEPROM_MBX_FOE (0x08u)
185#define EC_EEPROM_MBX_SOE (0x10u)
186#define EC_EEPROM_MBX_VOE (0x20u)
187
188#define EC_EEPROM_ADR_VENDOR_ID (0x0008u)
189#define EC_EEPROM_ADR_PRODUCT_CODE (0x000Au)
190#define EC_EEPROM_ADR_BOOT_MBX_RECV_OFF (0x0014u)
191#define EC_EEPROM_ADR_BOOT_MBX_RECV_SIZE (0x0015u)
192#define EC_EEPROM_ADR_BOOT_MBX_SEND_OFF (0x0016u)
193#define EC_EEPROM_ADR_BOOT_MBX_SEND_SIZE (0x0017u)
194#define EC_EEPROM_ADR_STD_MBX_RECV_OFF (0x0018u)
195#define EC_EEPROM_ADR_STD_MBX_RECV_SIZE (0x0019u)
196#define EC_EEPROM_ADR_STD_MBX_SEND_OFF (0x001Au)
197#define EC_EEPROM_ADR_STD_MBX_SEND_SIZE (0x001Bu)
198#define EC_EEPROM_ADR_MBX_SUPPORTED (0x001Cu)
199#define EC_EEPROM_ADR_SIZE (0x003Eu)
200#define EC_EEPROM_ADR_CAT_OFFSET (0x0040u)
201
202#define EC_EEPROM_CAT_NOP ( 0u)
203#define EC_EEPROM_CAT_STRINGS ( 10u)
204#define EC_EEPROM_CAT_DATATYPES ( 20u)
205#define EC_EEPROM_CAT_GENERAL ( 30u)
206#define EC_EEPROM_CAT_FMMU ( 40u)
207#define EC_EEPROM_CAT_SM ( 41u)
208#define EC_EEPROM_CAT_TXPDO ( 50u)
209#define EC_EEPROM_CAT_RXPDO ( 51u)
210#define EC_EEPROM_CAT_DC ( 60u)
211#define EC_EEPROM_CAT_END (0xFFFFu)
212
213#ifdef __cplusplus
214extern "C" {
215#endif
216
217// forward decl
218struct ec;
219
221
231int ec_eeprom_to_pdi(struct ec *pec, osal_uint16_t slave);
232
234
244int ec_eeprom_to_ec(struct ec *pec, osal_uint16_t slave);
245
247
262int ec_eepromread(struct ec *pec, osal_uint16_t slave,
263 osal_uint32_t eepadr, osal_uint32_t *data);
264
266
281int ec_eepromwrite(struct ec *pec, osal_uint16_t slave,
282 osal_uint32_t eepadr, osal_uint16_t *data);
283
285
301int ec_eepromread_len(struct ec *pec, osal_uint16_t slave,
302 osal_uint32_t eepadr, osal_uint8_t *buf, osal_size_t buflen);
303
305
322int ec_eepromwrite_len(struct ec *pec, osal_uint16_t slave,
323 osal_uint32_t eepadr, const osal_uint8_t *buf, osal_size_t buflen);
324
326
339void ec_eeprom_dump(struct ec *pec, osal_uint16_t slave);
340
341#ifdef __cplusplus
342}
343#endif
344
347#endif // LIBETHERCAT_EEPROM_H
348
ethercat master common stuff
#define LEC_MAX_EEPROM_CAT_PDO
Maximum number of EEPROM catergory PDO entries.
Definition common.h:135
#define LEC_MAX_STRING_LEN
Maximum string length.
Definition common.h:167
#define LEC_MAX_EEPROM_CAT_DC
Maximum number of EEPROM catergory distributed clocks entries.
Definition common.h:159
#define LEC_MAX_EEPROM_CAT_FMMU
Maximum number of EEPROM catergory FMMU entries.
Definition common.h:127
#define LEC_MAX_EEPROM_CAT_SM
Maximum number of EEPROM catergory sync manager entries.
Definition common.h:119
#define LEC_MAX_EEPROM_CAT_STRINGS
Maximum number of EEPROM catergory string entries.
Definition common.h:151
#define LEC_MAX_EEPROM_CAT_PDO_ENTRIES
Maximum number of EEPROM catergory PDO entries.
Definition common.h:143
TAILQ_HEAD(ec_eeprom_cat_pdo_queue, ec_eeprom_cat_pdo)
head to PDO queue
struct PACKED ec_eeprom_cat_sm ec_eeprom_cat_sm_t
eeprom sync manager settings
int ec_eepromread_len(struct ec *pec, osal_uint16_t slave, osal_uint32_t eepadr, osal_uint8_t *buf, osal_size_t buflen)
Read a burst of eeprom data.
void ec_eeprom_dump(struct ec *pec, osal_uint16_t slave)
Read out whole eeprom and categories and store in EtherCAT master structure.
int ec_eepromread(struct ec *pec, osal_uint16_t slave, osal_uint32_t eepadr, osal_uint32_t *data)
Read 32-bit word of eeprom.
struct PACKED ec_eeprom_cat_dc ec_eeprom_cat_dc_t
eeprom distributed clocks settings
struct PACKED ec_eeprom_cat_fmmu ec_eeprom_cat_fmmu_t
eeporm fmmu description
int ec_eeprom_to_pdi(struct ec *pec, osal_uint16_t slave)
Set eeprom control to pdi.
int ec_eepromwrite(struct ec *pec, osal_uint16_t slave, osal_uint32_t eepadr, osal_uint16_t *data)
Write 32-bit word to eeprom.
int ec_eeprom_to_ec(struct ec *pec, osal_uint16_t slave)
Set eeprom control to ec.
int ec_eepromwrite_len(struct ec *pec, osal_uint16_t slave, osal_uint32_t eepadr, const osal_uint8_t *buf, osal_size_t buflen)
Write a burst of eeprom data.
eeprom distributed clocks settings
Definition eeprom.h:123
osal_uint8_t desc_idx
description index
Definition eeprom.h:131
osal_uint32_t cycle_time_0
cycle time sync0
Definition eeprom.h:124
osal_uint32_t shift_time_0
shift time sync0
Definition eeprom.h:125
osal_uint32_t shift_time_1
shift time sync1
Definition eeprom.h:126
osal_uint8_t name_idx
name index in eeprom strings
Definition eeprom.h:130
osal_uint16_t assign_active
activation flags
Definition eeprom.h:128
osal_int16_t sync_0_cycle_factor
cycle factor sync0
Definition eeprom.h:129
osal_int16_t sync_1_cycle_factor
cycle factor sync1
Definition eeprom.h:127
eeporm fmmu description
Definition eeprom.h:139
osal_uint8_t type
fmmu type
Definition eeprom.h:140
Definition eeprom.h:59
osal_uint8_t sysman_class
sys man ?
Definition eeprom.h:70
osal_uint8_t flags
eeprom flags
Definition eeprom.h:71
osal_uint8_t soe_channels
supported soe channels
Definition eeprom.h:68
osal_uint8_t ds402_channels
supported ds402 channels
Definition eeprom.h:69
osal_uint8_t img_idx
image name, index to STRING
Definition eeprom.h:61
osal_uint8_t ethernet
eoe support
Definition eeprom.h:67
osal_uint8_t file_access
foe support
Definition eeprom.h:66
osal_uint8_t name_idx
device name, index to STRING
Definition eeprom.h:63
osal_uint8_t can_open
coe support
Definition eeprom.h:65
osal_uint8_t physical_layer
physical layer, 0 e-bus, 1, 100base-tx
Definition eeprom.h:64
osal_uint16_t current_on_ebus
ebus current in [mA], negative = feed-in
Definition eeprom.h:72
osal_uint8_t group_idx
group information, index to STRING
Definition eeprom.h:60
osal_uint8_t order_idx
device order number, index to STRING
Definition eeprom.h:62
Definition eeprom.h:87
osal_uint16_t flags
PDO flags.
Definition eeprom.h:93
osal_uint8_t n_entry
number of PDO entries
Definition eeprom.h:89
osal_uint8_t sm_nr
assigned sync manager
Definition eeprom.h:90
osal_uint8_t name_idx
name index in eeprom strings
Definition eeprom.h:92
osal_uint16_t pdo_index
PDO index.
Definition eeprom.h:88
osal_uint8_t dc_sync
use distributed clocks
Definition eeprom.h:91
Definition eeprom.h:77
osal_uint16_t entry_index
PDO entry index (CoE)
Definition eeprom.h:78
osal_uint16_t flags
PDO entry flags.
Definition eeprom.h:83
osal_uint8_t entry_name_idx
name index in eeprom strings
Definition eeprom.h:80
osal_uint8_t sub_index
PDO entry subindex.
Definition eeprom.h:79
osal_uint8_t data_type
data type
Definition eeprom.h:81
osal_uint8_t bit_len
length in bits
Definition eeprom.h:82
Definition eeprom.h:86
ec_eeprom_cat_pdo_entry_t entries[LEC_MAX_EEPROM_CAT_PDO_ENTRIES]
PDO entries, (n_entry count)
Definition eeprom.h:98
TAILQ_ENTRY(ec_eeprom_cat_pdo) qh
queue handle for PDO queue
eeprom sync manager settings
Definition eeprom.h:111
osal_uint8_t activate
activation flags
Definition eeprom.h:116
osal_uint8_t ctrl_reg
control register init value
Definition eeprom.h:114
osal_uint16_t len
length at physical start address
Definition eeprom.h:113
osal_uint8_t pdi_ctrl
pdi control register
Definition eeprom.h:117
osal_uint8_t status_reg
status register init value
Definition eeprom.h:115
osal_uint16_t adr
physical start addres
Definition eeprom.h:112
ethercat master structure
Definition ec.h:188
Definition eeprom.h:143
struct ec_eeprom_cat_pdo_queue free_pdo_queue
free pdo queue.
Definition eeprom.h:172
osal_uint16_t mbx_receive_size
default mailbox receive size
Definition eeprom.h:151
osal_uint16_t boot_mbx_send_size
boot mailbox send size
Definition eeprom.h:158
osal_uint16_t mbx_send_size
default mailbox send size
Definition eeprom.h:153
ec_eeprom_cat_pdo_t free_pdos[LEC_MAX_EEPROM_CAT_PDO]
static pdos for free queue.
Definition eeprom.h:171
osal_uint32_t vendor_id
vendor id
Definition eeprom.h:146
osal_uint8_t dcs_cnt
count of distributed clocks settings
Definition eeprom.h:177
struct ec_eeprom_cat_pdo_queue txpdos
queue with TXPDOs
Definition eeprom.h:174
ec_eeprom_cat_general_t general
general category
Definition eeprom.h:160
ec_eeprom_cat_sm_t sms[LEC_MAX_EEPROM_CAT_SM]
array of sync manager settings
Definition eeprom.h:166
osal_char_t strings[LEC_MAX_EEPROM_CAT_STRINGS][LEC_MAX_STRING_LEN]
array of strings
Definition eeprom.h:163
osal_uint16_t boot_mbx_send_offset
boot mailbox send offset
Definition eeprom.h:157
osal_uint16_t mbx_receive_offset
default mailbox receive offset
Definition eeprom.h:150
osal_uint32_t product_code
product code
Definition eeprom.h:147
osal_uint16_t mbx_supported
mailbox supported by slave
Definition eeprom.h:148
osal_uint8_t sms_cnt
count of sync manager settings
Definition eeprom.h:165
ec_eeprom_cat_fmmu_t fmmus[LEC_MAX_EEPROM_CAT_FMMU]
array of fmmu settings
Definition eeprom.h:169
osal_uint16_t mbx_send_offset
default mailbox send offset
Definition eeprom.h:152
osal_uint16_t boot_mbx_receive_size
boot mailbox receive size
Definition eeprom.h:156
osal_uint16_t boot_mbx_receive_offset
boot mailbox receive offset
Definition eeprom.h:155
struct ec_eeprom_cat_pdo_queue rxpdos
queue with RXPDOs
Definition eeprom.h:175
osal_uint8_t fmmus_cnt
count of fmmu settings
Definition eeprom.h:168
ec_eeprom_cat_dc_t dcs[LEC_MAX_EEPROM_CAT_DC]
array of distributed clocks settings
Definition eeprom.h:178
int read_eeprom
read eeprom while reaching PREOP state
Definition eeprom.h:144
osal_uint8_t strings_cnt
count of strings
Definition eeprom.h:162