IgH EtherCAT Master  1.5.2
fmmu_config.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 
34 /*****************************************************************************/
35 
36 #include "globals.h"
37 #include "slave_config.h"
38 #include "master.h"
39 
40 #include "fmmu_config.h"
41 
42 /*****************************************************************************/
43 
51  ec_fmmu_config_t *fmmu,
52  ec_slave_config_t *sc,
53  ec_domain_t *domain,
54  uint8_t sync_index,
55  ec_direction_t dir
56  )
57 {
58  INIT_LIST_HEAD(&fmmu->list);
59  fmmu->sc = sc;
60  fmmu->sync_index = sync_index;
61  fmmu->dir = dir;
62 
63  fmmu->logical_domain_offset = 0;
64  fmmu->data_size = 0;
65 
66  ec_domain_add_fmmu_config(domain, fmmu);
67 }
68 
70  ec_fmmu_config_t *fmmu,
71  uint32_t logical_domain_offset,
73  unsigned data_size
74  )
75 {
76  fmmu->logical_domain_offset = logical_domain_offset;
77  fmmu->data_size = data_size;
78 }
79 
80 /*****************************************************************************/
81 
87  const ec_fmmu_config_t *fmmu,
88  const ec_sync_t *sync,
89  uint8_t *data
90  )
91 {
92  EC_CONFIG_DBG(fmmu->sc, 1, "FMMU: LogOff 0x%08X, Size %3u,"
93  " PhysAddr 0x%04X, SM%u, Dir %s\n",
94  fmmu->logical_domain_offset, fmmu->data_size,
96  fmmu->dir == EC_DIR_INPUT ? "in" : "out");
97 
99  fmmu->logical_domain_offset);
100  EC_WRITE_U16(data + 4, fmmu->data_size); // size of fmmu
101  EC_WRITE_U8 (data + 6, 0x00); // logical start bit
102  EC_WRITE_U8 (data + 7, 0x07); // logical end bit
103  EC_WRITE_U16(data + 8, sync->physical_start_address);
104  EC_WRITE_U8 (data + 10, 0x00); // physical start bit
105  EC_WRITE_U8 (data + 11, fmmu->dir == EC_DIR_INPUT ? 0x01 : 0x02);
106  EC_WRITE_U16(data + 12, 0x0001); // enable
107  EC_WRITE_U16(data + 14, 0x0000); // reserved
108 }
109 
110 /*****************************************************************************/
const ec_slave_config_t * sc
EtherCAT slave config.
Definition: fmmu_config.h:48
uint32_t logical_domain_offset
Logical offset address relative to domain->logical_base_address.
Definition: fmmu_config.h:52
FMMU configuration.
Definition: fmmu_config.h:46
void ec_fmmu_config_init(ec_fmmu_config_t *fmmu, ec_slave_config_t *sc, ec_domain_t *domain, uint8_t sync_index, ec_direction_t dir)
FMMU configuration constructor.
Definition: fmmu_config.c:50
#define EC_WRITE_U8(DATA, VAL)
Write an 8-bit unsigned value to EtherCAT data.
Definition: ecrt.h:2642
unsigned int data_size
Covered PDO size.
Definition: fmmu_config.h:54
void ec_fmmu_config_page(const ec_fmmu_config_t *fmmu, const ec_sync_t *sync, uint8_t *data)
Initializes an FMMU configuration page.
Definition: fmmu_config.c:86
Global definitions and macros.
EtherCAT master structure.
struct list_head list
List node used by domain.
Definition: fmmu_config.h:47
const ec_domain_t * domain
Domain.
Definition: fmmu_config.h:49
#define EC_WRITE_U32(DATA, VAL)
Write a 32-bit unsigned value to EtherCAT data.
Definition: ecrt.h:2676
uint8_t sync_index
Index of sync manager to use.
Definition: fmmu_config.h:50
Sync manager.
Definition: sync.h:47
#define EC_WRITE_U16(DATA, VAL)
Write a 16-bit unsigned value to EtherCAT data.
Definition: ecrt.h:2659
#define EC_CONFIG_DBG(sc, level, fmt, args...)
Convenience macro for printing configuration-specific debug messages to syslog.
Definition: slave_config.h:106
ec_direction_t
Direction type for PDO assignment functions.
Definition: ecrt.h:436
void ec_fmmu_set_domain_offset_size(ec_fmmu_config_t *fmmu, uint32_t logical_domain_offset, unsigned data_size)
Definition: fmmu_config.c:69
EtherCAT FMMU configuration structure.
Values read by the master.
Definition: ecrt.h:439
uint32_t logical_base_address
Logical offset address of the process data.
Definition: domain.h:64
void ec_domain_add_fmmu_config(ec_domain_t *domain, ec_fmmu_config_t *fmmu)
Adds an FMMU configuration to the domain.
Definition: domain.c:131
uint16_t physical_start_address
Physical start address.
Definition: sync.h:49
EtherCAT slave configuration.
Definition: slave_config.h:118
EtherCAT slave configuration structure.
ec_direction_t dir
FMMU direction.
Definition: fmmu_config.h:51
EtherCAT domain.
Definition: domain.h:54