WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
osal_timer

函数

int osal_timer_init (osal_timer *timer)
 Initialize the timer.
 
int osal_timer_start (osal_timer *timer)
 start a timer.
 
int osal_timer_mod (osal_timer *timer, unsigned int interval)
 modify a timer's timeout.
 
int osal_timer_start_on (osal_timer *timer, unsigned long delay, int cpu)
 Start a timer on a particular CPU.
 
int osal_timer_stop (osal_timer *timer)
 Deactivate a timer.
 
int osal_timer_destroy (osal_timer *timer)
 destroy the timer.
 
unsigned long osal_timer_get_private_data (const void *sys_data)
 get_private_data by timer.
 
int osal_timer_destroy_sync (osal_timer *timer)
 deactivate a timer and wait for the handler to finish.
 
unsigned long long osal_sched_clock (void)
 Obtain system time in nanoseconds.
 
unsigned long long osal_get_jiffies (void)
 Obtain the number of Ticks(in liteos) or jiffies(in linux).
 
unsigned long osal_msecs_to_jiffies (const unsigned int m)
 Convert milliseconds to Ticks/jiffies.
 
unsigned int osal_jiffies_to_msecs (const unsigned int n)
 Convert Ticks/jiffies to milliseconds.
 
unsigned int osal_get_cycle_per_tick (void)
 Obtain the number of cycles in one tick.
 
void osal_gettimeofday (osal_timeval *tv)
 Obtaining the Current System Kernel Time.
 
int osal_hrtimer_create (osal_hrtimer *hrtimer)
 Create a high-resolution timer.
 
int osal_hrtimer_start (osal_hrtimer *hrtimer)
 Start a high-resolution timer.
 
int osal_hrtimer_destroy (osal_hrtimer *hrtimer)
 Delete an existing high-resolution timer.
 

详细描述

函数说明

◆ osal_get_cycle_per_tick()

unsigned int osal_get_cycle_per_tick ( void  )

Obtain the number of cycles in one tick.

Description:
This API is used to obtain the number of cycles in one tick.
返回
Number of cycles in one tick.
Support System:
liteos.

◆ osal_get_jiffies()

unsigned long long osal_get_jiffies ( void  )

Obtain the number of Ticks(in liteos) or jiffies(in linux).

Description:
Obtain the number of Ticks(in liteos) or jiffies(in linux).
返回
Return the number of Ticks(in liteos) or jiffies(in linux).
Support System:
linux liteos freertos.

◆ osal_gettimeofday()

void osal_gettimeofday ( osal_timeval tv)

Obtaining the Current System Kernel Time.

Description:
Obtaining the Current System Kernel Time.
参数
tv[out] Obtained Current System Kernel Time.
Support System:
linux liteos freertos.

◆ osal_hrtimer_create()

int osal_hrtimer_create ( osal_hrtimer hrtimer)

Create a high-resolution timer.

Description:
This API is used to create a high-resolution timer node and initialize timer parameters.
参数
hrtimer[in/out] The hrtimer to be initialized. Assign values to hrtimer->handler and hrtimer->interval before calling this interface, because you will not be able to change them after that.
注意
When mod exit, must call osal_hrtimer_destroy to free the timer, otherwise will lead to memory leak;
返回
OSAL_SUCCESS/OSAL_FAILURE
Support System:
liteos.

◆ osal_hrtimer_destroy()

int osal_hrtimer_destroy ( osal_hrtimer hrtimer)

Delete an existing high-resolution timer.

Description:
Delete an existing high-resolution timer.
注意
If the pointer to the high-resolution timer is null or the timer node does not exist, the high-resolution timer fails to be deleted.
返回
OSAL_SUCCESS/OSAL_FAILURE
Support System:
liteos.

◆ osal_hrtimer_start()

int osal_hrtimer_start ( osal_hrtimer hrtimer)

Start a high-resolution timer.

Description:
This API is used to add a high-resolution timer node to the global linked list and start timing.
返回值
-1The high-resolution timer fails to be started.
0The high-resolution timer is successfully started.
1The high-resolution timer node is already in the linked list.
Support System:
liteos.

◆ osal_jiffies_to_msecs()

unsigned int osal_jiffies_to_msecs ( const unsigned int  n)

Convert Ticks/jiffies to milliseconds.

Description:
Convert Ticks/jiffies to milliseconds.
返回
Milliseconds obtained through the conversion, if value > 0xFFFFFFFF, the value will be 0xFFFFFFFF.
参数
n[in] Number of Ticks/jiffies be converted.
Support System:
linux liteos freertos.

◆ osal_msecs_to_jiffies()

unsigned long osal_msecs_to_jiffies ( const unsigned int  m)

Convert milliseconds to Ticks/jiffies.

Description:
Convert milliseconds to Ticks/jiffies.
参数
m[in] The time to be converted. Unit: ms.
返回
Ticks/jiffies after conversion
Support System:
linux liteos freertos.

◆ osal_sched_clock()

unsigned long long osal_sched_clock ( void  )

Obtain system time in nanoseconds.

Description:
Obtain system time in nanoseconds.
返回
returns current time in nanoseconds.
Support System:
linux liteos.

◆ osal_timer_destroy()

int osal_timer_destroy ( osal_timer timer)

destroy the timer.

Description:
destroy the timer.
参数
timer[in] The timer to be destroyed.
注意
When mod exit, this function must be called to free the timer, otherwise will lead to memory leak;
返回
OSAL_SUCCESS/OSAL_FAILURE
Support System:
linux liteos freertos.

◆ osal_timer_destroy_sync()

int osal_timer_destroy_sync ( osal_timer timer)

deactivate a timer and wait for the handler to finish.

Description:
This function only differs from del_timer() on SMP, besides deactivating the timer it also makes sure the handler has finished executing on other CPUs.
注意
Synchronization rules: Callers must prevent restarting of the timer, otherwise this function is meaningless. It must not be called from interrupt contexts unless the timer is an irqsafe one. The caller must not hold locks which would prevent completion of the timer's handler. The timer's handler must not call add_timer_on(). Upon exit the timer is not queued and the handler is not running on any CPU.
返回
OSAL_SUCCESS/OSAL_FAILURE
Support System:
linux.

◆ osal_timer_get_private_data()

unsigned long osal_timer_get_private_data ( const void *  sys_data)

get_private_data by timer.

Description:
The parameters of the timer callback function cannot be directly used. You need to invoke this interface in the callback function to obtain the parameters that can be used.
参数
sys_data[in] Parameters passed to the callback function.
返回
Returns the parameters that can be used directly.
Support System:
linux liteos freertos.

◆ osal_timer_init()

int osal_timer_init ( osal_timer timer)

Initialize the timer.

Description:
Initialize the timer.
参数
timer[in/out] The timer to be initialized. Assign values to timer->handler and timer->data before calling this interface, because you will not be able to change them after that.
注意
When mod exit, must call osal_timer_destroy to free the timer, otherwise will lead to memory leak;
返回
OSAL_SUCCESS/OSAL_FAILURE
Support System:
linux liteos freertos.

◆ osal_timer_mod()

int osal_timer_mod ( osal_timer timer,
unsigned int  interval 
)

modify a timer's timeout.

Description:
modify a timer's timeout. This API is a more efficient way to update the expire field of an active timer (if the timer is inactive it will be activated).
参数
timer[in] the timer to be modified.
interval[in] new timeout, unit: ms.
返回
OSAL_SUCCESS/OSAL_FAILURE
Support System:
linux liteos freertos.

◆ osal_timer_start()

int osal_timer_start ( osal_timer timer)

start a timer.

Description:
start a timer.
注意
The kernel will do a ->function(timer) callback from the timer interrupt at the ->expires point in the future. The timer's ->expires, ->function fields must be set prior calling this function. Timers with an ->expires field in the past will be executed in the next timer tick.
参数
timer[in] the timer to be start.
返回
OSAL_SUCCESS/OSAL_FAILURE
Support System:
linux liteos freertos.

◆ osal_timer_start_on()

int osal_timer_start_on ( osal_timer timer,
unsigned long  delay,
int  cpu 
)

Start a timer on a particular CPU.

Description:
Start a timer on a particular CPU.
参数
timer[in] the timer to be added.
delay[in] delay time.
cpu[in] the CPU to start it on.
返回
OSAL_SUCCESS/OSAL_FAILURE
Support System:
linux.

◆ osal_timer_stop()

int osal_timer_stop ( osal_timer timer)

Deactivate a timer.

Description:
Deactivate a timer. This works on both active and inactive timers.
参数
timer[in] the timer to be deactivated.
返回值
1stop success, timer is pengding. (Only Linux and LiteOS are supported return 1)
OSAL_SUCCESSstop success, timer is already stoped.
OSAL_FAILURE
Support System:
linux liteos freertos.