master/fmmu_config.c
changeset 2068 3001f6523e63
parent 1989 6aa393418fb3
child 2093 c7e7d80e49ea
equal deleted inserted replaced
2067:19732da2cf86 2068:3001f6523e63
    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  *
    77         const ec_fmmu_config_t *fmmu, /**< EtherCAT FMMU configuration. */
    93         const ec_fmmu_config_t *fmmu, /**< EtherCAT FMMU configuration. */
    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     EC_CONFIG_DBG(fmmu->sc, 1, "FMMU: LogAddr 0x%08X, Size %3u,"
    98     EC_CONFIG_DBG(fmmu->sc, 1, "FMMU: LogAddr 0x%08X, DomAddr 0x%08X,"
       
    99             " Size %3u, Tx %3u"
    83             " PhysAddr 0x%04X, SM%u, Dir %s\n",
   100             " PhysAddr 0x%04X, SM%u, Dir %s\n",
    84             fmmu->logical_start_address, fmmu->data_size,
   101             fmmu->logical_start_address, fmmu->domain_address,
       
   102             fmmu->data_size, fmmu->data_size,
    85             sync->physical_start_address, fmmu->sync_index,
   103             sync->physical_start_address, fmmu->sync_index,
    86             fmmu->dir == EC_DIR_INPUT ? "in" : "out");
   104             fmmu->dir == EC_DIR_INPUT ? "in" : "out");
    87 
   105 
    88     EC_WRITE_U32(data,      fmmu->logical_start_address);
   106     EC_WRITE_U32(data,      fmmu->logical_start_address);
    89     EC_WRITE_U16(data + 4,  fmmu->data_size); // size of fmmu
   107     EC_WRITE_U16(data + 4,  fmmu->data_size); // size of fmmu