master/slave_config.c
changeset 925 939f3e9bba1e
parent 924 d8d9a1056afa
child 926 6bb33c6ec770
equal deleted inserted replaced
924:d8d9a1056afa 925:939f3e9bba1e
   606 int ecrt_slave_config_reg_pdo_entry(
   606 int ecrt_slave_config_reg_pdo_entry(
   607         ec_slave_config_t *sc,
   607         ec_slave_config_t *sc,
   608         uint16_t index,
   608         uint16_t index,
   609         uint8_t subindex,
   609         uint8_t subindex,
   610         ec_domain_t *domain,
   610         ec_domain_t *domain,
   611         unsigned int *bitpos
   611         unsigned int *bit_position
   612         )
   612         )
   613 {
   613 {
   614     ec_direction_t dir;
   614     ec_direction_t dir;
   615     ec_pdo_list_t *pdos;
   615     ec_pdo_list_t *pdos;
   616     unsigned int bit_offset;
   616     unsigned int bit_offset, bit_pos;
   617     ec_pdo_t *pdo;
   617     ec_pdo_t *pdo;
   618     ec_pdo_entry_t *entry;
   618     ec_pdo_entry_t *entry;
   619     int sync_offset;
   619     int sync_offset;
   620 
   620 
   621     for (dir = EC_DIR_OUTPUT; dir <= EC_DIR_INPUT; dir++) {
   621     for (dir = EC_DIR_OUTPUT; dir <= EC_DIR_INPUT; dir++) {
   639 found:
   639 found:
   640     sync_offset = ec_slave_config_prepare_fmmu(sc, domain, dir);
   640     sync_offset = ec_slave_config_prepare_fmmu(sc, domain, dir);
   641     if (sync_offset < 0)
   641     if (sync_offset < 0)
   642         return -2;
   642         return -2;
   643 
   643 
   644     if (bitpos) {
   644     bit_pos = bit_offset % 8;
   645         *bitpos = bit_offset % 8;
   645     if (bit_position) {
   646     } else if (bit_offset % 8) {
   646         *bit_position = bit_pos;
   647         EC_ERR("Bytewise Pdo entry registration requested, but the result is "
   647     } else if (bit_pos) {
   648                 "not byte-aligned.\n");
   648         EC_ERR("Pdo entry 0x%04X:%X does not byte-align in config %u:%u.\n",
       
   649                 index, subindex, sc->alias, sc->position);
   649         return -3;
   650         return -3;
   650     }
   651     }
   651 
   652 
   652     return sync_offset + bit_offset / 8;
   653     return sync_offset + bit_offset / 8;
   653 }
   654 }