Chinaunix首页 | 论坛 | 博客
  • 博客访问: 218519
  • 博文数量: 39
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 584
  • 用 户 组: 普通用户
  • 注册时间: 2015-04-18 20:24
个人简介

学习总结,分享快乐。 望指正错误, 共同提高!!!

文章分类

全部博文(39)

分类: 嵌入式

2015-06-17 18:43:40

0> 固定步骤:

1步:定义定时器:
            struct timer_list   my_time;
2步:初始化:
            init_time(&my_time);
3步:实例化:
            my_timer.expirex = jiffies + delay;               /*期望定时值*/
            my_timer.date  =  0;                                /*传给定时器处理函数的参数,不用时写0*/
            my_timer.function = my_fun;                  /*定时器处理函数*/
4步:启动:
            add_timer(&my_timer);                         /*这句话后,定时器开始工作*/
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

1> 小简化操作:
        将2, 3步合并:setup_time(&my_time, my_fun, 0);
                                        my_timer.expirex = jiffies + delay;
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

2> 大简化操作:
           将1,2,3步合并:DEFINE_TIMER(my_time, my_fun, jiffies+delay, 0);
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

4> 更新定时器时刻:
            int mod_timer(struct timer_list *timer, unsigned long expires);

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
5> 移除定时器:
           int del_timer_sync(struct timer_list  *timer);





                 
阅读(3708) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~