master/sync.c
branchstable-1.3
changeset 1746 72e7507b3f1b
parent 1744 7bc131b92039
child 1749 696dd9f22777
equal deleted inserted replaced
1745:07fd94c5119d 1746:72e7507b3f1b
   138 }
   138 }
   139 
   139 
   140 /*****************************************************************************/
   140 /*****************************************************************************/
   141 
   141 
   142 /**
   142 /**
       
   143  * Adds a PDO to the list of known mapped PDOs.
       
   144  * \return 0 on success, else < 0
   143  */
   145  */
   144 
   146 
   145 int ec_sync_add_pdo(
   147 int ec_sync_add_pdo(
   146         ec_sync_t *sync, /**< EtherCAT sync manager */
   148         ec_sync_t *sync, /**< EtherCAT sync manager */
   147         const ec_pdo_t *pdo /**< PDO to map */
   149         const ec_pdo_t *pdo /**< PDO to map */
   170 
   172 
   171     // set appropriate sync manager index
   173     // set appropriate sync manager index
   172     mapped_pdo->sync_index = sync->index;
   174     mapped_pdo->sync_index = sync->index;
   173 
   175 
   174     list_add_tail(&mapped_pdo->list, &sync->pdos);
   176     list_add_tail(&mapped_pdo->list, &sync->pdos);
   175     sync->alt_mapping = 1;
       
   176     return 0;
   177     return 0;
   177 }
   178 }
   178 
   179 
   179 /*****************************************************************************/
   180 /*****************************************************************************/
   180 
   181 
   181 /**
   182 /**
       
   183  * Clears the list of known mapped PDOs.
   182  */
   184  */
   183 
   185 
   184 void ec_sync_clear_pdos(
   186 void ec_sync_clear_pdos(
   185         ec_sync_t *sync /**< EtherCAT sync manager */
   187         ec_sync_t *sync /**< EtherCAT sync manager */
   186         )
   188         )
   191     list_for_each_entry_safe(pdo, next, &sync->pdos, list) {
   193     list_for_each_entry_safe(pdo, next, &sync->pdos, list) {
   192         list_del(&pdo->list);
   194         list_del(&pdo->list);
   193         ec_pdo_clear(pdo);
   195         ec_pdo_clear(pdo);
   194         kfree(pdo);
   196         kfree(pdo);
   195     }
   197     }
   196 
   198 }
   197     sync->alt_mapping = 1;
   199 
   198 }
   200 /*****************************************************************************/
   199 
   201 
   200 /*****************************************************************************/
   202 /**
       
   203  * \return Type of PDOs covered by the given sync manager.
       
   204  */
       
   205 
       
   206 ec_pdo_type_t ec_sync_get_pdo_type(
       
   207         const ec_sync_t *sync /**< EtherCAT sync manager */
       
   208         )
       
   209 {
       
   210     int index = sync->index;
       
   211 
       
   212     if (sync->slave && sync->slave->sii_mailbox_protocols) {
       
   213         index -= 2;
       
   214     }
       
   215 
       
   216     if (index < 0 || index > 1) {
       
   217         EC_WARN("ec_sync_get_pdo_type(): invalid sync manager index.\n");
       
   218         return EC_RX_PDO;
       
   219     }
       
   220 
       
   221     return (ec_pdo_type_t) index;
       
   222 }
       
   223 
       
   224 /*****************************************************************************/