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