[LPC3250] High Resoulution Timer Support
임베디드/LPC3250 2012. 3. 28. 13:32
linux kernel 2.6.27.8에서 설정한다.
이 기능은 고분해능 타이머를 사용 할 수 있게 해 준다.
이 타이머는 나노초 단위로 작동한다.
해당하는 함수로는
예)void hrtimer_init( struct hrtimer *time, clockid_t which_clock,
enum hrtimer_mode mode ); int hrtimer_start(struct hrtimer *timer, ktime_t time,const enum hrtimer_mode mode);
int hrtimer_cancel(struct hrtimer *timer); int hrtimer_try_to_cancel(struct hrtimer *timer);int hrtimer_callback_running(struct hrtimer *timer);
#include <linux/kernel.h> #include <linux/module.h> #include <linux/hrtimer.h> #include <linux/ktime.h> MODULE_LICENSE( "GPL" ); #define MS_TO_NS(x) (x * 1E6L) static struct hrtimer hr_timer; enum hrtimer_restart my_hrtimer_callback( struct hrtimer *timer ) { printk( "my_hrtimer_callback called (%ld).\n", jiffies ); return HRTIMER_NORESTART; } int init_module( void ) { ktime_t ktime; unsigned long delay_in_ms = 200L; printk("HR Timer module installing\n"); ktime = ktime_set( 0, MS_TO_NS(delay_in_ms) ); hrtimer_init( &hr_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL ); hr_timer.function = &my_hrtimer_callback; printk( "Starting timer to fire in %ldms (%ld)\n",
delay_in_ms, jiffies ); hrtimer_start( &hr_timer, ktime, HRTIMER_MODE_REL ); return 0; } void cleanup_module( void ) { int ret; ret = hrtimer_cancel( &hr_timer ); if (ret) printk("The timer was still in use...\n"); printk("HR Timer module uninstalling\n"); return; }
'임베디드 > LPC3250' 카테고리의 다른 글
stage1 app information (0) | 2012.04.05 |
---|---|
[LPC3250] bootargs (0) | 2012.03.28 |
[LPC3250] root 파일 시스템 파일명 (0) | 2012.03.28 |
[LPC3250] Kernel boot message (0) | 2012.03.28 |
[LPC3250] kernel partition (0) | 2012.03.28 |