62 * EC_HAVE_SELECT_REF_CLOCK to check, if the method is available. |
62 * EC_HAVE_SELECT_REF_CLOCK to check, if the method is available. |
63 * - Added method to get the reference clock time, |
63 * - Added method to get the reference clock time, |
64 * ecrt_master_reference_clock_time() and the feature flag |
64 * ecrt_master_reference_clock_time() and the feature flag |
65 * EC_HAVE_REF_CLOCK_TIME to have the possibility to synchronize the master |
65 * EC_HAVE_REF_CLOCK_TIME to have the possibility to synchronize the master |
66 * clock to the reference clock. |
66 * clock to the reference clock. |
67 * - Changed the datatypes of the shift times in ecrt_slave_config_dc() to |
67 * - Changed the data types of the shift times in ecrt_slave_config_dc() to |
68 * int32_t to correctly display negative shift times. |
68 * int32_t to correctly display negative shift times. |
69 * - Added ecrt_slave_config_reg_pdo_entry_pos() and the feature flag |
69 * - Added ecrt_slave_config_reg_pdo_entry_pos() and the feature flag |
70 * EC_HAVE_REG_BY_POS for registering PDO entries with non-unique indices |
70 * EC_HAVE_REG_BY_POS for registering PDO entries with non-unique indices |
71 * via their positions in the mapping. |
71 * via their positions in the mapping. |
72 * |
72 * |
586 |
586 |
587 /** Releases a requested EtherCAT master. |
587 /** Releases a requested EtherCAT master. |
588 * |
588 * |
589 * After use, a master it has to be released to make it available for other |
589 * After use, a master it has to be released to make it available for other |
590 * applications. |
590 * applications. |
|
591 * |
|
592 * This method frees all created data structures. It should not be called in |
|
593 * realtime context. |
|
594 * |
|
595 * If the master was activated, ecrt_master_deactivate() is called internally. |
591 */ |
596 */ |
592 void ecrt_release_master( |
597 void ecrt_release_master( |
593 ec_master_t *master /**< EtherCAT master */ |
598 ec_master_t *master /**< EtherCAT master */ |
594 ); |
599 ); |
595 |
600 |
603 * |
608 * |
604 * Before an application can use PDO/domain registration functions or SDO |
609 * Before an application can use PDO/domain registration functions or SDO |
605 * request functions on the master, it has to reserve one for exclusive use. |
610 * request functions on the master, it has to reserve one for exclusive use. |
606 * |
611 * |
607 * \return 0 in case of success, else < 0 |
612 * \return 0 in case of success, else < 0 |
608 * |
|
609 */ |
613 */ |
610 int ecrt_master_reserve( |
614 int ecrt_master_reserve( |
611 ec_master_t *master /**< EtherCAT master */ |
615 ec_master_t *master /**< EtherCAT master */ |
612 ); |
616 ); |
613 |
617 |
627 * currently accessible and whether or not to call the ecrt_master_send_ext() |
631 * currently accessible and whether or not to call the ecrt_master_send_ext() |
628 * method. |
632 * method. |
629 * |
633 * |
630 * The task of the receive callback (\a receive_cb) is to decide, if a call to |
634 * The task of the receive callback (\a receive_cb) is to decide, if a call to |
631 * ecrt_master_receive() is allowed and to execute it respectively. |
635 * ecrt_master_receive() is allowed and to execute it respectively. |
|
636 * |
|
637 * \attention This method has to be called before ecrt_master_activate(). |
632 */ |
638 */ |
633 void ecrt_master_callbacks( |
639 void ecrt_master_callbacks( |
634 ec_master_t *master, /**< EtherCAT master */ |
640 ec_master_t *master, /**< EtherCAT master */ |
635 void (*send_cb)(void *), /**< Datagram sending callback. */ |
641 void (*send_cb)(void *), /**< Datagram sending callback. */ |
636 void (*receive_cb)(void *), /**< Receive callback. */ |
642 void (*receive_cb)(void *), /**< Receive callback. */ |
644 * |
650 * |
645 * For process data exchange, at least one process data domain is needed. |
651 * For process data exchange, at least one process data domain is needed. |
646 * This method creates a new process data domain and returns a pointer to the |
652 * This method creates a new process data domain and returns a pointer to the |
647 * new domain object. This object can be used for registering PDOs and |
653 * new domain object. This object can be used for registering PDOs and |
648 * exchanging them in cyclic operation. |
654 * exchanging them in cyclic operation. |
|
655 * |
|
656 * This method allocates memory and should be called in non-realtime context |
|
657 * before ecrt_master_activate(). |
649 * |
658 * |
650 * \return Pointer to the new domain on success, else NULL. |
659 * \return Pointer to the new domain on success, else NULL. |
651 */ |
660 */ |
652 ec_domain_t *ecrt_master_create_domain( |
661 ec_domain_t *ecrt_master_create_domain( |
653 ec_master_t *master /**< EtherCAT master. */ |
662 ec_master_t *master /**< EtherCAT master. */ |
674 * mismatch, the slave is not configured and an error message is raised. |
683 * mismatch, the slave is not configured and an error message is raised. |
675 * |
684 * |
676 * If different slave configurations are pointing to the same slave during bus |
685 * If different slave configurations are pointing to the same slave during bus |
677 * configuration, a warning is raised and only the first configuration is |
686 * configuration, a warning is raised and only the first configuration is |
678 * applied. |
687 * applied. |
|
688 * |
|
689 * This method allocates memory and should be called in non-realtime context |
|
690 * before ecrt_master_activate(). |
679 * |
691 * |
680 * \retval >0 Pointer to the slave configuration structure. |
692 * \retval >0 Pointer to the slave configuration structure. |
681 * \retval NULL in the error case. |
693 * \retval NULL in the error case. |
682 */ |
694 */ |
683 ec_slave_config_t *ecrt_master_slave_config( |
695 ec_slave_config_t *ecrt_master_slave_config( |
897 * |
909 * |
898 * \attention After this function has been called, the realtime application is |
910 * \attention After this function has been called, the realtime application is |
899 * in charge of cyclically calling ecrt_master_send() and |
911 * in charge of cyclically calling ecrt_master_send() and |
900 * ecrt_master_receive() to ensure bus communication. Before calling this |
912 * ecrt_master_receive() to ensure bus communication. Before calling this |
901 * function, the master thread is responsible for that, so these functions may |
913 * function, the master thread is responsible for that, so these functions may |
902 * not be called! |
914 * not be called! The method itself allocates memory and should not be called |
|
915 * in realtime context. |
903 * |
916 * |
904 * \return 0 in case of success, else < 0 |
917 * \return 0 in case of success, else < 0 |
905 */ |
918 */ |
906 int ecrt_master_activate( |
919 int ecrt_master_activate( |
907 ec_master_t *master /**< EtherCAT master. */ |
920 ec_master_t *master /**< EtherCAT master. */ |
912 * Removes the bus configuration. All objects created by |
925 * Removes the bus configuration. All objects created by |
913 * ecrt_master_create_domain(), ecrt_master_slave_config(), ecrt_domain_data() |
926 * ecrt_master_create_domain(), ecrt_master_slave_config(), ecrt_domain_data() |
914 * ecrt_slave_config_create_sdo_request() and |
927 * ecrt_slave_config_create_sdo_request() and |
915 * ecrt_slave_config_create_voe_handler() are freed, so pointers to them |
928 * ecrt_slave_config_create_voe_handler() are freed, so pointers to them |
916 * become invalid. |
929 * become invalid. |
|
930 * |
|
931 * This method should not be called in realtime context. |
917 */ |
932 */ |
918 void ecrt_master_deactivate( |
933 void ecrt_master_deactivate( |
919 ec_master_t *master /**< EtherCAT master. */ |
934 ec_master_t *master /**< EtherCAT master. */ |
920 ); |
935 ); |
921 |
936 |
922 /** Set interval between calls to ecrt_master_send(). |
937 /** Set interval between calls to ecrt_master_send(). |
923 * |
938 * |
|
939 * This information helps the master to decide, how much data can be appended |
|
940 * to a frame by the master state machine. When the master is configured with |
|
941 * --enable-hrtimers, this is used to calculate the scheduling of the master |
|
942 * thread. |
|
943 * |
924 * \retval 0 on success. |
944 * \retval 0 on success. |
925 * \retval <0 Error code. |
945 * \retval <0 Error code. |
926 * |
|
927 */ |
946 */ |
928 int ecrt_master_set_send_interval( |
947 int ecrt_master_set_send_interval( |
929 ec_master_t *master, /**< EtherCAT master. */ |
948 ec_master_t *master, /**< EtherCAT master. */ |
930 size_t send_interval /**< Send interval in us */ |
949 size_t send_interval /**< Send interval in us */ |
931 ); |
950 ); |
995 * |
1014 * |
996 * The master has to know the application's time when operating slaves with |
1015 * The master has to know the application's time when operating slaves with |
997 * distributed clocks. The time is not incremented by the master itself, so |
1016 * distributed clocks. The time is not incremented by the master itself, so |
998 * this method has to be called cyclically. |
1017 * this method has to be called cyclically. |
999 * |
1018 * |
|
1019 * \attention The first call of this method is used to calculate the phase |
|
1020 * delay for the slaves' SYNC0/1 interrupts. Either the method has to be |
|
1021 * called during the realtime cycle *only*, or the first time submitted must |
|
1022 * be in-phase with the realtime cycle. Otherwise synchronisation problems can |
|
1023 * occur. |
|
1024 * |
1000 * The time is used when setting the slaves' <tt>System Time Offset</tt> and |
1025 * The time is used when setting the slaves' <tt>System Time Offset</tt> and |
1001 * <tt>Cyclic Operation Start Time</tt> registers and when synchronizing the |
1026 * <tt>Cyclic Operation Start Time</tt> registers and when synchronizing the |
1002 * DC reference clock to the application time via |
1027 * DC reference clock to the application time via |
1003 * ecrt_master_sync_reference_clock(). |
1028 * ecrt_master_sync_reference_clock(). |
1004 * |
1029 * |
1087 |
1112 |
1088 /** Configure a sync manager. |
1113 /** Configure a sync manager. |
1089 * |
1114 * |
1090 * Sets the direction of a sync manager. This overrides the direction bits |
1115 * Sets the direction of a sync manager. This overrides the direction bits |
1091 * from the default control register from SII. |
1116 * from the default control register from SII. |
|
1117 * |
|
1118 * This method has to be called in non-realtime context before |
|
1119 * ecrt_master_activate(). |
1092 * |
1120 * |
1093 * \return zero on success, else non-zero |
1121 * \return zero on success, else non-zero |
1094 */ |
1122 */ |
1095 int ecrt_slave_config_sync_manager( |
1123 int ecrt_slave_config_sync_manager( |
1096 ec_slave_config_t *sc, /**< Slave configuration. */ |
1124 ec_slave_config_t *sc, /**< Slave configuration. */ |
1099 ec_direction_t direction, /**< Input/Output. */ |
1127 ec_direction_t direction, /**< Input/Output. */ |
1100 ec_watchdog_mode_t watchdog_mode /** Watchdog mode. */ |
1128 ec_watchdog_mode_t watchdog_mode /** Watchdog mode. */ |
1101 ); |
1129 ); |
1102 |
1130 |
1103 /** Configure a slave's watchdog times. |
1131 /** Configure a slave's watchdog times. |
|
1132 * |
|
1133 * This method has to be called in non-realtime context before |
|
1134 * ecrt_master_activate(). |
1104 */ |
1135 */ |
1105 void ecrt_slave_config_watchdog( |
1136 void ecrt_slave_config_watchdog( |
1106 ec_slave_config_t *sc, /**< Slave configuration. */ |
1137 ec_slave_config_t *sc, /**< Slave configuration. */ |
1107 uint16_t watchdog_divider, /**< Number of 40 ns intervals. Used as a |
1138 uint16_t watchdog_divider, /**< Number of 40 ns intervals. Used as a |
1108 base unit for all slave watchdogs. If set |
1139 base unit for all slave watchdogs. If set |
1114 */ |
1145 */ |
1115 ); |
1146 ); |
1116 |
1147 |
1117 /** Add a PDO to a sync manager's PDO assignment. |
1148 /** Add a PDO to a sync manager's PDO assignment. |
1118 * |
1149 * |
|
1150 * This method has to be called in non-realtime context before |
|
1151 * ecrt_master_activate(). |
|
1152 * |
1119 * \see ecrt_slave_config_pdos() |
1153 * \see ecrt_slave_config_pdos() |
1120 * \return zero on success, else non-zero |
1154 * \return zero on success, else non-zero |
1121 */ |
1155 */ |
1122 int ecrt_slave_config_pdo_assign_add( |
1156 int ecrt_slave_config_pdo_assign_add( |
1123 ec_slave_config_t *sc, /**< Slave configuration. */ |
1157 ec_slave_config_t *sc, /**< Slave configuration. */ |
1130 * |
1164 * |
1131 * This can be called before assigning PDOs via |
1165 * This can be called before assigning PDOs via |
1132 * ecrt_slave_config_pdo_assign_add(), to clear the default assignment of a |
1166 * ecrt_slave_config_pdo_assign_add(), to clear the default assignment of a |
1133 * sync manager. |
1167 * sync manager. |
1134 * |
1168 * |
|
1169 * This method has to be called in non-realtime context before |
|
1170 * ecrt_master_activate(). |
|
1171 * |
1135 * \see ecrt_slave_config_pdos() |
1172 * \see ecrt_slave_config_pdos() |
1136 */ |
1173 */ |
1137 void ecrt_slave_config_pdo_assign_clear( |
1174 void ecrt_slave_config_pdo_assign_clear( |
1138 ec_slave_config_t *sc, /**< Slave configuration. */ |
1175 ec_slave_config_t *sc, /**< Slave configuration. */ |
1139 uint8_t sync_index /**< Sync manager index. Must be less |
1176 uint8_t sync_index /**< Sync manager index. Must be less |
1140 than #EC_MAX_SYNC_MANAGERS. */ |
1177 than #EC_MAX_SYNC_MANAGERS. */ |
1141 ); |
1178 ); |
1142 |
1179 |
1143 /** Add a PDO entry to the given PDO's mapping. |
1180 /** Add a PDO entry to the given PDO's mapping. |
|
1181 * |
|
1182 * This method has to be called in non-realtime context before |
|
1183 * ecrt_master_activate(). |
1144 * |
1184 * |
1145 * \see ecrt_slave_config_pdos() |
1185 * \see ecrt_slave_config_pdos() |
1146 * \return zero on success, else non-zero |
1186 * \return zero on success, else non-zero |
1147 */ |
1187 */ |
1148 int ecrt_slave_config_pdo_mapping_add( |
1188 int ecrt_slave_config_pdo_mapping_add( |
1158 /** Clear the mapping of a given PDO. |
1198 /** Clear the mapping of a given PDO. |
1159 * |
1199 * |
1160 * This can be called before mapping PDO entries via |
1200 * This can be called before mapping PDO entries via |
1161 * ecrt_slave_config_pdo_mapping_add(), to clear the default mapping. |
1201 * ecrt_slave_config_pdo_mapping_add(), to clear the default mapping. |
1162 * |
1202 * |
|
1203 * This method has to be called in non-realtime context before |
|
1204 * ecrt_master_activate(). |
|
1205 * |
1163 * \see ecrt_slave_config_pdos() |
1206 * \see ecrt_slave_config_pdos() |
1164 */ |
1207 */ |
1165 void ecrt_slave_config_pdo_mapping_clear( |
1208 void ecrt_slave_config_pdo_mapping_clear( |
1166 ec_slave_config_t *sc, /**< Slave configuration. */ |
1209 ec_slave_config_t *sc, /**< Slave configuration. */ |
1167 uint16_t pdo_index /**< Index of the PDO. */ |
1210 uint16_t pdo_index /**< Index of the PDO. */ |
1230 * Processing of \a syncs will stop, if |
1273 * Processing of \a syncs will stop, if |
1231 * - the number of processed items reaches \a n_syncs, or |
1274 * - the number of processed items reaches \a n_syncs, or |
1232 * - the \a index member of an ec_sync_info_t item is 0xff. In this case, |
1275 * - the \a index member of an ec_sync_info_t item is 0xff. In this case, |
1233 * \a n_syncs should set to a number greater than the number of list items; |
1276 * \a n_syncs should set to a number greater than the number of list items; |
1234 * using EC_END is recommended. |
1277 * using EC_END is recommended. |
|
1278 * |
|
1279 * This method has to be called in non-realtime context before |
|
1280 * ecrt_master_activate(). |
1235 * |
1281 * |
1236 * \return zero on success, else non-zero |
1282 * \return zero on success, else non-zero |
1237 */ |
1283 */ |
1238 int ecrt_slave_config_pdos( |
1284 int ecrt_slave_config_pdos( |
1239 ec_slave_config_t *sc, /**< Slave configuration. */ |
1285 ec_slave_config_t *sc, /**< Slave configuration. */ |
1253 * the domain's process data is returned. Optionally, the PDO entry bit |
1299 * the domain's process data is returned. Optionally, the PDO entry bit |
1254 * position (0-7) can be retrieved via the \a bit_position output parameter. |
1300 * position (0-7) can be retrieved via the \a bit_position output parameter. |
1255 * This pointer may be \a NULL, in this case an error is raised if the PDO |
1301 * This pointer may be \a NULL, in this case an error is raised if the PDO |
1256 * entry does not byte-align. |
1302 * entry does not byte-align. |
1257 * |
1303 * |
|
1304 * This method has to be called in non-realtime context before |
|
1305 * ecrt_master_activate(). |
|
1306 * |
1258 * \retval >=0 Success: Offset of the PDO entry's process data. |
1307 * \retval >=0 Success: Offset of the PDO entry's process data. |
1259 * \retval <0 Error code. |
1308 * \retval <0 Error code. |
1260 */ |
1309 */ |
1261 int ecrt_slave_config_reg_pdo_entry( |
1310 int ecrt_slave_config_reg_pdo_entry( |
1262 ec_slave_config_t *sc, /**< Slave configuration. */ |
1311 ec_slave_config_t *sc, /**< Slave configuration. */ |
1271 * |
1320 * |
1272 * Similar to ecrt_slave_config_reg_pdo_entry(), but not using PDO indices but |
1321 * Similar to ecrt_slave_config_reg_pdo_entry(), but not using PDO indices but |
1273 * offsets in the PDO mapping, because PDO entry indices may not be unique |
1322 * offsets in the PDO mapping, because PDO entry indices may not be unique |
1274 * inside a slave's PDO mapping. An error is raised, if |
1323 * inside a slave's PDO mapping. An error is raised, if |
1275 * one of the given positions is out of range. |
1324 * one of the given positions is out of range. |
|
1325 * |
|
1326 * This method has to be called in non-realtime context before |
|
1327 * ecrt_master_activate(). |
1276 * |
1328 * |
1277 * \retval >=0 Success: Offset of the PDO entry's process data. |
1329 * \retval >=0 Success: Offset of the PDO entry's process data. |
1278 * \retval <0 Error code. |
1330 * \retval <0 Error code. |
1279 */ |
1331 */ |
1280 int ecrt_slave_config_reg_pdo_entry_pos( |
1332 int ecrt_slave_config_reg_pdo_entry_pos( |
1294 * |
1346 * |
1295 * The AssignActivate word is vendor-specific and can be taken from the XML |
1347 * The AssignActivate word is vendor-specific and can be taken from the XML |
1296 * device description file (Device -> Dc -> AssignActivate). Set this to zero, |
1348 * device description file (Device -> Dc -> AssignActivate). Set this to zero, |
1297 * if the slave shall be operated without distributed clocks (default). |
1349 * if the slave shall be operated without distributed clocks (default). |
1298 * |
1350 * |
|
1351 * This method has to be called in non-realtime context before |
|
1352 * ecrt_master_activate(). |
|
1353 * |
1299 * \attention The \a sync1_shift time is ignored. |
1354 * \attention The \a sync1_shift time is ignored. |
1300 */ |
1355 */ |
1301 void ecrt_slave_config_dc( |
1356 void ecrt_slave_config_dc( |
1302 ec_slave_config_t *sc, /**< Slave configuration. */ |
1357 ec_slave_config_t *sc, /**< Slave configuration. */ |
1303 uint16_t assign_activate, /**< AssignActivate word. */ |
1358 uint16_t assign_activate, /**< AssignActivate word. */ |
1319 * configured with this function, because they are part of the slave |
1374 * configured with this function, because they are part of the slave |
1320 * configuration done by the master. Please use ecrt_slave_config_pdos() and |
1375 * configuration done by the master. Please use ecrt_slave_config_pdos() and |
1321 * friends instead. |
1376 * friends instead. |
1322 * |
1377 * |
1323 * This is the generic function for adding an SDO configuration. Please note |
1378 * This is the generic function for adding an SDO configuration. Please note |
1324 * that the this function does not do any endianess correction. If |
1379 * that the this function does not do any endianness correction. If |
1325 * datatype-specific functions are needed (that automatically correct the |
1380 * datatype-specific functions are needed (that automatically correct the |
1326 * endianess), have a look at ecrt_slave_config_sdo8(), |
1381 * endianness), have a look at ecrt_slave_config_sdo8(), |
1327 * ecrt_slave_config_sdo16() and ecrt_slave_config_sdo32(). |
1382 * ecrt_slave_config_sdo16() and ecrt_slave_config_sdo32(). |
|
1383 * |
|
1384 * This method has to be called in non-realtime context before |
|
1385 * ecrt_master_activate(). |
1328 * |
1386 * |
1329 * \retval 0 Success. |
1387 * \retval 0 Success. |
1330 * \retval <0 Error code. |
1388 * \retval <0 Error code. |
1331 */ |
1389 */ |
1332 int ecrt_slave_config_sdo( |
1390 int ecrt_slave_config_sdo( |
1337 size_t size /**< Size of the \a data. */ |
1395 size_t size /**< Size of the \a data. */ |
1338 ); |
1396 ); |
1339 |
1397 |
1340 /** Add a configuration value for an 8-bit SDO. |
1398 /** Add a configuration value for an 8-bit SDO. |
1341 * |
1399 * |
|
1400 * This method has to be called in non-realtime context before |
|
1401 * ecrt_master_activate(). |
|
1402 * |
1342 * \see ecrt_slave_config_sdo(). |
1403 * \see ecrt_slave_config_sdo(). |
1343 * |
1404 * |
1344 * \retval 0 Success. |
1405 * \retval 0 Success. |
1345 * \retval <0 Error code. |
1406 * \retval <0 Error code. |
1346 */ |
1407 */ |
1351 uint8_t value /**< Value to set. */ |
1412 uint8_t value /**< Value to set. */ |
1352 ); |
1413 ); |
1353 |
1414 |
1354 /** Add a configuration value for a 16-bit SDO. |
1415 /** Add a configuration value for a 16-bit SDO. |
1355 * |
1416 * |
|
1417 * This method has to be called in non-realtime context before |
|
1418 * ecrt_master_activate(). |
|
1419 * |
1356 * \see ecrt_slave_config_sdo(). |
1420 * \see ecrt_slave_config_sdo(). |
1357 * |
1421 * |
1358 * \retval 0 Success. |
1422 * \retval 0 Success. |
1359 * \retval <0 Error code. |
1423 * \retval <0 Error code. |
1360 */ |
1424 */ |
1365 uint16_t value /**< Value to set. */ |
1429 uint16_t value /**< Value to set. */ |
1366 ); |
1430 ); |
1367 |
1431 |
1368 /** Add a configuration value for a 32-bit SDO. |
1432 /** Add a configuration value for a 32-bit SDO. |
1369 * |
1433 * |
|
1434 * This method has to be called in non-realtime context before |
|
1435 * ecrt_master_activate(). |
|
1436 * |
1370 * \see ecrt_slave_config_sdo(). |
1437 * \see ecrt_slave_config_sdo(). |
1371 * |
1438 * |
1372 * \retval 0 Success. |
1439 * \retval 0 Success. |
1373 * \retval <0 Error code. |
1440 * \retval <0 Error code. |
1374 */ |
1441 */ |
1382 /** Add configuration data for a complete SDO. |
1449 /** Add configuration data for a complete SDO. |
1383 * |
1450 * |
1384 * The SDO data are transferred via CompleteAccess. Data for the first |
1451 * The SDO data are transferred via CompleteAccess. Data for the first |
1385 * subindex (0) have to be included. |
1452 * subindex (0) have to be included. |
1386 * |
1453 * |
|
1454 * This method has to be called in non-realtime context before |
|
1455 * ecrt_master_activate(). |
|
1456 * |
1387 * \see ecrt_slave_config_sdo(). |
1457 * \see ecrt_slave_config_sdo(). |
1388 * |
1458 * |
1389 * \retval 0 Success. |
1459 * \retval 0 Success. |
1390 * \retval <0 Error code. |
1460 * \retval <0 Error code. |
1391 */ |
1461 */ |
1399 /** Set the size of the CoE emergency ring buffer. |
1469 /** Set the size of the CoE emergency ring buffer. |
1400 * |
1470 * |
1401 * The initial size is zero, so all messages will be dropped. This method can |
1471 * The initial size is zero, so all messages will be dropped. This method can |
1402 * be called even after master activation, but it will clear the ring buffer! |
1472 * be called even after master activation, but it will clear the ring buffer! |
1403 * |
1473 * |
|
1474 * This method has to be called in non-realtime context before |
|
1475 * ecrt_master_activate(). |
|
1476 * |
1404 * \return 0 on success, or negative error code. |
1477 * \return 0 on success, or negative error code. |
1405 */ |
1478 */ |
1406 int ecrt_slave_config_emerg_size( |
1479 int ecrt_slave_config_emerg_size( |
1407 ec_slave_config_t *sc, /**< Slave configuration. */ |
1480 ec_slave_config_t *sc, /**< Slave configuration. */ |
1408 size_t elements /**< Number of records of the CoE emergency ring. */ |
1481 size_t elements /**< Number of records of the CoE emergency ring. */ |
1447 |
1520 |
1448 /** Create an SDO request to exchange SDOs during realtime operation. |
1521 /** Create an SDO request to exchange SDOs during realtime operation. |
1449 * |
1522 * |
1450 * The created SDO request object is freed automatically when the master is |
1523 * The created SDO request object is freed automatically when the master is |
1451 * released. |
1524 * released. |
|
1525 * |
|
1526 * This method has to be called in non-realtime context before |
|
1527 * ecrt_master_activate(). |
1452 * |
1528 * |
1453 * \return New SDO request, or NULL on error. |
1529 * \return New SDO request, or NULL on error. |
1454 */ |
1530 */ |
1455 ec_sdo_request_t *ecrt_slave_config_create_sdo_request( |
1531 ec_sdo_request_t *ecrt_slave_config_create_sdo_request( |
1456 ec_slave_config_t *sc, /**< Slave configuration. */ |
1532 ec_slave_config_t *sc, /**< Slave configuration. */ |
1467 * both can be done simultaneously. |
1543 * both can be done simultaneously. |
1468 * |
1544 * |
1469 * The created VoE handler object is freed automatically when the master is |
1545 * The created VoE handler object is freed automatically when the master is |
1470 * released. |
1546 * released. |
1471 * |
1547 * |
|
1548 * This method has to be called in non-realtime context before |
|
1549 * ecrt_master_activate(). |
|
1550 * |
1472 * \return New VoE handler, or NULL on error. |
1551 * \return New VoE handler, or NULL on error. |
1473 */ |
1552 */ |
1474 ec_voe_handler_t *ecrt_slave_config_create_voe_handler( |
1553 ec_voe_handler_t *ecrt_slave_config_create_voe_handler( |
1475 ec_slave_config_t *sc, /**< Slave configuration. */ |
1554 ec_slave_config_t *sc, /**< Slave configuration. */ |
1476 size_t size /**< Data size to reserve. */ |
1555 size_t size /**< Data size to reserve. */ |
1482 * This interface should not be used to take over master functionality, |
1561 * This interface should not be used to take over master functionality, |
1483 * instead it is intended for debugging and monitoring reasons. |
1562 * instead it is intended for debugging and monitoring reasons. |
1484 * |
1563 * |
1485 * The created register request object is freed automatically when the master |
1564 * The created register request object is freed automatically when the master |
1486 * is released. |
1565 * is released. |
|
1566 * |
|
1567 * This method has to be called in non-realtime context before |
|
1568 * ecrt_master_activate(). |
1487 * |
1569 * |
1488 * \return New register request, or NULL on error. |
1570 * \return New register request, or NULL on error. |
1489 */ |
1571 */ |
1490 ec_reg_request_t *ecrt_slave_config_create_reg_request( |
1572 ec_reg_request_t *ecrt_slave_config_create_reg_request( |
1491 ec_slave_config_t *sc, /**< Slave configuration. */ |
1573 ec_slave_config_t *sc, /**< Slave configuration. */ |
1517 * The \a idn parameter can be separated into several sections: |
1599 * The \a idn parameter can be separated into several sections: |
1518 * - Bit 15: Standard data (0) or Product data (1) |
1600 * - Bit 15: Standard data (0) or Product data (1) |
1519 * - Bit 14 - 12: Parameter set (0 - 7) |
1601 * - Bit 14 - 12: Parameter set (0 - 7) |
1520 * - Bit 11 - 0: Data block number (0 - 4095) |
1602 * - Bit 11 - 0: Data block number (0 - 4095) |
1521 * |
1603 * |
1522 * Please note that the this function does not do any endianess correction. |
1604 * Please note that the this function does not do any endianness correction. |
1523 * Multi-byte data have to be passed in EtherCAT endianess (little-endian). |
1605 * Multi-byte data have to be passed in EtherCAT endianness (little-endian). |
|
1606 * |
|
1607 * This method has to be called in non-realtime context before |
|
1608 * ecrt_master_activate(). |
1524 * |
1609 * |
1525 * \retval 0 Success. |
1610 * \retval 0 Success. |
1526 * \retval <0 Error code. |
1611 * \retval <0 Error code. |
1527 */ |
1612 */ |
1528 int ecrt_slave_config_idn( |
1613 int ecrt_slave_config_idn( |
1539 * Domain methods |
1624 * Domain methods |
1540 *****************************************************************************/ |
1625 *****************************************************************************/ |
1541 |
1626 |
1542 /** Registers a bunch of PDO entries for a domain. |
1627 /** Registers a bunch of PDO entries for a domain. |
1543 * |
1628 * |
1544 * \todo doc |
1629 * This method has to be called in non-realtime context before |
|
1630 * ecrt_master_activate(). |
|
1631 * |
|
1632 * \see ecrt_slave_config_reg_pdo_entry() |
|
1633 * |
1545 * \attention The registration array has to be terminated with an empty |
1634 * \attention The registration array has to be terminated with an empty |
1546 * structure, or one with the \a index field set to zero! |
1635 * structure, or one with the \a index field set to zero! |
1547 * \return 0 on success, else non-zero. |
1636 * \return 0 on success, else non-zero. |
1548 */ |
1637 */ |
1549 int ecrt_domain_reg_pdo_entry_list( |
1638 int ecrt_domain_reg_pdo_entry_list( |
1567 * Call this after all PDO entries have been registered and before activating |
1656 * Call this after all PDO entries have been registered and before activating |
1568 * the master. |
1657 * the master. |
1569 * |
1658 * |
1570 * The size of the allocated memory must be at least ecrt_domain_size(), after |
1659 * The size of the allocated memory must be at least ecrt_domain_size(), after |
1571 * all PDO entries have been registered. |
1660 * all PDO entries have been registered. |
|
1661 * |
|
1662 * This method has to be called in non-realtime context before |
|
1663 * ecrt_master_activate(). |
|
1664 * |
1572 */ |
1665 */ |
1573 void ecrt_domain_external_memory( |
1666 void ecrt_domain_external_memory( |
1574 ec_domain_t *domain, /**< Domain. */ |
1667 ec_domain_t *domain, /**< Domain. */ |
1575 uint8_t *memory /**< Address of the memory to store the process |
1668 uint8_t *memory /**< Address of the memory to store the process |
1576 data in. */ |
1669 data in. */ |
1851 ec_voe_handler_t *voe /**< VoE handler. */ |
1944 ec_voe_handler_t *voe /**< VoE handler. */ |
1852 ); |
1945 ); |
1853 |
1946 |
1854 /** Execute the handler. |
1947 /** Execute the handler. |
1855 * |
1948 * |
1856 * This method executes the VoE handler. It has to be called in every bus cycle |
1949 * This method executes the VoE handler. It has to be called in every bus |
1857 * as long as it returns EC_REQUEST_BUSY. |
1950 * cycle as long as it returns EC_REQUEST_BUSY. |
1858 * |
1951 * |
1859 * \return Handler state. |
1952 * \return Handler state. |
1860 */ |
1953 */ |
1861 ec_request_state_t ecrt_voe_handler_execute( |
1954 ec_request_state_t ecrt_voe_handler_execute( |
1862 ec_voe_handler_t *voe /**< VoE handler. */ |
1955 ec_voe_handler_t *voe /**< VoE handler. */ |
1868 |
1961 |
1869 /** Access to the register request's data. |
1962 /** Access to the register request's data. |
1870 * |
1963 * |
1871 * This function returns a pointer to the request's internal memory. |
1964 * This function returns a pointer to the request's internal memory. |
1872 * |
1965 * |
1873 * - After a read operation was successful, integer data can be evaluated using |
1966 * - After a read operation was successful, integer data can be evaluated |
1874 * the EC_READ_*() macros as usual. Example: |
1967 * using the EC_READ_*() macros as usual. Example: |
1875 * \code |
1968 * \code |
1876 * uint16_t value = EC_READ_U16(ecrt_reg_request_data(reg_request))); |
1969 * uint16_t value = EC_READ_U16(ecrt_reg_request_data(reg_request))); |
1877 * \endcode |
1970 * \endcode |
1878 * - If a write operation shall be triggered, the data have to be written to |
1971 * - If a write operation shall be triggered, the data have to be written to |
1879 * the internal memory. Use the EC_WRITE_*() macros, if you are writing |
1972 * the internal memory. Use the EC_WRITE_*() macros, if you are writing |