rt/msr_module.c
changeset 137 3fb18812871a
parent 136 a03a684cac89
child 138 7e743a61a991
equal deleted inserted replaced
136:a03a684cac89 137:3fb18812871a
    36 
    36 
    37 // EtherCAT
    37 // EtherCAT
    38 #include "../include/ecrt.h"
    38 #include "../include/ecrt.h"
    39 
    39 
    40 #define ASYNC
    40 #define ASYNC
    41 //#define BLOCK1
    41 #define BLOCK1
    42 
    42 
    43 // Defines/Makros
    43 // Defines/Makros
    44 #define HZREDUCTION (MSR_ABTASTFREQUENZ / HZ)
    44 #define HZREDUCTION (MSR_ABTASTFREQUENZ / HZ)
    45 
    45 
    46 /*****************************************************************************/
    46 /*****************************************************************************/
    68 uint32_t k_postio;
    68 uint32_t k_postio;
    69 uint32_t k_finished;
    69 uint32_t k_finished;
    70 
    70 
    71 #ifdef BLOCK1
    71 #ifdef BLOCK1
    72 ec_field_init_t domain1_fields[] = {
    72 ec_field_init_t domain1_fields[] = {
    73     {&r_ssi,    "1", "Beckhoff", "EL5001", "InputValue", 0},
    73     {&r_ssi,    "5", "Beckhoff", "EL5001", "InputValue", 0},
    74     {&r_ssi_st, "1", "Beckhoff", "EL5001", "Status",     0},
    74     {&r_ssi_st, "5", "Beckhoff", "EL5001", "Status",     0},
    75     {}
    75     {}
    76 };
    76 };
    77 #else
    77 #else
    78 ec_field_init_t domain1_fields[] = {
    78 ec_field_init_t domain1_fields[] = {
    79     {&r_inc,    "4", "Beckhoff", "EL5101", "InputValue", 0},
    79     {&r_inc,    "4", "Beckhoff", "EL5101", "InputValue", 0},
   182 /*****************************************************************************/
   182 /*****************************************************************************/
   183 
   183 
   184 int __init init_rt_module(void)
   184 int __init init_rt_module(void)
   185 {
   185 {
   186     struct ipipe_domain_attr attr; //ipipe
   186     struct ipipe_domain_attr attr; //ipipe
   187     uint32_t version;
   187     uint8_t string[10];
   188 
   188     size_t size;
   189     // Als allererstes die RT-lib initialisieren
   189 
       
   190     // Als allererstes die RT-Lib initialisieren
   190     if (msr_rtlib_init(1, MSR_ABTASTFREQUENZ, 10, &msr_globals_register) < 0) {
   191     if (msr_rtlib_init(1, MSR_ABTASTFREQUENZ, 10, &msr_globals_register) < 0) {
   191         msr_print_warn("msr_modul: can't initialize rtlib!");
   192         msr_print_warn("msr_modul: can't initialize rtlib!");
   192         goto out_return;
   193         goto out_return;
   193     }
   194     }
   194 
   195 
   228     //ecrt_master_debug(master, 0);
   229     //ecrt_master_debug(master, 0);
   229 
   230 
   230     ecrt_master_print(master);
   231     ecrt_master_print(master);
   231 
   232 
   232 #ifdef BLOCK1
   233 #ifdef BLOCK1
   233     if (ecrt_master_sdo_read(master, "1", 0x100A, 1, &version)) {
   234     size = 10;
       
   235     if (ecrt_master_sdo_read(master, "1", 0x100A, 0, string, &size)) {
   234         printk(KERN_ERR "Could not read SSI version!\n");
   236         printk(KERN_ERR "Could not read SSI version!\n");
   235         goto out_deactivate;
   237         goto out_deactivate;
   236     }
   238     }
   237     printk(KERN_INFO "Software-version: %u\n", version);
   239     string[size] = 0;
   238 
   240     printk(KERN_INFO "Software-version 1: %s\n", string);
   239     if (ecrt_master_sdo_write(master, "1", 0x4061, 1,  0, 1) ||
   241 
   240         ecrt_master_sdo_write(master, "1", 0x4061, 2,  1, 1) ||
   242     size = 10;
   241         ecrt_master_sdo_write(master, "1", 0x4061, 3,  1, 1) ||
   243     if (ecrt_master_sdo_read(master, "5", 0x100A, 0, string, &size)) {
   242         ecrt_master_sdo_write(master, "1", 0x4066, 0,  0, 1) ||
   244         printk(KERN_ERR "Could not read SSI version!\n");
   243         ecrt_master_sdo_write(master, "1", 0x4067, 0,  4, 1) ||
   245         goto out_deactivate;
   244         ecrt_master_sdo_write(master, "1", 0x4068, 0,  0, 1) ||
   246     }
   245         ecrt_master_sdo_write(master, "1", 0x4069, 0, 25, 1) ||
   247     string[size] = 0;
   246         ecrt_master_sdo_write(master, "1", 0x406A, 0, 25, 1) ||
   248     printk(KERN_INFO "Software-version 5: %s\n", string);
   247         ecrt_master_sdo_write(master, "1", 0x406B, 0, 50, 1)) {
   249 
       
   250     if (ecrt_master_sdo_exp_write(master, "5", 0x4061, 1,  0, 1) ||
       
   251         ecrt_master_sdo_exp_write(master, "5", 0x4061, 2,  1, 1) ||
       
   252         ecrt_master_sdo_exp_write(master, "5", 0x4061, 3,  1, 1) ||
       
   253         ecrt_master_sdo_exp_write(master, "5", 0x4066, 0,  0, 1) ||
       
   254         ecrt_master_sdo_exp_write(master, "5", 0x4067, 0,  4, 1) ||
       
   255         ecrt_master_sdo_exp_write(master, "5", 0x4068, 0,  0, 1) ||
       
   256         ecrt_master_sdo_exp_write(master, "5", 0x4069, 0, 25, 1) ||
       
   257         ecrt_master_sdo_exp_write(master, "5", 0x406A, 0, 25, 1) ||
       
   258         ecrt_master_sdo_exp_write(master, "5", 0x406B, 0, 50, 1)) {
   248         printk(KERN_ERR "Failed to configure SSI slave!\n");
   259         printk(KERN_ERR "Failed to configure SSI slave!\n");
   249         goto out_deactivate;
   260         goto out_deactivate;
   250     }
   261     }
   251 #endif
   262 #endif
   252 
   263