Timer

group group_abstraction_rtos_timer

APIs for creating and working with Timers.

Unnamed Group

cy_rslt_t cy_rtos_init_timer(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.

note

The callback may be (likely will be) called from a different thread.

Return

The status of the creation request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]

Parameters
  • [out] timer: Pointer to the timer handle to initialize

  • [in] type: Type of timer (periodic or once)

  • [in] fun: The function

  • [in] arg: Argument to pass along to the callback function

cy_rslt_t cy_rtos_start_timer(cy_timer_t *timer, cy_time_t num_ms)

Start a timer.

Return

The status of the creation request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]

Parameters
  • [in] timer: Pointer to the timer handle

  • [in] num_ms: The number of milliseconds to wait before the timer fires

cy_rslt_t cy_rtos_stop_timer(cy_timer_t *timer)

Stop a timer.

Return

The status of the creation request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]

Parameters
  • [in] timer: Pointer to the timer handle

cy_rslt_t cy_rtos_is_running_timer(cy_timer_t *timer, bool *state)

Returns state of a timer.

Return

The status of the creation request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]

Parameters
  • [in] timer: Pointer to the timer handle

  • [out] state: Return value for state, true if running, false otherwise

cy_rslt_t cy_rtos_deinit_timer(cy_timer_t *timer)

Deinit the timer.

This function deinitializes the timer and frees all consumed resources.

Return

The status of the creation request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]

Parameters
  • [in] timer: Pointer to the timer handle

Typedefs

typedef void (*cy_timer_callback_t)(cy_timer_callback_arg_t arg)

The callback function to be called by a timer.

Enums

enum cy_timer_trigger_type_t

cy_timer_trigger_type_t: The type of timer.

Values:

enumerator CY_TIMER_TYPE_PERIODIC

called periodically until stopped

enumerator CY_TIMER_TYPE_ONCE

called once only

enumerator cy_timer_type_periodic

Deprecated:

replaced by CY_TIMER_TYPE_PERIODIC

enumerator cy_timer_type_once

Deprecated:

replaced by CY_TIMER_TYPE_ONCE