master/globals.h
branchstable-1.1
changeset 1732 1cc865ba17c2
parent 1731 60b2aad9d40b
child 1739 5fcbd29151d2
equal deleted inserted replaced
1731:60b2aad9d40b 1732:1cc865ba17c2
    36    Global definitions and macros.
    36    Global definitions and macros.
    37 */
    37 */
    38 
    38 
    39 /*****************************************************************************/
    39 /*****************************************************************************/
    40 
    40 
    41 #ifndef _EC_GLOBALS_
    41 #ifndef _EC_MASTER_GLOBALS_
    42 #define _EC_GLOBALS_
    42 #define _EC_MASTER_GLOBALS_
    43 
    43 
    44 #include <linux/types.h>
    44 #include <linux/types.h>
    45 
    45 
    46 #include "../config.h"
    46 #include "../globals.h"
    47 
    47 
    48 /******************************************************************************
    48 /******************************************************************************
    49  *  EtherCAT master
    49  *  EtherCAT master
    50  *****************************************************************************/
    50  *****************************************************************************/
    51 
       
    52 /** master main version */
       
    53 #define EC_MASTER_VERSION_MAIN  1
       
    54 
       
    55 /** master sub version (after the dot) */
       
    56 #define EC_MASTER_VERSION_SUB   1
       
    57 
       
    58 /** master extra version (just a string) */
       
    59 #define EC_MASTER_VERSION_EXTRA "stable"
       
    60 
       
    61 /** Compile version info. */
       
    62 
       
    63 #define EC_MASTER_VERSION EC_STR(EC_MASTER_VERSION_MAIN) \
       
    64                           "." EC_STR(EC_MASTER_VERSION_SUB) \
       
    65                           " " EC_MASTER_VERSION_EXTRA \
       
    66                           " r" EC_STR(SVNREV)
       
    67 
    51 
    68 /** maximum number of FMMUs per slave */
    52 /** maximum number of FMMUs per slave */
    69 #define EC_MAX_FMMUS 16
    53 #define EC_MAX_FMMUS 16
    70 
    54 
    71 /** size of the EoE tx queue */
    55 /** size of the EoE tx queue */
    74 /** clock frequency for the EoE state machines */
    58 /** clock frequency for the EoE state machines */
    75 #define EC_EOE_FREQUENCY 1000
    59 #define EC_EOE_FREQUENCY 1000
    76 
    60 
    77 /** datagram timeout in microseconds */
    61 /** datagram timeout in microseconds */
    78 #define EC_IO_TIMEOUT 500
    62 #define EC_IO_TIMEOUT 500
       
    63 
       
    64 /** Seconds to wait before fetching SDO dictionary
       
    65     after slave entered PREOP state. */
       
    66 #define EC_WAIT_SDO_DICT 3
       
    67 
       
    68 /** minimum size of a buffer used with ec_state_string() */
       
    69 #define EC_STATE_STRING_SIZE 32
    79 
    70 
    80 /******************************************************************************
    71 /******************************************************************************
    81  *  EtherCAT protocol
    72  *  EtherCAT protocol
    82  *****************************************************************************/
    73  *****************************************************************************/
    83 
    74 
   141 
   132 
   142 #define EC_DBG(fmt, args...) \
   133 #define EC_DBG(fmt, args...) \
   143     printk(KERN_DEBUG "EtherCAT DEBUG: " fmt, ##args)
   134     printk(KERN_DEBUG "EtherCAT DEBUG: " fmt, ##args)
   144 
   135 
   145 /**
   136 /**
   146    Helper macro for EC_STR(), literates a macro argument.
       
   147    \param X argument to literate.
       
   148 */
       
   149 
       
   150 #define EC_LIT(X) #X
       
   151 
       
   152 /**
       
   153    Converts a macro argument to a string.
       
   154    \param X argument to stringify.
       
   155 */
       
   156 
       
   157 #define EC_STR(X) EC_LIT(X)
       
   158 
       
   159 /**
       
   160    Convenience macro for defining read-only SysFS attributes.
   137    Convenience macro for defining read-only SysFS attributes.
   161    This results in creating a static variable called attr_\a NAME. The SysFS
   138    This results in creating a static variable called attr_\a NAME. The SysFS
   162    file will be world-readable.
   139    file will be world-readable.
   163    \param NAME name of the attribute to create.
   140    \param NAME name of the attribute to create.
   164 */
   141 */
   180         .name = EC_STR(NAME), .owner = THIS_MODULE, .mode = S_IRUGO | S_IWUSR \
   157         .name = EC_STR(NAME), .owner = THIS_MODULE, .mode = S_IRUGO | S_IWUSR \
   181     }
   158     }
   182 
   159 
   183 /*****************************************************************************/
   160 /*****************************************************************************/
   184 
   161 
       
   162 extern char *ec_master_version_str;
       
   163 
       
   164 /*****************************************************************************/
       
   165 
   185 void ec_print_data(const uint8_t *, size_t);
   166 void ec_print_data(const uint8_t *, size_t);
   186 void ec_print_data_diff(const uint8_t *, const uint8_t *, size_t);
   167 void ec_print_data_diff(const uint8_t *, const uint8_t *, size_t);
   187 size_t ec_state_string(uint8_t, char *);
   168 size_t ec_state_string(uint8_t, char *);
   188 
   169 
   189 /*****************************************************************************/
   170 /*****************************************************************************/