summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
Diffstat (limited to 'components')
-rw-r--r--components/drivers/hwtimer/hwtimer.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/components/drivers/hwtimer/hwtimer.c b/components/drivers/hwtimer/hwtimer.c
index 49a57be9af..c1a7b75ecc 100644
--- a/components/drivers/hwtimer/hwtimer.c
+++ b/components/drivers/hwtimer/hwtimer.c
@@ -40,8 +40,8 @@ rt_inline rt_uint32_t timeout_calc(rt_hwtimer_t *timer, rt_hwtimerval_t *tv)
if (timeout <= overflow)
{
- counter = timeout*timer->freq;
- devi = tv_sec - (counter/(float)timer->freq)*i;
+ counter = (rt_uint32_t)(timeout * timer->freq);
+ devi = tv_sec - (counter / (float)timer->freq) * i;
/* Minimum calculation error */
if (devi > devi_min)
{
@@ -65,7 +65,7 @@ rt_inline rt_uint32_t timeout_calc(rt_hwtimer_t *timer, rt_hwtimerval_t *tv)
timer->cycles = i;
timer->reload = i;
timer->period_sec = timeout;
- counter = timeout*timer->freq;
+ counter = (rt_uint32_t)(timeout * timer->freq);
return counter;
}
@@ -160,12 +160,12 @@ static rt_size_t rt_hwtimer_read(struct rt_device *dev, rt_off_t pos, void *buff
if (timer->info->cntmode == HWTIMER_CNTMODE_DW)
{
- cnt = (timer->freq * timer->period_sec) - cnt;
+ cnt = (rt_uint32_t)(timer->freq * timer->period_sec) - cnt;
}
t = overflow * timer->period_sec + cnt/(float)timer->freq;
- tv.sec = t;
- tv.usec = (t - tv.sec) * 1000000;
+ tv.sec = (rt_int32_t)t;
+ tv.usec = (rt_int32_t)((t - tv.sec) * 1000000);
size = size > sizeof(tv)? sizeof(tv) : size;
rt_memcpy(buffer, &tv, size);