fp@630: /****************************************************************************** fp@630: * fp@630: * $Id$ fp@630: * fp@630: * Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH fp@630: * fp@630: * This file is part of the IgH EtherCAT Master. fp@630: * fp@630: * The IgH EtherCAT Master is free software; you can redistribute it fp@630: * and/or modify it under the terms of the GNU General Public License fp@630: * as published by the Free Software Foundation; either version 2 of the fp@630: * License, or (at your option) any later version. fp@630: * fp@630: * The IgH EtherCAT Master is distributed in the hope that it will be fp@630: * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of fp@630: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the fp@630: * GNU General Public License for more details. fp@630: * fp@630: * You should have received a copy of the GNU General Public License fp@630: * along with the IgH EtherCAT Master; if not, write to the Free Software fp@630: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA fp@630: * fp@630: * The right to use EtherCAT Technology is granted and comes free of fp@630: * charge under condition of compatibility of product made by fp@630: * Licensee. People intending to distribute/sell products based on the fp@630: * code, have to sign an agreement to guarantee that products using fp@630: * software based on IgH EtherCAT master stay compatible with the actual fp@630: * EtherCAT specification (which are released themselves as an open fp@630: * standard) as the (only) precondition to have the right to use EtherCAT fp@630: * Technology, IP and trade marks. fp@630: * fp@630: *****************************************************************************/ fp@630: fp@630: /** fp@630: \file fp@630: EtherCAT FMMU methods. fp@630: */ fp@630: fp@630: /*****************************************************************************/ fp@630: fp@630: #include "globals.h" fp@630: #include "slave.h" fp@630: #include "master.h" fp@630: #include "fmmu.h" fp@630: fp@630: /*****************************************************************************/ fp@630: fp@630: /** fp@630: * FMMU Constructor. fp@630: */ fp@630: fp@630: void ec_fmmu_init( fp@630: ec_fmmu_t *fmmu, /**< EtherCAT FMMU */ fp@630: ec_slave_t *slave, /**< EtherCAT slave */ fp@630: unsigned int index /**< FMMU index */ fp@630: ) fp@630: { fp@630: fmmu->slave = slave; fp@630: fmmu->index = index; fp@630: } fp@630: fp@630: /*****************************************************************************/ fp@630: fp@630: /** fp@630: * Initializes an FMMU configuration page. fp@630: * The referenced memory (\a data) must be at least EC_FMMU_SIZE bytes. fp@630: */ fp@630: fp@630: void ec_fmmu_config( fp@630: const ec_fmmu_t *fmmu, /**< EtherCAT FMMU */ fp@630: uint8_t *data /**> configuration memory */ fp@630: ) fp@630: { fp@630: size_t sync_size; fp@630: fp@630: sync_size = ec_slave_calc_sync_size(fmmu->slave, fmmu->sync); fp@630: fp@630: if (fmmu->slave->master->debug_level) { fp@630: EC_DBG("FMMU%u: LogAddr 0x%08X, Size %3i, PhysAddr 0x%04X, Dir %s\n", fp@630: fmmu->index, fmmu->logical_start_address, fp@630: sync_size, fmmu->sync->physical_start_address, fp@630: ((fmmu->sync->control_register & 0x04) ? "out" : "in")); fp@630: } fp@630: fp@630: EC_WRITE_U32(data, fmmu->logical_start_address); fp@630: EC_WRITE_U16(data + 4, sync_size); // size of fmmu fp@630: EC_WRITE_U8 (data + 6, 0x00); // logical start bit fp@630: EC_WRITE_U8 (data + 7, 0x07); // logical end bit fp@630: EC_WRITE_U16(data + 8, fmmu->sync->physical_start_address); fp@630: EC_WRITE_U8 (data + 10, 0x00); // physical start bit fp@630: EC_WRITE_U8 (data + 11, ((fmmu->sync->control_register & 0x04) fp@630: ? 0x02 : 0x01)); fp@630: EC_WRITE_U16(data + 12, 0x0001); // enable fp@630: EC_WRITE_U16(data + 14, 0x0000); // reserved fp@630: } fp@630: fp@630: /*****************************************************************************/