# HG changeset patch # User Florian Pose # Date 1144227480 0 # Node ID ff65679b65feb620561ad18054f5f4fa8b2fe6de # Parent 94d780887be010feb57467bd5e21bb4f19f1b3ae Plugfest: Configure mailbox for unknown slaves. diff -r 94d780887be0 -r ff65679b65fe master/master.c --- a/master/master.c Wed Apr 05 08:47:28 2006 +0000 +++ b/master/master.c Wed Apr 05 08:58:00 2006 +0000 @@ -116,7 +116,7 @@ master->command_index = 0; master->debug_level = 0; - master->timeout = 100; // us + master->timeout = 500; // 500us master->slaves_responding = 0; master->slave_states = EC_SLAVE_STATE_UNKNOWN; @@ -790,7 +790,7 @@ const ec_fmmu_t *fmmu; uint32_t domain_offset; ec_domain_t *domain; - ec_eeprom_sync_t *eeprom_sync; + ec_eeprom_sync_t *eeprom_sync, mbox_sync; command = &master->simple_command; @@ -852,6 +852,8 @@ } // Set Sync Managers + + // Known slave type, take type's SM information if (type) { for (j = 0; type->sync_managers[j] && j < EC_MAX_SYNC; j++) { @@ -867,18 +869,59 @@ } } } - else if (slave->sii_mailbox_protocols) { // Unknown slave, has mailbox - list_for_each_entry(eeprom_sync, &slave->eeprom_syncs, list) { - if (ec_command_npwr(command, slave->station_address, - 0x800 + eeprom_sync->index * EC_SYNC_SIZE, - EC_SYNC_SIZE)) return -1; - ec_eeprom_sync_config(eeprom_sync, command->data); - if (unlikely(ec_master_simple_io(master, command))) { - EC_ERR("Setting sync manager %i failed on slave %i!\n", - eeprom_sync->index, slave->ring_position); - return -1; - } + + // Unknown slave type, but has mailbox + else if (slave->sii_mailbox_protocols) { + + // Does the device supply SM configurations in its EEPROM? + if (!list_empty(&slave->eeprom_syncs)) { + list_for_each_entry(eeprom_sync, &slave->eeprom_syncs, list) { + EC_INFO("Sync manager %i...\n", eeprom_sync->index); + if (ec_command_npwr(command, slave->station_address, + 0x800 + eeprom_sync->index * + EC_SYNC_SIZE, + EC_SYNC_SIZE)) return -1; + ec_eeprom_sync_config(eeprom_sync, command->data); + if (unlikely(ec_master_simple_io(master, command))) { + EC_ERR("Setting sync manager %i failed on slave %i!\n", + eeprom_sync->index, slave->ring_position); + return -1; + } + } } + + // No sync manager information; guess mailbox settings + else { + mbox_sync.physical_start_address = + slave->sii_rx_mailbox_offset; + mbox_sync.length = slave->sii_rx_mailbox_size; + mbox_sync.control_register = 0x26; + mbox_sync.enable = 1; + if (ec_command_npwr(command, slave->station_address, + 0x800,EC_SYNC_SIZE)) return -1; + ec_eeprom_sync_config(&mbox_sync, command->data); + if (unlikely(ec_master_simple_io(master, command))) { + EC_ERR("Setting sync manager 0 failed on slave %i!\n", + slave->ring_position); + return -1; + } + + mbox_sync.physical_start_address = + slave->sii_tx_mailbox_offset; + mbox_sync.length = slave->sii_tx_mailbox_size; + mbox_sync.control_register = 0x22; + mbox_sync.enable = 1; + if (ec_command_npwr(command, slave->station_address, + 0x808, EC_SYNC_SIZE)) return -1; + ec_eeprom_sync_config(&mbox_sync, command->data); + if (unlikely(ec_master_simple_io(master, command))) { + EC_ERR("Setting sync manager 1 failed on slave %i!\n", + slave->ring_position); + return -1; + } + } + EC_INFO("Mailbox configured for unknown slave %i\n", + slave->ring_position); } // Change state to PREOP diff -r 94d780887be0 -r ff65679b65fe master/slave.c --- a/master/slave.c Wed Apr 05 08:47:28 2006 +0000 +++ b/master/slave.c Wed Apr 05 08:58:00 2006 +0000 @@ -88,8 +88,8 @@ ec_eeprom_sync_t *sync, *next_sync; ec_eeprom_pdo_t *pdo, *next_pdo; ec_eeprom_pdo_entry_t *entry, *next_ent; - ec_sdo_t *sdo, *next_sdo; - ec_sdo_entry_t *en, *next_en; + //ec_sdo_t *sdo, *next_sdo; + //ec_sdo_entry_t *en, *next_en; // Alle Strings freigeben list_for_each_entry_safe(string, next_str, &slave->eeprom_strings, list) { @@ -122,6 +122,7 @@ if (slave->eeprom_group) kfree(slave->eeprom_group); if (slave->eeprom_desc) kfree(slave->eeprom_desc); +#if 0 // Alle SDOs freigeben list_for_each_entry_safe(sdo, next_sdo, &slave->sdo_dictionary, list) { list_del(&sdo->list); @@ -135,6 +136,7 @@ } ec_command_clear(&slave->mbox_command); +#endif } /*****************************************************************************/