[drivers][hwtimer] Fix compilation warning

This commit is contained in:
tyx 2022-04-17 21:39:26 +08:00 committed by guo
parent 175ca2ee09
commit 8aecd43c78
1 changed files with 6 additions and 6 deletions

View File

@ -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);