Refactor fmmu->logical_start_address to fmmu->logical_domain_offset

This commit is contained in:
Dave Page 2015-03-26 17:41:57 -04:00
parent b8c5ff836d
commit 7beb81207d
6 changed files with 27 additions and 22 deletions

27
master/domain.c Normal file → Executable file
View File

@ -130,8 +130,8 @@ void ec_domain_add_fmmu_config(
list_add_tail(&fmmu->list, &domain->fmmu_configs);
EC_MASTER_DBG(domain->master, 1, "Domain %u:"
" Added %u bytes, total %zu.\n",
domain->index, fmmu->data_size, domain->data_size);
" Added %u bytes.\n",
domain->index, fmmu->data_size);
}
/*****************************************************************************/
@ -237,6 +237,15 @@ int ec_domain_finish(
const ec_datagram_pair_t *datagram_pair;
int ret;
#if 0
// Determine domain size from furthest extent of FMMU data
domain->data_size = 0;
list_for_each_entry(fmmu, &domain->fmmu_configs, list) {
domain->data_size = max(domain->data_size,
fmmu->logical_domain_offset + fmmu->data_size);
}
#endif
domain->logical_base_address = base_address;
if (domain->data_size && domain->data_origin == EC_ORIG_INTERNAL) {
@ -265,10 +274,6 @@ int ec_domain_finish(
}
list_for_each_entry(fmmu, &domain->fmmu_configs, list) {
// Correct logical FMMU address
fmmu->logical_start_address += base_address;
// Increment Input/Output counter to determine datagram types
// and calculate expected working counters
if (shall_count(fmmu, datagram_first_fmmu)) {
@ -503,19 +508,17 @@ void ecrt_domain_process(ec_domain_t *domain)
continue;
}
if (fmmu->logical_start_address >=
logical_datagram_address + datagram_size) {
if (fmmu->logical_domain_offset >= datagram_size) {
// fmmu data contained in next datagram pair
break;
}
datagram_offset =
fmmu->logical_start_address - logical_datagram_address;
datagram_offset = fmmu->logical_domain_offset;
#if DEBUG_REDUNDANCY
EC_MASTER_DBG(domain->master, 1,
"input fmmu log=%u size=%u offset=%u\n",
fmmu->logical_start_address, fmmu->data_size,
"input fmmu log_off=%u size=%u offset=%u\n",
fmmu->logical_domain_offset, fmmu->data_size,
datagram_offset);
if (domain->master->debug_level > 0) {
ec_print_data(pair->send_buffer + datagram_offset,

9
master/fmmu_config.c Normal file → Executable file
View File

@ -60,7 +60,7 @@ void ec_fmmu_config_init(
fmmu->sync_index = sync_index;
fmmu->dir = dir;
fmmu->logical_start_address = domain->data_size;
fmmu->logical_domain_offset = domain->data_size;
fmmu->data_size = ec_pdo_list_total_size(
&sc->sync_configs[sync_index].pdos);
@ -79,13 +79,14 @@ void ec_fmmu_config_page(
uint8_t *data /**> Configuration page memory. */
)
{
EC_CONFIG_DBG(fmmu->sc, 1, "FMMU: LogAddr 0x%08X, Size %3u,"
EC_CONFIG_DBG(fmmu->sc, 1, "FMMU: LogOff 0x%08X, Size %3u,"
" PhysAddr 0x%04X, SM%u, Dir %s\n",
fmmu->logical_start_address, fmmu->data_size,
fmmu->logical_domain_offset, fmmu->data_size,
sync->physical_start_address, fmmu->sync_index,
fmmu->dir == EC_DIR_INPUT ? "in" : "out");
EC_WRITE_U32(data, fmmu->logical_start_address);
EC_WRITE_U32(data, fmmu->domain->logical_base_address +
fmmu->logical_domain_offset);
EC_WRITE_U16(data + 4, fmmu->data_size); // size of fmmu
EC_WRITE_U8 (data + 6, 0x00); // logical start bit
EC_WRITE_U8 (data + 7, 0x07); // logical end bit

3
master/fmmu_config.h Normal file → Executable file
View File

@ -49,7 +49,8 @@ typedef struct {
const ec_domain_t *domain; /**< Domain. */
uint8_t sync_index; /**< Index of sync manager to use. */
ec_direction_t dir; /**< FMMU direction. */
uint32_t logical_start_address; /**< Logical start address. */
uint32_t logical_domain_offset; /**< Logical offset address relative to
domain->logical_base_address. */
unsigned int data_size; /**< Covered PDO size. */
} ec_fmmu_config_t;

View File

@ -54,7 +54,7 @@
// uint8_t reserved
// uint32_t PacketNo, Password, ErrorCode
#define DEBUG_FOE
//#define DEBUG_FOE
/*****************************************************************************/

2
master/ioctl.c Normal file → Executable file
View File

@ -544,7 +544,7 @@ static ATTRIBUTES int ec_ioctl_domain_fmmu(
data.slave_config_position = fmmu->sc->position;
data.sync_index = fmmu->sync_index;
data.dir = fmmu->dir;
data.logical_address = fmmu->logical_start_address;
data.logical_address = fmmu->domain->logical_base_address + fmmu->logical_domain_offset;
data.data_size = fmmu->data_size;
up(&master->master_sem);

6
master/slave_config.c Normal file → Executable file
View File

@ -182,7 +182,7 @@ int ec_slave_config_prepare_fmmu(
for (i = 0; i < sc->used_fmmus; i++) {
fmmu = &sc->fmmu_configs[i];
if (fmmu->domain == domain && fmmu->sync_index == sync_index)
return fmmu->logical_start_address;
return fmmu->logical_domain_offset;
}
if (sc->used_fmmus == EC_MAX_FMMUS) {
@ -216,7 +216,7 @@ int ec_slave_config_prepare_fmmu(
prev_fmmu->tx_size = max(fmmu->data_size, prev_fmmu->data_size);
domain->tx_size += prev_fmmu->tx_size - old_prev_tx_size;
tx_size = 0;
fmmu_logical_start_address = prev_fmmu->logical_start_address;
fmmu_logical_start_address = prev_fmmu->logical_domain_offset;
}
}
@ -227,7 +227,7 @@ int ec_slave_config_prepare_fmmu(
sc->used_fmmus++;
up(&sc->master->master_sem);
return fmmu->logical_start_address;
return fmmu->logical_domain_offset;
}
/*****************************************************************************/