rectangle.c

来自「上传的是rtlinux的源码包」· C语言 代码 · 共 50 行

C
50
字号
/* 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);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?