master/fmmu_config.c
changeset 1981 c14b6bb14fdf
parent 1363 11c0b2caa253
child 1989 6aa393418fb3
equal deleted inserted replaced
1980:a89e2bedf004 1981:c14b6bb14fdf
    41 
    41 
    42 /*****************************************************************************/
    42 /*****************************************************************************/
    43 
    43 
    44 /** FMMU configuration constructor.
    44 /** FMMU configuration constructor.
    45  *
    45  *
    46  * Inits an FMMU configuration, sets the logical start address and adds the
    46  * Inits an FMMU configuration and the process data size forthe mapped PDOs
    47  * process data size for the mapped PDOs of the given direction to the domain
    47  * of the given direction to the domain data size.
    48  * data size.
       
    49  */
    48  */
    50 void ec_fmmu_config_init(
    49 void ec_fmmu_config_init(
    51         ec_fmmu_config_t *fmmu, /**< EtherCAT FMMU configuration. */
    50         ec_fmmu_config_t *fmmu, /**< EtherCAT FMMU configuration. */
    52         ec_slave_config_t *sc, /**< EtherCAT slave configuration. */
    51         ec_slave_config_t *sc, /**< EtherCAT slave configuration. */
    53         ec_domain_t *domain, /**< EtherCAT domain. */
       
    54         uint8_t sync_index, /**< Sync manager index to use. */
    52         uint8_t sync_index, /**< Sync manager index to use. */
    55         ec_direction_t dir /**< PDO direction. */
    53         ec_direction_t dir /**< PDO direction. */
    56         )
    54         )
    57 {
    55 {
    58     INIT_LIST_HEAD(&fmmu->list);
    56     INIT_LIST_HEAD(&fmmu->list);
    59     fmmu->sc = sc;
    57     fmmu->sc = sc;
    60     fmmu->sync_index = sync_index;
    58     fmmu->sync_index = sync_index;
    61     fmmu->dir = dir;
    59     fmmu->dir = dir;
    62 
       
    63     fmmu->logical_start_address = domain->data_size;
       
    64     fmmu->data_size = ec_pdo_list_total_size(
    60     fmmu->data_size = ec_pdo_list_total_size(
    65             &sc->sync_configs[sync_index].pdos);
    61             &sc->sync_configs[sync_index].pdos);
       
    62 }
    66 
    63 
       
    64 
       
    65 /*****************************************************************************/
       
    66 
       
    67 /** Sets FMMU domain
       
    68  *
       
    69  * Sets the logical start address and the size of the transmitted data
       
    70  */
       
    71 void ec_fmmu_config_domain(
       
    72         ec_fmmu_config_t *fmmu, /**< EtherCAT FMMU configuration. */
       
    73         ec_domain_t *domain, /**< EtherCAT domain. */
       
    74         uint32_t logical_start_address, /**< FMMU logical start address. */
       
    75         size_t tx_size /**< Size of transmitted data */
       
    76         )
       
    77 {
       
    78     fmmu->domain = domain;
       
    79     fmmu->domain_address = domain->data_size;
       
    80     fmmu->logical_start_address = logical_start_address;
       
    81     fmmu->tx_size = tx_size;
    67     ec_domain_add_fmmu_config(domain, fmmu);
    82     ec_domain_add_fmmu_config(domain, fmmu);
    68 }
    83 }
       
    84 
    69 
    85 
    70 /*****************************************************************************/
    86 /*****************************************************************************/
    71 
    87 
    72 /** Initializes an FMMU configuration page.
    88 /** Initializes an FMMU configuration page.
    73  *
    89  *
    78         const ec_sync_t *sync, /**< Sync manager. */
    94         const ec_sync_t *sync, /**< Sync manager. */
    79         uint8_t *data /**> Configuration page memory. */
    95         uint8_t *data /**> Configuration page memory. */
    80         )
    96         )
    81 {
    97 {
    82     if (fmmu->sc->master->debug_level) {
    98     if (fmmu->sc->master->debug_level) {
    83         EC_DBG("FMMU: LogAddr 0x%08X, Size %3u, PhysAddr 0x%04X, SM%u, "
    99         EC_DBG("FMMU: LogAddr 0x%08X, DomAddr 0x%08X, Size %3u, Tx %3u, PhysAddr 0x%04X, SM%u, "
    84                 "Dir %s\n", fmmu->logical_start_address, fmmu->data_size,
   100                 "Dir %s\n", fmmu->logical_start_address, fmmu->domain_address, fmmu->data_size,
    85                sync->physical_start_address, fmmu->sync_index,
   101                 fmmu->tx_size, sync->physical_start_address, fmmu->sync_index,
    86                fmmu->dir == EC_DIR_INPUT ? "in" : "out");
   102                fmmu->dir == EC_DIR_INPUT ? "in" : "out");
    87     }
   103     }
    88 
   104 
    89     EC_WRITE_U32(data,      fmmu->logical_start_address);
   105     EC_WRITE_U32(data,      fmmu->logical_start_address);
    90     EC_WRITE_U16(data + 4,  fmmu->data_size); // size of fmmu
   106     EC_WRITE_U16(data + 4,  fmmu->data_size); // size of fmmu