fp@792: /****************************************************************************** fp@792: * fp@792: * $Id$ fp@792: * fp@1326: * Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH fp@792: * fp@792: * This file is part of the IgH EtherCAT Master. fp@792: * fp@1326: * The IgH EtherCAT Master is free software; you can redistribute it and/or fp@1326: * modify it under the terms of the GNU General Public License version 2, as fp@1326: * published by the Free Software Foundation. fp@792: * fp@1326: * The IgH EtherCAT Master is distributed in the hope that it will be useful, fp@1326: * but WITHOUT ANY WARRANTY; without even the implied warranty of fp@1326: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General fp@1326: * Public License for more details. fp@792: * fp@1326: * You should have received a copy of the GNU General Public License along fp@1326: * with the IgH EtherCAT Master; if not, write to the Free Software fp@792: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA fp@792: * fp@1363: * --- fp@1363: * fp@1363: * The license mentioned above concerns the source code only. Using the fp@1363: * EtherCAT technology and brand is only permitted in compliance with the fp@1363: * industrial property and similar rights of Beckhoff Automation GmbH. fp@792: * fp@792: *****************************************************************************/ fp@792: fp@792: /** \file fp@792: * EtherCAT FMMU configuration methods. fp@792: */ fp@792: fp@792: /*****************************************************************************/ fp@792: fp@792: #include "globals.h" fp@792: #include "slave_config.h" fp@792: #include "master.h" fp@792: fp@792: #include "fmmu_config.h" fp@792: fp@792: /*****************************************************************************/ fp@792: fp@792: /** FMMU configuration constructor. fp@792: * fp@792: * Inits an FMMU configuration, sets the logical start address and adds the fp@1327: * process data size for the mapped PDOs of the given direction to the domain fp@792: * data size. fp@792: */ fp@792: void ec_fmmu_config_init( fp@792: ec_fmmu_config_t *fmmu, /**< EtherCAT FMMU configuration. */ fp@792: ec_slave_config_t *sc, /**< EtherCAT slave configuration. */ fp@792: ec_domain_t *domain, /**< EtherCAT domain. */ fp@1055: uint8_t sync_index, /**< Sync manager index to use. */ fp@1327: ec_direction_t dir /**< PDO direction. */ fp@792: ) fp@792: { fp@950: INIT_LIST_HEAD(&fmmu->list); fp@792: fmmu->sc = sc; fp@1055: fmmu->sync_index = sync_index; fp@792: fmmu->dir = dir; fp@792: fp@792: fmmu->logical_start_address = domain->data_size; fp@1055: fmmu->data_size = ec_pdo_list_total_size( fp@1055: &sc->sync_configs[sync_index].pdos); fp@818: fp@818: ec_domain_add_fmmu_config(domain, fmmu); fp@792: } fp@792: fp@792: /*****************************************************************************/ fp@792: fp@792: /** Initializes an FMMU configuration page. fp@792: * fp@792: * The referenced memory (\a data) must be at least EC_FMMU_PAGE_SIZE bytes. fp@792: */ fp@792: void ec_fmmu_config_page( fp@792: const ec_fmmu_config_t *fmmu, /**< EtherCAT FMMU configuration. */ fp@792: const ec_sync_t *sync, /**< Sync manager. */ fp@792: uint8_t *data /**> Configuration page memory. */ fp@792: ) fp@792: { fp@1921: EC_CONFIG_DBG(fmmu->sc, 1, "FMMU: LogAddr 0x%08X, Size %3u," fp@1921: " PhysAddr 0x%04X, SM%u, Dir %s\n", fp@1921: fmmu->logical_start_address, fmmu->data_size, fp@1921: sync->physical_start_address, fmmu->sync_index, fp@1921: fmmu->dir == EC_DIR_INPUT ? "in" : "out"); fp@792: fp@792: EC_WRITE_U32(data, fmmu->logical_start_address); fp@792: EC_WRITE_U16(data + 4, fmmu->data_size); // size of fmmu fp@792: EC_WRITE_U8 (data + 6, 0x00); // logical start bit fp@792: EC_WRITE_U8 (data + 7, 0x07); // logical end bit fp@792: EC_WRITE_U16(data + 8, sync->physical_start_address); fp@792: EC_WRITE_U8 (data + 10, 0x00); // physical start bit fp@1055: EC_WRITE_U8 (data + 11, fmmu->dir == EC_DIR_INPUT ? 0x01 : 0x02); fp@792: EC_WRITE_U16(data + 12, 0x0001); // enable fp@792: EC_WRITE_U16(data + 14, 0x0000); // reserved fp@792: } fp@792: fp@792: /*****************************************************************************/