include/ecrt.h
changeset 1209 8be462afb7f4
parent 1182 f5e725aa5483
child 1218 6f3a973fc29e
equal deleted inserted replaced
1208:026e35646ab4 1209:8be462afb7f4
   111  */
   111  */
   112 #define ECRT_VER_MAJOR 1
   112 #define ECRT_VER_MAJOR 1
   113 
   113 
   114 /** EtherCAT realtime interface minor version number.
   114 /** EtherCAT realtime interface minor version number.
   115  */
   115  */
   116 #define ECRT_VER_MINOR 4
   116 #define ECRT_VER_MINOR 5
   117 
   117 
   118 /** EtherCAT realtime interface version word generator.
   118 /** EtherCAT realtime interface version word generator.
   119  */
   119  */
   120 #define ECRT_VERSION(a, b) (((a) << 8) + (b))
   120 #define ECRT_VERSION(a, b) (((a) << 8) + (b))
   121 
   121 
   148 struct ec_domain;
   148 struct ec_domain;
   149 typedef struct ec_domain ec_domain_t; /**< \see ec_domain */
   149 typedef struct ec_domain ec_domain_t; /**< \see ec_domain */
   150 
   150 
   151 struct ec_sdo_request;
   151 struct ec_sdo_request;
   152 typedef struct ec_sdo_request ec_sdo_request_t; /**< \see ec_sdo_request. */
   152 typedef struct ec_sdo_request ec_sdo_request_t; /**< \see ec_sdo_request. */
       
   153 
       
   154 struct ec_voe_handler;
       
   155 typedef struct ec_voe_handler ec_voe_handler_t; /**< \see ec_voe_handler. */
   153 
   156 
   154 /*****************************************************************************/
   157 /*****************************************************************************/
   155 
   158 
   156 /** Master state.
   159 /** Master state.
   157  *
   160  *
   303                                   Pdo entry does not byte-align. */
   306                                   Pdo entry does not byte-align. */
   304 } ec_pdo_entry_reg_t;
   307 } ec_pdo_entry_reg_t;
   305 
   308 
   306 /*****************************************************************************/
   309 /*****************************************************************************/
   307 
   310 
   308 /** Sdo request state.
   311 /** Request state.
   309  *
   312  *
   310  * This is used as return type of ecrt_sdo_request_state().
   313  * This is used as return type for ecrt_sdo_request_state() and
       
   314  * ecrt_voe_handler_state().
   311  */
   315  */
   312 typedef enum {
   316 typedef enum {
   313     EC_SDO_REQUEST_UNUSED, /**< Not requested. */
   317     EC_REQUEST_UNUSED, /**< Not requested. */
   314     EC_SDO_REQUEST_BUSY, /**< Request is being processed. */
   318     EC_REQUEST_BUSY, /**< Request is being processed. */
   315     EC_SDO_REQUEST_SUCCESS, /**< Request was processed successfully. */
   319     EC_REQUEST_SUCCESS, /**< Request was processed successfully. */
   316     EC_SDO_REQUEST_ERROR, /**< Request processing failed. */
   320     EC_REQUEST_ERROR, /**< Request processing failed. */
   317 } ec_sdo_request_state_t;
   321 } ec_request_state_t;
   318 
   322 
   319 /******************************************************************************
   323 /******************************************************************************
   320  * Global functions
   324  * Global functions
   321  *****************************************************************************/
   325  *****************************************************************************/
   322 
   326 
   725         uint16_t index, /**< Sdo index. */
   729         uint16_t index, /**< Sdo index. */
   726         uint8_t subindex, /**< Sdo subindex. */
   730         uint8_t subindex, /**< Sdo subindex. */
   727         size_t size /**< Data size to reserve. */
   731         size_t size /**< Data size to reserve. */
   728         );
   732         );
   729 
   733 
       
   734 /** Create an VoE handler to exchange vendor-specific data during realtime
       
   735  * operation.
       
   736  *
       
   737  * The created VoE handler object is freed automatically when the master is
       
   738  * released.
       
   739  */
       
   740 ec_voe_handler_t *ecrt_slave_config_create_voe_handler(
       
   741         ec_slave_config_t *sc, /**< Slave configuration. */
       
   742         size_t size /**< Data size to reserve. */
       
   743         );
       
   744 
   730 /** Outputs the state of the slave configuration.
   745 /** Outputs the state of the slave configuration.
   731  *
   746  *
   732  * Stores the state information in the given \a state structure.
   747  * Stores the state information in the given \a state structure.
   733  */
   748  */
   734 void ecrt_slave_config_state(
   749 void ecrt_slave_config_state(
   876 
   891 
   877 /** Get the current state of the Sdo request.
   892 /** Get the current state of the Sdo request.
   878  *
   893  *
   879  * \return Request state.
   894  * \return Request state.
   880  */
   895  */
   881 ec_sdo_request_state_t ecrt_sdo_request_state(
   896 ec_request_state_t ecrt_sdo_request_state(
   882     const ec_sdo_request_t *req /**< Sdo request. */
   897     const ec_sdo_request_t *req /**< Sdo request. */
   883     );
   898     );
   884 
   899 
   885 /** Schedule an Sdo write operation.
   900 /** Schedule an Sdo write operation.
   886  *
   901  *
   901  * ecrt_sdo_request_state() returns EC_SDO_REQUEST_BUSY.
   916  * ecrt_sdo_request_state() returns EC_SDO_REQUEST_BUSY.
   902  */
   917  */
   903 void ecrt_sdo_request_read(
   918 void ecrt_sdo_request_read(
   904         ec_sdo_request_t *req /**< Sdo request. */
   919         ec_sdo_request_t *req /**< Sdo request. */
   905         );
   920         );
       
   921 
       
   922 /*****************************************************************************
       
   923  * VoE handler methods.
       
   924  ****************************************************************************/
       
   925 
       
   926 /** Access to the VoE handler's data.
       
   927  *
       
   928  * This function returns a pointer to the handler's internal memory.
       
   929  *
       
   930  * - After a read operation was successful, the memory contains the received
       
   931  *   data. The size of the received data can be determined via
       
   932  *   ecrt_voe_handler_data_size().
       
   933  * - Before a write operation is triggered, the data have to be written to
       
   934  *   the internal memory. Be sure, that the data fit into the memory. The
       
   935  *   memory size is a parameter of ecrt_slave_config_create_voe_handler().
       
   936  *
       
   937  * \return Pointer to the internal memory.
       
   938  */
       
   939 uint8_t *ecrt_voe_handler_data(
       
   940         ec_voe_handler_t *voe /**< VoE handler. */
       
   941         );
       
   942 
       
   943 /** Returns the current data size.
       
   944  *
       
   945  * When the VoE handler is created, the data size is set to the size of the
       
   946  * reserved memory. At a write operation, the data size is set to the number
       
   947  * of bytes to write. After a read operation the size is set to the size of
       
   948  * the read data. The size is not modified in any other situation.
       
   949  *
       
   950  * \return Data size in bytes.
       
   951  */
       
   952 size_t ecrt_voe_handler_data_size(
       
   953         const ec_voe_handler_t *voe /**< VoE handler. */
       
   954         );
       
   955 
       
   956 /** Start a VoE write operation.
       
   957  *
       
   958  * After this function has been called, the ecrt_voe_handler_execute() method
       
   959  * must be called in every bus cycle as long as it returns EC_REQUEST_BUSY.
       
   960  */
       
   961 void ecrt_voe_handler_write(
       
   962         ec_voe_handler_t *voe, /**< VoE handler. */
       
   963         size_t size /**< Number of bytes to write. */
       
   964         );
       
   965 
       
   966 /** Start a VoE read operation.
       
   967  *
       
   968  * After this function has been called, the ecrt_voe_handler_execute() method
       
   969  * must be called in every bus cycle as long as it returns EC_REQUEST_BUSY.
       
   970  *
       
   971  * On success, the size of the read data can be determined via
       
   972  * ecrt_voe_handler_data_size().
       
   973  */
       
   974 void ecrt_voe_handler_read(
       
   975         ec_voe_handler_t *voe /**< VoE handler. */
       
   976         );
       
   977 
       
   978 /** Execute the handler.
       
   979  *
       
   980  * This method executes the VoE handler. It has to be called in every bus cycle
       
   981  * as long as it returns EC_REQUEST_BUSY.
       
   982  *
       
   983  * \return Handler state.
       
   984  */
       
   985 ec_request_state_t ecrt_voe_handler_execute(
       
   986     ec_voe_handler_t *voe /**< VoE handler. */
       
   987     );
   906 
   988 
   907 /******************************************************************************
   989 /******************************************************************************
   908  * Bitwise read/write macros
   990  * Bitwise read/write macros
   909  *****************************************************************************/
   991  *****************************************************************************/
   910 
   992