master/types.c
changeset 54 7506e67dd122
parent 39 6965c23a6826
child 55 059a9e712aa7
equal deleted inserted replaced
53:6b3b8acb71b5 54:7506e67dd122
       
     1 /******************************************************************************
       
     2  *
       
     3  *  t y p e s . c
       
     4  *
       
     5  *  EtherCAT-Slave-Typen.
       
     6  *
       
     7  *  $Id$
       
     8  *
       
     9  *****************************************************************************/
       
    10 
       
    11 #include <linux/module.h>
       
    12 
       
    13 #include "globals.h"
       
    14 #include "types.h"
       
    15 
       
    16 /*****************************************************************************/
       
    17 
       
    18 /* Konfigurationen der Sync-Manager */
       
    19 
       
    20 unsigned char sm0_multi[] = {0x00, 0x18, 0xF6, 0x00, 0x26, 0x00, 0x01, 0x00};
       
    21 unsigned char sm1_multi[] = {0xF6, 0x18, 0xF6, 0x00, 0x22, 0x00, 0x01, 0x00};
       
    22 
       
    23 unsigned char sm0_1014[] = {0x00, 0x10, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00};
       
    24 
       
    25 unsigned char sm0_2004[] = {0x00, 0x0F, 0x01, 0x00, 0x46, 0x00, 0x01, 0x00};
       
    26 
       
    27 unsigned char sm2_31xx[] = {0x00, 0x10, 0x04, 0x00, 0x24, 0x00, 0x00, 0x00};
       
    28 unsigned char sm3_31xx[] = {0x00, 0x11, 0x06, 0x00, 0x20, 0x00, 0x01, 0x00};
       
    29 
       
    30 unsigned char sm2_41xx[] = {0x00, 0x10, 0x04, 0x00, 0x24, 0x00, 0x01, 0x00};
       
    31 
       
    32 /* Konfigurationen der Memory-Management-Units */
       
    33 
       
    34 unsigned char fmmu0_1014[] = {0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x07,
       
    35                               0x00, 0x10, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00};
       
    36 
       
    37 unsigned char fmmu0_2004[] = {0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x07,
       
    38                               0x00, 0x0F, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00};
       
    39 
       
    40 unsigned char fmmu0_31xx[] = {0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x07,
       
    41                               0x00, 0x11, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00};
       
    42 
       
    43 unsigned char fmmu0_41xx[] = {0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x07,
       
    44                               0x00, 0x10, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00};
       
    45 
       
    46 /*****************************************************************************/
       
    47 
       
    48 /* Lese- und Schreibfunktionen */
       
    49 
       
    50 int read_1014(unsigned char *data, unsigned int channel)
       
    51 {
       
    52   return (data[0] >> channel) & 0x01;
       
    53 }
       
    54 
       
    55 void write_2004(unsigned char *data, unsigned int channel, int value)
       
    56 {
       
    57   if (value) {
       
    58     data[0] |= (1 << channel);
       
    59   }
       
    60   else {
       
    61     data[0] &= ~(1 << channel);
       
    62   }
       
    63 }
       
    64 
       
    65 int read_31xx(unsigned char *data, unsigned int channel)
       
    66 {
       
    67   return (short int) ((data[channel * 3 + 2] << 8) | data[channel * 3 + 1]);
       
    68 }
       
    69 
       
    70 void write_41xx(unsigned char *data, unsigned int channel, int value)
       
    71 {
       
    72   data[channel * 3 + 1] = (value & 0xFF00) >> 8;
       
    73   data[channel * 3 + 2] = value & 0xFF;
       
    74 }
       
    75 
       
    76 /*****************************************************************************/
       
    77 
       
    78 /* Klemmen-Objekte */
       
    79 
       
    80 ec_slave_desc_t Beckhoff_EK1100[] =
       
    81 {{
       
    82   "Beckhoff", "EK1100", "Bus Coupler",
       
    83   EC_NOSYNC_SLAVE,
       
    84   NULL, NULL, NULL, NULL,
       
    85   NULL,
       
    86   0, 0,
       
    87   NULL, NULL
       
    88 }};
       
    89 
       
    90 ec_slave_desc_t Beckhoff_EL1014[] =
       
    91 {{
       
    92   "Beckhoff", "EL1014", "4x Digital Input",
       
    93   EC_SIMPLE_SLAVE,
       
    94   sm0_1014, NULL, NULL, NULL,
       
    95   fmmu0_1014,
       
    96   1, 4,
       
    97   read_1014, NULL
       
    98 }};
       
    99 
       
   100 ec_slave_desc_t Beckhoff_EL2004[] =
       
   101 {{
       
   102   "Beckhoff", "EL2004", "4x Digital Output",
       
   103   EC_SIMPLE_SLAVE,
       
   104   sm0_2004, NULL, NULL, NULL,
       
   105   fmmu0_2004,
       
   106   1, 4,
       
   107   NULL, write_2004
       
   108 }};
       
   109 
       
   110 ec_slave_desc_t Beckhoff_EL3102[] =
       
   111 {{
       
   112   "Beckhoff", "EL3102", "2x Analog Input diff.",
       
   113   EC_MAILBOX_SLAVE,
       
   114   sm0_multi, sm1_multi, sm2_31xx, sm3_31xx,
       
   115   fmmu0_31xx,
       
   116   6, 2,
       
   117   read_31xx, NULL
       
   118 }};
       
   119 
       
   120 ec_slave_desc_t Beckhoff_EL3162[] =
       
   121 {{
       
   122   "Beckhoff", "EL3162", "2x Analog Input",
       
   123   EC_MAILBOX_SLAVE,
       
   124   sm0_multi, sm1_multi, sm2_31xx, sm3_31xx,
       
   125   fmmu0_31xx,
       
   126   6, 2,
       
   127   read_31xx, NULL
       
   128 }};
       
   129 
       
   130 ec_slave_desc_t Beckhoff_EL4102[] =
       
   131 {{
       
   132   "Beckhoff", "EL4102", "2x Analog Output",
       
   133   EC_MAILBOX_SLAVE,
       
   134   sm0_multi, sm1_multi, sm2_41xx, NULL,
       
   135   fmmu0_41xx,
       
   136   4, 2,
       
   137   NULL, write_41xx
       
   138 }};
       
   139 
       
   140 ec_slave_desc_t Beckhoff_EL4132[] =
       
   141 {{
       
   142   "Beckhoff", "EL4132", "2x Analog Output diff.",
       
   143   EC_MAILBOX_SLAVE,
       
   144   sm0_multi, sm1_multi, sm2_41xx, NULL,
       
   145   fmmu0_41xx,
       
   146   4, 2,
       
   147   NULL, write_41xx
       
   148 }};
       
   149 
       
   150 ec_slave_desc_t Beckhoff_EL5001[] =
       
   151 {{
       
   152   "Beckhoff", "EL5001", "SSI-Interface",
       
   153   EC_SIMPLE_SLAVE,
       
   154   NULL, NULL, NULL, NULL, // Noch nicht eingepflegt...
       
   155   NULL,
       
   156   0, 0,
       
   157   NULL, NULL
       
   158 }};
       
   159 
       
   160 /*****************************************************************************/
       
   161 
       
   162 /**
       
   163    Beziehung zwischen Identifikationsnummern und Klemmen-Objekt.
       
   164 
       
   165    Diese Tabelle stellt die Beziehungen zwischen bestimmten Kombinationen
       
   166    aus Vendor-IDs und Product-Codes und der entsprechenden Klemme her.
       
   167    Neue Klemmen müssen hier eingetragen werden.
       
   168 */
       
   169 
       
   170 ec_slave_ident_t slave_idents[] =
       
   171 {
       
   172   {0x00000002, 0x03F63052, Beckhoff_EL1014},
       
   173   {0x00000002, 0x044C2C52, Beckhoff_EK1100},
       
   174   {0x00000002, 0x07D43052, Beckhoff_EL2004},
       
   175   {0x00000002, 0x0C1E3052, Beckhoff_EL3102},
       
   176   {0x00000002, 0x0C5A3052, Beckhoff_EL3162},
       
   177   {0x00000002, 0x10063052, Beckhoff_EL4102},
       
   178   {0x00000002, 0x10243052, Beckhoff_EL4132},
       
   179   {0x00000002, 0x13893052, Beckhoff_EL5001}
       
   180 };
       
   181 
       
   182 unsigned int slave_ident_count = sizeof(slave_idents)
       
   183      / sizeof(ec_slave_ident_t);
       
   184 
       
   185 
       
   186 /*****************************************************************************/