[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
[rtl] Trying To Use "request_RTirq"
The code below is a modified version of "rt_process.c" found in the 2tasks
example. I have the orginal 2task working but am curious about using an
interrupt instead. From what I read about "request_RTirq" and "free_RTirq"
the below program should send a message to the FIFO everytime the timer
interrupt goes off. Doesn't seem to do that though. Nothing happens than
the linux task (app.c) ends.
I tried changing timer_irq value to 1 (keyboard) and I'll receive the data
message just after hitting the return key on the prompt line. But no matter
how many times I hit the keyboard, nothing comes back from the RT-Task.
I understand "request_RTirq" to work as follows:
request_RTirq ( monitor_irq, execute_some_func );
Whenever the monitor_irq (whichever one I want) goes off, perform the
function (ie execute_some_func). I'm I wrong, or is there something else
that needs to be setup???
Donald Radke
/********************************** Example Program
****************************************/
#define MODULE
#include <stdio.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/version.h>
#include <linux/errno.h>
#include <linux/rt_sched.h>
#include <linux/rtf.h>
#include <asm/rt_irq.h>
#include "control.h"
RT_TASK tasks[2];
static char data[1024];
/* Actual function to handle output */
void irq_handler ( )
{
int i;
for ( i = 0; i < 1024; i++ )
{
data[i] = 'R';
}
rtf_put ( fifo
, &data
, 1024
);
return;
} /* End Of irq_handler */
int main_handler ( unsigned int fifo )
{
struct my_msg_struct msg;
int err;
int timer_irq = 0; /* Set to timer interrupt */
while ((err = rtf_get(3, &msg, sizeof(msg))) == sizeof(msg))
{
switch (msg.command)
{
case START_TASK:
request_RTirq ( timer_irq, &irq_handler );
break;
case STOP_TASK:
free_RTirq ( timer_irq );
break;
default:
return ( -EINVAL );
}
}
if (err != 0)
{
return ( -EINVAL );
}
return ( 0 );
}
int init_module(void)
{
rtf_create(1, 8000);
rtf_create(3, 100); /* input control channel */
rtf_create_handler(3, &main_handler);
return ( 0 );
}
void cleanup_module(void)
{
rtf_destroy(1);
rtf_destroy(3);
}
--- [rtl] ---
For more information on Real-Time Linux see:
http://www.rtlinux.org/