73 #define EC_DEFAULTMBXSM0 0x00010026 75 #define EC_DEFAULTMBXSM1 0x00010022 77 #define EC_DEFAULTDOSM0 0x00010044 112 for(lp = 0; lp < context->
maxgroup; lp++)
143 EC_PRINT(
"Error: too many slaves on network: num_slaves=%d, EC_MAXSLAVE=%d\n",
156 memset(&zbuf, 0x00,
sizeof(zbuf));
210 if (csl->
Obits && !csl->
SM[2].StartAddr)
212 csl->
SM[0].StartAddr =
htoes(0x0f00);
215 csl->
FMMU[0].FMMUactive = 1;
216 csl->
FMMU[0].FMMUtype = 2;
228 if (csl->
Ibits && !csl->
SM[3].StartAddr)
230 csl->
SM[1].StartAddr =
htoes(0x1000);
232 csl->
SM[1].SMflags =
htoel(0x00000000);
233 csl->
FMMU[1].FMMUactive = 1;
234 csl->
FMMU[1].FMMUtype = 1;
261 if ((slave > 1) && (*(context->
slavecount) > 0))
285 for( nSM=0 ; nSM <
EC_MAXSM ; nSM++ )
295 EC_PRINT(
"Copy SII slave %d from %d.\n", slave, i);
312 int16 topoc, slavec, aliasadr;
316 int wkc, cindex, nSM;
319 EC_PRINT(
"ec_config_init %d\n",usetable);
325 for (slave = 1; slave <= *(context->
slavecount); slave++)
327 ADPh = (
uint16)(1 - slave);
343 configadr =
etohs(configadr);
348 estat =
etohs(estat);
355 for (slave = 1; slave <= *(context->
slavecount); slave++)
361 for (slave = 1; slave <= *(context->
slavecount); slave++)
367 for (slave = 1; slave <= *(context->
slavecount); slave++)
373 for (slave = 1; slave <= *(context->
slavecount); slave++)
383 for (slave = 1; slave <= *(context->
slavecount); slave++)
398 if ((
etohs(val16) & 0x04) > 0)
407 topology =
etohs(topology);
410 if ((topology & 0x0300) == 0x0200)
415 if ((topology & 0x0c00) == 0x0800)
420 if ((topology & 0x3000) == 0x2000)
425 if ((topology & 0xc000) == 0x8000)
461 if (((topoc >= 0) && (topology > 1)) ||
569 if (context->
slavelist[slave].
SM[0].StartAddr == 0x0000)
571 EC_PRINT(
"Slave %d has no proper mailbox in configuration, try default.\n", slave);
577 if (context->
slavelist[slave].
SM[1].StartAddr == 0x0000)
579 EC_PRINT(
"Slave %d has no proper mailbox out configuration, try default.\n", slave);
613 if ((slave > 1) && (*(context->
slavecount) > 0))
625 for( nSM=0 ; nSM <
EC_MAXSM ; nSM++ )
634 EC_PRINT(
"Copy mapping slave %d from %d.\n", slave, i);
648 EC_PRINT(
" >Slave %d, configadr %x, state %2.2x\n",
678 EC_PRINT(
" CoE Osize:%d Isize:%d\n", Osize, Isize);
686 EC_PRINT(
" SoE Osize:%d Isize:%d\n", Osize, Isize);
704 if (!Isize && !Osize)
708 if (!Isize && !Osize)
710 memset(&eepPDO, 0,
sizeof(eepPDO));
711 Isize = (int)
ecx_siiPDO(context, slave, &eepPDO, 0);
713 for( nSM=0 ; nSM <
EC_MAXSM ; nSM++ )
722 Osize = (int)
ecx_siiPDO(context, slave, &eepPDO, 1);
724 for( nSM=0 ; nSM <
EC_MAXSM ; nSM++ )
754 EC_PRINT(
" SM0 Type:%d StartAddr:%4.4x Flags:%8.8x\n",
763 EC_PRINT(
" SM1 Type:%d StartAddr:%4.4x Flags:%8.8x\n",
769 for( nSM = 2 ; nSM <
EC_MAXSM ; nSM++ )
774 if( context->
slavelist[slave].
SM[nSM].SMlength == 0)
787 EC_PRINT(
" SM%d Type:%d StartAddr:%4.4x Flags:%8.8x\n", nSM,
814 static int ecx_find_mapt(
void)
839 thrc += ecx_mapt[thrn].
running;
854 for (slave = 1; slave <= *(context->
slavecount); slave++)
860 while ((thrn = ecx_find_mapt()) < 0)
864 ecx_mapt[thrn].
context = context;
869 &ecx_mapper_thread, &(ecx_mapt[thrn]));
886 for (slave = 1; slave <= *(context->
slavecount); slave++)
909 EC_PRINT(
" =Slave %d, INPUT MAPPING\n", slave);
932 ByteCount += SMlength;
933 BitCount += SMlength * 8;
935 while ((BitCount < context->slavelist[slave].Ibits) && (SMc < (
EC_MAXSM - 1)))
949 ByteCount += SMlength;
950 BitCount += SMlength * 8;
986 FMMUsize = ByteCount;
991 *LogAddr += FMMUsize;
996 FMMUdone += FMMUsize;
1025 EC_PRINT(
" Inputs %p startbit %d\n",
1064 ByteCount += SMlength;
1065 BitCount += SMlength * 8;
1067 while ((BitCount < context->slavelist[slave].Obits) && (SMc < (
EC_MAXSM - 1)))
1081 ByteCount += SMlength;
1082 BitCount += SMlength * 8;
1118 FMMUsize = ByteCount;
1123 *LogAddr += FMMUsize;
1128 FMMUdone += FMMUsize;
1153 EC_PRINT(
" slave %d Outputs %p startbit %d\n",
1179 uint16 currentsegment = 0;
1182 if ((*(context->
slavecount) > 0) && (group < context->maxgroup))
1184 EC_PRINT(
"ec_config_map_group IOmap:%p group:%d\n", pIOmap, group);
1196 for (slave = 1; slave <= *(context->
slavecount); slave++)
1206 diff = LogAddr - oLogAddr;
1219 segmentsize += diff;
1256 for (slave = 1; slave <= *(context->
slavecount); slave++)
1266 diff = LogAddr - oLogAddr;
1279 segmentsize += diff;
1359 uint16 currentsegment = 0;
1362 if ((*(context->
slavecount) > 0) && (group < context->maxgroup))
1364 EC_PRINT(
"ec_config_map_group IOmap:%p group:%d\n", pIOmap, group);
1366 siLogAddr = mLogAddr;
1367 soLogAddr = mLogAddr;
1377 for (slave = 1; slave <= *(context->
slavecount); slave++)
1380 siLogAddr = soLogAddr = mLogAddr;
1389 slave, &soLogAddr, &BitPos);
1401 slave, &siLogAddr, &BitPos);
1409 tempLogAddr = (siLogAddr > soLogAddr) ? siLogAddr : soLogAddr;
1410 diff = tempLogAddr - mLogAddr;
1411 mLogAddr = tempLogAddr;
1424 segmentsize += diff;
1458 for (slave = 1; slave <= *(context->
slavecount); slave++)
1492 uint16 ADPh, configadr, readadr;
1496 ADPh = (
uint16)(1 - slave);
1501 if(readadr == configadr)
1506 if( (wkc > 0) && (readadr == 0))
1553 int state, nSM, FMMUc;
1568 for( nSM = 0 ; nSM <
EC_MAXSM ; nSM++ )
int(* PO2SOconfigx)(ecx_contextt *context, uint16 slave)
int ec_reconfig_slave(uint16 slave, int timeout)
static void ecx_config_create_input_mappings(ecx_contextt *context, void *pIOmap, uint8 group, int16 slave, uint32 *LogAddr, uint8 *BitPos)
static int ecx_lookup_mapping(ecx_contextt *context, uint16 slave, int *Osize, int *Isize)
void ecx_init_context(ecx_contextt *context)
int ecx_detect_slaves(ecx_contextt *context)
int ecx_reconfig_slave(ecx_contextt *context, uint16 slave, int timeout)
uint8 ecx_siigetbyte(ecx_contextt *context, uint16 slave, uint16 address)
static void ecx_config_find_mappings(ecx_contextt *context, uint8 group)
int ecx_readIDNmap(ecx_contextt *context, uint16 slave, int *Osize, int *Isize)
uint16 ecx_statecheck(ecx_contextt *context, uint16 slave, uint16 reqstate, int timeout)
int ecx_APWRw(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 data, int timeout)
#define EC_FIRSTDCDATAGRAM
int ec_recover_slave(uint16 slave, int timeout)
ec_fmmut FMMU[EC_MAXFMMU]
int ecx_FPWRw(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 data, int timeout)
void ecx_siistring(ecx_contextt *context, char *str, uint16 slave, uint16 Sn)
int ecx_FPWR(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
static int ecx_map_sm(ecx_contextt *context, uint16 slave)
int ec_config_overlap(uint8 usetable, void *pIOmap)
int ecx_eeprom2master(ecx_contextt *context, uint16 slave)
General typedefs and defines for EtherCAT.
Headerfile for ethercatcoe.c.
uint16 ecx_siiFMMU(ecx_contextt *context, uint16 slave, ec_eepromFMMUt *FMMU)
uint32 ecx_readeeprom(ecx_contextt *context, uint16 slave, uint16 eeproma, int timeout)
int ec_config_map(void *pIOmap)
int ecx_FPRD(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
#define OSAL_THREAD_HANDLE
int ec_config_overlap_map(void *pIOmap)
static void ecx_set_slaves_to_default(ecx_contextt *context)
uint32 IOsegment[EC_MAXIOSEGMENTS]
uint16 ecx_siiSMnext(ecx_contextt *context, uint16 slave, ec_eepromSMt *SM, uint16 n)
static int ecx_map_sii(ecx_contextt *context, uint16 slave)
int ec_config_overlap_map_group(void *pIOmap, uint8 group)
PACKED_END PACKED_BEGIN struct PACKED ec_sm ec_smt
int ecx_config_init(ecx_contextt *context, uint8 usetable)
int ec_findconfig(uint32 man, uint32 id)
int ecx_BRD(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
int ecx_recover_slave(ecx_contextt *context, uint16 slave, int timeout)
uint16 SMbitsize[EC_MAXSM]
uint32 ecx_readeeprom2(ecx_contextt *context, uint16 slave, int timeout)
DEPRECATED Configuration list of known EtherCAT slave devices.
static int ecx_config_from_table(ecx_contextt *context, uint16 slave)
int osal_usleep(uint32 usec)
int osal_thread_create(void *thandle, int stacksize, void *func, void *param)
Headerfile for ethercatsoe.c.
int ecx_BWR(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
ecx_mapt_t ecx_mapt[EC_MAX_MAPT]
#define EC_LOGGROUPOFFSET
static int ecx_map_coe_soe(ecx_contextt *context, uint16 slave, int thread_n)
int ecx_APRD(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
int ecx_config_map_group(ecx_contextt *context, void *pIOmap, uint8 group)
ec_configlist_t ec_configlist[]
void ecx_readeeprom1(ecx_contextt *context, uint16 slave, uint16 eeproma)
static void ecx_config_create_output_mappings(ecx_contextt *context, void *pIOmap, uint8 group, int16 slave, uint32 *LogAddr, uint8 *BitPos)
PACKED_BEGIN struct PACKED ec_fmmu ec_fmmut
Headerfile for ethercatbase.c.
int ec_config(uint8 usetable, void *pIOmap)
int ecx_siiPDO(ecx_contextt *context, uint16 slave, ec_eepromPDOt *PDO, uint8 t)
int ecx_eeprom2pdi(ecx_contextt *context, uint16 slave)
int(* PO2SOconfig)(uint16 slave)
int ecx_config_overlap_map_group(ecx_contextt *context, void *pIOmap, uint8 group)
Headerfile for ethercatmain.c.
uint16 ecx_FPRDw(ecx_portt *port, uint16 ADP, uint16 ADO, int timeout)
uint16 ecx_APRDw(ecx_portt *port, uint16 ADP, uint16 ADO, int timeout)
#define EC_SLAVECOUNTEXCEEDED
int ecx_readPDOmapCA(ecx_contextt *context, uint16 Slave, int Thread_n, int *Osize, int *Isize)
int16 ecx_siifind(ecx_contextt *context, uint16 slave, uint16 cat)
uint16 ecx_siiSM(ecx_contextt *context, uint16 slave, ec_eepromSMt *SM)
Headerfile for ethercatconfig.c.
static int ecx_get_threadcount(void)
int ecx_readPDOmap(ecx_contextt *context, uint16 Slave, int *Osize, int *Isize)
int ec_config_init(uint8 usetable)
static int ecx_lookup_prev_sii(ecx_contextt *context, uint16 slave)
int ec_config_map_group(void *pIOmap, uint8 group)