227 sync_ref_counter = 9; |
227 sync_ref_counter = 9; |
228 ecrt_master_sync_reference_clock(master); |
228 ecrt_master_sync_reference_clock(master); |
229 } |
229 } |
230 ecrt_master_sync_slave_clocks(master); |
230 ecrt_master_sync_slave_clocks(master); |
231 ecrt_domain_queue(domain1); |
231 ecrt_domain_queue(domain1); |
|
232 rt_sem_signal(&master_sem); |
232 ecrt_master_send(master); |
233 ecrt_master_send(master); |
233 rt_sem_signal(&master_sem); |
|
234 |
234 |
235 rt_task_wait_period(); |
235 rt_task_wait_period(); |
236 } |
236 } |
237 } |
237 } |
238 |
238 |
239 /*****************************************************************************/ |
239 /*****************************************************************************/ |
240 |
240 |
241 void send_callback(void *cb_data) |
241 void request_lock_callback(void *cb_data) |
242 { |
242 { |
243 ec_master_t *m = (ec_master_t *) cb_data; |
243 ec_master_t *m = (ec_master_t *) cb_data; |
244 |
244 rt_sem_wait(&master_sem); |
245 // too close to the next real time cycle: deny access... |
245 } |
246 if (get_cycles() - t_last_cycle <= t_critical) { |
246 |
247 rt_sem_wait(&master_sem); |
247 /*****************************************************************************/ |
248 ecrt_master_send_ext(m); |
248 |
249 rt_sem_signal(&master_sem); |
249 void release_lock_callback(void *cb_data) |
250 } |
|
251 } |
|
252 |
|
253 /*****************************************************************************/ |
|
254 |
|
255 void receive_callback(void *cb_data) |
|
256 { |
250 { |
257 ec_master_t *m = (ec_master_t *) cb_data; |
251 ec_master_t *m = (ec_master_t *) cb_data; |
258 |
252 rt_sem_signal(&master_sem); |
259 // too close to the next real time cycle: deny access... |
|
260 if (get_cycles() - t_last_cycle <= t_critical) { |
|
261 rt_sem_wait(&master_sem); |
|
262 ecrt_master_receive(m); |
|
263 rt_sem_signal(&master_sem); |
|
264 } |
|
265 } |
253 } |
266 |
254 |
267 /*****************************************************************************/ |
255 /*****************************************************************************/ |
268 |
256 |
269 int __init init_mod(void) |
257 int __init init_mod(void) |
283 ret = -EBUSY; |
271 ret = -EBUSY; |
284 printk(KERN_ERR PFX "Requesting master 0 failed!\n"); |
272 printk(KERN_ERR PFX "Requesting master 0 failed!\n"); |
285 goto out_return; |
273 goto out_return; |
286 } |
274 } |
287 |
275 |
288 ecrt_master_callbacks(master, send_callback, receive_callback, master); |
276 ecrt_master_callbacks(master, request_lock_callback, release_lock_callback, master); |
289 |
277 |
290 printk(KERN_INFO PFX "Registering domain...\n"); |
278 printk(KERN_INFO PFX "Registering domain...\n"); |
291 if (!(domain1 = ecrt_master_create_domain(master))) { |
279 if (!(domain1 = ecrt_master_create_domain(master))) { |
292 printk(KERN_ERR PFX "Domain creation failed!\n"); |
280 printk(KERN_ERR PFX "Domain creation failed!\n"); |
293 goto out_release_master; |
281 goto out_release_master; |