RTOS Abstraction (abstraction-rtos)
Timer

General Description

APIs for creating and working with Timers.

Typedefs

typedef void(* cy_timer_callback_t) (cy_timer_callback_arg_t arg)
 The callback function to be called by a timer.
 

Enumerations

enum  cy_timer_trigger_type_t {
  CY_TIMER_TYPE_PERIODIC ,
  CY_TIMER_TYPE_ONCE
}
 The type of timer. More...
 
cy_rslt_t cy_rtos_timer_init (cy_timer_t *timer, cy_timer_trigger_type_t type, cy_timer_callback_t fun, cy_timer_callback_arg_t arg)
 Create a new timer. More...
 
cy_rslt_t cy_rtos_timer_start (cy_timer_t *timer, cy_time_t num_ms)
 Sends a request to start the timer. More...
 
cy_rslt_t cy_rtos_timer_stop (cy_timer_t *timer)
 Sends a request to stop the timer. More...
 
cy_rslt_t cy_rtos_timer_is_running (cy_timer_t *timer, bool *state)
 Returns state of a timer. More...
 
cy_rslt_t cy_rtos_timer_deinit (cy_timer_t *timer)
 Deinit the timer. More...
 
#define cy_rtos_init_timer(timer, type, fun, arg)    cy_rtos_timer_init(timer, type, fun, arg)
 Create a new timer. More...
 
#define cy_rtos_start_timer(timer, num_ms)    cy_rtos_timer_start(timer, num_ms)
 Sends a request to start the timer. More...
 
#define cy_rtos_stop_timer(timer)   cy_rtos_timer_stop(timer)
 Sends a request to stop the timer. More...
 
#define cy_rtos_is_running_timer(timer, state)    cy_rtos_timer_is_running(timer, state)
 Returns state of a timer. More...
 
#define cy_rtos_deinit_timer(timer)   cy_rtos_timer_deinit(timer)
 Deinit the timer. More...
 

Macro Definition Documentation

◆ cy_rtos_init_timer

#define cy_rtos_init_timer (   timer,
  type,
  fun,
  arg 
)     cy_rtos_timer_init(timer, type, fun, arg)

Create a new timer.

This function initializes a timer object.

Note
The timer is not active until start is called.
The callback may be (likely will be) called from a different thread.
Parameters
[out]timerPointer to the timer handle to initialize
[in]typeType of timer (periodic or once)
[in]funThe function
[in]argArgument to pass along to the callback function
Returns
The status of the init request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]

◆ cy_rtos_start_timer

#define cy_rtos_start_timer (   timer,
  num_ms 
)     cy_rtos_timer_start(timer, num_ms)

Sends a request to start the timer.

Depending on the priorities of threads in the system, it may be necessary for high priority items to wait before the timer actually starts running.

Parameters
[in]timerPointer to the timer handle
[in]num_msThe number of milliseconds to wait before the timer fires
Returns
The status of the start request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]

◆ cy_rtos_stop_timer

#define cy_rtos_stop_timer (   timer)    cy_rtos_timer_stop(timer)

Sends a request to stop the timer.

Depending on the priorities of threads in the system, it may be necessary for high priority items to wait before the timer is actually stopped.

Parameters
[in]timerPointer to the timer handle
Returns
The status of the stop request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]

◆ cy_rtos_is_running_timer

#define cy_rtos_is_running_timer (   timer,
  state 
)     cy_rtos_timer_is_running(timer, state)

Returns state of a timer.

Parameters
[in]timerPointer to the timer handle
[out]stateReturn value for state, true if running, false otherwise
Returns
The status of the is_running request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]

◆ cy_rtos_deinit_timer

#define cy_rtos_deinit_timer (   timer)    cy_rtos_timer_deinit(timer)

Deinit the timer.

This function deinitializes the timer and frees all consumed resources.

Parameters
[in]timerPointer to the timer handle
Returns
The status of the deinit request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]

Enumeration Type Documentation

◆ cy_timer_trigger_type_t

The type of timer.

Enumerator
CY_TIMER_TYPE_PERIODIC 

called periodically until stopped

CY_TIMER_TYPE_ONCE 

called once only

Function Documentation

◆ cy_rtos_timer_init()

cy_rslt_t cy_rtos_timer_init ( cy_timer_t timer,
cy_timer_trigger_type_t  type,
cy_timer_callback_t  fun,
cy_timer_callback_arg_t  arg 
)

Create a new timer.

This function initializes a timer object.

Note
The timer is not active until start is called.
The callback may be (likely will be) called from a different thread.
Parameters
[out]timerPointer to the timer handle to initialize
[in]typeType of timer (periodic or once)
[in]funThe function
[in]argArgument to pass along to the callback function
Returns
The status of the init request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]

◆ cy_rtos_timer_start()

cy_rslt_t cy_rtos_timer_start ( cy_timer_t timer,
cy_time_t  num_ms 
)

Sends a request to start the timer.

Depending on the priorities of threads in the system, it may be necessary for high priority items to wait before the timer actually starts running.

Parameters
[in]timerPointer to the timer handle
[in]num_msThe number of milliseconds to wait before the timer fires
Returns
The status of the start request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]

◆ cy_rtos_timer_stop()

cy_rslt_t cy_rtos_timer_stop ( cy_timer_t timer)

Sends a request to stop the timer.

Depending on the priorities of threads in the system, it may be necessary for high priority items to wait before the timer is actually stopped.

Parameters
[in]timerPointer to the timer handle
Returns
The status of the stop request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]

◆ cy_rtos_timer_is_running()

cy_rslt_t cy_rtos_timer_is_running ( cy_timer_t timer,
bool *  state 
)

Returns state of a timer.

Parameters
[in]timerPointer to the timer handle
[out]stateReturn value for state, true if running, false otherwise
Returns
The status of the is_running request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]

◆ cy_rtos_timer_deinit()

cy_rslt_t cy_rtos_timer_deinit ( cy_timer_t timer)

Deinit the timer.

This function deinitializes the timer and frees all consumed resources.

Parameters
[in]timerPointer to the timer handle
Returns
The status of the deinit request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]