master/fmmu_config.c
changeset 2635 42b62867574d
parent 2611 f09b0623a2c1
equal deleted inserted replaced
2634:f859d567f94e 2635:42b62867574d
    58     INIT_LIST_HEAD(&fmmu->list);
    58     INIT_LIST_HEAD(&fmmu->list);
    59     fmmu->sc = sc;
    59     fmmu->sc = sc;
    60     fmmu->sync_index = sync_index;
    60     fmmu->sync_index = sync_index;
    61     fmmu->dir = dir;
    61     fmmu->dir = dir;
    62 
    62 
    63     fmmu->logical_start_address = domain->data_size;
    63     fmmu->logical_domain_offset = 0;
    64     fmmu->data_size = ec_pdo_list_total_size(
    64     fmmu->data_size = 0;
    65             &sc->sync_configs[sync_index].pdos);
       
    66 
    65 
    67     ec_domain_add_fmmu_config(domain, fmmu);
    66     ec_domain_add_fmmu_config(domain, fmmu);
       
    67 }
       
    68 
       
    69 void ec_fmmu_set_domain_offset_size(
       
    70         ec_fmmu_config_t *fmmu, /**< EtherCAT FMMU configuration. */
       
    71         uint32_t logical_domain_offset, /**< Logical offset address
       
    72             relative to domain->logical_base_address. */
       
    73         unsigned data_size /**< Covered PDO size. */
       
    74         )
       
    75 {
       
    76     fmmu->logical_domain_offset = logical_domain_offset;
       
    77     fmmu->data_size = data_size;
    68 }
    78 }
    69 
    79 
    70 /*****************************************************************************/
    80 /*****************************************************************************/
    71 
    81 
    72 /** Initializes an FMMU configuration page.
    82 /** Initializes an FMMU configuration page.
    77         const ec_fmmu_config_t *fmmu, /**< EtherCAT FMMU configuration. */
    87         const ec_fmmu_config_t *fmmu, /**< EtherCAT FMMU configuration. */
    78         const ec_sync_t *sync, /**< Sync manager. */
    88         const ec_sync_t *sync, /**< Sync manager. */
    79         uint8_t *data /**> Configuration page memory. */
    89         uint8_t *data /**> Configuration page memory. */
    80         )
    90         )
    81 {
    91 {
    82     EC_CONFIG_DBG(fmmu->sc, 1, "FMMU: LogAddr 0x%08X, Size %3u,"
    92     EC_CONFIG_DBG(fmmu->sc, 1, "FMMU: LogOff 0x%08X, Size %3u,"
    83             " PhysAddr 0x%04X, SM%u, Dir %s\n",
    93             " PhysAddr 0x%04X, SM%u, Dir %s\n",
    84             fmmu->logical_start_address, fmmu->data_size,
    94             fmmu->logical_domain_offset, fmmu->data_size,
    85             sync->physical_start_address, fmmu->sync_index,
    95             sync->physical_start_address, fmmu->sync_index,
    86             fmmu->dir == EC_DIR_INPUT ? "in" : "out");
    96             fmmu->dir == EC_DIR_INPUT ? "in" : "out");
    87 
    97 
    88     EC_WRITE_U32(data,      fmmu->logical_start_address);
    98     EC_WRITE_U32(data,      fmmu->domain->logical_base_address +
       
    99         fmmu->logical_domain_offset);
    89     EC_WRITE_U16(data + 4,  fmmu->data_size); // size of fmmu
   100     EC_WRITE_U16(data + 4,  fmmu->data_size); // size of fmmu
    90     EC_WRITE_U8 (data + 6,  0x00); // logical start bit
   101     EC_WRITE_U8 (data + 6,  0x00); // logical start bit
    91     EC_WRITE_U8 (data + 7,  0x07); // logical end bit
   102     EC_WRITE_U8 (data + 7,  0x07); // logical end bit
    92     EC_WRITE_U16(data + 8,  sync->physical_start_address);
   103     EC_WRITE_U16(data + 8,  sync->physical_start_address);
    93     EC_WRITE_U8 (data + 10, 0x00); // physical start bit
   104     EC_WRITE_U8 (data + 10, 0x00); // physical start bit