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,
53 ec_domain_t *domain,
54 uint8_t sync_index,
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_start_address = domain->data_size;
65 &sc->sync_configs[sync_index].pdos);
66
67 ec_domain_add_fmmu_config(domain, fmmu);
68}
69
70/*****************************************************************************/
71
77 const ec_fmmu_config_t *fmmu,
78 const ec_sync_t *sync,
79 uint8_t *data
80 )
81{
82 EC_CONFIG_DBG(fmmu->sc, 1, "FMMU: LogAddr 0x%08X, Size %3u,"
83 " PhysAddr 0x%04X, SM%u, Dir %s\n",
86 fmmu->dir == EC_DIR_INPUT ? "in" : "out");
87
89 EC_WRITE_U16(data + 4, fmmu->data_size); // size of fmmu
90 EC_WRITE_U8 (data + 6, 0x00); // logical start bit
91 EC_WRITE_U8 (data + 7, 0x07); // logical end bit
92 EC_WRITE_U16(data + 8, sync->physical_start_address);
93 EC_WRITE_U8 (data + 10, 0x00); // physical start bit
94 EC_WRITE_U8 (data + 11, fmmu->dir == EC_DIR_INPUT ? 0x01 : 0x02);
95 EC_WRITE_U16(data + 12, 0x0001); // enable
96 EC_WRITE_U16(data + 14, 0x0000); // reserved
97}
98
99/*****************************************************************************/
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:122
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:76
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
EtherCAT FMMU configuration structure.
Global definitions and macros.
#define EC_WRITE_U8(DATA, VAL)
Write an 8-bit unsigned value to EtherCAT data.
Definition: ecrt.h:2266
ec_direction_t
Direction type for PDO assignment functions.
Definition: ecrt.h:430
#define EC_WRITE_U32(DATA, VAL)
Write a 32-bit unsigned value to EtherCAT data.
Definition: ecrt.h:2300
#define EC_WRITE_U16(DATA, VAL)
Write a 16-bit unsigned value to EtherCAT data.
Definition: ecrt.h:2283
@ EC_DIR_INPUT
Values read by the master.
Definition: ecrt.h:433
EtherCAT master structure.
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:87
EtherCAT slave configuration structure.
#define EC_CONFIG_DBG(sc, level, fmt, args...)
Convenience macro for printing configuration-specific debug messages to syslog.
Definition: slave_config.h:107
EtherCAT domain.
Definition: domain.h:55
size_t data_size
Size of the process data.
Definition: domain.h:61
FMMU configuration.
Definition: fmmu_config.h:46
uint32_t logical_start_address
Logical start address.
Definition: fmmu_config.h:52
const ec_slave_config_t * sc
EtherCAT slave config.
Definition: fmmu_config.h:48
unsigned int data_size
Covered PDO size.
Definition: fmmu_config.h:53
uint8_t sync_index
Index of sync manager to use.
Definition: fmmu_config.h:50
struct list_head list
List node used by domain.
Definition: fmmu_config.h:47
ec_direction_t dir
FMMU direction.
Definition: fmmu_config.h:51
EtherCAT slave configuration.
Definition: slave_config.h:119
ec_sync_config_t sync_configs[EC_MAX_SYNC_MANAGERS]
Sync manager configurations.
Definition: slave_config.h:137
ec_pdo_list_t pdos
Current PDO assignment.
Definition: sync_config.h:49
Sync manager.
Definition: sync.h:47
uint16_t physical_start_address
Physical start address.
Definition: sync.h:49