Separated ec_sdo_request_init() and ec_sdo_request_read().
authorFlorian Pose <fp@igh-essen.com>
Mon, 03 Mar 2008 13:26:32 +0000
changeset 852 ab439cbc7a81
parent 851 2bb18adcd204
child 853 726326d0aef4
Separated ec_sdo_request_init() and ec_sdo_request_read().
master/fsm_coe_map.c
master/sdo_entry.c
master/sdo_request.c
master/sdo_request.h
--- a/master/fsm_coe_map.c	Mon Mar 03 11:42:05 2008 +0000
+++ b/master/fsm_coe_map.c	Mon Mar 03 13:26:32 2008 +0000
@@ -70,8 +70,9 @@
         ec_fsm_coe_t *fsm_coe /**< CoE state machine to use */
         )
 {
+    fsm->fsm_coe = fsm_coe;
     fsm->state = NULL;
-    fsm->fsm_coe = fsm_coe;
+    ec_sdo_request_init(&fsm->request);
     ec_pdo_mapping_init(&fsm->mapping);
 }
 
@@ -83,6 +84,7 @@
 
 void ec_fsm_coe_map_clear(ec_fsm_coe_map_t *fsm /**< finite state machine */)
 {
+    ec_sdo_request_clear(&fsm->request);
     ec_pdo_mapping_clear(&fsm->mapping);
 }
 
@@ -179,7 +181,7 @@
 
         ec_pdo_mapping_clear_pdos(&fsm->mapping);
 
-        ec_sdo_request_init(&fsm->request, fsm->sync_sdo_index, 0);
+        ec_sdo_request_read(&fsm->request, fsm->sync_sdo_index, 0);
         fsm->state = ec_fsm_coe_map_state_pdo_count;
         ec_fsm_coe_upload(fsm->fsm_coe, fsm->slave, &fsm->request);
         ec_fsm_coe_exec(fsm->fsm_coe); // execute immediately
@@ -233,7 +235,7 @@
         )
 {
     if (fsm->sync_subindex <= fsm->sync_subindices) {
-        ec_sdo_request_init(&fsm->request, fsm->sync_sdo_index,
+        ec_sdo_request_read(&fsm->request, fsm->sync_sdo_index,
                 fsm->sync_subindex);
         fsm->state = ec_fsm_coe_map_state_pdo;
         ec_fsm_coe_upload(fsm->fsm_coe, fsm->slave, &fsm->request);
@@ -290,7 +292,7 @@
 
     list_add_tail(&fsm->pdo->list, &fsm->mapping.pdos);
 
-    ec_sdo_request_init(&fsm->request, fsm->pdo->index, 0);
+    ec_sdo_request_read(&fsm->request, fsm->pdo->index, 0);
     fsm->state = ec_fsm_coe_map_state_pdo_entry_count;
     ec_fsm_coe_upload(fsm->fsm_coe, fsm->slave, &fsm->request);
     ec_fsm_coe_exec(fsm->fsm_coe); // execute immediately
@@ -336,7 +338,7 @@
         )
 {
     if (fsm->pdo_subindex <= fsm->pdo_subindices) {
-        ec_sdo_request_init(&fsm->request, fsm->pdo->index, fsm->pdo_subindex);
+        ec_sdo_request_read(&fsm->request, fsm->pdo->index, fsm->pdo_subindex);
         fsm->state = ec_fsm_coe_map_state_pdo_entry;
         ec_fsm_coe_upload(fsm->fsm_coe, fsm->slave, &fsm->request);
         ec_fsm_coe_exec(fsm->fsm_coe); // execute immediately
--- a/master/sdo_entry.c	Mon Mar 03 11:42:05 2008 +0000
+++ b/master/sdo_entry.c	Mon Mar 03 13:26:32 2008 +0000
@@ -267,7 +267,8 @@
     ec_master_sdo_request_t request;
 
     request.slave = entry->sdo->slave;
-    ec_sdo_request_init(&request.req, entry->sdo->index, entry->subindex);
+    ec_sdo_request_init(&request.req);
+    ec_sdo_request_read(&request.req, entry->sdo->index, entry->subindex);
 
     // schedule request.
     down(&master->sdo_sem);
--- a/master/sdo_request.c	Mon Mar 03 11:42:05 2008 +0000
+++ b/master/sdo_request.c	Mon Mar 03 13:26:32 2008 +0000
@@ -44,19 +44,19 @@
 
 /*****************************************************************************/
 
+void ec_sdo_request_clear_data(ec_sdo_request_t *);
+
+/*****************************************************************************/
+
 /** Sdo request constructor.
  */
 void ec_sdo_request_init(
-        ec_sdo_request_t *req, /**< Sdo request. */
-        uint16_t index, /**< Sdo index. */
-        uint8_t subindex /**< Sdo subindex. */
+        ec_sdo_request_t *req /**< Sdo request. */
         )
 {
-    req->index = index;
-    req->subindex = subindex;
     req->data = NULL;
     req->size = 0;
-    req->state = EC_REQUEST_QUEUED;
+    req->state = EC_REQUEST_COMPLETE;
 }
 
 /*****************************************************************************/
@@ -67,8 +67,40 @@
         ec_sdo_request_t *req /**< Sdo request. */
         )
 {
-    if (req->data)
-        kfree(req->data);
+    ec_sdo_request_clear_data(req);
 }
 
 /*****************************************************************************/
+
+/** Sdo request destructor.
+ */
+void ec_sdo_request_clear_data(
+        ec_sdo_request_t *req /**< Sdo request. */
+        )
+{
+    if (req->data) {
+        kfree(req->data);
+        req->data = NULL;
+    }
+
+    req->size = 0;
+}
+
+/*****************************************************************************/
+
+/** Start an Sdo read operation (download).
+ */
+void ec_sdo_request_read(
+        ec_sdo_request_t *req, /**< Sdo request. */
+        uint16_t index, /**< Sdo index. */
+        uint8_t subindex /**< Sdo subindex. */
+        )
+{
+    req->index = index;
+    req->subindex = subindex;
+    req->state = EC_REQUEST_QUEUED;
+
+    ec_sdo_request_clear_data(req);
+}
+
+/*****************************************************************************/
--- a/master/sdo_request.h	Mon Mar 03 11:42:05 2008 +0000
+++ b/master/sdo_request.h	Mon Mar 03 13:26:32 2008 +0000
@@ -60,9 +60,11 @@
 
 /*****************************************************************************/
 
-void ec_sdo_request_init(ec_sdo_request_t *, uint16_t, uint8_t);
+void ec_sdo_request_init(ec_sdo_request_t *);
 void ec_sdo_request_clear(ec_sdo_request_t *);
 
+void ec_sdo_request_read(ec_sdo_request_t *, uint16_t, uint8_t);
+
 /*****************************************************************************/
 
 #endif