PSoC 6 Hardware Abstraction Layer (HAL)
LPTIMER (Low-Power Timer)

General Description

High level interface for interacting with the Cypress LPTIMER.

This can be used to measure timing between events, or to perform some action the ability after a set interval. It continues to operate in some low power modes; see the device datasheet for details.

Typedefs

typedef void(* cyhal_lptimer_event_callback_t) (void *callback_arg, cyhal_lptimer_event_t event)
 

Enumerations

enum  cyhal_lptimer_event_t { CYHAL_LPTIMER_COMPARE_MATCH }
 

Functions

cy_rslt_t cyhal_lptimer_init (cyhal_lptimer_t *obj)
 
void cyhal_lptimer_free (cyhal_lptimer_t *obj)
 
cy_rslt_t cyhal_lptimer_reload (cyhal_lptimer_t *obj)
 
cy_rslt_t cyhal_lptimer_set_time (cyhal_lptimer_t *obj, uint32_t time)
 
cy_rslt_t cyhal_lptimer_set_match (cyhal_lptimer_t *obj, uint32_t value)
 
uint32_t cyhal_lptimer_read (const cyhal_lptimer_t *obj)
 
void cyhal_lptimer_register_callback (cyhal_lptimer_t *obj, cyhal_lptimer_event_callback_t callback, void *callback_arg)
 
void cyhal_lptimer_enable_event (cyhal_lptimer_t *obj, cyhal_lptimer_event_t event, uint8_t intrPriority, bool enable)
 
void cyhal_lptimer_irq_trigger (cyhal_lptimer_t *obj)
 

Typedef Documentation

◆ cyhal_lptimer_event_callback_t

typedef void(* cyhal_lptimer_event_callback_t) (void *callback_arg, cyhal_lptimer_event_t event)

Handler for LPTIMER interrupts

Enumeration Type Documentation

◆ cyhal_lptimer_event_t

LPTIMER interrupt triggers

Function Documentation

◆ cyhal_lptimer_init()

cy_rslt_t cyhal_lptimer_init ( cyhal_lptimer_t *  obj)

Initialize the LPTIMER

Initialize or re-initialize the LPTIMER. This resets all the clocking and prescaler registers, along with disabling the compare interrupt. Refer to the BSP for the clock source for the LPTIMER.

Parameters
[out]objThe LPTIMER object
Returns
The status of the init request

◆ cyhal_lptimer_free()

void cyhal_lptimer_free ( cyhal_lptimer_t *  obj)

Deinitialize the LPTIMER

Powers down the LPTIMER. After calling this function no other LPTIMER functions should be called except cyhal_lptimer_init(). Calling any function other than init after freeing is undefined.

Parameters
[in,out]objThe LPTIMER object

◆ cyhal_lptimer_reload()

cy_rslt_t cyhal_lptimer_reload ( cyhal_lptimer_t *  obj)

Reload/Reset the Low-Power timer.

Parameters
[in]objThe LPTIMER object
Returns
The status of the reload request

◆ cyhal_lptimer_set_time()

cy_rslt_t cyhal_lptimer_set_time ( cyhal_lptimer_t *  obj,
uint32_t  time 
)

Set timeframe between interrupts

Configures the LPTIMER in free-running mode. Generates an interrupt on match. This function is for initial configuration. For quick updates to the match value, use cyhal_lptimer_set_time().

Parameters
[in]objThe LPTIMER object
[in]timeThe time in ticks to be set
Returns
The status of the set_time request

◆ cyhal_lptimer_set_match()

cy_rslt_t cyhal_lptimer_set_match ( cyhal_lptimer_t *  obj,
uint32_t  value 
)

Update the match/compare value

Update the match value of an already configured LPTIMER set up to generate an interrupt on match. Note that this function does not reinitialize the counter or the associated peripheral initialization sequence.

Parameters
[in]objThe LPTIMER object
[in]valueThe match value in ticks
Returns
The status of the set_match request

◆ cyhal_lptimer_read()

uint32_t cyhal_lptimer_read ( const cyhal_lptimer_t *  obj)

Read the current tick

If no rollover has occurred, the seconds passed since cyhal_lptimer_init() or cyhal_lptimer_set_time() was called can be found by dividing the ticks returned by this function by the frequency of the source clock (refer to the BSP for the clock source).

Parameters
[in]objThe LPTIMER object
Returns
The timer's timer value in ticks

◆ cyhal_lptimer_register_callback()

void cyhal_lptimer_register_callback ( cyhal_lptimer_t *  obj,
cyhal_lptimer_event_callback_t  callback,
void *  callback_arg 
)

The LPTIMER match event handler registration

Parameters
[in]objThe LPTIMER object
[in]callbackThe callback handler which will be invoked when the interrupt triggers
[in]callback_argGeneric argument that will be provided to the handler when called

◆ cyhal_lptimer_enable_event()

void cyhal_lptimer_enable_event ( cyhal_lptimer_t *  obj,
cyhal_lptimer_event_t  event,
uint8_t  intrPriority,
bool  enable 
)

Configure and Enable/Disable the LPTIMER events

Parameters
[in]objThe LPTIMER object
[in]eventThe LPTIMER event type
[in]intrPriorityThe priority for NVIC interrupt events
[in]enableTrue to turn on event, False to turn off

◆ cyhal_lptimer_irq_trigger()

void cyhal_lptimer_irq_trigger ( cyhal_lptimer_t *  obj)

Manually trigger the LPTIMER interrupt.

Parameters
[in]objThe LPTIMER object