fp@628: /****************************************************************************** fp@628: * fp@628: * $Id$ fp@628: * fp@628: * Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH fp@628: * fp@628: * This file is part of the IgH EtherCAT Master. fp@628: * fp@628: * The IgH EtherCAT Master is free software; you can redistribute it fp@628: * and/or modify it under the terms of the GNU General Public License fp@628: * as published by the Free Software Foundation; either version 2 of the fp@628: * License, or (at your option) any later version. fp@628: * fp@628: * The IgH EtherCAT Master is distributed in the hope that it will be fp@628: * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of fp@628: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the fp@628: * GNU General Public License for more details. fp@628: * fp@628: * You should have received a copy of the GNU General Public License fp@628: * along with the IgH EtherCAT Master; if not, write to the Free Software fp@628: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA fp@628: * fp@628: * The right to use EtherCAT Technology is granted and comes free of fp@628: * charge under condition of compatibility of product made by fp@628: * Licensee. People intending to distribute/sell products based on the fp@628: * code, have to sign an agreement to guarantee that products using fp@628: * software based on IgH EtherCAT master stay compatible with the actual fp@628: * EtherCAT specification (which are released themselves as an open fp@628: * standard) as the (only) precondition to have the right to use EtherCAT fp@628: * Technology, IP and trade marks. fp@628: * fp@628: *****************************************************************************/ fp@628: fp@628: /** fp@628: \file fp@628: EtherCAT sync manager methods. fp@628: */ fp@628: fp@628: /*****************************************************************************/ fp@628: fp@628: #include "globals.h" fp@628: #include "slave.h" fp@628: #include "master.h" fp@628: #include "sync.h" fp@628: fp@628: /*****************************************************************************/ fp@628: fp@628: /** fp@628: * Constructor. fp@628: */ fp@628: fp@628: void ec_sync_init( fp@628: ec_sync_t *sync, /**< EtherCAT sync manager */ fp@628: const ec_slave_t *slave, /**< EtherCAT slave */ fp@628: unsigned int index /**< sync manager index */ fp@628: ) fp@628: { fp@628: sync->slave = slave; fp@628: sync->index = index; fp@628: fp@628: sync->est_length = 0; fp@628: } fp@628: fp@628: /*****************************************************************************/ fp@628: fp@628: /** fp@628: * Destructor. fp@628: */ fp@628: fp@628: void ec_sync_clear( fp@628: ec_sync_t *sync /**< EtherCAT sync manager */ fp@628: ) fp@628: { fp@628: } fp@628: fp@628: /*****************************************************************************/ fp@628: fp@628: /** fp@628: Initializes a sync manager configuration page with EEPROM data. fp@628: The referenced memory (\a data) must be at least EC_SYNC_SIZE bytes. fp@628: */ fp@628: fp@628: void ec_sync_config( fp@628: const ec_sync_t *sync, /**< sync manager */ fp@628: uint8_t *data /**> configuration memory */ fp@628: ) fp@628: { fp@628: size_t sync_size; fp@628: fp@628: sync_size = ec_slave_calc_sync_size(sync->slave, sync); fp@628: fp@628: if (sync->slave->master->debug_level) { fp@628: EC_DBG("SM%i: Addr 0x%04X, Size %3i, Ctrl 0x%02X, En %i\n", fp@628: sync->index, sync->physical_start_address, fp@628: sync_size, sync->control_register, sync->enable); fp@628: } fp@628: fp@628: EC_WRITE_U16(data, sync->physical_start_address); fp@628: EC_WRITE_U16(data + 2, sync_size); fp@628: EC_WRITE_U8 (data + 4, sync->control_register); fp@628: EC_WRITE_U8 (data + 5, 0x00); // status byte (read only) fp@628: EC_WRITE_U16(data + 6, sync->enable ? 0x0001 : 0x0000); // enable fp@628: } fp@628: fp@628: /*****************************************************************************/