Implemented missing datagram types.
This commit is contained in:
parent
350c159a9d
commit
39f4da4d4f
1
NEWS
1
NEWS
|
|
@ -49,6 +49,7 @@ Changes in version 1.4.0:
|
|||
* Renamed ec_master module parameters main and backup to main_devices and
|
||||
backup_devices to avoid warnings of some compilers.
|
||||
* Added MODPROBE_FLAGS variable in start script and sysconfig file.
|
||||
* Implemented missing datagram types.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
1
TODO
1
TODO
|
|
@ -22,7 +22,6 @@ Version 1.4.0:
|
|||
* Calculate expected working counter for domains.
|
||||
* Distributed clocks.
|
||||
* Support slaves, that don't support the LRW datagram, only LRD/LWR.
|
||||
* Implement all EtherCAT datagram types.
|
||||
|
||||
Future issues:
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@
|
|||
|
||||
/** Constructor.
|
||||
*/
|
||||
void ec_datagram_init(ec_datagram_t *datagram /**< EtherCAT datagram */)
|
||||
void ec_datagram_init(ec_datagram_t *datagram /**< EtherCAT datagram. */)
|
||||
{
|
||||
INIT_LIST_HEAD(&datagram->queue); // mark as unqueued
|
||||
datagram->type = EC_DATAGRAM_NONE;
|
||||
|
|
@ -90,7 +90,7 @@ void ec_datagram_init(ec_datagram_t *datagram /**< EtherCAT datagram */)
|
|||
|
||||
/** Destructor.
|
||||
*/
|
||||
void ec_datagram_clear(ec_datagram_t *datagram /**< EtherCAT datagram */)
|
||||
void ec_datagram_clear(ec_datagram_t *datagram /**< EtherCAT datagram. */)
|
||||
{
|
||||
if (datagram->data_origin == EC_ORIG_INTERNAL && datagram->data)
|
||||
kfree(datagram->data);
|
||||
|
|
@ -107,8 +107,9 @@ void ec_datagram_clear(ec_datagram_t *datagram /**< EtherCAT datagram */)
|
|||
*
|
||||
* \return 0 in case of success, else < 0
|
||||
*/
|
||||
int ec_datagram_prealloc(ec_datagram_t *datagram, /**< EtherCAT datagram */
|
||||
size_t size /**< New size in bytes */
|
||||
int ec_datagram_prealloc(
|
||||
ec_datagram_t *datagram, /**< EtherCAT datagram. */
|
||||
size_t size /**< New payload size in bytes. */
|
||||
)
|
||||
{
|
||||
if (datagram->data_origin == EC_ORIG_EXTERNAL
|
||||
|
|
@ -132,161 +133,284 @@ int ec_datagram_prealloc(ec_datagram_t *datagram, /**< EtherCAT datagram */
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Initializes an EtherCAT NPRD datagram.
|
||||
*
|
||||
* Node-adressed physical read.
|
||||
*
|
||||
* \return 0 in case of success, else < 0
|
||||
*/
|
||||
int ec_datagram_nprd(ec_datagram_t *datagram,
|
||||
/**< EtherCAT datagram */
|
||||
uint16_t node_address,
|
||||
/**< configured station address */
|
||||
uint16_t offset,
|
||||
/**< physical memory address */
|
||||
size_t data_size
|
||||
/**< number of bytes to read */
|
||||
)
|
||||
{
|
||||
if (unlikely(node_address == 0x0000))
|
||||
EC_WARN("Using node address 0x0000!\n");
|
||||
|
||||
EC_FUNC_HEADER;
|
||||
datagram->type = EC_DATAGRAM_NPRD;
|
||||
EC_WRITE_U16(datagram->address, node_address);
|
||||
EC_WRITE_U16(datagram->address + 2, offset);
|
||||
EC_FUNC_FOOTER;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Initializes an EtherCAT NPWR datagram.
|
||||
*
|
||||
* Node-adressed physical write.
|
||||
*
|
||||
* \return 0 in case of success, else < 0
|
||||
*/
|
||||
int ec_datagram_npwr(ec_datagram_t *datagram,
|
||||
/**< EtherCAT datagram */
|
||||
uint16_t node_address,
|
||||
/**< configured station address */
|
||||
uint16_t offset,
|
||||
/**< physical memory address */
|
||||
size_t data_size
|
||||
/**< number of bytes to write */
|
||||
)
|
||||
{
|
||||
if (unlikely(node_address == 0x0000))
|
||||
EC_WARN("Using node address 0x0000!\n");
|
||||
|
||||
EC_FUNC_HEADER;
|
||||
datagram->type = EC_DATAGRAM_NPWR;
|
||||
EC_WRITE_U16(datagram->address, node_address);
|
||||
EC_WRITE_U16(datagram->address + 2, offset);
|
||||
EC_FUNC_FOOTER;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Initializes an EtherCAT APRD datagram.
|
||||
*
|
||||
* Autoincrement physical read.
|
||||
*
|
||||
* \return 0 in case of success, else < 0
|
||||
*/
|
||||
int ec_datagram_aprd(ec_datagram_t *datagram,
|
||||
/**< EtherCAT datagram */
|
||||
uint16_t ring_position,
|
||||
/**< auto-increment position */
|
||||
uint16_t offset,
|
||||
/**< physical memory address */
|
||||
size_t data_size
|
||||
/**< number of bytes to read */
|
||||
)
|
||||
int ec_datagram_aprd(
|
||||
ec_datagram_t *datagram, /**< EtherCAT datagram. */
|
||||
uint16_t ring_position, /**< Auto-increment address. */
|
||||
uint16_t mem_address, /**< Physical memory address. */
|
||||
size_t data_size /**< Number of bytes to read. */
|
||||
)
|
||||
{
|
||||
EC_FUNC_HEADER;
|
||||
datagram->type = EC_DATAGRAM_APRD;
|
||||
EC_WRITE_S16(datagram->address, (int16_t) ring_position * (-1));
|
||||
EC_WRITE_U16(datagram->address + 2, offset);
|
||||
EC_WRITE_U16(datagram->address + 2, mem_address);
|
||||
EC_FUNC_FOOTER;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Initializes an EtherCAT APWR datagram.
|
||||
*
|
||||
* Autoincrement physical write.
|
||||
*
|
||||
* \return 0 in case of success, else < 0
|
||||
*/
|
||||
int ec_datagram_apwr(ec_datagram_t *datagram,
|
||||
/**< EtherCAT datagram */
|
||||
uint16_t ring_position,
|
||||
/**< auto-increment position */
|
||||
uint16_t offset,
|
||||
/**< physical memory address */
|
||||
size_t data_size
|
||||
/**< number of bytes to write */
|
||||
)
|
||||
int ec_datagram_apwr(
|
||||
ec_datagram_t *datagram, /**< EtherCAT datagram. */
|
||||
uint16_t ring_position, /**< Auto-increment address. */
|
||||
uint16_t mem_address, /**< Physical memory address. */
|
||||
size_t data_size /**< Number of bytes to write. */
|
||||
)
|
||||
{
|
||||
EC_FUNC_HEADER;
|
||||
datagram->type = EC_DATAGRAM_APWR;
|
||||
EC_WRITE_S16(datagram->address, (int16_t) ring_position * (-1));
|
||||
EC_WRITE_U16(datagram->address + 2, offset);
|
||||
EC_WRITE_U16(datagram->address + 2, mem_address);
|
||||
EC_FUNC_FOOTER;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Initializes an EtherCAT APRW datagram.
|
||||
*
|
||||
* \return 0 in case of success, else < 0
|
||||
*/
|
||||
int ec_datagram_aprw(
|
||||
ec_datagram_t *datagram, /**< EtherCAT datagram. */
|
||||
uint16_t ring_position, /**< Auto-increment address. */
|
||||
uint16_t mem_address, /**< Physical memory address. */
|
||||
size_t data_size /**< Number of bytes to write. */
|
||||
)
|
||||
{
|
||||
EC_FUNC_HEADER;
|
||||
datagram->type = EC_DATAGRAM_APRW;
|
||||
EC_WRITE_S16(datagram->address, (int16_t) ring_position * (-1));
|
||||
EC_WRITE_U16(datagram->address + 2, mem_address);
|
||||
EC_FUNC_FOOTER;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Initializes an EtherCAT ARMW datagram.
|
||||
*
|
||||
* \return 0 in case of success, else < 0
|
||||
*/
|
||||
int ec_datagram_armw(
|
||||
ec_datagram_t *datagram, /**< EtherCAT datagram. */
|
||||
uint16_t ring_position, /**< Auto-increment address. */
|
||||
uint16_t mem_address, /**< Physical memory address. */
|
||||
size_t data_size /**< Number of bytes to read. */
|
||||
)
|
||||
{
|
||||
EC_FUNC_HEADER;
|
||||
datagram->type = EC_DATAGRAM_ARMW;
|
||||
EC_WRITE_S16(datagram->address, (int16_t) ring_position * (-1));
|
||||
EC_WRITE_U16(datagram->address + 2, mem_address);
|
||||
EC_FUNC_FOOTER;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Initializes an EtherCAT FPRD datagram.
|
||||
*
|
||||
* \return 0 in case of success, else < 0
|
||||
*/
|
||||
int ec_datagram_fprd(
|
||||
ec_datagram_t *datagram, /**< EtherCAT datagram. */
|
||||
uint16_t configured_address, /**< Configured station address. */
|
||||
uint16_t mem_address, /**< Physical memory address. */
|
||||
size_t data_size /**< Number of bytes to read. */
|
||||
)
|
||||
{
|
||||
if (unlikely(configured_address == 0x0000))
|
||||
EC_WARN("Using configured station address 0x0000!\n");
|
||||
|
||||
EC_FUNC_HEADER;
|
||||
datagram->type = EC_DATAGRAM_FPRD;
|
||||
EC_WRITE_U16(datagram->address, configured_address);
|
||||
EC_WRITE_U16(datagram->address + 2, mem_address);
|
||||
EC_FUNC_FOOTER;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Initializes an EtherCAT FPWR datagram.
|
||||
*
|
||||
* \return 0 in case of success, else < 0
|
||||
*/
|
||||
int ec_datagram_fpwr(
|
||||
ec_datagram_t *datagram, /**< EtherCAT datagram. */
|
||||
uint16_t configured_address, /**< Configured station address. */
|
||||
uint16_t mem_address, /**< Physical memory address. */
|
||||
size_t data_size /**< Number of bytes to write. */
|
||||
)
|
||||
{
|
||||
if (unlikely(configured_address == 0x0000))
|
||||
EC_WARN("Using configured station address 0x0000!\n");
|
||||
|
||||
EC_FUNC_HEADER;
|
||||
datagram->type = EC_DATAGRAM_FPWR;
|
||||
EC_WRITE_U16(datagram->address, configured_address);
|
||||
EC_WRITE_U16(datagram->address + 2, mem_address);
|
||||
EC_FUNC_FOOTER;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Initializes an EtherCAT FPRW datagram.
|
||||
*
|
||||
* \return 0 in case of success, else < 0
|
||||
*/
|
||||
int ec_datagram_fprw(
|
||||
ec_datagram_t *datagram, /**< EtherCAT datagram. */
|
||||
uint16_t configured_address, /**< Configured station address. */
|
||||
uint16_t mem_address, /**< Physical memory address. */
|
||||
size_t data_size /**< Number of bytes to write. */
|
||||
)
|
||||
{
|
||||
if (unlikely(configured_address == 0x0000))
|
||||
EC_WARN("Using configured station address 0x0000!\n");
|
||||
|
||||
EC_FUNC_HEADER;
|
||||
datagram->type = EC_DATAGRAM_FPRW;
|
||||
EC_WRITE_U16(datagram->address, configured_address);
|
||||
EC_WRITE_U16(datagram->address + 2, mem_address);
|
||||
EC_FUNC_FOOTER;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Initializes an EtherCAT FRMW datagram.
|
||||
*
|
||||
* \return 0 in case of success, else < 0
|
||||
*/
|
||||
int ec_datagram_frmw(
|
||||
ec_datagram_t *datagram, /**< EtherCAT datagram. */
|
||||
uint16_t configured_address, /**< Configured station address. */
|
||||
uint16_t mem_address, /**< Physical memory address. */
|
||||
size_t data_size /**< Number of bytes to write. */
|
||||
)
|
||||
{
|
||||
if (unlikely(configured_address == 0x0000))
|
||||
EC_WARN("Using configured station address 0x0000!\n");
|
||||
|
||||
EC_FUNC_HEADER;
|
||||
datagram->type = EC_DATAGRAM_FRMW;
|
||||
EC_WRITE_U16(datagram->address, configured_address);
|
||||
EC_WRITE_U16(datagram->address + 2, mem_address);
|
||||
EC_FUNC_FOOTER;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Initializes an EtherCAT BRD datagram.
|
||||
*
|
||||
* Broadcast read.
|
||||
*
|
||||
* \return 0 in case of success, else < 0
|
||||
*/
|
||||
int ec_datagram_brd(ec_datagram_t *datagram,
|
||||
/**< EtherCAT datagram */
|
||||
uint16_t offset,
|
||||
/**< physical memory address */
|
||||
size_t data_size
|
||||
/**< number of bytes to read */
|
||||
)
|
||||
int ec_datagram_brd(
|
||||
ec_datagram_t *datagram, /**< EtherCAT datagram. */
|
||||
uint16_t mem_address, /**< Physical memory address. */
|
||||
size_t data_size /**< Number of bytes to read. */
|
||||
)
|
||||
{
|
||||
EC_FUNC_HEADER;
|
||||
datagram->type = EC_DATAGRAM_BRD;
|
||||
EC_WRITE_U16(datagram->address, 0x0000);
|
||||
EC_WRITE_U16(datagram->address + 2, offset);
|
||||
EC_WRITE_U16(datagram->address + 2, mem_address);
|
||||
EC_FUNC_FOOTER;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Initializes an EtherCAT BWR datagram.
|
||||
*
|
||||
* Broadcast write.
|
||||
*
|
||||
* \return 0 in case of success, else < 0
|
||||
*/
|
||||
int ec_datagram_bwr(ec_datagram_t *datagram,
|
||||
/**< EtherCAT datagram */
|
||||
uint16_t offset,
|
||||
/**< physical memory address */
|
||||
size_t data_size
|
||||
/**< number of bytes to write */
|
||||
)
|
||||
int ec_datagram_bwr(
|
||||
ec_datagram_t *datagram, /**< EtherCAT datagram. */
|
||||
uint16_t mem_address, /**< Physical memory address. */
|
||||
size_t data_size /**< Number of bytes to write. */
|
||||
)
|
||||
{
|
||||
EC_FUNC_HEADER;
|
||||
datagram->type = EC_DATAGRAM_BWR;
|
||||
EC_WRITE_U16(datagram->address, 0x0000);
|
||||
EC_WRITE_U16(datagram->address + 2, offset);
|
||||
EC_WRITE_U16(datagram->address + 2, mem_address);
|
||||
EC_FUNC_FOOTER;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Initializes an EtherCAT BRW datagram.
|
||||
*
|
||||
* \return 0 in case of success, else < 0
|
||||
*/
|
||||
int ec_datagram_brw(
|
||||
ec_datagram_t *datagram, /**< EtherCAT datagram. */
|
||||
uint16_t mem_address, /**< Physical memory address. */
|
||||
size_t data_size /**< Number of bytes to write. */
|
||||
)
|
||||
{
|
||||
EC_FUNC_HEADER;
|
||||
datagram->type = EC_DATAGRAM_BRW;
|
||||
EC_WRITE_U16(datagram->address, 0x0000);
|
||||
EC_WRITE_U16(datagram->address + 2, mem_address);
|
||||
EC_FUNC_FOOTER;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Initializes an EtherCAT LRD datagram.
|
||||
*
|
||||
* \attention It is assumed, that the external memory is at least \a data_size
|
||||
* bytes large.
|
||||
*
|
||||
* \return 0 in case of success, else < 0
|
||||
*/
|
||||
int ec_datagram_lrd(
|
||||
ec_datagram_t *datagram, /**< EtherCAT datagram. */
|
||||
uint32_t offset, /**< Logical address. */
|
||||
size_t data_size, /**< Number of bytes to read/write. */
|
||||
uint8_t *external_memory /**< Pointer to the memory to use. */
|
||||
)
|
||||
{
|
||||
datagram->data = external_memory;
|
||||
datagram->data_origin = EC_ORIG_EXTERNAL;
|
||||
EC_FUNC_HEADER;
|
||||
datagram->type = EC_DATAGRAM_LRD;
|
||||
EC_WRITE_U32(datagram->address, offset);
|
||||
EC_FUNC_FOOTER;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Initializes an EtherCAT LWR datagram.
|
||||
*
|
||||
* \attention It is assumed, that the external memory is at least \a data_size
|
||||
* bytes large.
|
||||
*
|
||||
* \return 0 in case of success, else < 0
|
||||
*/
|
||||
int ec_datagram_lwr(
|
||||
ec_datagram_t *datagram, /**< EtherCAT datagram. */
|
||||
uint32_t offset, /**< Logical address. */
|
||||
size_t data_size, /**< Number of bytes to read/write. */
|
||||
uint8_t *external_memory /**< Pointer to the memory to use. */
|
||||
)
|
||||
{
|
||||
datagram->data = external_memory;
|
||||
datagram->data_origin = EC_ORIG_EXTERNAL;
|
||||
EC_FUNC_HEADER;
|
||||
datagram->type = EC_DATAGRAM_LWR;
|
||||
EC_WRITE_U32(datagram->address, offset);
|
||||
EC_FUNC_FOOTER;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Initializes an EtherCAT LRW datagram.
|
||||
*
|
||||
* Logical read write.
|
||||
*
|
||||
* \attention It is assumed, that the external memory is at least \a data_size
|
||||
* bytes large.
|
||||
|
|
@ -294,7 +418,7 @@ int ec_datagram_bwr(ec_datagram_t *datagram,
|
|||
* \return 0 in case of success, else < 0
|
||||
*/
|
||||
int ec_datagram_lrw(
|
||||
ec_datagram_t *datagram, /**< EtherCAT datagram */
|
||||
ec_datagram_t *datagram, /**< EtherCAT datagram. */
|
||||
uint32_t offset, /**< Logical address. */
|
||||
size_t data_size, /**< Number of bytes to read/write. */
|
||||
uint8_t *external_memory /**< Pointer to the memory to use. */
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
/** size of the datagram description string */
|
||||
/** Size of the datagram description string. */
|
||||
#define EC_DATAGRAM_NAME_SIZE 20
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -58,13 +58,22 @@
|
|||
*/
|
||||
typedef enum {
|
||||
EC_DATAGRAM_NONE = 0x00, /**< Dummy. */
|
||||
EC_DATAGRAM_APRD = 0x01, /**< Auto-increment physical read. */
|
||||
EC_DATAGRAM_APWR = 0x02, /**< Auto-increment physical write. */
|
||||
EC_DATAGRAM_NPRD = 0x04, /**< Node-addressed physical read. */
|
||||
EC_DATAGRAM_NPWR = 0x05, /**< Node-addressed physical write. */
|
||||
EC_DATAGRAM_BRD = 0x07, /**< Broadcast read. */
|
||||
EC_DATAGRAM_BWR = 0x08, /**< Broadcast write. */
|
||||
EC_DATAGRAM_LRW = 0x0C /**< Logical read/write. */
|
||||
EC_DATAGRAM_APRD = 0x01, /**< Auto Increment Physical Read. */
|
||||
EC_DATAGRAM_APWR = 0x02, /**< Auto Increment Physical Write. */
|
||||
EC_DATAGRAM_APRW = 0x03, /**< Auto Increment Physical ReadWrite. */
|
||||
EC_DATAGRAM_FPRD = 0x04, /**< Configured Address Physical Read. */
|
||||
EC_DATAGRAM_FPWR = 0x05, /**< Configured Address Physical Write. */
|
||||
EC_DATAGRAM_FPRW = 0x06, /**< Configured Address Physical ReadWrite. */
|
||||
EC_DATAGRAM_BRD = 0x07, /**< Broadcast Read. */
|
||||
EC_DATAGRAM_BWR = 0x08, /**< Broadcast Write. */
|
||||
EC_DATAGRAM_BRW = 0x09, /**< Broadcast ReadWrite. */
|
||||
EC_DATAGRAM_LRD = 0x0A, /**< Logical Read. */
|
||||
EC_DATAGRAM_LWR = 0x0B, /**< Logical Write. */
|
||||
EC_DATAGRAM_LRW = 0x0C, /**< Logical ReadWrite. */
|
||||
EC_DATAGRAM_ARMW = 0x0D, /**< Auto Increment Physical Read Multiple
|
||||
Write. */
|
||||
EC_DATAGRAM_FRMW = 0x0E, /**< Configured Address Physical Read Multiple
|
||||
Write. */
|
||||
} ec_datagram_type_t;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -113,12 +122,19 @@ void ec_datagram_init(ec_datagram_t *);
|
|||
void ec_datagram_clear(ec_datagram_t *);
|
||||
int ec_datagram_prealloc(ec_datagram_t *, size_t);
|
||||
|
||||
int ec_datagram_nprd(ec_datagram_t *, uint16_t, uint16_t, size_t);
|
||||
int ec_datagram_npwr(ec_datagram_t *, uint16_t, uint16_t, size_t);
|
||||
int ec_datagram_aprd(ec_datagram_t *, uint16_t, uint16_t, size_t);
|
||||
int ec_datagram_apwr(ec_datagram_t *, uint16_t, uint16_t, size_t);
|
||||
int ec_datagram_aprw(ec_datagram_t *, uint16_t, uint16_t, size_t);
|
||||
int ec_datagram_armw(ec_datagram_t *, uint16_t, uint16_t, size_t);
|
||||
int ec_datagram_fprd(ec_datagram_t *, uint16_t, uint16_t, size_t);
|
||||
int ec_datagram_fpwr(ec_datagram_t *, uint16_t, uint16_t, size_t);
|
||||
int ec_datagram_fprw(ec_datagram_t *, uint16_t, uint16_t, size_t);
|
||||
int ec_datagram_frmw(ec_datagram_t *, uint16_t, uint16_t, size_t);
|
||||
int ec_datagram_brd(ec_datagram_t *, uint16_t, size_t);
|
||||
int ec_datagram_bwr(ec_datagram_t *, uint16_t, size_t);
|
||||
int ec_datagram_brw(ec_datagram_t *, uint16_t, size_t);
|
||||
int ec_datagram_lrd(ec_datagram_t *, uint32_t, size_t, uint8_t *);
|
||||
int ec_datagram_lwr(ec_datagram_t *, uint32_t, size_t, uint8_t *);
|
||||
int ec_datagram_lrw(ec_datagram_t *, uint32_t, size_t, uint8_t *);
|
||||
|
||||
void ec_datagram_print_wc_error(const ec_datagram_t *);
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ void ec_fsm_change_state_start(ec_fsm_change_t *fsm
|
|||
fsm->old_state = fsm->slave->current_state;
|
||||
|
||||
// write new state to slave
|
||||
ec_datagram_npwr(datagram, slave->station_address, 0x0120, 2);
|
||||
ec_datagram_fpwr(datagram, slave->station_address, 0x0120, 2);
|
||||
EC_WRITE_U16(datagram->data, fsm->requested_state);
|
||||
fsm->retries = EC_FSM_RETRIES;
|
||||
fsm->state = ec_fsm_change_state_check;
|
||||
|
|
@ -203,7 +203,7 @@ void ec_fsm_change_state_check(ec_fsm_change_t *fsm
|
|||
}
|
||||
|
||||
// repeat writing new state to slave
|
||||
ec_datagram_npwr(datagram, slave->station_address, 0x0120, 2);
|
||||
ec_datagram_fpwr(datagram, slave->station_address, 0x0120, 2);
|
||||
EC_WRITE_U16(datagram->data, fsm->requested_state);
|
||||
fsm->retries = EC_FSM_RETRIES;
|
||||
return;
|
||||
|
|
@ -222,7 +222,7 @@ void ec_fsm_change_state_check(ec_fsm_change_t *fsm
|
|||
fsm->take_time = 1;
|
||||
|
||||
// read AL status from slave
|
||||
ec_datagram_nprd(datagram, slave->station_address, 0x0130, 2);
|
||||
ec_datagram_fprd(datagram, slave->station_address, 0x0130, 2);
|
||||
fsm->retries = EC_FSM_RETRIES;
|
||||
fsm->spontaneous_change = 0;
|
||||
fsm->state = ec_fsm_change_state_status;
|
||||
|
|
@ -298,7 +298,7 @@ void ec_fsm_change_state_status(ec_fsm_change_t *fsm
|
|||
EC_ERR("Failed to set %s state, slave %i refused state change (%s).\n",
|
||||
req_state, slave->ring_position, cur_state);
|
||||
// fetch AL status error code
|
||||
ec_datagram_nprd(datagram, slave->station_address, 0x0134, 2);
|
||||
ec_datagram_fprd(datagram, slave->station_address, 0x0134, 2);
|
||||
fsm->retries = EC_FSM_RETRIES;
|
||||
fsm->state = ec_fsm_change_state_code;
|
||||
return;
|
||||
|
|
@ -318,7 +318,7 @@ void ec_fsm_change_state_status(ec_fsm_change_t *fsm
|
|||
|
||||
check_again:
|
||||
// no timeout yet. check again
|
||||
ec_datagram_nprd(datagram, slave->station_address, 0x0130, 2);
|
||||
ec_datagram_fprd(datagram, slave->station_address, 0x0130, 2);
|
||||
fsm->retries = EC_FSM_RETRIES;
|
||||
}
|
||||
|
||||
|
|
@ -417,7 +417,7 @@ void ec_fsm_change_state_start_ack(ec_fsm_change_t *fsm
|
|||
ec_slave_t *slave = fsm->slave;
|
||||
ec_datagram_t *datagram = fsm->datagram;
|
||||
|
||||
ec_datagram_npwr(datagram, slave->station_address, 0x0120, 2);
|
||||
ec_datagram_fpwr(datagram, slave->station_address, 0x0120, 2);
|
||||
EC_WRITE_U16(datagram->data, slave->current_state);
|
||||
fsm->retries = EC_FSM_RETRIES;
|
||||
fsm->state = ec_fsm_change_state_ack;
|
||||
|
|
@ -456,7 +456,7 @@ void ec_fsm_change_state_ack(ec_fsm_change_t *fsm /**< finite state machine */)
|
|||
fsm->take_time = 1;
|
||||
|
||||
// read new AL status
|
||||
ec_datagram_nprd(datagram, slave->station_address, 0x0130, 2);
|
||||
ec_datagram_fprd(datagram, slave->station_address, 0x0130, 2);
|
||||
fsm->retries = EC_FSM_RETRIES;
|
||||
fsm->state = ec_fsm_change_state_check_ack;
|
||||
}
|
||||
|
|
@ -524,7 +524,7 @@ void ec_fsm_change_state_check_ack(ec_fsm_change_t *fsm
|
|||
}
|
||||
|
||||
// reread new AL status
|
||||
ec_datagram_nprd(datagram, slave->station_address, 0x0130, 2);
|
||||
ec_datagram_fprd(datagram, slave->station_address, 0x0130, 2);
|
||||
fsm->retries = EC_FSM_RETRIES;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -297,7 +297,7 @@ void ec_fsm_master_state_broadcast(ec_fsm_master_t *fsm /**< master state machin
|
|||
|
||||
// fetch state from each slave
|
||||
fsm->slave = list_entry(master->slaves.next, ec_slave_t, list);
|
||||
ec_datagram_nprd(fsm->datagram, fsm->slave->station_address, 0x0130, 2);
|
||||
ec_datagram_fprd(fsm->datagram, fsm->slave->station_address, 0x0130, 2);
|
||||
fsm->retries = EC_FSM_RETRIES;
|
||||
fsm->state = ec_fsm_master_state_read_states;
|
||||
}
|
||||
|
|
@ -347,7 +347,7 @@ int ec_fsm_master_action_process_eeprom(
|
|||
fsm->eeprom_request = request;
|
||||
fsm->eeprom_index = 0;
|
||||
ec_fsm_sii_write(&fsm->fsm_sii, request->slave, request->word_offset,
|
||||
request->data, EC_FSM_SII_NODE);
|
||||
request->data, EC_FSM_SII_USE_CONFIGURED_ADDRESS);
|
||||
fsm->state = ec_fsm_master_state_write_eeprom;
|
||||
fsm->state(fsm); // execute immediately
|
||||
return 1;
|
||||
|
|
@ -572,7 +572,7 @@ void ec_fsm_master_action_next_slave_state(ec_fsm_master_t *fsm
|
|||
// process next slave
|
||||
fsm->idle = 1;
|
||||
fsm->slave = list_entry(slave->list.next, ec_slave_t, list);
|
||||
ec_datagram_nprd(fsm->datagram, fsm->slave->station_address,
|
||||
ec_datagram_fprd(fsm->datagram, fsm->slave->station_address,
|
||||
0x0130, 2);
|
||||
fsm->retries = EC_FSM_RETRIES;
|
||||
fsm->state = ec_fsm_master_state_read_states;
|
||||
|
|
@ -592,7 +592,8 @@ void ec_fsm_master_action_next_slave_state(ec_fsm_master_t *fsm
|
|||
fsm->idle = 0;
|
||||
fsm->slave = list_entry(master->slaves.next, ec_slave_t, list);
|
||||
fsm->state = ec_fsm_master_state_validate_vendor;
|
||||
ec_fsm_sii_read(&fsm->fsm_sii, slave, 0x0008, EC_FSM_SII_POSITION);
|
||||
ec_fsm_sii_read(&fsm->fsm_sii, slave, 0x0008,
|
||||
EC_FSM_SII_USE_INCREMENT_ADDRESS);
|
||||
ec_fsm_sii_exec(&fsm->fsm_sii); // execute immediately
|
||||
return;
|
||||
}
|
||||
|
|
@ -701,7 +702,8 @@ void ec_fsm_master_state_validate_vendor(ec_fsm_master_t *fsm /**< master state
|
|||
|
||||
// vendor ID is ok. check product code.
|
||||
fsm->state = ec_fsm_master_state_validate_product;
|
||||
ec_fsm_sii_read(&fsm->fsm_sii, slave, 0x000A, EC_FSM_SII_POSITION);
|
||||
ec_fsm_sii_read(&fsm->fsm_sii, slave, 0x000A,
|
||||
EC_FSM_SII_USE_INCREMENT_ADDRESS);
|
||||
ec_fsm_sii_exec(&fsm->fsm_sii); // execute immediately
|
||||
}
|
||||
|
||||
|
|
@ -778,7 +780,8 @@ void ec_fsm_master_state_validate_product(ec_fsm_master_t *fsm /**< master state
|
|||
// validate next slave
|
||||
fsm->slave = list_entry(fsm->slave->list.next, ec_slave_t, list);
|
||||
fsm->state = ec_fsm_master_state_validate_vendor;
|
||||
ec_fsm_sii_read(&fsm->fsm_sii, slave, 0x0008, EC_FSM_SII_POSITION);
|
||||
ec_fsm_sii_read(&fsm->fsm_sii, slave, 0x0008,
|
||||
EC_FSM_SII_USE_INCREMENT_ADDRESS);
|
||||
ec_fsm_sii_exec(&fsm->fsm_sii); // execute immediately
|
||||
}
|
||||
|
||||
|
|
@ -980,7 +983,7 @@ void ec_fsm_master_state_write_eeprom(
|
|||
ec_fsm_sii_write(&fsm->fsm_sii, slave,
|
||||
request->word_offset + fsm->eeprom_index,
|
||||
request->data + fsm->eeprom_index * 2,
|
||||
EC_FSM_SII_NODE);
|
||||
EC_FSM_SII_USE_CONFIGURED_ADDRESS);
|
||||
ec_fsm_sii_exec(&fsm->fsm_sii); // execute immediately
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -172,11 +172,11 @@ void ec_fsm_sii_state_start_reading(
|
|||
|
||||
// initiate read operation
|
||||
switch (fsm->mode) {
|
||||
case EC_FSM_SII_POSITION:
|
||||
case EC_FSM_SII_USE_INCREMENT_ADDRESS:
|
||||
ec_datagram_apwr(datagram, fsm->slave->ring_position, 0x502, 4);
|
||||
break;
|
||||
case EC_FSM_SII_NODE:
|
||||
ec_datagram_npwr(datagram, fsm->slave->station_address, 0x502, 4);
|
||||
case EC_FSM_SII_USE_CONFIGURED_ADDRESS:
|
||||
ec_datagram_fpwr(datagram, fsm->slave->station_address, 0x502, 4);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -230,11 +230,11 @@ void ec_fsm_sii_state_read_check(
|
|||
|
||||
// issue check/fetch datagram
|
||||
switch (fsm->mode) {
|
||||
case EC_FSM_SII_POSITION:
|
||||
case EC_FSM_SII_USE_INCREMENT_ADDRESS:
|
||||
ec_datagram_aprd(datagram, fsm->slave->ring_position, 0x502, 10);
|
||||
break;
|
||||
case EC_FSM_SII_NODE:
|
||||
ec_datagram_nprd(datagram, fsm->slave->station_address, 0x502, 10);
|
||||
case EC_FSM_SII_USE_CONFIGURED_ADDRESS:
|
||||
ec_datagram_fprd(datagram, fsm->slave->station_address, 0x502, 10);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -324,7 +324,7 @@ void ec_fsm_sii_state_start_writing(
|
|||
ec_datagram_t *datagram = fsm->datagram;
|
||||
|
||||
// initiate write operation
|
||||
ec_datagram_npwr(datagram, fsm->slave->station_address, 0x502, 8);
|
||||
ec_datagram_fpwr(datagram, fsm->slave->station_address, 0x502, 8);
|
||||
EC_WRITE_U8 (datagram->data, 0x81); // two address octets
|
||||
// + enable write access
|
||||
EC_WRITE_U8 (datagram->data + 1, 0x02); // request write operation
|
||||
|
|
@ -376,7 +376,7 @@ void ec_fsm_sii_state_write_check(
|
|||
fsm->check_once_more = 1;
|
||||
|
||||
// issue check datagram
|
||||
ec_datagram_nprd(datagram, fsm->slave->station_address, 0x502, 2);
|
||||
ec_datagram_fprd(datagram, fsm->slave->station_address, 0x502, 2);
|
||||
fsm->retries = EC_FSM_RETRIES;
|
||||
fsm->state = ec_fsm_sii_state_write_check2;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,15 +48,12 @@
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* SII access addressing mode.
|
||||
/** SII access addressing mode.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
EC_FSM_SII_POSITION,
|
||||
EC_FSM_SII_NODE
|
||||
}
|
||||
ec_fsm_sii_addressing_t;
|
||||
typedef enum {
|
||||
EC_FSM_SII_USE_INCREMENT_ADDRESS, /**< Use auto-increment addressing. */
|
||||
EC_FSM_SII_USE_CONFIGURED_ADDRESS /**< Use configured addresses. */
|
||||
} ec_fsm_sii_addressing_t;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
|
|
|||
|
|
@ -232,7 +232,7 @@ void ec_fsm_slave_scan_state_address(ec_fsm_slave_t *fsm /**< slave state machin
|
|||
}
|
||||
|
||||
// Read AL state
|
||||
ec_datagram_nprd(datagram, fsm->slave->station_address, 0x0130, 2);
|
||||
ec_datagram_fprd(datagram, fsm->slave->station_address, 0x0130, 2);
|
||||
fsm->retries = EC_FSM_RETRIES;
|
||||
fsm->state = ec_fsm_slave_scan_state_state;
|
||||
}
|
||||
|
|
@ -279,7 +279,7 @@ void ec_fsm_slave_scan_state_state(
|
|||
}
|
||||
|
||||
// read base data
|
||||
ec_datagram_nprd(datagram, fsm->slave->station_address, 0x0000, 6);
|
||||
ec_datagram_fprd(datagram, fsm->slave->station_address, 0x0000, 6);
|
||||
fsm->retries = EC_FSM_RETRIES;
|
||||
fsm->state = ec_fsm_slave_scan_state_base;
|
||||
}
|
||||
|
|
@ -324,7 +324,7 @@ void ec_fsm_slave_scan_state_base(ec_fsm_slave_t *fsm /**< slave state machine *
|
|||
slave->base_fmmu_count = EC_MAX_FMMUS;
|
||||
|
||||
// read data link status
|
||||
ec_datagram_nprd(datagram, slave->station_address, 0x0110, 2);
|
||||
ec_datagram_fprd(datagram, slave->station_address, 0x0110, 2);
|
||||
fsm->retries = EC_FSM_RETRIES;
|
||||
fsm->state = ec_fsm_slave_scan_state_datalink;
|
||||
}
|
||||
|
|
@ -372,7 +372,8 @@ void ec_fsm_slave_scan_state_datalink(ec_fsm_slave_t *fsm /**< slave state machi
|
|||
// Start fetching EEPROM size
|
||||
|
||||
fsm->sii_offset = EC_FIRST_EEPROM_CATEGORY_OFFSET; // first category header
|
||||
ec_fsm_sii_read(&fsm->fsm_sii, slave, fsm->sii_offset, EC_FSM_SII_NODE);
|
||||
ec_fsm_sii_read(&fsm->fsm_sii, slave, fsm->sii_offset,
|
||||
EC_FSM_SII_USE_CONFIGURED_ADDRESS);
|
||||
fsm->state = ec_fsm_slave_scan_state_eeprom_size;
|
||||
fsm->state(fsm); // execute state immediately
|
||||
}
|
||||
|
|
@ -413,7 +414,7 @@ void ec_fsm_slave_scan_state_eeprom_size(ec_fsm_slave_t *fsm /**< slave state ma
|
|||
}
|
||||
fsm->sii_offset = next_offset;
|
||||
ec_fsm_sii_read(&fsm->fsm_sii, slave, fsm->sii_offset,
|
||||
EC_FSM_SII_NODE);
|
||||
EC_FSM_SII_USE_CONFIGURED_ADDRESS);
|
||||
ec_fsm_sii_exec(&fsm->fsm_sii); // execute state immediately
|
||||
return;
|
||||
}
|
||||
|
|
@ -441,7 +442,8 @@ alloc_eeprom:
|
|||
|
||||
fsm->state = ec_fsm_slave_scan_state_eeprom_data;
|
||||
fsm->sii_offset = 0x0000;
|
||||
ec_fsm_sii_read(&fsm->fsm_sii, slave, fsm->sii_offset, EC_FSM_SII_NODE);
|
||||
ec_fsm_sii_read(&fsm->fsm_sii, slave, fsm->sii_offset,
|
||||
EC_FSM_SII_USE_CONFIGURED_ADDRESS);
|
||||
ec_fsm_sii_exec(&fsm->fsm_sii); // execute state immediately
|
||||
}
|
||||
|
||||
|
|
@ -481,7 +483,7 @@ void ec_fsm_slave_scan_state_eeprom_data(ec_fsm_slave_t *fsm /**< slave state ma
|
|||
// fetch the next 2 words
|
||||
fsm->sii_offset += 2;
|
||||
ec_fsm_sii_read(&fsm->fsm_sii, slave, fsm->sii_offset,
|
||||
EC_FSM_SII_NODE);
|
||||
EC_FSM_SII_USE_CONFIGURED_ADDRESS);
|
||||
ec_fsm_sii_exec(&fsm->fsm_sii); // execute state immediately
|
||||
return;
|
||||
}
|
||||
|
|
@ -660,7 +662,7 @@ void ec_fsm_slave_conf_state_init(ec_fsm_slave_t *fsm /**< slave state machine *
|
|||
slave->ring_position);
|
||||
|
||||
// clear FMMU configurations
|
||||
ec_datagram_npwr(datagram, slave->station_address,
|
||||
ec_datagram_fpwr(datagram, slave->station_address,
|
||||
0x0600, EC_FMMU_PAGE_SIZE * slave->base_fmmu_count);
|
||||
memset(datagram->data, 0x00, EC_FMMU_PAGE_SIZE * slave->base_fmmu_count);
|
||||
fsm->retries = EC_FSM_RETRIES;
|
||||
|
|
@ -740,7 +742,7 @@ void ec_fsm_slave_conf_enter_mbox_sync(
|
|||
}
|
||||
|
||||
if (slave->sii_sync_count >= 2) { // mailbox configuration provided
|
||||
ec_datagram_npwr(datagram, slave->station_address, 0x0800,
|
||||
ec_datagram_fpwr(datagram, slave->station_address, 0x0800,
|
||||
EC_SYNC_PAGE_SIZE * slave->sii_sync_count);
|
||||
memset(datagram->data, 0x00,
|
||||
EC_SYNC_PAGE_SIZE * slave->sii_sync_count);
|
||||
|
|
@ -757,7 +759,7 @@ void ec_fsm_slave_conf_enter_mbox_sync(
|
|||
" mailbox sync manager configurations.\n",
|
||||
slave->ring_position);
|
||||
|
||||
ec_datagram_npwr(datagram, slave->station_address, 0x0800,
|
||||
ec_datagram_fpwr(datagram, slave->station_address, 0x0800,
|
||||
EC_SYNC_PAGE_SIZE * 2);
|
||||
memset(datagram->data, 0x00, EC_SYNC_PAGE_SIZE * 2);
|
||||
|
||||
|
|
@ -1024,7 +1026,7 @@ void ec_fsm_slave_conf_enter_pdo_sync(
|
|||
num_syncs = slave->sii_sync_count - offset;
|
||||
|
||||
// configure sync managers for process data
|
||||
ec_datagram_npwr(datagram, slave->station_address,
|
||||
ec_datagram_fpwr(datagram, slave->station_address,
|
||||
0x0800 + EC_SYNC_PAGE_SIZE * offset,
|
||||
EC_SYNC_PAGE_SIZE * num_syncs);
|
||||
memset(datagram->data, 0x00, EC_SYNC_PAGE_SIZE * num_syncs);
|
||||
|
|
@ -1094,7 +1096,7 @@ void ec_fsm_slave_conf_enter_fmmu(ec_fsm_slave_t *fsm /**< slave state machine *
|
|||
}
|
||||
|
||||
// configure FMMUs
|
||||
ec_datagram_npwr(datagram, slave->station_address,
|
||||
ec_datagram_fpwr(datagram, slave->station_address,
|
||||
0x0600, EC_FMMU_PAGE_SIZE * slave->base_fmmu_count);
|
||||
memset(datagram->data, 0x00, EC_FMMU_PAGE_SIZE * slave->base_fmmu_count);
|
||||
for (i = 0; i < slave->config->used_fmmus; i++) {
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ uint8_t *ec_slave_mbox_prepare_send(const ec_slave_t *slave, /**< slave */
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (ec_datagram_npwr(datagram, slave->station_address,
|
||||
if (ec_datagram_fpwr(datagram, slave->station_address,
|
||||
slave->sii_rx_mailbox_offset,
|
||||
slave->sii_rx_mailbox_size))
|
||||
return NULL;
|
||||
|
|
@ -97,7 +97,7 @@ int ec_slave_mbox_prepare_check(const ec_slave_t *slave, /**< slave */
|
|||
ec_datagram_t *datagram /**< datagram */
|
||||
)
|
||||
{
|
||||
if (ec_datagram_nprd(datagram, slave->station_address, 0x808, 8))
|
||||
if (ec_datagram_fprd(datagram, slave->station_address, 0x808, 8))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
|
|
@ -126,7 +126,7 @@ int ec_slave_mbox_prepare_fetch(const ec_slave_t *slave, /**< slave */
|
|||
ec_datagram_t *datagram /**< datagram */
|
||||
)
|
||||
{
|
||||
if (ec_datagram_nprd(datagram, slave->station_address,
|
||||
if (ec_datagram_fprd(datagram, slave->station_address,
|
||||
slave->sii_tx_mailbox_offset,
|
||||
slave->sii_tx_mailbox_size)) return -1;
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue