2216 EC_DEVICE_MAIN); |
2216 EC_DEVICE_MAIN); |
2217 master->injection_seq_rt = master->injection_seq_fsm; |
2217 master->injection_seq_rt = master->injection_seq_fsm; |
2218 } |
2218 } |
2219 ec_master_inject_external_datagrams(master); |
2219 ec_master_inject_external_datagrams(master); |
2220 |
2220 |
2221 if (unlikely(!master->devices[EC_DEVICE_MAIN].link_state)) { |
|
2222 // link is down, no datagram can be sent |
|
2223 list_for_each_entry_safe(datagram, n, |
|
2224 &master->datagram_queue, queue) { |
|
2225 datagram->state = EC_DATAGRAM_ERROR; |
|
2226 list_del_init(&datagram->queue); |
|
2227 } |
|
2228 |
|
2229 // query link state |
|
2230 ec_device_poll(&master->devices[EC_DEVICE_MAIN]); |
|
2231 |
|
2232 // clear frame statistics |
|
2233 ec_device_clear_stats(&master->devices[EC_DEVICE_MAIN]); |
|
2234 return; |
|
2235 } |
|
2236 |
|
2237 // send frames |
|
2238 for (i = 0; i < EC_NUM_DEVICES; i++) { |
2221 for (i = 0; i < EC_NUM_DEVICES; i++) { |
2239 if (master->devices[i].dev) { |
2222 if (unlikely(!master->devices[i].link_state)) { |
2240 ec_master_send_datagrams(master, i); |
2223 // link is down, no datagram can be sent |
2241 } |
2224 list_for_each_entry_safe(datagram, n, |
|
2225 &master->datagram_queue, queue) { |
|
2226 if (datagram->device_index == i) { |
|
2227 datagram->state = EC_DATAGRAM_ERROR; |
|
2228 list_del_init(&datagram->queue); |
|
2229 } |
|
2230 } |
|
2231 |
|
2232 if (!master->devices[i].dev) { |
|
2233 continue; |
|
2234 } |
|
2235 |
|
2236 // query link state |
|
2237 ec_device_poll(&master->devices[i]); |
|
2238 |
|
2239 // clear frame statistics |
|
2240 ec_device_clear_stats(&master->devices[i]); |
|
2241 return; |
|
2242 } |
|
2243 |
|
2244 // send frames |
|
2245 ec_master_send_datagrams(master, i); |
2242 } |
2246 } |
2243 } |
2247 } |
2244 |
2248 |
2245 /*****************************************************************************/ |
2249 /*****************************************************************************/ |
2246 |
2250 |