ecrt_master_prepare_async_io() hinzugefügt.
This commit is contained in:
parent
e310c9f3e4
commit
c9e8fc62c9
|
|
@ -49,6 +49,7 @@ void ecrt_master_deactivate(ec_master_t *master);
|
|||
void ecrt_master_sync_io(ec_master_t *master);
|
||||
void ecrt_master_async_send(ec_master_t *master);
|
||||
void ecrt_master_async_receive(ec_master_t *master);
|
||||
void ecrt_master_prepare_async_io(ec_master_t *master);
|
||||
void ecrt_master_debug(ec_master_t *master, int level);
|
||||
void ecrt_master_print(const ec_master_t *master);
|
||||
int ecrt_master_sdo_write(ec_master_t *master,
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@ void ec_master_reset(ec_master_t *master
|
|||
|
||||
master->command_index = 0;
|
||||
master->debug_level = 0;
|
||||
master->timeout = 100; // us
|
||||
master->stats.timeouts = 0;
|
||||
master->stats.delayed = 0;
|
||||
master->stats.corrupted = 0;
|
||||
|
|
@ -857,7 +858,7 @@ void ecrt_master_sync_io(ec_master_t *master)
|
|||
ec_master_send_commands(master);
|
||||
|
||||
t_start = get_cycles(); // Sendezeit nehmen
|
||||
t_timeout = 100 * cpu_khz / 1000; // 100us
|
||||
t_timeout = master->timeout * cpu_khz / 1000;
|
||||
|
||||
do {
|
||||
ec_device_call_isr(master->device);
|
||||
|
|
@ -959,6 +960,37 @@ void ecrt_master_async_receive(ec_master_t *master)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
Bereitet Synchronen Datenverkehr vor.
|
||||
|
||||
Fürgt einmal die Kommandos aller Domains zur Warteschlange hinzu, sendet
|
||||
diese ab und wartet so lange, bis diese anschließend problemlos empfangen
|
||||
werden können.
|
||||
*/
|
||||
|
||||
void ecrt_master_prepare_async_io(ec_master_t *master)
|
||||
{
|
||||
ec_domain_t *domain;
|
||||
cycles_t t_start, t_end, t_timeout;
|
||||
|
||||
// Alle empfangenen Kommandos aus der Liste entfernen
|
||||
list_for_each_entry(domain, &master->domains, list)
|
||||
ecrt_domain_queue(domain);
|
||||
|
||||
ecrt_master_async_send(master);
|
||||
|
||||
t_start = get_cycles(); // Sendezeit nehmen
|
||||
t_timeout = master->timeout * cpu_khz / 1000;
|
||||
|
||||
// Aktiv warten!
|
||||
do {
|
||||
t_end = get_cycles();
|
||||
}
|
||||
while (t_end - t_start < t_timeout);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
Setzt die Debug-Ebene des Masters.
|
||||
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ struct ec_master
|
|||
struct list_head domains; /**< Liste der Prozessdatendomänen */
|
||||
int debug_level; /**< Debug-Level im Master-Code */
|
||||
ec_stats_t stats; /**< Rahmen-Statistiken */
|
||||
unsigned int timeout; /**< Timeout für synchronen Datenaustausch */
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
#include "../include/ecrt.h" // Echtzeitschnittstelle
|
||||
|
||||
//#define ASYNC
|
||||
#define ASYNC
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
|
@ -115,9 +115,8 @@ int __init init_mini_module(void)
|
|||
}
|
||||
|
||||
#ifdef ASYNC
|
||||
ecrt_domain_queue(domain1);
|
||||
ecrt_master_async_send(master);
|
||||
udelay(100);
|
||||
// Einmal senden und warten...
|
||||
ecrt_master_prepare_async_io(master);
|
||||
#endif
|
||||
|
||||
printk("Starting cyclic sample thread.\n");
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
// EtherCAT
|
||||
#include "../include/ecrt.h"
|
||||
|
||||
//#define ASYNC
|
||||
#define ASYNC
|
||||
|
||||
// Defines/Makros
|
||||
#define HZREDUCTION (MSR_ABTASTFREQUENZ / HZ)
|
||||
|
|
@ -229,10 +229,8 @@ int __init init_rt_module(void)
|
|||
#endif
|
||||
|
||||
#ifdef ASYNC
|
||||
ecrt_domain_queue(domain1);
|
||||
ecrt_domain_queue(domain2);
|
||||
ecrt_master_async_send(master);
|
||||
udelay(100);
|
||||
// Einmal senden und warten...
|
||||
ecrt_master_prepare_async_io(master);
|
||||
#endif
|
||||
|
||||
ipipe_init_attr(&attr);
|
||||
|
|
|
|||
Loading…
Reference in New Issue