00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
#include <linux/kernel.h>
00022
#include <linux/module.h>
00023
#include <rtai.h>
00024
#include <rtai_leds.h>
00025
00026
MODULE_LICENSE(
"GPL");
00027
00028 static unsigned int leds;
00029 static unsigned long port;
00030
00031 static void (*leds_func)(
unsigned long port,
unsigned int leds);
00032
00033 void rt_leds_set_mask(
unsigned int mask,
unsigned int value)
00034 {
00035
leds &= ~mask;
00036
leds |= (mask & value);
00037
leds_func(
port,
leds);
00038 }
00039
00040 void rt_toggle_leds(
unsigned int l)
00041 {
00042
leds ^= l;
00043
leds_func(
port,
leds);
00044 }
00045
00046 void rt_reset_leds(
unsigned int l)
00047 {
00048
leds &= ~l;
00049
leds_func(
port,
leds);
00050 }
00051
00052 void rt_set_leds(
unsigned int l)
00053 {
00054
leds |= l;
00055
leds_func(
port,
leds);
00056 }
00057
00058 void rt_clear_leds(
void)
00059 {
00060
leds = 0;
00061
leds_func(
port,
leds);
00062 }
00063
00064 unsigned int rt_get_leds(
void)
00065 {
00066
return leds;
00067 }
00068
00069 void rt_set_leds_port(
int p)
00070 {
00071
port = p;
00072 }
00073
00074 void rt_config_leds(
unsigned int type,
00075
void (*func)(
unsigned long p,
unsigned int l),
00076
unsigned long p)
00077 {
00078
00079
switch(type){
00080
case 0:
00081
leds_func = func;
00082
port = p;
00083
break;
00084
case 1:
00085
leds_func =
LEDS_DEFAULT_FUNC;
00086
port =
LEDS_DEFAULT_PORT;
00087
break;
00088 }
00089 }
00090
00091 int __rtai_leds_init(
void)
00092 {
00093
rt_config_leds(1,NULL,0);
00094
00095
printk(KERN_INFO
"RTAI[leds]: loaded.\n");
00096
return(0);
00097 }
00098
00099 void __rtai_leds_exit(
void)
00100 {
00101
printk(KERN_INFO
"RTAI[leds]: unloaded.\n");
00102 }
00103
00104
#ifndef CONFIG_RTAI_LEDS_BUILTIN
00105
module_init(__rtai_leds_init);
00106
module_exit(__rtai_leds_exit);
00107
#endif
00108
00109
#ifdef CONFIG_KBUILD
00110
EXPORT_SYMBOL(rt_leds_set_mask);
00111
EXPORT_SYMBOL(rt_toggle_leds);
00112
EXPORT_SYMBOL(rt_reset_leds);
00113
EXPORT_SYMBOL(rt_set_leds);
00114
EXPORT_SYMBOL(rt_clear_leds);
00115
EXPORT_SYMBOL(rt_get_leds);
00116
EXPORT_SYMBOL(rt_set_leds_port);
00117
EXPORT_SYMBOL(rt_config_leds);
00118
#endif