# Include <Linux/fs. h> # Include <Linux/module. h> # Include <Linux/errno. h> # Include <Linux/kernel. h> # Include <Linux/init. h> # Include <Linux/cdev. h> # Include <Linux/ioport. h> # Include <Linux/PCI. h> # Include <ASM/uaccess. h> # Include <ASM/IO. h> Static volatile unsigned long * gpfcon; // = (volatile unsigned long x) 0x56000050; Static volatile unsigned long * gpfdat; // = (volatile unsigned long x) 0x56000054; Static struct timer_list led_timer; VoidLed_timer_function(Unsigned long data) { Static int cur_val = 0; If (cur_val) { Cur_val = 0; * Gpfdat & = ~ (1 <4 ); } Else { Cur_val = 1; * Gpfdat | = (1 <4 ); } Mod_timer(& Led_timer, jiffies + 50);/* 50*10 Ms = 500 ms = 0.5 s */ } Int led_timer_init (void) { Gpfcon = ioremap (0x56000050, 8);/* obtain the virtual address */ Gpfdat = gpfcon + 1; * Gpfcon & = ~ (0x3 <(4*2 )); * Gpfcon | = (0x1 <(4*2 ));; Init_timer (& led_timer ); Led_timer.function = led_timer_function; Led_timer.expires = jiffies + 50; Add_timer (& led_timer ); } Void led_timer_exit (void) { Del_timer(& Led_timer ); Iounmap (gpfcon ); } Module_init (led_timer_init ); Module_exit (led_timer_exit ); Module_license ("GPL "); |