55 ec_slave_t *slave; /**< EtherCAT slave. */ |
56 ec_slave_t *slave; /**< EtherCAT slave. */ |
56 uint16_t offset; /**< SII word offset. */ |
57 uint16_t offset; /**< SII word offset. */ |
57 size_t nwords; /**< Number of words. */ |
58 size_t nwords; /**< Number of words. */ |
58 const uint16_t *words; /**< Pointer to the data words. */ |
59 const uint16_t *words; /**< Pointer to the data words. */ |
59 ec_internal_request_state_t state; /**< State of the request. */ |
60 ec_internal_request_state_t state; /**< State of the request. */ |
|
61 struct kref refcount; |
60 } ec_sii_write_request_t; |
62 } ec_sii_write_request_t; |
|
63 |
|
64 void ec_master_sii_write_request_release(struct kref *); |
61 |
65 |
62 /*****************************************************************************/ |
66 /*****************************************************************************/ |
63 |
67 |
64 /** Register request. |
68 /** Register request. |
65 */ |
69 */ |
69 ec_direction_t dir; /**< Direction. */ |
73 ec_direction_t dir; /**< Direction. */ |
70 uint16_t offset; /**< Register address. */ |
74 uint16_t offset; /**< Register address. */ |
71 size_t length; /**< Number of bytes. */ |
75 size_t length; /**< Number of bytes. */ |
72 uint8_t *data; /**< Data to write / memory for read data. */ |
76 uint8_t *data; /**< Data to write / memory for read data. */ |
73 ec_internal_request_state_t state; /**< State of the request. */ |
77 ec_internal_request_state_t state; /**< State of the request. */ |
|
78 struct kref refcount; |
74 } ec_reg_request_t; |
79 } ec_reg_request_t; |
|
80 |
|
81 void ec_master_reg_request_release(struct kref *); |
75 |
82 |
76 /*****************************************************************************/ |
83 /*****************************************************************************/ |
77 |
84 |
78 /** Slave/SDO request record for master's SDO request list. |
85 /** Slave/SDO request record for master's SDO request list. |
79 */ |
86 */ |
80 typedef struct { |
87 typedef struct { |
81 struct list_head list; /**< List element. */ |
88 struct list_head list; /**< List element. */ |
82 ec_slave_t *slave; /**< Slave. */ |
89 ec_slave_t *slave; /**< Slave. */ |
83 ec_sdo_request_t req; /**< SDO request. */ |
90 ec_sdo_request_t req; /**< SDO request. */ |
|
91 struct kref refcount; |
84 } ec_master_sdo_request_t; |
92 } ec_master_sdo_request_t; |
|
93 |
|
94 void ec_master_sdo_request_release(struct kref *); |
85 |
95 |
86 /*****************************************************************************/ |
96 /*****************************************************************************/ |
87 |
97 |
88 /** FoE request. |
98 /** FoE request. |
89 */ |
99 */ |
90 typedef struct { |
100 typedef struct { |
91 struct list_head list; /**< List head. */ |
101 struct list_head list; /**< List head. */ |
92 ec_slave_t *slave; /**< EtherCAT slave. */ |
102 ec_slave_t *slave; /**< EtherCAT slave. */ |
93 ec_foe_request_t req; /**< FoE request. */ |
103 ec_foe_request_t req; /**< FoE request. */ |
|
104 struct kref refcount; |
94 } ec_master_foe_request_t; |
105 } ec_master_foe_request_t; |
|
106 |
|
107 void ec_master_foe_request_release(struct kref *); |
95 |
108 |
96 /*****************************************************************************/ |
109 /*****************************************************************************/ |
97 |
110 |
98 /** SoE request. |
111 /** SoE request. |
99 */ |
112 */ |
100 typedef struct { |
113 typedef struct { |
101 struct list_head list; /**< List head. */ |
114 struct list_head list; /**< List head. */ |
102 ec_slave_t *slave; /**< EtherCAT slave. */ |
115 ec_slave_t *slave; /**< EtherCAT slave. */ |
103 ec_soe_request_t req; /**< SoE request. */ |
116 ec_soe_request_t req; /**< SoE request. */ |
|
117 struct kref refcount; |
104 } ec_master_soe_request_t; |
118 } ec_master_soe_request_t; |
|
119 |
|
120 void ec_master_soe_request_release(struct kref *); |
105 |
121 |
106 /*****************************************************************************/ |
122 /*****************************************************************************/ |
107 |
123 |
108 typedef struct ec_fsm_master ec_fsm_master_t; /**< \see ec_fsm_master */ |
124 typedef struct ec_fsm_master ec_fsm_master_t; /**< \see ec_fsm_master */ |
109 |
125 |
110 /** Finite state machine of an EtherCAT master. |
126 /** Finite state machine of an EtherCAT master. |
111 */ |
127 */ |
112 struct ec_fsm_master { |
128 struct ec_fsm_master { |
113 ec_master_t *master; /**< master the FSM runs on */ |
129 ec_master_t *master; /**< master the FSM runs on */ |
114 ec_datagram_t *datagram; /**< datagram used in the state machine */ |
130 ec_datagram_t *datagram; /**< datagram used in the state machine */ |
|
131 ec_mailbox_t* mbox; /**< mailbox used in the CoE state machine */ |
115 unsigned int retries; /**< retries on datagram timeout. */ |
132 unsigned int retries; /**< retries on datagram timeout. */ |
116 |
133 |
117 void (*state)(ec_fsm_master_t *); /**< master state function */ |
134 void (*state)(ec_fsm_master_t *); /**< master state function */ |
118 int idle; /**< state machine is in idle phase */ |
135 int idle; /**< state machine is in idle phase */ |
119 unsigned long scan_jiffies; /**< beginning of slave scanning */ |
136 unsigned long scan_jiffies; /**< beginning of slave scanning */ |