master/slave_config.c
changeset 2609 777d1a8b3a27
parent 2589 2b9c78543663
child 2610 f0fdcce9874b
equal deleted inserted replaced
2608:ec0b5d9a2ff1 2609:777d1a8b3a27
    68     sc->alias = alias;
    68     sc->alias = alias;
    69     sc->position = position;
    69     sc->position = position;
    70     sc->vendor_id = vendor_id;
    70     sc->vendor_id = vendor_id;
    71     sc->product_code = product_code;
    71     sc->product_code = product_code;
    72     sc->watchdog_divider = 0; // use default
    72     sc->watchdog_divider = 0; // use default
       
    73     sc->allow_overlapping_pdos = 0; // default not allowed
    73     sc->watchdog_intervals = 0; // use default
    74     sc->watchdog_intervals = 0; // use default
    74 
    75 
    75     sc->slave = NULL;
    76     sc->slave = NULL;
    76 
    77 
    77     for (i = 0; i < EC_MAX_SYNC_MANAGERS; i++)
    78     for (i = 0; i < EC_MAX_SYNC_MANAGERS; i++)
   187     if (sc->used_fmmus == EC_MAX_FMMUS) {
   188     if (sc->used_fmmus == EC_MAX_FMMUS) {
   188         EC_CONFIG_ERR(sc, "FMMU limit reached!\n");
   189         EC_CONFIG_ERR(sc, "FMMU limit reached!\n");
   189         return -EOVERFLOW;
   190         return -EOVERFLOW;
   190     }
   191     }
   191 
   192 
   192     fmmu = &sc->fmmu_configs[sc->used_fmmus++];
   193     fmmu = &sc->fmmu_configs[sc->used_fmmus];
   193 
   194 
   194     down(&sc->master->master_sem);
   195     down(&sc->master->master_sem);
   195     ec_fmmu_config_init(fmmu, sc, domain, sync_index, dir);
   196     ec_fmmu_config_init(fmmu, sc, domain, sync_index, dir);
       
   197 
       
   198 #if 0 //TODO overlapping PDOs
       
   199     // Overlapping PDO Support from 4751747d4e6d
       
   200     // FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME
       
   201     // parent code does not call ec_fmmu_config_domain
       
   202     // FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME
       
   203     fmmu_logical_start_address = domain->tx_size;
       
   204     tx_size = fmmu->data_size;
       
   205 
       
   206     // FIXME is it enough to take only the *previous* FMMU into account?
       
   207 
       
   208     // FIXME Need to qualify allow_overlapping_pdos with slave->sii.general_flags.enable_not_lrw
       
   209 
       
   210     if (sc->allow_overlapping_pdos && sc->used_fmmus > 0) {
       
   211         prev_fmmu = &sc->fmmu_configs[sc->used_fmmus - 1];
       
   212         if (fmmu->dir != prev_fmmu->dir && prev_fmmu->tx_size != 0) {
       
   213             // prev fmmu has opposite direction
       
   214             // and is not already paired with prev-prev fmmu
       
   215             old_prev_tx_size = prev_fmmu->tx_size;
       
   216             prev_fmmu->tx_size = max(fmmu->data_size, prev_fmmu->data_size);
       
   217             domain->tx_size += prev_fmmu->tx_size - old_prev_tx_size;
       
   218             tx_size = 0;
       
   219             fmmu_logical_start_address = prev_fmmu->logical_start_address;
       
   220         }
       
   221     }
       
   222 
       
   223     ec_fmmu_config_domain(fmmu, domain, fmmu_logical_start_address, tx_size);
       
   224     // Overlapping PDO Support from 4751747d4e6d
       
   225 #endif
       
   226 
       
   227     sc->used_fmmus++;
   196     up(&sc->master->master_sem);
   228     up(&sc->master->master_sem);
   197 
   229 
   198     return fmmu->logical_start_address;
   230     return fmmu->logical_start_address;
   199 }
   231 }
   200 
   232 
   554     EC_CONFIG_DBG(sc, 1, "%s(sc = 0x%p, divider = %u, intervals = %u)\n",
   586     EC_CONFIG_DBG(sc, 1, "%s(sc = 0x%p, divider = %u, intervals = %u)\n",
   555             __func__, sc, divider, intervals);
   587             __func__, sc, divider, intervals);
   556 
   588 
   557     sc->watchdog_divider = divider;
   589     sc->watchdog_divider = divider;
   558     sc->watchdog_intervals = intervals;
   590     sc->watchdog_intervals = intervals;
       
   591 }
       
   592 
       
   593 /*****************************************************************************/
       
   594 
       
   595 void ecrt_slave_config_overlapping_pdos(ec_slave_config_t *sc,
       
   596         uint8_t allow_overlapping_pdos )
       
   597 {
       
   598     EC_CONFIG_DBG(sc, 1, "%s(sc = 0x%p, allow_overlapping_pdos = %u)\n",
       
   599                 __func__, sc, allow_overlapping_pdos);
       
   600 
       
   601     sc->allow_overlapping_pdos = allow_overlapping_pdos;
   559 }
   602 }
   560 
   603 
   561 /*****************************************************************************/
   604 /*****************************************************************************/
   562 
   605 
   563 int ecrt_slave_config_pdo_assign_add(ec_slave_config_t *sc,
   606 int ecrt_slave_config_pdo_assign_add(ec_slave_config_t *sc,