Renamed some fields in ec_sii_request_t to word addressing.
authorFlorian Pose <fp@igh-essen.com>
Mon, 09 Jun 2008 14:32:16 +0000
changeset 979 405cc2d033e0
parent 978 2962baf7e6d1
child 980 c07dd38243ba
Renamed some fields in ec_sii_request_t to word addressing.
master/fsm_master.c
master/fsm_master.h
master/fsm_sii.c
master/fsm_sii.h
master/slave.c
--- a/master/fsm_master.c	Mon Jun 09 13:45:22 2008 +0000
+++ b/master/fsm_master.c	Mon Jun 09 14:32:16 2008 +0000
@@ -324,8 +324,8 @@
                     request->slave->ring_position);
         fsm->sii_request = request;
         fsm->sii_index = 0;
-        ec_fsm_sii_write(&fsm->fsm_sii, request->slave, request->word_offset,
-                request->data, EC_FSM_SII_USE_CONFIGURED_ADDRESS);
+        ec_fsm_sii_write(&fsm->fsm_sii, request->slave, request->offset,
+                request->words, EC_FSM_SII_USE_CONFIGURED_ADDRESS);
         fsm->state = ec_fsm_master_state_write_sii;
         fsm->state(fsm); // execute immediately
         return 1;
@@ -791,10 +791,10 @@
     }
 
     fsm->sii_index++;
-    if (fsm->sii_index < request->word_size) {
+    if (fsm->sii_index < request->nwords) {
         ec_fsm_sii_write(&fsm->fsm_sii, slave,
-                request->word_offset + fsm->sii_index,
-                request->data + fsm->sii_index * 2,
+                request->offset + fsm->sii_index,
+                request->words + fsm->sii_index,
                 EC_FSM_SII_USE_CONFIGURED_ADDRESS);
         ec_fsm_sii_exec(&fsm->fsm_sii); // execute immediately
         return;
@@ -803,7 +803,7 @@
     // finished writing SII
     if (master->debug_level)
         EC_DBG("Finished writing %u words of SII data to slave %u.\n",
-                request->word_size, slave->ring_position);
+                request->nwords, slave->ring_position);
     request->state = EC_REQUEST_SUCCESS;
     wake_up(&master->sii_queue);
 
--- a/master/fsm_master.h	Mon Jun 09 13:45:22 2008 +0000
+++ b/master/fsm_master.h	Mon Jun 09 14:32:16 2008 +0000
@@ -55,12 +55,12 @@
 /** SII write request.
  */
 typedef struct {
-    struct list_head list; /**< list head */
-    ec_slave_t *slave; /**< EtherCAT slave */
-    off_t word_offset; /**< SII address in words */
-    size_t word_size; /**< data size in words */
-    const uint8_t *data; /**< pointer to the data */
-    ec_request_state_t state; /**< state of the request */
+    struct list_head list; /**< List head. */
+    ec_slave_t *slave; /**< EtherCAT slave. */
+    uint16_t offset; /**< SII word offset. */
+    size_t nwords; /**< Number of words. */
+    const uint16_t *words; /**< Pointer to the data words. */
+    ec_request_state_t state; /**< State of the request. */
 } ec_sii_write_request_t;
 
 /*****************************************************************************/
--- a/master/fsm_sii.c	Mon Jun 09 13:45:22 2008 +0000
+++ b/master/fsm_sii.c	Mon Jun 09 14:32:16 2008 +0000
@@ -117,7 +117,7 @@
 void ec_fsm_sii_write(ec_fsm_sii_t *fsm, /**< finite state machine */
                       ec_slave_t *slave, /**< slave to read from */
                       uint16_t word_offset, /**< offset to read from */
-                      const uint8_t *value, /**< pointer to 2 bytes of data */
+                      const uint16_t *value, /**< pointer to 2 bytes of data */
                       ec_fsm_sii_addressing_t mode /**< addressing scheme */
                       )
 {
--- a/master/fsm_sii.h	Mon Jun 09 13:45:22 2008 +0000
+++ b/master/fsm_sii.h	Mon Jun 09 14:32:16 2008 +0000
@@ -85,7 +85,7 @@
 void ec_fsm_sii_read(ec_fsm_sii_t *, ec_slave_t *,
                      uint16_t, ec_fsm_sii_addressing_t);
 void ec_fsm_sii_write(ec_fsm_sii_t *, ec_slave_t *, uint16_t,
-        const uint8_t *, ec_fsm_sii_addressing_t);
+        const uint16_t *, ec_fsm_sii_addressing_t);
 
 int ec_fsm_sii_exec(ec_fsm_sii_t *);
 int ec_fsm_sii_success(ec_fsm_sii_t *);
--- a/master/slave.c	Mon Jun 09 13:45:22 2008 +0000
+++ b/master/slave.c	Mon Jun 09 14:32:16 2008 +0000
@@ -961,14 +961,14 @@
     // init SII write request
     INIT_LIST_HEAD(&request.list);
     request.slave = slave;
-    request.data = data;
-    request.word_offset = 0;
-    request.word_size = size / 2;
-
-    if (request.word_size < 0x0041) {
+    request.words = (const uint16_t *) data;
+    request.offset = 0;
+    request.nwords = size / 2;
+
+    if (request.nwords < 0x0041) {
         EC_ERR("SII data too short (%u words)! Mimimum is"
                 " 40 fixed words + 1 delimiter. Dropping.\n",
-                request.word_size);
+                request.nwords);
         return -EINVAL;
     }
 
@@ -978,18 +978,15 @@
         EC_WARN("SII CRC incorrect. Must be 0x%02x.\n", crc);
     }
 
-    cat_header = (const uint16_t *) request.data
-		+ EC_FIRST_SII_CATEGORY_OFFSET;
+    cat_header = request.words + EC_FIRST_SII_CATEGORY_OFFSET;
     cat_type = EC_READ_U16(cat_header);
     while (cat_type != 0xFFFF) { // cycle through categories
-        if (cat_header + 1 >
-				(const uint16_t *) request.data + request.word_size) {
+        if (cat_header + 1 > request.words + request.nwords) {
             EC_ERR("SII data corrupted! Dropping.\n");
             return -EINVAL;
         }
         cat_size = EC_READ_U16(cat_header + 1);
-        if (cat_header + cat_size + 2 >
-				(const uint16_t *) request.data + request.word_size) {
+        if (cat_header + cat_size + 2 > request.words + request.nwords) {
             EC_ERR("SII data corrupted! Dropping.\n");
             return -EINVAL;
         }
@@ -1052,9 +1049,9 @@
     // init SII write request
     INIT_LIST_HEAD(&request.list);
     request.slave = slave;
-    request.data = sii_data;
-    request.word_offset = 0x0000;
-    request.word_size = 8;
+    request.words = (const uint16_t *) sii_data;
+    request.offset = 0x0000;
+    request.nwords = 8;
 
     if ((ret = ec_slave_schedule_sii_writing(&request)))
         return ret; // error code