File: rectangle.c

package info (click to toggle)
rtlinux 3.1pre3-2
  • links: PTS
  • area: non-free
  • in suites: sarge, woody
  • size: 4,892 kB
  • ctags: 4,228
  • sloc: ansic: 26,204; sh: 2,069; makefile: 1,414; perl: 855; tcl: 489; asm: 380; cpp: 42
file content (49 lines) | stat: -rw-r--r-- 893 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* Produce a rectangular wave on output 0 of a parallel port */


#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/version.h>
#include <linux/cons.h>
#include <asm/io.h>

#include <rtl_sched.h>
#include "common.h"




RT_TASK mytask;
RT_TASK mytask2;

void fun(int t) {
	while(1){
		outb(t, LPT_PORT);		/* write on the parallel port */
		rt_task_wait();
	}
}


int init_module(void)
{
	RTIME now = rt_get_time();

		/* this task will be setting the bit */
	rt_task_init(&mytask, fun, 0xffff, 3000, 4);

		/* this task will be resetting the bit */
	rt_task_init(&mytask2, fun, 0, 3000, 5);


	/* the 2 tasks run periodically with an offset of 200000 time units */
	rt_task_make_periodic(&mytask, now + 3000000, 500000);
	rt_task_make_periodic(&mytask2, now + 3200000, 500000);
	return 0;
}


void cleanup_module(void)
{
	rt_task_delete(&mytask);
	rt_task_delete(&mytask2);
}