--- a/TODO Tue Mar 04 09:57:36 2008 +0000
+++ b/TODO Tue Mar 04 10:18:02 2008 +0000
@@ -8,8 +8,6 @@
Version 1.4.0:
-* Realtime interface changes:
- - SDO access.
* Mailbox handler
* READMEs for examples.
* Remove get_cycles() calls and references to cpu_khz to increase
--- a/master/fsm_coe.c Tue Mar 04 09:57:36 2008 +0000
+++ b/master/fsm_coe.c Tue Mar 04 10:18:02 2008 +0000
@@ -180,10 +180,10 @@
/*****************************************************************************/
/**
- Starts to download an Sdo to a slave.
-*/
-
-void ec_fsm_coe_download(
+ Starts to transfer an Sdo to/from a slave.
+*/
+
+void ec_fsm_coe_transfer(
ec_fsm_coe_t *fsm, /**< State machine. */
ec_slave_t *slave, /**< EtherCAT slave. */
ec_sdo_request_t *request /**< Sdo request. */
@@ -191,23 +191,10 @@
{
fsm->slave = slave;
fsm->request = request;
- fsm->state = ec_fsm_coe_down_start;
-}
-
-/*****************************************************************************/
-
-/**
- Starts to upload an Sdo from a slave.
-*/
-
-void ec_fsm_coe_upload(ec_fsm_coe_t *fsm, /**< finite state machine */
- ec_slave_t *slave, /**< EtherCAT slave */
- ec_sdo_request_t *request /**< Sdo request */
- )
-{
- fsm->slave = slave;
- fsm->request = request;
- fsm->state = ec_fsm_coe_up_start;
+ if (request->dir == EC_DIR_OUTPUT)
+ fsm->state = ec_fsm_coe_down_start;
+ else
+ fsm->state = ec_fsm_coe_up_start;
}
/*****************************************************************************/
--- a/master/fsm_coe.h Tue Mar 04 09:57:36 2008 +0000
+++ b/master/fsm_coe.h Tue Mar 04 10:18:02 2008 +0000
@@ -73,8 +73,7 @@
void ec_fsm_coe_clear(ec_fsm_coe_t *);
void ec_fsm_coe_dictionary(ec_fsm_coe_t *, ec_slave_t *);
-void ec_fsm_coe_download(ec_fsm_coe_t *, ec_slave_t *, ec_sdo_request_t *);
-void ec_fsm_coe_upload(ec_fsm_coe_t *, ec_slave_t *, ec_sdo_request_t *);
+void ec_fsm_coe_transfer(ec_fsm_coe_t *, ec_slave_t *, ec_sdo_request_t *);
int ec_fsm_coe_exec(ec_fsm_coe_t *);
int ec_fsm_coe_success(ec_fsm_coe_t *);
--- a/master/fsm_coe_map.c Tue Mar 04 09:57:36 2008 +0000
+++ b/master/fsm_coe_map.c Tue Mar 04 10:18:02 2008 +0000
@@ -184,7 +184,7 @@
ec_sdo_request_address(&fsm->request, fsm->sync_sdo_index, 0);
ecrt_sdo_request_read(&fsm->request);
fsm->state = ec_fsm_coe_map_state_pdo_count;
- ec_fsm_coe_upload(fsm->fsm_coe, fsm->slave, &fsm->request);
+ ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request);
ec_fsm_coe_exec(fsm->fsm_coe); // execute immediately
return;
}
@@ -240,7 +240,7 @@
fsm->sync_subindex);
ecrt_sdo_request_read(&fsm->request);
fsm->state = ec_fsm_coe_map_state_pdo;
- ec_fsm_coe_upload(fsm->fsm_coe, fsm->slave, &fsm->request);
+ ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request);
ec_fsm_coe_exec(fsm->fsm_coe); // execute immediately
return;
}
@@ -297,7 +297,7 @@
ec_sdo_request_address(&fsm->request, fsm->pdo->index, 0);
ecrt_sdo_request_read(&fsm->request);
fsm->state = ec_fsm_coe_map_state_pdo_entry_count;
- ec_fsm_coe_upload(fsm->fsm_coe, fsm->slave, &fsm->request);
+ ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request);
ec_fsm_coe_exec(fsm->fsm_coe); // execute immediately
}
@@ -344,7 +344,7 @@
ec_sdo_request_address(&fsm->request, fsm->pdo->index, fsm->pdo_subindex);
ecrt_sdo_request_read(&fsm->request);
fsm->state = ec_fsm_coe_map_state_pdo_entry;
- ec_fsm_coe_upload(fsm->fsm_coe, fsm->slave, &fsm->request);
+ ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request);
ec_fsm_coe_exec(fsm->fsm_coe); // execute immediately
return;
}
--- a/master/fsm_master.c Tue Mar 04 09:57:36 2008 +0000
+++ b/master/fsm_master.c Tue Mar 04 10:18:02 2008 +0000
@@ -402,7 +402,7 @@
fsm->sdo_request = req;
fsm->slave = slave;
fsm->state = ec_fsm_master_state_sdo_request;
- ec_fsm_coe_upload(&fsm->fsm_coe, slave, req);
+ ec_fsm_coe_transfer(&fsm->fsm_coe, slave, req);
ec_fsm_coe_exec(&fsm->fsm_coe); // execute immediately
return 1;
}
@@ -444,7 +444,7 @@
fsm->sdo_request = &request->req;
fsm->slave = slave;
fsm->state = ec_fsm_master_state_sdo_request;
- ec_fsm_coe_upload(&fsm->fsm_coe, slave, &request->req);
+ ec_fsm_coe_transfer(&fsm->fsm_coe, slave, &request->req);
ec_fsm_coe_exec(&fsm->fsm_coe); // execute immediately
return 1;
}
--- a/master/fsm_pdo_config.c Tue Mar 04 09:57:36 2008 +0000
+++ b/master/fsm_pdo_config.c Tue Mar 04 10:18:02 2008 +0000
@@ -220,7 +220,7 @@
fsm->pdo->index);
fsm->state = ec_fsm_pdo_config_state_zero_count;
- ec_fsm_coe_download(fsm->fsm_coe, fsm->slave, &fsm->request);
+ ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request);
ec_fsm_coe_exec(fsm->fsm_coe); // execute immediately
}
@@ -260,7 +260,7 @@
value, fsm->entry_count);
fsm->state = ec_fsm_pdo_config_state_add_entry;
- ec_fsm_coe_download(fsm->fsm_coe, fsm->slave, &fsm->request);
+ ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request);
ec_fsm_coe_exec(fsm->fsm_coe); // execute immediately
}
@@ -326,7 +326,7 @@
fsm->entry_count);
fsm->state = ec_fsm_pdo_config_state_entry_count;
- ec_fsm_coe_download(fsm->fsm_coe, fsm->slave, &fsm->request);
+ ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request);
ec_fsm_coe_exec(fsm->fsm_coe); // execute immediately
return;
}
--- a/master/fsm_pdo_mapping.c Tue Mar 04 09:57:36 2008 +0000
+++ b/master/fsm_pdo_mapping.c Tue Mar 04 10:18:02 2008 +0000
@@ -210,7 +210,7 @@
EC_DBG("Setting Pdo count to zero for SM%u.\n", fsm->sync->index);
fsm->state = ec_fsm_pdo_mapping_state_zero_count;
- ec_fsm_coe_download(fsm->fsm_coe, fsm->slave, &fsm->request);
+ ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request);
ec_fsm_coe_exec(fsm->fsm_coe); // execute immediately
return;
}
@@ -254,7 +254,7 @@
fsm->pdo->index, fsm->pdo_count);
fsm->state = ec_fsm_pdo_mapping_state_add_pdo;
- ec_fsm_coe_download(fsm->fsm_coe, fsm->slave, &fsm->request);
+ ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request);
ec_fsm_coe_exec(fsm->fsm_coe); // execute immediately
}
@@ -320,7 +320,7 @@
fsm->pdo_count);
fsm->state = ec_fsm_pdo_mapping_state_pdo_count;
- ec_fsm_coe_download(fsm->fsm_coe, fsm->slave, &fsm->request);
+ ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request);
ec_fsm_coe_exec(fsm->fsm_coe); // execute immediately
return;
}
--- a/master/fsm_slave_config.c Tue Mar 04 09:57:36 2008 +0000
+++ b/master/fsm_slave_config.c Tue Mar 04 10:18:02 2008 +0000
@@ -451,7 +451,7 @@
fsm->request = list_entry(fsm->slave->config->sdo_configs.next,
ec_sdo_request_t, list);
ecrt_sdo_request_write(fsm->request);
- ec_fsm_coe_download(&fsm->fsm_coe, fsm->slave, fsm->request);
+ ec_fsm_coe_transfer(&fsm->fsm_coe, fsm->slave, fsm->request);
ec_fsm_coe_exec(&fsm->fsm_coe); // execute immediately
}
@@ -480,7 +480,7 @@
fsm->request = list_entry(fsm->request->list.next, ec_sdo_request_t,
list);
ecrt_sdo_request_write(fsm->request);
- ec_fsm_coe_download(&fsm->fsm_coe, fsm->slave, fsm->request);
+ ec_fsm_coe_transfer(&fsm->fsm_coe, fsm->slave, fsm->request);
ec_fsm_coe_exec(&fsm->fsm_coe); // execute immediately
return;
}
--- a/master/sdo_request.c Tue Mar 04 09:57:36 2008 +0000
+++ b/master/sdo_request.c Tue Mar 04 10:18:02 2008 +0000
@@ -57,6 +57,7 @@
req->data = NULL;
req->mem_size = 0;
req->data_size = 0;
+ req->dir = EC_DIR_OUTPUT;
req->state = EC_REQUEST_COMPLETE;
}
@@ -181,6 +182,7 @@
void ecrt_sdo_request_read(ec_sdo_request_t *req)
{
+ req->dir = EC_DIR_INPUT;
req->state = EC_REQUEST_QUEUED;
}
@@ -188,6 +190,7 @@
void ecrt_sdo_request_write(ec_sdo_request_t *req)
{
+ req->dir = EC_DIR_OUTPUT;
req->state = EC_REQUEST_QUEUED;
}
@@ -199,3 +202,5 @@
EXPORT_SYMBOL(ecrt_sdo_request_error);
EXPORT_SYMBOL(ecrt_sdo_request_read);
EXPORT_SYMBOL(ecrt_sdo_request_write);
+
+/*****************************************************************************/
--- a/master/sdo_request.h Tue Mar 04 09:57:36 2008 +0000
+++ b/master/sdo_request.h Tue Mar 04 10:18:02 2008 +0000
@@ -58,6 +58,9 @@
uint8_t *data; /**< Pointer to Sdo data. */
size_t mem_size; /**< Size of Sdo data memory. */
size_t data_size; /**< Size of Sdo data. */
+ ec_direction_t dir; /**< Direction. EC_DIR_OUTPUT means downloading to
+ the slave, EC_DIR_INPUT means uploading from the
+ slave. */
ec_request_state_t state; /**< Sdo request state. */
};
--- a/master/slave_config.c Tue Mar 04 09:57:36 2008 +0000
+++ b/master/slave_config.c Tue Mar 04 10:18:02 2008 +0000
@@ -709,6 +709,10 @@
kfree(req);
return NULL;
}
+
+ // prepare data for optional writing
+ memset(req->data, 0x00, size);
+ req->data_size = size;
list_add_tail(&req->list, &sc->sdo_requests);
return req;