QT210 驱动 流水灯
扫描二维码
随时随地手机看文章
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
static struct delayed_work my_work;
//static int watercount=0;
volatile unsigned long *gph0con = NULL;
volatile unsigned long *gph0dat = NULL;
static void waterfun(void)
{
static int watercount=0;
*gph0dat = 0x1 << ((watercount++)%4);//流水灯
//printk("waterfun:watercount:%d\n",watercount);
schedule_delayed_work(&my_work,msecs_to_jiffies(1000));
}
static int __init waterinit(void)
{
int ret;
gph0con = (volatile unsigned long *)ioremap(0xE0200c00, 16);
gph0dat = gph0con + 1;
*gph0con |=0x1111 ;
*gph0con &=~0xf;
INIT_DELAYED_WORK(&my_work,waterfun);
ret = schedule_delayed_work(&my_work,msecs_to_jiffies(1000));
printk("water init:ret:%d\n",ret);
return 0;
}
static void __exit waterexit(void)
{
cancel_delayed_work(&my_work);
//destroy_wor(my_work);
//_work(&my_work);
iounmap(gph0con);
}
module_init(waterinit);
module_exit(waterexit);
MODULE_LICENSE("GPL");