64 #define EC_PRINT printf 66 #define EC_PRINT(...) do {} while (0) 103 #define EC_DEFAULTMBXSM0 0x00010026 105 #define EC_DEFAULTMBXSM1 0x00010022 107 #define EC_DEFAULTDOSM0 0x00010044 141 uint16 w, slave, ADPh, configadr, ssigen;
143 int16 topoc, slavec, aliasadr;
148 int wkc, cindex, nSM, lp;
150 EC_PRINT(
"ec_config_init %d\n",usetable);
154 memset(&zbuf, 0x00,
sizeof(zbuf));
159 for(lp = 0; lp < context->
maxgroup; lp++)
172 printf(
"wkc = %d\n",wkc);
200 for (slave = 1; slave <= *(context->
slavecount); slave++)
202 ADPh = (
uint16)(1 - slave);
222 estat =
etohs(estat);
229 for (slave = 1; slave <= *(context->
slavecount); slave++)
235 for (slave = 1; slave <= *(context->
slavecount); slave++)
241 for (slave = 1; slave <= *(context->
slavecount); slave++)
247 for (slave = 1; slave <= *(context->
slavecount); slave++)
257 for (slave = 1; slave <= *(context->
slavecount); slave++)
281 if ((topology & 0x0300) == 0x0200)
286 if ((topology & 0x0c00) == 0x0800)
291 if ((topology & 0x3000) == 0x2000)
296 if ((topology & 0xc000) == 0x8000)
332 if (((topoc >= 0) && (topology > 1)) ||
498 if (context->
slavelist[slave].
SM[0].StartAddr == 0x0000)
500 EC_PRINT(
"Slave %d has no proper mailbox in configuration, try default.\n", slave);
506 if (context->
slavelist[slave].
SM[1].StartAddr == 0x0000)
508 EC_PRINT(
"Slave %d has no proper mailbox out configuration, try default.\n", slave);
536 int Isize, Osize, BitCount, ByteCount, FMMUsize, FMMUdone;
545 uint16 currentsegment = 0;
548 if ((*(context->
slavecount) > 0) && (group < context->maxgroup))
550 EC_PRINT(
"ec_config_map_group IOmap:%p group:%d\n", pIOmap, group);
559 for (slave = 1; slave <= *(context->
slavecount); slave++)
565 EC_PRINT(
" >Slave %d, configadr %x, state %2.2x\n",
594 EC_PRINT(
" CoE Osize:%d Isize:%d\n", Osize, Isize);
602 EC_PRINT(
" SoE Osize:%d Isize:%d\n", Osize, Isize);
604 if (!Isize && !Osize)
606 memset(&eepPDO, 0,
sizeof(eepPDO));
607 Isize = (int)
ecx_siiPDO(context, slave, &eepPDO, 0);
609 for( nSM=0 ; nSM <
EC_MAXSM ; nSM++ )
618 Osize = (int)
ecx_siiPDO(context, slave, &eepPDO, 1);
620 for( nSM=0 ; nSM <
EC_MAXSM ; nSM++ )
641 EC_PRINT(
" SM0 Type:%d StartAddr:%4.4x Flags:%8.8x\n",
650 EC_PRINT(
" SM1 Type:%d StartAddr:%4.4x Flags:%8.8x\n",
656 for( nSM = 2 ; nSM <
EC_MAXSM ; nSM++ )
661 if( context->
slavelist[slave].
SM[nSM].SMlength == 0)
668 EC_PRINT(
" SM%d Type:%d StartAddr:%4.4x Flags:%8.8x\n", nSM,
694 while ( (SMc < (EC_MAXSM - 1)) && (FMMUdone < ((context->
slavelist[slave].
Obits + 7) / 8)))
697 while ( (SMc < (EC_MAXSM - 1)) && (context->
slavelist[slave].
SMtype[SMc] != 3)) SMc++;
702 ByteCount += SMlength;
703 BitCount += SMlength * 8;
705 while ( (BitCount < context->slavelist[slave].Obits) && (SMc < (EC_MAXSM - 1)) )
708 while ( (SMc < (EC_MAXSM - 1)) && (context->
slavelist[slave].
SMtype[SMc] != 3)) SMc++;
716 ByteCount += SMlength;
717 BitCount += SMlength * 8;
753 FMMUsize = ByteCount;
763 FMMUdone += FMMUsize;
777 EC_PRINT(
" slave %d Outputs %p startbit %d\n",
785 diff = LogAddr - oLogAddr;
834 for (slave = 1; slave <= *(context->
slavecount); slave++)
840 while ( context->
slavelist[slave].
FMMU[FMMUc].LogStart ) FMMUc++;
851 EC_PRINT(
" =Slave %d, INPUT MAPPING\n", slave);
861 ByteCount += SMlength;
862 BitCount += SMlength * 8;
864 while ( (BitCount < context->slavelist[slave].Ibits) && (SMc < (
EC_MAXSM - 1)) )
875 ByteCount += SMlength;
876 BitCount += SMlength * 8;
912 FMMUsize = ByteCount;
922 FMMUdone += FMMUsize;
940 EC_PRINT(
" Inputs %p startbit %d\n",
947 diff = LogAddr - oLogAddr;
1020 uint16 ADPh, configadr, readadr, wkc;
1024 ADPh = (
uint16)(1 - slave);
1029 if(readadr == configadr)
1034 if( (wkc > 0) && (readadr == 0))
1081 int state, nSM, FMMUc;
1096 for( nSM = 0 ; nSM <
EC_MAXSM ; nSM++ )
1128 int ec_config_init(
uint8 usetable)
1133 int ec_config_map_group(
void *pIOmap,
uint8 group)
1143 int ec_config_map(
void *pIOmap)
1145 return ec_config_map_group(pIOmap, 0);
1154 int ec_config(
uint8 usetable,
void *pIOmap)
1157 wkc = ec_config_init(usetable);
1160 ec_config_map(pIOmap);
1165 int ec_recover_slave(
uint16 slave,
int timeout)
1170 int ec_reconfig_slave(
uint16 slave,
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)
int ecx_reconfig_slave(ecx_contextt *context, uint16 slave, int timeout)
int(* PO2SOconfig)(uint16 slave)
uint16 ecx_siiSMnext(ecx_contextt *context, uint16 slave, ec_eepromSMt *SM, uint16 n)
int ecx_BWR(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
int ecx_readIDNmap(ecx_contextt *context, uint16 slave, int *Osize, int *Isize)
#define EC_FIRSTDCDATAGRAM
uint16 ecx_FPRDw(ecx_portt *port, uint16 ADP, uint16 ADO, int timeout)
int ecx_BRD(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
int ecx_eeprom2pdi(ecx_contextt *context, uint16 slave)
General typedefs and defines for EtherCAT.
Headerfile for ethercatcoe.c.
int ecx_APRD(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
uint16 ecx_statecheck(ecx_contextt *context, uint16 slave, uint16 reqstate, int timeout)
int ecx_config_init(ecx_contextt *context, uint8 usetable)
int16 ecx_siifind(ecx_contextt *context, uint16 slave, uint16 cat)
uint32 IOsegment[EC_MAXIOSEGMENTS]
int ecx_recover_slave(ecx_contextt *context, uint16 slave, int timeout)
uint32 ecx_readeeprom(ecx_contextt *context, uint16 slave, uint16 eeproma, int timeout)
DEPRICATED Configuration list of known EtherCAT slave devices.
uint16 SMbitsize[EC_MAXSM]
int ecx_readPDOmap(ecx_contextt *context, uint16 Slave, int *Osize, int *Isize)
Headerfile for ethercatsoe.c.
int ecx_siiPDO(ecx_contextt *context, uint16 slave, ec_eepromPDOt *PDO, uint8 t)
uint16 ecx_APRDw(ecx_portt *port, uint16 ADP, uint16 ADO, int timeout)
void ecx_readeeprom1(ecx_contextt *context, uint16 slave, uint16 eeproma)
int ecx_config_map_group(ecx_contextt *context, void *pIOmap, uint8 group)
ec_configlist_t ec_configlist[]
Headerfile for ethercatbase.c.
int ecx_eeprom2master(ecx_contextt *context, uint16 slave)
uint16 ecx_siiSM(ecx_contextt *context, uint16 slave, ec_eepromSMt *SM)
int ecx_APWRw(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 data, int timeout)
Headerfile for ethercatmain.c.
int ecx_FPWRw(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 data, int timeout)
int ecx_readPDOmapCA(ecx_contextt *context, uint16 Slave, int *Osize, int *Isize)
uint32 ecx_readeeprom2(ecx_contextt *context, uint16 slave, int timeout)
PACKED_BEGIN struct PACKED ec_fmmut
Headerfile for ethercatconfig.c.
uint16 ecx_siiFMMU(ecx_contextt *context, uint16 slave, ec_eepromFMMUt *FMMU)
PACKED_END PACKED_BEGIN struct PACKED ec_smt
int ecx_FPRD(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
uint8 ecx_siigetbyte(ecx_contextt *context, uint16 slave, uint16 address)
ec_fmmut FMMU[EC_MAXFMMU]