master/datagram.h
branchstable-1.3
changeset 1745 07fd94c5119d
parent 1744 7bc131b92039
equal deleted inserted replaced
1744:7bc131b92039 1745:07fd94c5119d
    47 
    47 
    48 #include "globals.h"
    48 #include "globals.h"
    49 
    49 
    50 /*****************************************************************************/
    50 /*****************************************************************************/
    51 
    51 
       
    52 /** size of the datagram description string */
       
    53 #define EC_DATAGRAM_NAME_SIZE 20
       
    54 
       
    55 /*****************************************************************************/
       
    56 
    52 /**
    57 /**
    53    EtherCAT datagram type.
    58    EtherCAT datagram type.
    54 */
    59 */
    55 
    60 
    56 typedef enum
    61 typedef enum
    82 ec_datagram_state_t;
    87 ec_datagram_state_t;
    83 
    88 
    84 /*****************************************************************************/
    89 /*****************************************************************************/
    85 
    90 
    86 /**
    91 /**
    87    EtherCAT address.
       
    88 */
       
    89 
       
    90 typedef union
       
    91 {
       
    92     /**
       
    93      * Physical address.
       
    94      */
       
    95     struct
       
    96     {
       
    97         uint16_t slave; /**< configured or autoincrement address */
       
    98         uint16_t mem; /**< physical memory address */
       
    99     }
       
   100     physical;
       
   101 
       
   102     uint32_t logical; /**< logical address */
       
   103 }
       
   104 ec_address_t;
       
   105 
       
   106 /*****************************************************************************/
       
   107 
       
   108 /**
       
   109    EtherCAT datagram.
    92    EtherCAT datagram.
   110 */
    93 */
   111 
    94 
   112 typedef struct
    95 typedef struct
   113 {
    96 {
   114     struct list_head list; /**< needed by domain datagram lists */
    97     struct list_head list; /**< needed by domain datagram lists */
   115     struct list_head queue; /**< master datagram queue item */
    98     struct list_head queue; /**< master datagram queue item */
   116     struct list_head sent; /**< master list item for sent datagrams */
    99     struct list_head sent; /**< master list item for sent datagrams */
   117     ec_datagram_type_t type; /**< datagram type (APRD, BWR, etc) */
   100     ec_datagram_type_t type; /**< datagram type (APRD, BWR, etc) */
   118     ec_address_t address; /**< recipient address */
   101     uint8_t address[EC_ADDR_LEN]; /**< recipient address */
   119     uint8_t *data; /**< datagram data */
   102     uint8_t *data; /**< datagram data */
   120     size_t mem_size; /**< datagram \a data memory size */
   103     size_t mem_size; /**< datagram \a data memory size */
   121     size_t data_size; /**< size of the data in \a data */
   104     size_t data_size; /**< size of the data in \a data */
   122     uint8_t index; /**< datagram index (set by master) */
   105     uint8_t index; /**< datagram index (set by master) */
   123     uint16_t working_counter; /**< working counter */
   106     uint16_t working_counter; /**< working counter */
   124     ec_datagram_state_t state; /**< datagram state */
   107     ec_datagram_state_t state; /**< datagram state */
   125     cycles_t cycles_sent; /**< time, the datagram was sent */
   108     cycles_t cycles_sent; /**< time, the datagram was sent */
   126     unsigned long jiffies_sent; /**< jiffies, when the datagram was sent */
   109     unsigned long jiffies_sent; /**< jiffies, when the datagram was sent */
   127     cycles_t cycles_received; /**< time, when the datagram was received */
   110     cycles_t cycles_received; /**< time, when the datagram was received */
   128     unsigned long jiffies_received; /**< jiffies, when the datagram was rec. */
   111     unsigned long jiffies_received; /**< jiffies the datagram was received */
       
   112     unsigned int skip_count; /**< number of requeues when not yet received */
       
   113     unsigned long stats_output_jiffies; /**< last statistics output */
       
   114     char name[EC_DATAGRAM_NAME_SIZE]; /**< description of the datagram */
   129 }
   115 }
   130 ec_datagram_t;
   116 ec_datagram_t;
   131 
   117 
   132 /*****************************************************************************/
   118 /*****************************************************************************/
   133 
   119 
   141 int ec_datagram_apwr(ec_datagram_t *, uint16_t, uint16_t, size_t);
   127 int ec_datagram_apwr(ec_datagram_t *, uint16_t, uint16_t, size_t);
   142 int ec_datagram_brd(ec_datagram_t *, uint16_t, size_t);
   128 int ec_datagram_brd(ec_datagram_t *, uint16_t, size_t);
   143 int ec_datagram_bwr(ec_datagram_t *, uint16_t, size_t);
   129 int ec_datagram_bwr(ec_datagram_t *, uint16_t, size_t);
   144 int ec_datagram_lrw(ec_datagram_t *, uint32_t, size_t);
   130 int ec_datagram_lrw(ec_datagram_t *, uint32_t, size_t);
   145 
   131 
       
   132 void ec_datagram_print_wc_error(const ec_datagram_t *);
       
   133 void ec_datagram_output_stats(ec_datagram_t *datagram);
       
   134 
   146 /*****************************************************************************/
   135 /*****************************************************************************/
   147 
   136 
   148 #endif
   137 #endif