IgH EtherCAT Master  1.6.9
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
25
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,
45 ec_domain_t *domain,
46 uint8_t sync_index,
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",
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/****************************************************************************/
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
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
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
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:3040
ec_direction_t
Direction type for PDO assignment functions.
Definition ecrt.h:504
struct ec_domain ec_domain_t
Definition ecrt.h:306
struct ec_slave_config ec_slave_config_t
Definition ecrt.h:303
#define EC_WRITE_U32(DATA, VAL)
Write a 32-bit unsigned value to EtherCAT data.
Definition ecrt.h:3074
#define EC_WRITE_U16(DATA, VAL)
Write a 16-bit unsigned value to EtherCAT data.
Definition ecrt.h:3057
@ EC_DIR_INPUT
Values read by the master.
Definition ecrt.h:507
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:79
EtherCAT slave configuration structure.
#define EC_CONFIG_DBG(sc, level, fmt, args...)
Convenience macro for printing configuration-specific debug messages to syslog.
size_t data_size
Size of the process data.
Definition domain.h:53
FMMU configuration.
Definition fmmu_config.h:38
uint32_t logical_start_address
Logical start address.
Definition fmmu_config.h:44
const ec_slave_config_t * sc
EtherCAT slave config.
Definition fmmu_config.h:40
unsigned int data_size
Covered PDO size.
Definition fmmu_config.h:45
uint8_t sync_index
Index of sync manager to use.
Definition fmmu_config.h:42
struct list_head list
List node used by domain.
Definition fmmu_config.h:39
ec_direction_t dir
FMMU direction.
Definition fmmu_config.h:43
ec_sync_config_t sync_configs[EC_MAX_SYNC_MANAGERS]
Sync manager configurations.
ec_pdo_list_t pdos
Current PDO assignment.
Definition sync_config.h:41
Sync manager.
Definition sync.h:39
uint16_t physical_start_address
Physical start address.
Definition sync.h:41