Add documentation for the ec_* functions.

pull/15/head
Albert Hofkamp 2015-11-04 12:40:04 +01:00
parent 6501580d9e
commit 0b677f832b
3 changed files with 396 additions and 61 deletions

View File

@ -93,7 +93,7 @@ PACKED_END
/** Report SDO error.
*
* @param[in] context = context struct
* @param[in] context = context struct
* @param[in] Slave = Slave number
* @param[in] Index = Index that generated error
* @param[in] SubIdx = Subindex that generated error
@ -116,7 +116,7 @@ void ecx_SDOerror(ecx_contextt *context, uint16 Slave, uint16 Index, uint8 SubId
/** Report SDO info error
*
* @param[in] context = context struct
* @param[in] context = context struct
* @param[in] Slave = Slave number
* @param[in] Index = Index that generated error
* @param[in] SubIdx = Subindex that generated error
@ -137,13 +137,13 @@ static void ecx_SDOinfoerror(ecx_contextt *context, uint16 Slave, uint16 Index,
}
/** CoE SDO read, blocking. Single subindex or Complete Access.
*
*
* Only a "normal" upload request is issued. If the requested parameter is <= 4bytes
* then a "expedited" response is returned, otherwise a "normal" response. If a "normal"
* response is larger than the mailbox size then the response is segmented. The function
* will combine all segments and copy them to the parameter buffer.
*
* @param[in] context = context struct
* @param[in] context = context struct
* @param[in] slave = Slave number
* @param[in] index = Index to read
* @param[in] subindex = Subindex to read, must be 0 or 1 if CA is used.
@ -347,13 +347,13 @@ int ecx_SDOread(ecx_contextt *context, uint16 slave, uint16 index, uint8 subinde
}
/** CoE SDO write, blocking. Single subindex or Complete Access.
*
*
* A "normal" download request is issued, unless we have
* small data, then a "expedited" transfer is used. If the parameter is larger than
* the mailbox size then the download is segmented. The function will split the
* parameter data in segments and send them to the slave one by one.
*
* @param[in] context = context struct
* @param[in] context = context struct
* @param[in] Slave = Slave number
* @param[in] Index = Index to write
* @param[in] SubIndex = Subindex to write, must be 0 or 1 if CA is used.
@ -575,10 +575,10 @@ int ecx_SDOwrite(ecx_contextt *context, uint16 Slave, uint16 Index, uint8 SubInd
}
/** CoE RxPDO write, blocking.
*
*
* A RxPDO download request is issued.
*
* @param[in] context = context struct
* @param[in] context = context struct
* @param[in] Slave = Slave number
* @param[in] RxPDOnumber = Related RxPDO number
* @param[in] psize = Size in bytes of PDO buffer.
@ -621,10 +621,10 @@ int ecx_RxPDO(ecx_contextt *context, uint16 Slave, uint16 RxPDOnumber, int psize
}
/** CoE TxPDO read remote request, blocking.
*
*
* A RxPDO download request is issued.
*
* @param[in] context = context struct
* @param[in] context = context struct
* @param[in] slave = Slave number
* @param[in] TxPDOnumber = Related TxPDO number
* @param[in,out] psize = Size in bytes of PDO buffer, returns bytes read from PDO.
@ -703,7 +703,7 @@ int ecx_TxPDO(ecx_contextt *context, uint16 slave, uint16 TxPDOnumber , int *psi
}
/** Read PDO assign structure
* @param[in] context = context struct
* @param[in] context = context struct
* @param[in] Slave = Slave number
* @param[in] PDOassign = PDO assign object
* @return total bitlength of PDO assign
@ -767,7 +767,7 @@ int ecx_readPDOassign(ecx_contextt *context, uint16 Slave, uint16 PDOassign)
}
/** Read PDO assign structure in Complete Access mode
* @param[in] context = context struct
* @param[in] context = context struct
* @param[in] Slave = Slave number
* @param[in] PDOassign = PDO assign object
* @return total bitlength of PDO assign
@ -833,8 +833,8 @@ int ecx_readPDOassignCA(ecx_contextt *context, uint16 Slave, uint16 PDOassign)
* 1A00:00 is number of object defined for this PDO\n
* 1A00:01 object mapping #1, f.e. 60100710 (SDO 6010 SI 07 bitlength 0x10)
*
* @param[in] context = context struct
* @param[in] Slave = Slave number
* @param[in] context = context struct
* @param[in] Slave = Slave number
* @param[out] Osize = Size in bits of output mapping (rxPDO) found
* @param[out] Isize = Size in bits of input mapping (txPDO) found
* @return >0 if mapping succesful.
@ -934,8 +934,8 @@ int ecx_readPDOmap(ecx_contextt *context, uint16 Slave, int *Osize, int *Isize)
* tries to read them and collect a full input and output mapping size
* of designated slave. Slave has to support CA, otherwise use ec_readPDOmap().
*
* @param[in] context = context struct
* @param[in] Slave = Slave number
* @param[in] context = context struct
* @param[in] Slave = Slave number
* @param[out] Osize = Size in bits of output mapping (rxPDO) found
* @param[out] Isize = Size in bits of input mapping (txPDO) found
* @return >0 if mapping succesful.
@ -1020,10 +1020,10 @@ int ecx_readPDOmapCA(ecx_contextt *context, uint16 Slave, int *Osize, int *Isize
return retVal;
}
/** CoE read Object Description List.
/** CoE read Object Description List.
*
* @param[in] context = context struct
* @param[in] Slave = Slave number.
* @param[in] context = context struct
* @param[in] Slave = Slave number.
* @param[out] pODlist = resulting Object Description list.
* @return Workcounter of slave response.
*/
@ -1141,7 +1141,7 @@ int ecx_readODlist(ecx_contextt *context, uint16 Slave, ec_ODlistt *pODlist)
/** CoE read Object Description. Adds textual description to object indexes.
*
* @param[in] context = context struct
* @param[in] context = context struct
* @param[in] Item = Item number in ODlist.
* @param[in,out] pODlist = referencing Object Description list.
* @return Workcounter of slave response.
@ -1225,7 +1225,7 @@ int ecx_readODdescription(ecx_contextt *context, uint16 Item, ec_ODlistt *pODlis
/** CoE read SDO service object entry, single subindex.
* Used in ec_readOE().
*
* @param[in] context = context struct
* @param[in] context = context struct
* @param[in] Item = Item in ODlist.
* @param[in] SubI = Subindex of item in ODlist.
* @param[in] pODlist = Object description list for reference.
@ -1316,7 +1316,7 @@ int ecx_readOEsingle(ecx_contextt *context, uint16 Item, uint8 SubI, ec_ODlistt
/** CoE read SDO service object entry.
*
* @param[in] context = context struct
* @param[in] context = context struct
* @param[in] Item = Item in ODlist.
* @param[in] pODlist = Object description list for reference.
* @param[out] pOElist = resulting object entry structure.
@ -1342,60 +1342,173 @@ int ecx_readOE(ecx_contextt *context, uint16 Item, ec_ODlistt *pODlist, ec_OElis
}
#ifdef EC_VER1
/** Report SDO error.
*
* @param[in] Slave = Slave number
* @param[in] Index = Index that generated error
* @param[in] SubIdx = Subindex that generated error
* @param[in] AbortCode = Abortcode, see EtherCAT documentation for list
* @see ecx_SDOerror
*/
void ec_SDOerror(uint16 Slave, uint16 Index, uint8 SubIdx, int32 AbortCode)
{
ecx_SDOerror(&ecx_context, Slave, Index, SubIdx, AbortCode);
}
/** CoE SDO read, blocking. Single subindex or Complete Access.
*
* Only a "normal" upload request is issued. If the requested parameter is <= 4bytes
* then a "expedited" response is returned, otherwise a "normal" response. If a "normal"
* response is larger than the mailbox size then the response is segmented. The function
* will combine all segments and copy them to the parameter buffer.
*
* @param[in] slave = Slave number
* @param[in] index = Index to read
* @param[in] subindex = Subindex to read, must be 0 or 1 if CA is used.
* @param[in] CA = FALSE = single subindex. TRUE = Complete Access, all subindexes read.
* @param[in,out] psize = Size in bytes of parameter buffer, returns bytes read from SDO.
* @param[out] p = Pointer to parameter buffer
* @param[in] timeout = Timeout in us, standard is EC_TIMEOUTRXM
* @return Workcounter from last slave response
* @see ecx_SDOread
*/
int ec_SDOread(uint16 slave, uint16 index, uint8 subindex,
boolean CA, int *psize, void *p, int timeout)
{
return ecx_SDOread(&ecx_context, slave, index, subindex, CA, psize, p, timeout);
}
/** CoE SDO write, blocking. Single subindex or Complete Access.
*
* A "normal" download request is issued, unless we have
* small data, then a "expedited" transfer is used. If the parameter is larger than
* the mailbox size then the download is segmented. The function will split the
* parameter data in segments and send them to the slave one by one.
*
* @param[in] Slave = Slave number
* @param[in] Index = Index to write
* @param[in] SubIndex = Subindex to write, must be 0 or 1 if CA is used.
* @param[in] CA = FALSE = single subindex. TRUE = Complete Access, all subindexes written.
* @param[in] psize = Size in bytes of parameter buffer.
* @param[out] p = Pointer to parameter buffer
* @param[in] Timeout = Timeout in us, standard is EC_TIMEOUTRXM
* @return Workcounter from last slave response
* @see ecx_SDOwrite
*/
int ec_SDOwrite(uint16 Slave, uint16 Index, uint8 SubIndex,
boolean CA, int psize, void *p, int Timeout)
{
return ecx_SDOwrite(&ecx_context, Slave, Index, SubIndex, CA, psize, p, Timeout);
}
/** CoE RxPDO write, blocking.
*
* A RxPDO download request is issued.
*
* @param[in] Slave = Slave number
* @param[in] RxPDOnumber = Related RxPDO number
* @param[in] psize = Size in bytes of PDO buffer.
* @param[out] p = Pointer to PDO buffer
* @return Workcounter from last slave response
* @see ecx_RxPDO
*/
int ec_RxPDO(uint16 Slave, uint16 RxPDOnumber, int psize, void *p)
{
return ecx_RxPDO(&ecx_context, Slave, RxPDOnumber, psize, p);
}
/** CoE TxPDO read remote request, blocking.
*
* A RxPDO download request is issued.
*
* @param[in] slave = Slave number
* @param[in] TxPDOnumber = Related TxPDO number
* @param[in,out] psize = Size in bytes of PDO buffer, returns bytes read from PDO.
* @param[out] p = Pointer to PDO buffer
* @param[in] timeout = Timeout in us, standard is EC_TIMEOUTRXM
* @return Workcounter from last slave response
* @see ecx_TxPDO
*/
int ec_TxPDO(uint16 slave, uint16 TxPDOnumber , int *psize, void *p, int timeout)
{
return ecx_TxPDO(&ecx_context, slave, TxPDOnumber, psize, p, timeout);
}
/** Read PDO assign structure */
/** Read PDO assign structure
* @param[in] Slave = Slave number
* @param[in] PDOassign = PDO assign object
* @return total bitlength of PDO assign
*/
int ec_readPDOassign(uint16 Slave, uint16 PDOassign)
{
return ecx_readPDOassign(&ecx_context, Slave, PDOassign);
}
/** Read PDO assign structure in Complete Access mode */
/** Read PDO assign structure in Complete Access mode
* @param[in] Slave = Slave number
* @param[in] PDOassign = PDO assign object
* @return total bitlength of PDO assign
* @see ecx_readPDOmap
*/
int ec_readPDOassignCA(uint16 Slave, uint16 PDOassign)
{
return ecx_readPDOassignCA(&ecx_context, Slave, PDOassign);
}
/** CoE read PDO mapping.
*
* CANopen has standard indexes defined for PDO mapping. This function
* tries to read them and collect a full input and output mapping size
* of designated slave.
*
* For details, see #ecx_readPDOmap
*
* @param[in] Slave = Slave number
* @param[out] Osize = Size in bits of output mapping (rxPDO) found
* @param[out] Isize = Size in bits of input mapping (txPDO) found
* @return >0 if mapping succesful.
*/
int ec_readPDOmap(uint16 Slave, int *Osize, int *Isize)
{
return ecx_readPDOmap(&ecx_context, Slave, Osize, Isize);
}
/** CoE read PDO mapping in Complete Access mode (CA).
*
* CANopen has standard indexes defined for PDO mapping. This function
* tries to read them and collect a full input and output mapping size
* of designated slave. Slave has to support CA, otherwise use ec_readPDOmap().
*
* @param[in] Slave = Slave number
* @param[out] Osize = Size in bits of output mapping (rxPDO) found
* @param[out] Isize = Size in bits of input mapping (txPDO) found
* @return >0 if mapping succesful.
* @see ecx_readPDOmap ec_readPDOmapCA
*/
int ec_readPDOmapCA(uint16 Slave, int *Osize, int *Isize)
{
return ecx_readPDOmapCA(&ecx_context, Slave, Osize, Isize);
}
/** CoE read Object Description List.
*
* @param[in] Slave = Slave number.
* @param[out] pODlist = resulting Object Description list.
* @return Workcounter of slave response.
* @see ecx_readODlist
*/
int ec_readODlist(uint16 Slave, ec_ODlistt *pODlist)
{
return ecx_readODlist(&ecx_context, Slave, pODlist);
}
/** CoE read Object Description. Adds textual description to object indexes.
*
* @param[in] Item = Item number in ODlist.
* @param[in,out] pODlist = referencing Object Description list.
* @return Workcounter of slave response.
* @see ecx_readODdescription
*/
int ec_readODdescription(uint16 Item, ec_ODlistt *pODlist)
{
return ecx_readODdescription(&ecx_context, Item, pODlist);
@ -1406,6 +1519,14 @@ int ec_readOEsingle(uint16 Item, uint8 SubI, ec_ODlistt *pODlist, ec_OElistt *pO
return ecx_readOEsingle(&ecx_context, Item, SubI, pODlist, pOElist);
}
/** CoE read SDO service object entry.
*
* @param[in] Item = Item in ODlist.
* @param[in] pODlist = Object description list for reference.
* @param[out] pOElist = resulting object entry structure.
* @return Workcounter of slave response.
* @see ecx_readOE
*/
int ec_readOE(uint16 Item, ec_ODlistt *pODlist, ec_OElistt *pOElist)
{
return ecx_readOE(&ecx_context, Item, pODlist, pOElist);

View File

@ -848,7 +848,7 @@ static int ecx_get_threadcount(void)
/** Map all PDOs in one group of slaves to IOmap.
*
* @param[in] context = context struct
* @param[in] context = context struct
* @param[out] pIOmap = pointer to IOmap
* @param[in] group = group to map, 0 = all groups
* @return IOmap size
@ -1265,7 +1265,7 @@ int ecx_config_map_group(ecx_contextt *context, void *pIOmap, uint8 group)
/** Recover slave.
*
* @param[in] context = context struct
* @param[in] context = context struct
* @param[in] slave = slave to recover
* @param[in] timeout = local timeout f.e. EC_TIMEOUTRET3
* @return >0 if successful
@ -1327,7 +1327,7 @@ int ecx_recover_slave(ecx_contextt *context, uint16 slave, int timeout)
/** Reconfigure slave.
*
* @param[in] context = context struct
* @param[in] context = context struct
* @param[in] slave = slave to reconfigure
* @param[in] timeout = local timeout f.e. EC_TIMEOUTRET3
* @return Slave state
@ -1381,11 +1381,24 @@ int ecx_reconfig_slave(ecx_contextt *context, uint16 slave, int timeout)
}
#ifdef EC_VER1
/** Enumerate and init all slaves.
*
* @param[in] usetable = TRUE when using configtable to init slaves, FALSE otherwise
* @return Workcounter of slave discover datagram = number of slaves found
* @see ecx_config_init
*/
int ec_config_init(uint8 usetable)
{
return ecx_config_init(&ecx_context, usetable);
}
/** Map all PDOs in one group of slaves to IOmap.
*
* @param[out] pIOmap = pointer to IOmap
* @param[in] group = group to map, 0 = all groups
* @return IOmap size
* @see ecx_config_map_group
*/
int ec_config_map_group(void *pIOmap, uint8 group)
{
return ecx_config_map_group(&ecx_context, pIOmap, group);
@ -1418,11 +1431,25 @@ int ec_config(uint8 usetable, void *pIOmap)
return wkc;
}
/** Recover slave.
*
* @param[in] slave = slave to recover
* @param[in] timeout = local timeout f.e. EC_TIMEOUTRET3
* @return >0 if successful
* @see ecx_recover_slave
*/
int ec_recover_slave(uint16 slave, int timeout)
{
return ecx_recover_slave(&ecx_context, slave, timeout);
}
/** Reconfigure slave.
*
* @param[in] slave = slave to reconfigure
* @param[in] timeout = local timeout f.e. EC_TIMEOUTRET3
* @return Slave state
* @see ecx_reconfig_slave
*/
int ec_reconfig_slave(uint16 slave, int timeout)
{
return ecx_reconfig_slave(&ecx_context, slave, timeout);

View File

@ -317,7 +317,7 @@ static void ecx_mbxemergencyerror(ecx_contextt *context, uint16 Slave,uint16 Err
}
/** Initialise lib in single NIC mode
* @param[in] context = context struct
* @param[in] context = context struct
* @param[in] ifname = Dev name, f.e. "eth0"
* @return >0 if OK
*/
@ -362,7 +362,7 @@ void ecx_close(ecx_contextt *context)
/** Read one byte from slave EEPROM via cache.
* If the cache location is empty then a read request is made to the slave.
* Depending on the slave capabillities the request is 4 or 8 bytes.
* @param[in] context = context struct
* @param[in] context = context struct
* @param[in] slave = slave number
* @param[in] address = eeprom address in bytes (slave uses words)
* @return requested byte, if not available then 0xff
@ -471,10 +471,10 @@ int16 ecx_siifind(ecx_contextt *context, uint16 slave, uint16 cat)
}
/** Get string from SII string section in slave EEPROM.
* @param[in] context = context struct
* @param[out] str = requested string, 0x00 if not found
* @param[in] slave = slave number
* @param[in] Sn = string number
* @param[in] context = context struct
* @param[out] str = requested string, 0x00 if not found
* @param[in] slave = slave number
* @param[in] Sn = string number
*/
void ecx_siistring(ecx_contextt *context, char *str, uint16 slave, uint16 Sn)
{
@ -529,9 +529,9 @@ void ecx_siistring(ecx_contextt *context, char *str, uint16 slave, uint16 Sn)
}
/** Get FMMU data from SII FMMU section in slave EEPROM.
* @param[in] context = context struct
* @param[in] slave = slave number
* @param[out] FMMU = FMMU struct from SII, max. 4 FMMU's
* @param[in] context = context struct
* @param[in] slave = slave number
* @param[out] FMMU = FMMU struct from SII, max. 4 FMMU's
* @return number of FMMU's defined in section
*/
uint16 ecx_siiFMMU(ecx_contextt *context, uint16 slave, ec_eepromFMMUt* FMMU)
@ -569,7 +569,7 @@ uint16 ecx_siiFMMU(ecx_contextt *context, uint16 slave, ec_eepromFMMUt* FMMU)
}
/** Get SM data from SII SM section in slave EEPROM.
* @param[in] context = context struct
* @param[in] context = context struct
* @param[in] slave = slave number
* @param[out] SM = first SM struct from SII
* @return number of SM's defined in section
@ -605,10 +605,10 @@ uint16 ecx_siiSM(ecx_contextt *context, uint16 slave, ec_eepromSMt* SM)
}
/** Get next SM data from SII SM section in slave EEPROM.
* @param[in] context = context struct
* @param[in] slave = slave number
* @param[out] SM = first SM struct from SII
* @param[in] n = SM number
* @param[in] context = context struct
* @param[in] slave = slave number
* @param[out] SM = first SM struct from SII
* @param[in] n = SM number
* @return >0 if OK
*/
uint16 ecx_siiSMnext(ecx_contextt *context, uint16 slave, ec_eepromSMt* SM, uint16 n)
@ -639,10 +639,10 @@ uint16 ecx_siiSMnext(ecx_contextt *context, uint16 slave, ec_eepromSMt* SM, uint
}
/** Get PDO data from SII PDO section in slave EEPROM.
* @param[in] context = context struct
* @param[in] slave = slave number
* @param[out] PDO = PDO struct from SII
* @param[in] t = 0=RXPDO 1=TXPDO
* @param[in] context = context struct
* @param[in] slave = slave number
* @param[out] PDO = PDO struct from SII
* @param[in] t = 0=RXPDO 1=TXPDO
* @return mapping size in bits of PDO
*/
int ecx_siiPDO(ecx_contextt *context, uint16 slave, ec_eepromPDOt* PDO, uint8 t)
@ -751,7 +751,7 @@ int ecx_FPRD_multi(ecx_contextt *context, int n, uint16 *configlst, ec_alstatust
}
/** Read all slave states in ec_slave.
* @param[in] context = context struct
* @param[in] context = context struct
* @return lowest state found
*/
int ecx_readstate(ecx_contextt *context)
@ -800,7 +800,7 @@ int ecx_readstate(ecx_contextt *context)
/** Write slave state, if slave = 0 then write to all slaves.
* The function does not check if the actual state is changed.
* @param[in] context = context struct
* @param[in] context = context struct
* @param[in] slave = Slave number, 0 = master
* @return 0
*/
@ -824,7 +824,7 @@ int ecx_writestate(ecx_contextt *context, uint16 slave)
/** Check actual slave state.
* This is a blocking function.
* @param[in] context = context struct
* @param[in] context = context struct
* @param[in] slave = Slave number, 0 = all slaves
* @param[in] reqstate = Requested state
* @param[in] timeout = Timout value in us
@ -895,7 +895,7 @@ void ec_clearmbx(ec_mbxbuft *Mbx)
}
/** Check if IN mailbox of slave is empty.
* @param[in] context = context struct
* @param[in] context = context struct
* @param[in] slave = Slave number
* @param[in] timeout = Timeout in us
* @return >0 is success
@ -930,7 +930,7 @@ int ecx_mbxempty(ecx_contextt *context, uint16 slave, int timeout)
}
/** Write IN mailbox to slave.
* @param[in] context = context struct
* @param[in] context = context struct
* @param[in] slave = Slave number
* @param[out] mbx = Mailbox data
* @param[in] timeout = Timeout in us
@ -963,7 +963,7 @@ int ecx_mbxsend(ecx_contextt *context, uint16 slave,ec_mbxbuft *mbx, int timeout
/** Read OUT mailbox from slave.
* Supports Mailbox Link Layer with repeat requests.
* @param[in] context = context struct
* @param[in] context = context struct
* @param[in] slave = Slave number
* @param[out] mbx = Mailbox data
* @param[in] timeout = Timeout in us
@ -1058,7 +1058,7 @@ int ecx_mbxreceive(ecx_contextt *context, uint16 slave, ec_mbxbuft *mbx, int tim
}
/** Dump complete EEPROM data from slave in buffer.
* @param[in] context = context struct
* @param[in] context = context struct
* @param[in] slave = Slave number
* @param[out] esibuf = EEPROM data buffer, make sure it is big enough.
*/
@ -1099,7 +1099,7 @@ void ecx_esidump(ecx_contextt *context, uint16 slave, uint8 *esibuf)
}
/** Read EEPROM from slave bypassing cache.
* @param[in] context = context struct
* @param[in] context = context struct
* @param[in] slave = Slave number
* @param[in] eeproma = (WORD) Address in the EEPROM
* @param[in] timeout = Timeout in us.
@ -1116,7 +1116,7 @@ uint32 ecx_readeeprom(ecx_contextt *context, uint16 slave, uint16 eeproma, int t
}
/** Write EEPROM to slave bypassing cache.
* @param[in] context = context struct
* @param[in] context = context struct
* @param[in] slave = Slave number
* @param[in] eeproma = (WORD) Address in the EEPROM
* @param[in] data = 16bit data
@ -1133,7 +1133,7 @@ int ecx_writeeeprom(ecx_contextt *context, uint16 slave, uint16 eeproma, uint16
}
/** Set eeprom control to master. Only if set to PDI.
* @param[in] context = context struct
* @param[in] context = context struct
* @param[in] slave = Slave number
* @return >0 if OK
*/
@ -1217,7 +1217,7 @@ uint16 ecx_eeprom_waitnotbusyAP(ecx_contextt *context, uint16 aiadr,uint16 *esta
}
/** Read EEPROM from slave bypassing cache. APRD method.
* @param[in] context = context struct
* @param[in] context = context struct
* @param[in] aiadr = auto increment address of slave
* @param[in] eeproma = (WORD) Address in the EEPROM
* @param[in] timeout = Timeout in us.
@ -1296,8 +1296,8 @@ uint64 ecx_readeepromAP(ecx_contextt *context, uint16 aiadr, uint16 eeproma, int
}
/** Write EEPROM to slave bypassing cache. APWR method.
* @param[in] context = context struct
* @param[in] aiadr = configured address of slave
* @param[in] context = context struct
* @param[in] aiadr = configured address of slave
* @param[in] eeproma = (WORD) Address in the EEPROM
* @param[in] data = 16bit data
* @param[in] timeout = Timeout in us.
@ -1386,7 +1386,7 @@ uint16 ecx_eeprom_waitnotbusyFP(ecx_contextt *context, uint16 configadr,uint16 *
}
/** Read EEPROM from slave bypassing cache. FPRD method.
* @param[in] context = context struct
* @param[in] context = context struct
* @param[in] configadr = configured address of slave
* @param[in] eeproma = (WORD) Address in the EEPROM
* @param[in] timeout = Timeout in us.
@ -1529,7 +1529,7 @@ int ecx_writeeepromFP(ecx_contextt *context, uint16 configadr, uint16 eeproma, u
/** Read EEPROM from slave bypassing cache.
* Parallel read step 1, make request to slave.
* @param[in] context = context struct
* @param[in] context = context struct
* @param[in] slave = Slave number
* @param[in] eeproma = (WORD) Address in the EEPROM
*/
@ -1900,101 +1900,225 @@ void ec_packeterror(uint16 Slave, uint16 Index, uint8 SubIdx, uint16 ErrorCode)
ecx_packeterror(&ecx_context, Slave, Index, SubIdx, ErrorCode);
}
/** Initialise lib in single NIC mode
* @param[in] ifname = Dev name, f.e. "eth0"
* @return >0 if OK
* @see ecx_init
*/
int ec_init(char * ifname)
{
return ecx_init(&ecx_context, ifname);
}
/** Initialise lib in redundant NIC mode
* @param[in] ifname = Primary Dev name, f.e. "eth0"
* @param[in] if2name = Secondary Dev name, f.e. "eth1"
* @return >0 if OK
* @see ecx_init_redundant
*/
int ec_init_redundant(char *ifname, char *if2name)
{
return ecx_init_redundant (&ecx_context, &ecx_redport, ifname, if2name);
}
/** Close lib.
* @see ecx_close
*/
void ec_close(void)
{
ecx_close(&ecx_context);
};
/** Read one byte from slave EEPROM via cache.
* If the cache location is empty then a read request is made to the slave.
* Depending on the slave capabillities the request is 4 or 8 bytes.
* @param[in] slave = slave number
* @param[in] address = eeprom address in bytes (slave uses words)
* @return requested byte, if not available then 0xff
* @see ecx_siigetbyte
*/
uint8 ec_siigetbyte(uint16 slave, uint16 address)
{
return ecx_siigetbyte (&ecx_context, slave, address);
}
/** Find SII section header in slave EEPROM.
* @param[in] slave = slave number
* @param[in] cat = section category
* @return byte address of section at section length entry, if not available then 0
* @see ecx_siifind
*/
int16 ec_siifind(uint16 slave, uint16 cat)
{
return ecx_siifind (&ecx_context, slave, cat);
}
/** Get string from SII string section in slave EEPROM.
* @param[out] str = requested string, 0x00 if not found
* @param[in] slave = slave number
* @param[in] Sn = string number
* @see ecx_siistring
*/
void ec_siistring(char *str, uint16 slave, uint16 Sn)
{
ecx_siistring(&ecx_context, str, slave, Sn);
}
/** Get FMMU data from SII FMMU section in slave EEPROM.
* @param[in] slave = slave number
* @param[out] FMMU = FMMU struct from SII, max. 4 FMMU's
* @return number of FMMU's defined in section
* @see ecx_siiFMMU
*/
uint16 ec_siiFMMU(uint16 slave, ec_eepromFMMUt* FMMU)
{
return ecx_siiFMMU (&ecx_context, slave, FMMU);
}
/** Get SM data from SII SM section in slave EEPROM.
* @param[in] slave = slave number
* @param[out] SM = first SM struct from SII
* @return number of SM's defined in section
* @see ecx_siiSM
*/
uint16 ec_siiSM(uint16 slave, ec_eepromSMt* SM)
{
return ecx_siiSM (&ecx_context, slave, SM);
}
/** Get next SM data from SII SM section in slave EEPROM.
* @param[in] slave = slave number
* @param[out] SM = first SM struct from SII
* @param[in] n = SM number
* @return >0 if OK
* @see ecx_siiSMnext
*/
uint16 ec_siiSMnext(uint16 slave, ec_eepromSMt* SM, uint16 n)
{
return ecx_siiSMnext (&ecx_context, slave, SM, n);
}
/** Get PDO data from SII PDO section in slave EEPROM.
* @param[in] slave = slave number
* @param[out] PDO = PDO struct from SII
* @param[in] t = 0=RXPDO 1=TXPDO
* @return mapping size in bits of PDO
* @see ecx_siiPDO
*/
int ec_siiPDO(uint16 slave, ec_eepromPDOt* PDO, uint8 t)
{
return ecx_siiPDO (&ecx_context, slave, PDO, t);
}
/** Read all slave states in ec_slave.
* @return lowest state found
* @see ecx_readstate
*/
int ec_readstate(void)
{
return ecx_readstate (&ecx_context);
}
/** Write slave state, if slave = 0 then write to all slaves.
* The function does not check if the actual state is changed.
* @param[in] slave = Slave number, 0 = master
* @return 0
* @see ecx_writestate
*/
int ec_writestate(uint16 slave)
{
return ecx_writestate(&ecx_context, slave);
}
/** Check actual slave state.
* This is a blocking function.
* @param[in] slave = Slave number, 0 = all slaves
* @param[in] reqstate = Requested state
* @param[in] timeout = Timout value in us
* @return Requested state, or found state after timeout.
* @see ecx_statecheck
*/
uint16 ec_statecheck(uint16 slave, uint16 reqstate, int timeout)
{
return ecx_statecheck (&ecx_context, slave, reqstate, timeout);
}
/** Check if IN mailbox of slave is empty.
* @param[in] slave = Slave number
* @param[in] timeout = Timeout in us
* @return >0 is success
* @see ecx_mbxempty
*/
int ec_mbxempty(uint16 slave, int timeout)
{
return ecx_mbxempty (&ecx_context, slave, timeout);
}
/** Write IN mailbox to slave.
* @param[in] slave = Slave number
* @param[out] mbx = Mailbox data
* @param[in] timeout = Timeout in us
* @return Work counter (>0 is success)
* @see ecx_mbxsend
*/
int ec_mbxsend(uint16 slave,ec_mbxbuft *mbx, int timeout)
{
return ecx_mbxsend (&ecx_context, slave, mbx, timeout);
}
/** Read OUT mailbox from slave.
* Supports Mailbox Link Layer with repeat requests.
* @param[in] slave = Slave number
* @param[out] mbx = Mailbox data
* @param[in] timeout = Timeout in us
* @return Work counter (>0 is success)
* @see ecx_mbxreceive
*/
int ec_mbxreceive(uint16 slave, ec_mbxbuft *mbx, int timeout)
{
return ecx_mbxreceive (&ecx_context, slave, mbx, timeout);
}
/** Dump complete EEPROM data from slave in buffer.
* @param[in] slave = Slave number
* @param[out] esibuf = EEPROM data buffer, make sure it is big enough.
* @see ecx_esidump
*/
void ec_esidump(uint16 slave, uint8 *esibuf)
{
ecx_esidump (&ecx_context, slave, esibuf);
}
/** Read EEPROM from slave bypassing cache.
* @param[in] slave = Slave number
* @param[in] eeproma = (WORD) Address in the EEPROM
* @param[in] timeout = Timeout in us.
* @return EEPROM data 32bit
* @see ecx_readeeprom
*/
uint32 ec_readeeprom(uint16 slave, uint16 eeproma, int timeout)
{
return ecx_readeeprom (&ecx_context, slave, eeproma, timeout);
}
/** Write EEPROM to slave bypassing cache.
* @param[in] slave = Slave number
* @param[in] eeproma = (WORD) Address in the EEPROM
* @param[in] data = 16bit data
* @param[in] timeout = Timeout in us.
* @return >0 if OK
* @see ecx_writeeeprom
*/
int ec_writeeeprom(uint16 slave, uint16 eeproma, uint16 data, int timeout)
{
return ecx_writeeeprom (&ecx_context, slave, eeproma, data, timeout);
}
/** Set eeprom control to master. Only if set to PDI.
* @param[in] slave = Slave number
* @return >0 if OK
* @see ecx_eeprom2master
*/
int ec_eeprom2master(uint16 slave)
{
return ecx_eeprom2master(&ecx_context, slave);
@ -2010,11 +2134,25 @@ uint16 ec_eeprom_waitnotbusyAP(uint16 aiadr,uint16 *estat, int timeout)
return ecx_eeprom_waitnotbusyAP (&ecx_context, aiadr, estat, timeout);
}
/** Read EEPROM from slave bypassing cache. APRD method.
* @param[in] aiadr = auto increment address of slave
* @param[in] eeproma = (WORD) Address in the EEPROM
* @param[in] timeout = Timeout in us.
* @return EEPROM data 64bit or 32bit
*/
uint64 ec_readeepromAP(uint16 aiadr, uint16 eeproma, int timeout)
{
return ecx_readeepromAP (&ecx_context, aiadr, eeproma, timeout);
}
/** Write EEPROM to slave bypassing cache. APWR method.
* @param[in] aiadr = configured address of slave
* @param[in] eeproma = (WORD) Address in the EEPROM
* @param[in] data = 16bit data
* @param[in] timeout = Timeout in us.
* @return >0 if OK
* @see ecx_writeeepromAP
*/
int ec_writeeepromAP(uint16 aiadr, uint16 eeproma, uint16 data, int timeout)
{
return ecx_writeeepromAP (&ecx_context, aiadr, eeproma, data, timeout);
@ -2025,31 +2163,80 @@ uint16 ec_eeprom_waitnotbusyFP(uint16 configadr,uint16 *estat, int timeout)
return ecx_eeprom_waitnotbusyFP (&ecx_context, configadr, estat, timeout);
}
/** Read EEPROM from slave bypassing cache. FPRD method.
* @param[in] configadr = configured address of slave
* @param[in] eeproma = (WORD) Address in the EEPROM
* @param[in] timeout = Timeout in us.
* @return EEPROM data 64bit or 32bit
* @see ecx_readeepromFP
*/
uint64 ec_readeepromFP(uint16 configadr, uint16 eeproma, int timeout)
{
return ecx_readeepromFP (&ecx_context, configadr, eeproma, timeout);
}
/** Write EEPROM to slave bypassing cache. FPWR method.
* @param[in] configadr = configured address of slave
* @param[in] eeproma = (WORD) Address in the EEPROM
* @param[in] data = 16bit data
* @param[in] timeout = Timeout in us.
* @return >0 if OK
* @see ecx_writeeepromFP
*/
int ec_writeeepromFP(uint16 configadr, uint16 eeproma, uint16 data, int timeout)
{
return ecx_writeeepromFP (&ecx_context, configadr, eeproma, data, timeout);
}
/** Read EEPROM from slave bypassing cache.
* Parallel read step 1, make request to slave.
* @param[in] slave = Slave number
* @param[in] eeproma = (WORD) Address in the EEPROM
* @see ecx_readeeprom1
*/
void ec_readeeprom1(uint16 slave, uint16 eeproma)
{
ecx_readeeprom1 (&ecx_context, slave, eeproma);
}
/** Read EEPROM from slave bypassing cache.
* Parallel read step 2, actual read from slave.
* @param[in] slave = Slave number
* @param[in] timeout = Timeout in us.
* @return EEPROM data 32bit
* @see ecx_readeeprom2
*/
uint32 ec_readeeprom2(uint16 slave, int timeout)
{
return ecx_readeeprom2 (&ecx_context, slave, timeout);
}
/** Transmit processdata to slaves.
* Uses LRW, or LRD/LWR if LRW is not allowed (blockLRW).
* Both the input and output processdata are transmitted.
* The outputs with the actual data, the inputs have a placeholder.
* The inputs are gathered with the receive processdata function.
* In contrast to the base LRW function this function is non-blocking.
* If the processdata does not fit in one datagram, multiple are used.
* In order to recombine the slave response, a stack is used.
* @param[in] group = group number
* @return >0 if processdata is transmitted.
* @see ecx_send_processdata_group
*/
int ec_send_processdata_group(uint8 group)
{
return ecx_send_processdata_group (&ecx_context, group);
}
/** Receive processdata from slaves.
* Second part from ec_send_processdata().
* Received datagrams are recombined with the processdata with help from the stack.
* If a datagram contains input processdata it copies it to the processdata structure.
* @param[in] group = group number
* @param[in] timeout = Timeout in us.
* @return Work counter.
* @see ecx_receive_processdata_group
*/
int ec_receive_processdata_group(uint8 group, int timeout)
{
return ecx_receive_processdata_group (&ecx_context, group, timeout);
@ -2064,4 +2251,4 @@ int ec_receive_processdata(int timeout)
{
return ec_receive_processdata_group(0, timeout);
}
#endif
#endif