SOEM v1.3.1
Data Structures | Defines | Functions | Variables
ethercatconfig.c File Reference

Configuration module for EtherCAT master. More...

#include <stdio.h>
#include <string.h>
#include "osal.h"
#include "oshw.h"
#include "ethercattype.h"
#include "ethercatbase.h"
#include "ethercatmain.h"
#include "ethercatcoe.h"
#include "ethercatsoe.h"
#include "ethercatconfig.h"
#include "ethercatconfiglist.h"

Data Structures

struct  ecx_mapt_t
struct  ec_configlist_t

Defines

#define EC_PRINT(...)   do {} while (0)
#define MAX_MAPT   8
#define EC_DEFAULTMBXSM0   0x00010026
#define EC_DEFAULTMBXSM1   0x00010022
#define EC_DEFAULTDOSM0   0x00010044

Functions

int ec_findconfig (uint32 man, uint32 id)
void ecx_init_context (ecx_contextt *context)
int ecx_detect_slaves (ecx_contextt *context)
static void ecx_set_slaves_to_default (ecx_contextt *context)
static int ecx_config_from_table (ecx_contextt *context, uint16 slave)
static int ecx_lookup_prev_sii (ecx_contextt *context, uint16 slave)
int ecx_config_init (ecx_contextt *context, uint8 usetable)
static int ecx_lookup_mapping (ecx_contextt *context, uint16 slave, int *Osize, int *Isize)
static int ecx_map_coe_soe (ecx_contextt *context, uint16 slave)
static int ecx_map_sii (ecx_contextt *context, uint16 slave)
static int ecx_map_sm (ecx_contextt *context, uint16 slave)
OSAL_THREAD_FUNC ecx_mapper_thread (void *param)
static int ecx_find_mapt (void)
static int ecx_get_threadcount (void)
int ecx_config_map_group (ecx_contextt *context, void *pIOmap, uint8 group)
int ecx_recover_slave (ecx_contextt *context, uint16 slave, int timeout)
int ecx_reconfig_slave (ecx_contextt *context, uint16 slave, int timeout)
int ec_config_init (uint8 usetable)
int ec_config_map_group (void *pIOmap, uint8 group)
int ec_config_map (void *pIOmap)
int ec_config (uint8 usetable, void *pIOmap)
int ec_recover_slave (uint16 slave, int timeout)
int ec_reconfig_slave (uint16 slave, int timeout)

Variables

ecx_mapt_t ecx_mapt [MAX_MAPT]
OSAL_THREAD_HANDLE ecx_threadh [MAX_MAPT]

Detailed Description

Configuration module for EtherCAT master.

After successful initialisation with ec_init() or ec_init_redundant() the slaves can be auto configured with this module.


Define Documentation

#define EC_DEFAULTDOSM0   0x00010044

standard SM0 flags configuration for digital output slaves

#define EC_DEFAULTMBXSM0   0x00010026

standard SM0 flags configuration for mailbox slaves

#define EC_DEFAULTMBXSM1   0x00010022

standard SM1 flags configuration for mailbox slaves

#define EC_PRINT (   ...)    do {} while (0)
#define MAX_MAPT   8

Function Documentation

int ec_config ( uint8  usetable,
void *  pIOmap 
)

Enumerate / map and init all slaves.

Parameters:
[in]usetable= TRUE when using configtable to init slaves, FALSE otherwise
[out]pIOmap= pointer to IOmap
Returns:
Workcounter of slave discover datagram = number of slaves found
int ec_config_init ( uint8  usetable)
int ec_config_map ( void *  pIOmap)

Map all PDOs from slaves to IOmap.

Parameters:
[out]pIOmap= pointer to IOmap
Returns:
IOmap size
int ec_config_map_group ( void *  pIOmap,
uint8  group 
)
int ec_findconfig ( uint32  man,
uint32  id 
)

Find slave in standard configuration list ec_configlist[]

Parameters:
[in]man= manufacturer
[in]id= ID
Returns:
index in ec_configlist[] when found, otherwise 0
int ec_reconfig_slave ( uint16  slave,
int  timeout 
)
int ec_recover_slave ( uint16  slave,
int  timeout 
)
static int ecx_config_from_table ( ecx_contextt context,
uint16  slave 
) [static]
int ecx_config_init ( ecx_contextt context,
uint8  usetable 
)

Enumerate and init all slaves.

Parameters:
[in]context= context struct
[in]usetable= TRUE when using configtable to init slaves, FALSE otherwise
Returns:
Workcounter of slave discover datagram = number of slaves found
int ecx_config_map_group ( ecx_contextt context,
void *  pIOmap,
uint8  group 
)

Map all PDOs in one group of slaves to IOmap.

Parameters:
[in]context= context struct
[out]pIOmap= pointer to IOmap
[in]group= group to map, 0 = all groups
Returns:
IOmap size
int ecx_detect_slaves ( ecx_contextt context)
static int ecx_find_mapt ( void  ) [static]
static int ecx_get_threadcount ( void  ) [static]
void ecx_init_context ( ecx_contextt context)
static int ecx_lookup_mapping ( ecx_contextt context,
uint16  slave,
int *  Osize,
int *  Isize 
) [static]
static int ecx_lookup_prev_sii ( ecx_contextt context,
uint16  slave 
) [static]
static int ecx_map_coe_soe ( ecx_contextt context,
uint16  slave 
) [static]
static int ecx_map_sii ( ecx_contextt context,
uint16  slave 
) [static]
static int ecx_map_sm ( ecx_contextt context,
uint16  slave 
) [static]
OSAL_THREAD_FUNC ecx_mapper_thread ( void *  param)
int ecx_reconfig_slave ( ecx_contextt context,
uint16  slave,
int  timeout 
)

Reconfigure slave.

Parameters:
[in]context= context struct
[in]slave= slave to reconfigure
[in]timeout= local timeout f.e. EC_TIMEOUTRET3
Returns:
Slave state
int ecx_recover_slave ( ecx_contextt context,
uint16  slave,
int  timeout 
)

Recover slave.

Parameters:
[in]context= context struct
[in]slave= slave to recover
[in]timeout= local timeout f.e. EC_TIMEOUTRET3
Returns:
>0 if successful
static void ecx_set_slaves_to_default ( ecx_contextt context) [static]

Variable Documentation

ecx_mapt_t ecx_mapt[MAX_MAPT]
OSAL_THREAD_HANDLE ecx_threadh[MAX_MAPT]