diff -r 9d7453c16ade -r 4bbe090553f7 examples/mini/mini.c --- a/examples/mini/mini.c Mon May 29 09:54:18 2006 +0000 +++ b/examples/mini/mini.c Mon Jun 26 15:04:06 2006 +0000 @@ -57,14 +57,15 @@ // data fields //void *r_ssi_input, *r_ssi_status, *r_4102[3]; +void *r_kbus_in, *r_kbus_out; // channels uint32_t k_pos; uint8_t k_stat; ec_field_init_t domain1_fields[] = { - {NULL, "3", "Beckhoff", "EL5001", "InputValue", 0}, - {NULL, "2", "Beckhoff", "EL4132", "OutputValue", 0}, + //{&r_kbus_out, "0", "Beckhoff", "BK1120", "Outputs", 0}, + //{&r_kbus_in, "0", "Beckhoff", "BK1120", "Inputs", 0}, {} }; @@ -73,6 +74,7 @@ void run(unsigned long data) { static unsigned int counter = 0; + unsigned int i; spin_lock(&master_lock); @@ -105,8 +107,9 @@ } else { counter = FREQUENCY; - //printk(KERN_INFO "k_pos = %i\n", k_pos); - //printk(KERN_INFO "k_stat = 0x%02X\n", k_stat); + printk(KERN_INFO "input = "); + for (i = 0; i < 22; i++) printk("%02X ", *((uint8_t *) r_kbus_in + i)); + printk("\n"); } // restart timer @@ -133,6 +136,8 @@ int __init init_mini_module(void) { + ec_slave_t *slave; + printk(KERN_INFO "=== Starting Minimal EtherCAT environment... ===\n"); if ((master = ecrt_request_master(0)) == NULL) { @@ -155,13 +160,23 @@ goto out_release_master; } +#if 1 + printk(KERN_INFO "Setting variable data field sizes...\n"); + if (!(slave = ecrt_master_get_slave(master, "0"))) { + printk(KERN_ERR "Failed to get slave!\n"); + goto out_deactivate; + } + ecrt_slave_field_size(slave, "Outputs", 0, 0x16); + ecrt_slave_field_size(slave, "Inputs", 0, 0x16); +#endif + printk(KERN_INFO "Activating master...\n"); if (ecrt_master_activate(master)) { printk(KERN_ERR "Failed to activate master!\n"); goto out_release_master; } -#if 0 +#if 1 if (ecrt_master_fetch_sdo_lists(master)) { printk(KERN_ERR "Failed to fetch SDO lists!\n"); goto out_deactivate; @@ -191,14 +206,6 @@ } #endif -#if 0 - printk(KERN_INFO "Writing alias...\n"); - if (ecrt_slave_sdo_write_exp16(slave, 0xBEEF)) { - printk(KERN_ERR "Failed to write alias!\n"); - goto out_deactivate; - } -#endif - #ifdef ASYNC // send once and wait... ecrt_master_prepare_async_io(master);