Implemented missing datagram types.
--- a/NEWS Fri Feb 22 12:29:30 2008 +0000
+++ b/NEWS Fri Feb 22 15:35:39 2008 +0000
@@ -49,6 +49,7 @@
* 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.
-------------------------------------------------------------------------------
--- a/TODO Fri Feb 22 12:29:30 2008 +0000
+++ b/TODO Fri Feb 22 15:35:39 2008 +0000
@@ -22,7 +22,6 @@
* 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:
--- a/master/datagram.c Fri Feb 22 12:29:30 2008 +0000
+++ b/master/datagram.c Fri Feb 22 15:35:39 2008 +0000
@@ -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 @@
/** 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 @@
*
* \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,82 +133,21 @@
/*****************************************************************************/
-/** 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 */
- )
+ * \return 0 in case of success, else < 0
+ */
+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;
}
@@ -215,24 +155,151 @@
/** 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 */
- )
+ * \return 0 in case of success, else < 0
+ */
+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;
}
@@ -240,22 +307,18 @@
/** 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 */
- )
+ * \return 0 in case of success, else < 0
+ */
+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;
}
@@ -263,38 +326,99 @@
/** 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 */
- )
+ * \return 0 in case of success, else < 0
+ */
+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_FUNC_FOOTER;
-}
-
-/*****************************************************************************/
-
-/** Initializes an EtherCAT LRW datagram.
- *
- * Logical read write.
+ 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.
+ *
+ * \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_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. */
--- a/master/datagram.h Fri Feb 22 12:29:30 2008 +0000
+++ b/master/datagram.h Fri Feb 22 15:35:39 2008 +0000
@@ -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_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 *);
--- a/master/fsm_change.c Fri Feb 22 12:29:30 2008 +0000
+++ b/master/fsm_change.c Fri Feb 22 15:35:39 2008 +0000
@@ -157,7 +157,7 @@
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 @@
}
// 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
}
// 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;
}
--- a/master/fsm_master.c Fri Feb 22 12:29:30 2008 +0000
+++ b/master/fsm_master.c Fri Feb 22 15:35:39 2008 +0000
@@ -297,7 +297,7 @@
// 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 @@
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 @@
// 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 @@
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 @@
// 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 @@
// 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 @@
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;
}
--- a/master/fsm_sii.c Fri Feb 22 12:29:30 2008 +0000
+++ b/master/fsm_sii.c Fri Feb 22 15:35:39 2008 +0000
@@ -172,11 +172,11 @@
// 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 @@
// 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 @@
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 @@
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;
}
--- a/master/fsm_sii.h Fri Feb 22 12:29:30 2008 +0000
+++ b/master/fsm_sii.h Fri Feb 22 15:35:39 2008 +0000
@@ -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;
/*****************************************************************************/
--- a/master/fsm_slave.c Fri Feb 22 12:29:30 2008 +0000
+++ b/master/fsm_slave.c Fri Feb 22 15:35:39 2008 +0000
@@ -232,7 +232,7 @@
}
// 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 @@
}
// 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 @@
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 @@
// 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 @@
}
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 @@
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 @@
// 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 @@
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 @@
}
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 @@
" 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 @@
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 @@
}
// 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++) {
--- a/master/mailbox.c Fri Feb 22 12:29:30 2008 +0000
+++ b/master/mailbox.c Fri Feb 22 15:35:39 2008 +0000
@@ -72,7 +72,7 @@
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 @@
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 @@
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;