# HG changeset patch # User Florian Pose # Date 1230548118 0 # Node ID 6e8477e16eec8657fc982cfd06df3a39523cece7 # Parent 8765cdafdc1705b8ddb4df13b52b11a8bdb6a19e Reverted rtai example changes. diff -r 8765cdafdc17 -r 6e8477e16eec examples/rtai/rtai_sample.c --- a/examples/rtai/rtai_sample.c Mon Dec 29 10:52:51 2008 +0000 +++ b/examples/rtai/rtai_sample.c Mon Dec 29 10:55:18 2008 +0000 @@ -47,7 +47,7 @@ // Module parameters -#define FREQUENCY 1000 // task frequency in Hz +#define FREQUENCY 2000 // task frequency in Hz #define INHIBIT_TIME 20 #define TIMERTICKS (1000000000 / FREQUENCY) @@ -95,6 +95,9 @@ {} }; +static unsigned int counter = 0; +static unsigned int blink = 0; + /*****************************************************************************/ #ifdef CONFIGURE_PDOS @@ -201,35 +204,42 @@ /*****************************************************************************/ -#define US(x) ((unsigned int) (x) * 1000 / cpu_khz) - void run(long data) { - cycles_t c0, c1, c2, c3, c4; - unsigned int c = 10000; - while (1) { t_last_cycle = get_cycles(); - c0 = get_cycles(); + // receive process data + rt_sem_wait(&master_sem); ecrt_master_receive(master); - c1 = get_cycles(); ecrt_domain_process(domain1); - c2 = get_cycles(); + rt_sem_signal(&master_sem); + + // check process data state (optional) + check_domain1_state(); + + if (counter) { + counter--; + } else { // do this at 1 Hz + counter = FREQUENCY; + + // calculate new process data + blink = !blink; + + // check for master state (optional) + check_master_state(); + + // check for islave configuration state(s) (optional) + check_slave_config_states(); + } + + // write process data + EC_WRITE_U8(domain1_pd + off_dig_out, blink ? 0x06 : 0x09); + + rt_sem_wait(&master_sem); ecrt_domain_queue(domain1); - c3 = get_cycles(); ecrt_master_send(master); - c4 = get_cycles(); - - if (c) { - printk("TTTT4 %6u %4u %4u %4u %4u\n", - c, - US(c1 - c0), - US(c2 - c1), - US(c3 - c2), - US(c4 - c3)); - c--; - } + rt_sem_signal(&master_sem); rt_task_wait_period(); }