diff options
| author | Meco Man <[email protected]> | 2021-03-07 08:34:04 +0800 |
|---|---|---|
| committer | Meco Man <[email protected]> | 2021-03-07 08:34:04 +0800 |
| commit | 08af426f01cf0321719c937d29a1d9315a0feab8 (patch) | |
| tree | cb9c4e5ba1db25c5878b732a2651ec3646efc4d1 /examples/test/hwtimer_test.c | |
| parent | ce86058201432e865b8d7c4096b3675642a43a42 (diff) | |
[example] 格式化整理
Diffstat (limited to 'examples/test/hwtimer_test.c')
| -rw-r--r-- | examples/test/hwtimer_test.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/examples/test/hwtimer_test.c b/examples/test/hwtimer_test.c index 428373dde0..b488c305b2 100644 --- a/examples/test/hwtimer_test.c +++ b/examples/test/hwtimer_test.c @@ -35,8 +35,8 @@ int hwtimer(void) return -1; } - /* ʱ����� */ - /* ����ʱ������(Ĭ��1Mhz��֧�ֵ���С����Ƶ��) */ + /* 时间测量 */ + /* 计数时钟设置(默认1Mhz或支持的最小计数频率) */ err = rt_device_control(dev, HWTIMER_CTRL_FREQ_SET, &freq); if (err != RT_EOK) { @@ -44,13 +44,13 @@ int hwtimer(void) goto EXIT; } - /* ����ģʽ */ + /* 周期模式 */ mode = HWTIMER_MODE_PERIOD; err = rt_device_control(dev, HWTIMER_CTRL_MODE_SET, &mode); tick = rt_tick_get(); rt_kprintf("Start Timer> Tick: %d\n", tick); - /* ���ö�ʱ����ʱֵ��������ʱ�� */ + /* 设置定时器超时值并启动定时器 */ val.sec = t; val.usec = 0; rt_kprintf("SetTime: Sec %d, Usec %d\n", val.sec, val.usec); @@ -62,22 +62,22 @@ int hwtimer(void) rt_kprintf("Sleep %d sec\n", t); rt_thread_delay(t*RT_TICK_PER_SECOND); - /* ֹͣ��ʱ�� */ + /* 停止定时器 */ err = rt_device_control(dev, HWTIMER_CTRL_STOP, RT_NULL); rt_kprintf("Timer Stoped\n"); - /* ��ȡ���� */ + /* 读取计数 */ rt_device_read(dev, 0, &val, sizeof(val)); rt_kprintf("Read: Sec = %d, Usec = %d\n", val.sec, val.usec); - /* ��ʱִ�лص����� -- ����ģʽ */ - /* ���ó�ʱ�ص����� */ + /* 定时执行回调函数 -- 单次模式 */ + /* 设置超时回调函数 */ rt_device_set_rx_indicate(dev, timer_timeout_cb); - /* ����ģʽ */ + /* 单次模式 */ mode = HWTIMER_MODE_PERIOD; err = rt_device_control(dev, HWTIMER_CTRL_MODE_SET, &mode); - /* ���ö�ʱ����ʱֵ��������ʱ�� */ + /* 设置定时器超时值并启动定时器 */ val.sec = t; val.usec = 0; rt_kprintf("SetTime: Sec %d, Usec %d\n", val.sec, val.usec); @@ -87,7 +87,7 @@ int hwtimer(void) goto EXIT; } - /* �ȴ��ص�����ִ�� */ + /* 等待回调函数执行 */ rt_thread_delay((t + 1)*RT_TICK_PER_SECOND); EXIT: |
