base/leds/leds.c

Go to the documentation of this file.
00001 /* 00002 * rtai_leds.c - mini-driver for generic control of digital signals 00003 * 00004 * Copyright (C) 2000 Pierre Cloutier <pcloutier@PoseidonControls.com> 00005 * 2001 David A. Schleef <ds@schleef.org> 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of version 2 of the GNU General Public 00009 * License as published by the Free Software Foundation. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 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 /* !CONFIG_RTAI_LEDS_BUILTIN */ 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 /* CONFIG_KBUILD */

Generated on Thu Nov 20 11:49:51 2008 for RTAI API by doxygen 1.3.8