IgH EtherCAT Master  1.6.1
fmmu_config.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 
26 /****************************************************************************/
27 
28 #include "globals.h"
29 #include "slave_config.h"
30 #include "master.h"
31 
32 #include "fmmu_config.h"
33 
34 /****************************************************************************/
35 
43  ec_fmmu_config_t *fmmu,
44  ec_slave_config_t *sc,
45  ec_domain_t *domain,
46  uint8_t sync_index,
47  ec_direction_t dir
48  )
49 {
50  INIT_LIST_HEAD(&fmmu->list);
51  fmmu->sc = sc;
52  fmmu->sync_index = sync_index;
53  fmmu->dir = dir;
54 
55  fmmu->logical_start_address = domain->data_size;
57  &sc->sync_configs[sync_index].pdos);
58 
59  ec_domain_add_fmmu_config(domain, fmmu);
60 }
61 
62 /****************************************************************************/
63 
69  const ec_fmmu_config_t *fmmu,
70  const ec_sync_t *sync,
71  uint8_t *data
72  )
73 {
74  EC_CONFIG_DBG(fmmu->sc, 1, "FMMU: LogAddr 0x%08X, Size %3u,"
75  " PhysAddr 0x%04X, SM%u, Dir %s\n",
76  fmmu->logical_start_address, fmmu->data_size,
78  fmmu->dir == EC_DIR_INPUT ? "in" : "out");
79 
81  EC_WRITE_U16(data + 4, fmmu->data_size); // size of fmmu
82  EC_WRITE_U8 (data + 6, 0x00); // logical start bit
83  EC_WRITE_U8 (data + 7, 0x07); // logical end bit
84  EC_WRITE_U16(data + 8, sync->physical_start_address);
85  EC_WRITE_U8 (data + 10, 0x00); // physical start bit
86  EC_WRITE_U8 (data + 11, fmmu->dir == EC_DIR_INPUT ? 0x01 : 0x02);
87  EC_WRITE_U16(data + 12, 0x0001); // enable
88  EC_WRITE_U16(data + 14, 0x0000); // reserved
89 }
90 
91 /****************************************************************************/
const ec_slave_config_t * sc
EtherCAT slave config.
Definition: fmmu_config.h:40
FMMU configuration.
Definition: fmmu_config.h:38
size_t data_size
Size of the process data.
Definition: domain.h:53
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:42
#define EC_WRITE_U8(DATA, VAL)
Write an 8-bit unsigned value to EtherCAT data.
Definition: ecrt.h:3137
unsigned int data_size
Covered PDO size.
Definition: fmmu_config.h:45
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:68
Global definitions and macros.
EtherCAT master structure.
uint32_t logical_start_address
Logical start address.
Definition: fmmu_config.h:44
struct list_head list
List node used by domain.
Definition: fmmu_config.h:39
uint16_t ec_pdo_list_total_size(const ec_pdo_list_t *pl)
Calculates the total size of the mapped PDO entries.
Definition: pdo_list.c:79
ec_sync_config_t sync_configs[EC_MAX_SYNC_MANAGERS]
Sync manager configurations.
Definition: slave_config.h:129
#define EC_WRITE_U32(DATA, VAL)
Write a 32-bit unsigned value to EtherCAT data.
Definition: ecrt.h:3171
uint8_t sync_index
Index of sync manager to use.
Definition: fmmu_config.h:42
Sync manager.
Definition: sync.h:39
ec_pdo_list_t pdos
Current PDO assignment.
Definition: sync_config.h:41
#define EC_WRITE_U16(DATA, VAL)
Write a 16-bit unsigned value to EtherCAT data.
Definition: ecrt.h:3154
#define EC_CONFIG_DBG(sc, level, fmt, args...)
Convenience macro for printing configuration-specific debug messages to syslog.
Definition: slave_config.h:99
ec_direction_t
Direction type for PDO assignment functions.
Definition: ecrt.h:504
EtherCAT FMMU configuration structure.
Values read by the master.
Definition: ecrt.h:507
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:121
uint16_t physical_start_address
Physical start address.
Definition: sync.h:41
EtherCAT slave configuration.
Definition: slave_config.h:111
EtherCAT slave configuration structure.
ec_direction_t dir
FMMU direction.
Definition: fmmu_config.h:43
EtherCAT domain.
Definition: domain.h:46