equal
deleted
inserted
replaced
55 ec_domain_t *domain1 = NULL; |
55 ec_domain_t *domain1 = NULL; |
56 spinlock_t master_lock = SPIN_LOCK_UNLOCKED; |
56 spinlock_t master_lock = SPIN_LOCK_UNLOCKED; |
57 |
57 |
58 // data fields |
58 // data fields |
59 //void *r_ssi_input, *r_ssi_status, *r_4102[3]; |
59 //void *r_ssi_input, *r_ssi_status, *r_4102[3]; |
|
60 void *r_kbus_in; |
60 |
61 |
61 // channels |
62 // channels |
62 uint32_t k_pos; |
63 uint32_t k_pos; |
63 uint8_t k_stat; |
64 uint8_t k_stat; |
64 |
65 |
65 ec_field_init_t domain1_fields[] = { |
66 ec_field_init_t domain1_fields[] = { |
66 {NULL, "3", "Beckhoff", "EL5001", "InputValue", 0}, |
67 {&r_kbus_in, "0", "Beckhoff", "BK1120", "Inputs", 0}, |
67 {NULL, "2", "Beckhoff", "EL4132", "OutputValue", 0}, |
|
68 {} |
68 {} |
69 }; |
69 }; |
70 |
70 |
71 /*****************************************************************************/ |
71 /*****************************************************************************/ |
72 |
72 |
131 |
131 |
132 /*****************************************************************************/ |
132 /*****************************************************************************/ |
133 |
133 |
134 int __init init_mini_module(void) |
134 int __init init_mini_module(void) |
135 { |
135 { |
|
136 ec_slave_t *slave; |
|
137 |
136 printk(KERN_INFO "=== Starting Minimal EtherCAT environment... ===\n"); |
138 printk(KERN_INFO "=== Starting Minimal EtherCAT environment... ===\n"); |
137 |
139 |
138 if ((master = ecrt_request_master(0)) == NULL) { |
140 if ((master = ecrt_request_master(0)) == NULL) { |
139 printk(KERN_ERR "Requesting master 0 failed!\n"); |
141 printk(KERN_ERR "Requesting master 0 failed!\n"); |
140 goto out_return; |
142 goto out_return; |
152 printk(KERN_INFO "Registering domain fields...\n"); |
154 printk(KERN_INFO "Registering domain fields...\n"); |
153 if (ecrt_domain_register_field_list(domain1, domain1_fields)) { |
155 if (ecrt_domain_register_field_list(domain1, domain1_fields)) { |
154 printk(KERN_ERR "Field registration failed!\n"); |
156 printk(KERN_ERR "Field registration failed!\n"); |
155 goto out_release_master; |
157 goto out_release_master; |
156 } |
158 } |
|
159 |
|
160 #if 1 |
|
161 printk(KERN_INFO "Setting variable data field sizes...\n"); |
|
162 if (!(slave = ecrt_master_get_slave(master, "0"))) { |
|
163 printk(KERN_ERR "Failed to get slave!\n"); |
|
164 goto out_deactivate; |
|
165 } |
|
166 ecrt_slave_field_size(slave, "Inputs", 0, 1); |
|
167 #endif |
157 |
168 |
158 printk(KERN_INFO "Activating master...\n"); |
169 printk(KERN_INFO "Activating master...\n"); |
159 if (ecrt_master_activate(master)) { |
170 if (ecrt_master_activate(master)) { |
160 printk(KERN_ERR "Failed to activate master!\n"); |
171 printk(KERN_ERR "Failed to activate master!\n"); |
161 goto out_release_master; |
172 goto out_release_master; |
189 printk(KERN_ERR "Failed to configure SSI slave!\n"); |
200 printk(KERN_ERR "Failed to configure SSI slave!\n"); |
190 goto out_deactivate; |
201 goto out_deactivate; |
191 } |
202 } |
192 #endif |
203 #endif |
193 |
204 |
194 #if 0 |
|
195 printk(KERN_INFO "Writing alias...\n"); |
|
196 if (ecrt_slave_sdo_write_exp16(slave, 0xBEEF)) { |
|
197 printk(KERN_ERR "Failed to write alias!\n"); |
|
198 goto out_deactivate; |
|
199 } |
|
200 #endif |
|
201 |
|
202 #ifdef ASYNC |
205 #ifdef ASYNC |
203 // send once and wait... |
206 // send once and wait... |
204 ecrt_master_prepare_async_io(master); |
207 ecrt_master_prepare_async_io(master); |
205 #endif |
208 #endif |
206 |
209 |