timer 修改触发时间 时间到了触发指定function log

1
2
3
4
5
6
7
8
9
10
11
12
13
14
static int (struct platform_device *pdev)
{

init_timer(&engpio_delay_timer);
engpio_delay_timer.function = engpio_delay_timer_func;
engpio_delay_timer.data = NULL;
}

static int remove(struct platform_device *pdev)
{
del_timer(&engpio_delay_timer);

return 0;
}

修改触发时间

1HZ=1s,所以触发时间是1s/20=50ms

1
2
printk("Enter %sn", __func__);
mod_timer(&engpio_delay_timer, jiffies + HZ/20);

时间到了触发指定function

1
2
3
4
static void engpio_delay_timer_func(u_long a)
{
printk("Enter %sn", __func__);
}

log

// 时间间隔50ms

[ 0.172768] Enter ldb_enable
[ 0.222668] Enter engpio_delay_timer_func