/* * scx200_gpio_ledpulse.c * * Driver for pulsating LEDS on scx200_gpio mapped to onboard or external * light emitting diodes. * * Copyright (C) 2005 Shane Spencer * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License version 2 as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 021110-1307, USA. */ #include #include #include #include #include #include #include #include #include MODULE_AUTHOR("Shane Spencer "); MODULE_DESCRIPTION("Modulates a sine wave patter acrossed detected/defined LED's on scx200_gpio pins, accepts speed adjustmends per LED"); MODULE_LICENSE("GPL"); MODULE_VERSION("0.0.1"); #include "scx200_gpio_ledpulse.h" static void ledpulse_fire(unsigned long); static struct timer_list ledpulse_ticktock = TIMER_INITIALIZER(ledpulse_fire, 0, 0); typedef struct { long ds_integrator1; long ds_integrator2; unsigned int ds_output; unsigned char intensity; unsigned char active; unsigned char gpio_pin; unsigned char state; unsigned char original_state; unsigned short int position; } led_t; static led_t led[32]; static void ledpulse_fire(unsigned long data) { unsigned int i; for(i=0;i<32;i++) { if(led[i].active) { led[i].position = led[i].position + led[i].intensity; led[i].position = led[i].position % pattern_mask; led[i].ds_integrator1 += pattern[led[i].position] - led[i].ds_output; led[i].ds_integrator2 += led[i].ds_integrator1 - led[i].ds_output; led[i].ds_output = (led[i].ds_integrator2 & 0x8000) ? 0xFFFF : 0x0000; led[i].state = !led[i].ds_output; printk("Ledpulse: LED %d PATTERNMASK %d POSITION %d DATA %d STATE %d2\n", i, pattern_mask, led[i].position, pattern[led[i].position], led[i].state); //scx200_gpio_set(3, led[i].state); } } mod_timer(&ledpulse_ticktock, jiffies + (HZ/50)); printk("Ledpulse: Cycled.\n"); } static int __init ledpulse_init(void) { printk("Ledpulse: Started scx200 gpio LED pulsation.\n"); printk("Ledpulse: Array Test %d\n", sizeof(led)); led[0].active = 1; led[0].intensity = 1; mod_timer(&ledpulse_ticktock, jiffies + (HZ)); return 0; } static void __exit ledpulse_exit(void) { del_timer_sync(&ledpulse_ticktock); printk("Ledpulse: Stopped scx200 gpio LED pulsation, LED state restored.\n"); } module_init(ledpulse_init); module_exit(ledpulse_exit);