Merge pull request #4198 from mysterywolf/gettick
[bug] add function rt_tick_get_millisecond() and fix bug #4012
This commit is contained in:
commit
4529e9a741
|
@ -58,7 +58,7 @@ void SysTick_Handler(void)
|
|||
|
||||
uint32_t HAL_GetTick(void)
|
||||
{
|
||||
return rt_tick_get() * 1000 / RT_TICK_PER_SECOND;
|
||||
return rt_tick_get_millisecond();
|
||||
}
|
||||
|
||||
void HAL_SuspendTick(void)
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rthw.h>
|
||||
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/opt.h"
|
||||
|
@ -617,7 +618,7 @@ u32_t sys_jiffies(void)
|
|||
|
||||
u32_t sys_now(void)
|
||||
{
|
||||
return rt_tick_get() * (1000 / RT_TICK_PER_SECOND);
|
||||
return rt_tick_get_millisecond();
|
||||
}
|
||||
|
||||
#ifdef RT_LWIP_PPP
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rthw.h>
|
||||
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/opt.h"
|
||||
|
@ -627,7 +628,7 @@ u32_t sys_jiffies(void)
|
|||
|
||||
u32_t sys_now(void)
|
||||
{
|
||||
return rt_tick_get() * (1000 / RT_TICK_PER_SECOND);
|
||||
return rt_tick_get_millisecond();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rthw.h>
|
||||
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/opt.h"
|
||||
|
@ -641,7 +642,7 @@ u32_t sys_jiffies(void)
|
|||
|
||||
u32_t sys_now(void)
|
||||
{
|
||||
return rt_tick_get() * (1000 / RT_TICK_PER_SECOND);
|
||||
return rt_tick_get_millisecond();
|
||||
}
|
||||
|
||||
#if MEM_OVERFLOW_CHECK || MEMP_OVERFLOW_CHECK
|
||||
|
|
|
@ -77,6 +77,7 @@ rt_tick_t rt_tick_get(void);
|
|||
void rt_tick_set(rt_tick_t tick);
|
||||
void rt_tick_increase(void);
|
||||
rt_tick_t rt_tick_from_millisecond(rt_int32_t ms);
|
||||
rt_tick_t rt_tick_get_millisecond(void);
|
||||
|
||||
void rt_system_timer_init(void);
|
||||
void rt_system_timer_thread_init(void);
|
||||
|
|
17
src/clock.c
17
src/clock.c
|
@ -13,6 +13,7 @@
|
|||
* 2010-07-13 Bernard fix rt_tick_from_millisecond issue found by kuronca
|
||||
* 2011-06-26 Bernard add rt_tick_set function.
|
||||
* 2018-11-22 Jesven add per cpu tick
|
||||
* 2020-12-29 Meco Man add function rt_tick_get_millisecond()
|
||||
*/
|
||||
|
||||
#include <rthw.h>
|
||||
|
@ -116,5 +117,21 @@ rt_tick_t rt_tick_from_millisecond(rt_int32_t ms)
|
|||
}
|
||||
RTM_EXPORT(rt_tick_from_millisecond);
|
||||
|
||||
/**
|
||||
* This function will provide the passed millisecond from boot.
|
||||
*
|
||||
* @return passed millisecond from boot
|
||||
*/
|
||||
RT_WEAK rt_tick_t rt_tick_get_millisecond(void)
|
||||
{
|
||||
#if 1000 % RT_TICK_PER_SECOND == 0u
|
||||
return rt_tick_get() * (1000u / RT_TICK_PER_SECOND);
|
||||
#else
|
||||
#warning "rt-thread cannot provide a correct 1ms-based tick any longer,\
|
||||
please redefine this function in another file by using a high-precision hard-timer."
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**@}*/
|
||||
|
||||
|
|
Loading…
Reference in New Issue