mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-10-17 16:32:14 +08:00
[example] Sync to latest version.
This commit is contained in:
@@ -48,7 +48,7 @@ static int timer_app_init(void)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
INIT_EXPORT_APP(timer_app_init);
|
||||
INIT_APP_EXPORT(timer_app_init);
|
||||
|
||||
#endif /* RT_USING_PM */
|
||||
|
||||
|
@@ -8,7 +8,7 @@
|
||||
|
||||
static rt_err_t timer_timeout_cb(rt_device_t dev, rt_size_t size)
|
||||
{
|
||||
rt_kprintf("HT %d\n", rt_tick_get());
|
||||
rt_kprintf("enter hardware timer isr\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -35,7 +35,7 @@ int hwtimer(void)
|
||||
return -1;
|
||||
}
|
||||
|
||||
rt_device_set_rx_indicate(dev, timer_timeout_cb);
|
||||
/* ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
/* <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(Ĭ<><C4AC>1Mhz<68><7A>֧<EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>) */
|
||||
err = rt_device_control(dev, HWTIMER_CTRL_FREQ_SET, &freq);
|
||||
if (err != RT_EOK)
|
||||
@@ -69,12 +69,34 @@ int hwtimer(void)
|
||||
rt_device_read(dev, 0, &val, sizeof(val));
|
||||
rt_kprintf("Read: Sec = %d, Usec = %d\n", val.sec, val.usec);
|
||||
|
||||
/* <20><>ʱִ<CAB1>лص<D0BB><D8B5><EFBFBD><EFBFBD><EFBFBD> -- <20><><EFBFBD><EFBFBD>ģʽ */
|
||||
/* <20><><EFBFBD>ó<EFBFBD>ʱ<EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD> */
|
||||
rt_device_set_rx_indicate(dev, timer_timeout_cb);
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>ģʽ */
|
||||
mode = HWTIMER_MODE_PERIOD;
|
||||
err = rt_device_control(dev, HWTIMER_CTRL_MODE_SET, &mode);
|
||||
|
||||
/* <20><><EFBFBD>ö<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʱֵ<CAB1><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1> */
|
||||
val.sec = t;
|
||||
val.usec = 0;
|
||||
rt_kprintf("SetTime: Sec %d, Usec %d\n", val.sec, val.usec);
|
||||
if (rt_device_write(dev, 0, &val, sizeof(val)) != sizeof(val))
|
||||
{
|
||||
rt_kprintf("SetTime Fail\n");
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
/* <20>ȴ<EFBFBD><C8B4>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4> */
|
||||
rt_thread_delay((t + 1)*RT_TICK_PER_SECOND);
|
||||
|
||||
EXIT:
|
||||
err = rt_device_close(dev);
|
||||
rt_kprintf("Close %s\n", TIMER);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
FINSH_FUNCTION_EXPORT(hwtimer, "Test hardware timer");
|
||||
#ifdef FINSH_USING_MSH
|
||||
MSH_CMD_EXPORT(hwtimer, "Test hardware timer");
|
||||
#endif
|
||||
#endif /* RT_USING_HWTIMER */
|
||||
|
@@ -77,7 +77,7 @@ typedef rt_base_t rt_off_t; /**< Type for offset */
|
||||
#define RT_TRUE 1 /**< boolean true */
|
||||
#define RT_FALSE 0 /**< boolean fails */
|
||||
|
||||
/*@}*/
|
||||
/**@}*/
|
||||
|
||||
/* maximum value of base type */
|
||||
#define RT_UINT8_MAX 0xff /**< Maxium number of UINT8 */
|
||||
|
Reference in New Issue
Block a user