SmartSnippets DA1459x SDK
Files | Data Structures | Macros | Enumerations | Functions

Wakeup Controller LLD API. More...

Files

file  hw_wkup_v2.h
 Definition of API for the Wakeup Controller Low Level Driver.
 

Data Structures

struct  wkup_config
 Wakeup Controller configuration. More...
 

Macros

#define HW_WKUP_REG_FIELD_MASK(reg, field)   (WAKEUP_WKUP_##reg##_REG_##field##_Msk)
 Get the mask of a field of an WKUP register. More...
 
#define HW_WKUP_REG_FIELD_POS(reg, field)   (WAKEUP_WKUP_##reg##_REG_##field##_Pos)
 Get the bit position of a field of an WKUP register. More...
 
#define HW_WKUP_REG_GETF(reg, field)   ((WAKEUP->WKUP_##reg##_REG & (WAKEUP_WKUP_##reg##_REG_##field##_Msk)) >> (WAKEUP_WKUP_##reg##_REG_##field##_Pos))
 Get the value of a field of an WKUP register. More...
 
#define HW_WKUP_REG_SETF(reg, field, new_val)
 Set the value of a field of an WKUP register. More...
 

Enumerations

enum  HW_WKUP_TRIGGER {
  HW_WKUP_TRIG_DISABLED, HW_WKUP_TRIG_LEVEL_HI_DEB, HW_WKUP_TRIG_LEVEL_LO_DEB, HW_WKUP_TRIG_LEVEL_HI,
  HW_WKUP_TRIG_LEVEL_LO, HW_WKUP_TRIG_EDGE_HI, HW_WKUP_TRIG_EDGE_LO
}
 Key and gpio trigger types. More...
 
enum  HW_WKUP_HIBERN_PIN { HW_WKUP_HIBERN_PIN_NONE = 0, HW_WKUP_HIBERN_P0_14_ONLY, HW_WKUP_HIBERN_P1_04_ONLY, HW_WKUP_HIBERN_BOTH_PINS }
 Wake up from hibernation controller pin settings. More...
 
enum  HW_WKUP_HIBERN_POLARITY { HW_WKUP_HIBERN_BOTH_PINS_ACTIVE_HIGH = 0, HW_WKUP_HIBERN_P0_14_ACTIVE_LOW_ONLY, HW_WKUP_HIBERN_P1_04_ACTIVE_LOW_ONLY, HW_WKUP_HIBERN_BOTH_PINS_ACTIVE_LOW }
 Wake up from hibernation pin polarity settings. More...
 

Functions

void hw_wkup_configure_hibernation (HW_WKUP_HIBERN_PIN pin, HW_WKUP_HIBERN_POLARITY pol)
 Configure wake up from hibernation block. More...
 
void hw_wkup_init (const wkup_config *cfg)
 Initialize peripheral. More...
 
void hw_wkup_configure (const wkup_config *cfg)
 Configure peripheral. More...
 
void hw_wkup_register_key_interrupt (hw_wkup_interrupt_cb cb, uint32_t prio)
 Register KEY interrupt handler. More...
 
void hw_wkup_register_gpio_p0_interrupt (hw_wkup_interrupt_cb cb, uint32_t prio)
 Register GPIO P0 interrupt handler. More...
 
void hw_wkup_register_gpio_p1_interrupt (hw_wkup_interrupt_cb cb, uint32_t prio)
 Register GPIO P1 interrupt handler. More...
 
void hw_wkup_unregister_interrupts (void)
 Unregister interrupt handlers. More...
 
__STATIC_INLINE void hw_wkup_reset_key_interrupt (void)
 Reset key interrupt. More...
 
void hw_wkup_handler (void)
 Interrupt handler. More...
 
__STATIC_INLINE void hw_wkup_set_key_debounce_time (uint8_t time_ms)
 Set debounce time. More...
 
__STATIC_INLINE uint8_t hw_wkup_get_key_debounce_time (void)
 Get current debounce time. More...
 
void hw_wkup_set_trigger (HW_GPIO_PORT port, HW_GPIO_PIN pin, HW_WKUP_TRIGGER trigger)
 Configure a gpio or key trigger event. More...
 
__STATIC_INLINE HW_WKUP_TRIGGER hw_wkup_get_trigger (HW_GPIO_PORT port, HW_GPIO_PIN pin)
 Get gpio or key trigger configuration. More...
 
__STATIC_INLINE void hw_wkup_emulate_key_hit (void)
 Emulate key hit. More...
 
__STATIC_INLINE void hw_wkup_enable_key_irq (void)
 Enable WKUP Key interrupts. More...
 
__STATIC_INLINE void hw_wkup_disable_key_irq (void)
 Disable WKUP interrupts. More...
 
__STATIC_INLINE void hw_wkup_freeze_key_timer (void)
 Freeze wakeup timer. More...
 
__STATIC_INLINE void hw_wkup_unfreeze_key_timer (void)
 Unfreeze wakeup controller timer. More...
 
__STATIC_INLINE uint32_t hw_wkup_get_gpio_status (HW_GPIO_PORT port)
 Get port status on last wake up. More...
 
__STATIC_INLINE void hw_wkup_clear_gpio_status (HW_GPIO_PORT port, uint32_t status)
 Clear latch status. More...
 

Detailed Description

Wakeup Controller LLD API.

Macro Definition Documentation

◆ HW_WKUP_REG_FIELD_MASK

#define HW_WKUP_REG_FIELD_MASK (   reg,
  field 
)    (WAKEUP_WKUP_##reg##_REG_##field##_Msk)

Get the mask of a field of an WKUP register.

Parameters
[in]regis the register to access
[in]fieldis the register field to access

◆ HW_WKUP_REG_FIELD_POS

#define HW_WKUP_REG_FIELD_POS (   reg,
  field 
)    (WAKEUP_WKUP_##reg##_REG_##field##_Pos)

Get the bit position of a field of an WKUP register.

Parameters
[in]regis the register to access
[in]fieldis the register field to access

◆ HW_WKUP_REG_GETF

#define HW_WKUP_REG_GETF (   reg,
  field 
)    ((WAKEUP->WKUP_##reg##_REG & (WAKEUP_WKUP_##reg##_REG_##field##_Msk)) >> (WAKEUP_WKUP_##reg##_REG_##field##_Pos))

Get the value of a field of an WKUP register.

Parameters
[in]regis the register to access
[in]fieldis the register field to write
Returns
the value of the register field

◆ HW_WKUP_REG_SETF

#define HW_WKUP_REG_SETF (   reg,
  field,
  new_val 
)
Value:
WAKEUP->WKUP_##reg##_REG = ((WAKEUP->WKUP_##reg##_REG & ~(WAKEUP_WKUP_##reg##_REG_##field##_Msk)) | \
((WAKEUP_WKUP_##reg##_REG_##field##_Msk) & ((new_val) << (WAKEUP_WKUP_##reg##_REG_##field##_Pos))))

Set the value of a field of an WKUP register.

Parameters
[in]regis the register to access
[in]fieldis the register field to write
[in]new_valis the value to write

Enumeration Type Documentation

◆ HW_WKUP_HIBERN_PIN

Wake up from hibernation controller pin settings.

Enumerator
HW_WKUP_HIBERN_PIN_NONE 

Resets hibernation pins

HW_WKUP_HIBERN_P0_14_ONLY 

If set, Pin P0_14 can be used to wake up from hibernation

HW_WKUP_HIBERN_P1_04_ONLY 

If set, Pin P1_04 can be used to wake up from hibernation

HW_WKUP_HIBERN_BOTH_PINS 

If set, any of the above pins can be used to wake up from hibernation

◆ HW_WKUP_HIBERN_POLARITY

Wake up from hibernation pin polarity settings.

Enumerator
HW_WKUP_HIBERN_BOTH_PINS_ACTIVE_HIGH 

If set, both hibernation pins are active high

HW_WKUP_HIBERN_P0_14_ACTIVE_LOW_ONLY 

If set, P0_14 hibernation pin is active low and P1_04 is active high

HW_WKUP_HIBERN_P1_04_ACTIVE_LOW_ONLY 

If set, P1_04 hibernation pin is active low and P0_14 is active high

HW_WKUP_HIBERN_BOTH_PINS_ACTIVE_LOW 

If set, both hibernation pins are active low

◆ HW_WKUP_TRIGGER

Key and gpio trigger types.

Enumerator
HW_WKUP_TRIG_DISABLED 

Disabled

HW_WKUP_TRIG_LEVEL_HI_DEB 

Debounced (KEY), level sensitivity, polarity HIGH trigger

HW_WKUP_TRIG_LEVEL_LO_DEB 

Debounced (KEY), level sensitivity, polarity LOW trigger

HW_WKUP_TRIG_LEVEL_HI 

Non- debounced (GPIO), level sensitivity, polarity HIGH trigger

HW_WKUP_TRIG_LEVEL_LO 

Non- debounced (GPIO), level sensitivity, polarity LOW trigger

HW_WKUP_TRIG_EDGE_HI 

Non- debounced (GPIO), edge sensitivity, polarity HIGH trigger

HW_WKUP_TRIG_EDGE_LO 

Non- debounced (GPIO), edge sensitivity, polarity LOW trigger

Function Documentation

◆ hw_wkup_clear_gpio_status()

__STATIC_INLINE void hw_wkup_clear_gpio_status ( HW_GPIO_PORT  port,
uint32_t  status 
)

Clear latch status.

Parameters
[in]portport number
[in]statuspin status bitmask
Warning
Function MUST be called by any user-specified interrupt callback, to clear the interrupt latch status
See also
hw_wkup_get_gpio_status

◆ hw_wkup_configure()

void hw_wkup_configure ( const wkup_config cfg)

Configure peripheral.

Shortcut to call appropriate configuration function. If cfg is NULL, this function does nothing.

Parameters
[in]cfgconfiguration

◆ hw_wkup_configure_hibernation()

void hw_wkup_configure_hibernation ( HW_WKUP_HIBERN_PIN  pin,
HW_WKUP_HIBERN_POLARITY  pol 
)

Configure wake up from hibernation block.

Parameters
[in]pinthe GPIO that triggers wake up from hibernation
[in]polthe GPIO polarity

◆ hw_wkup_disable_key_irq()

__STATIC_INLINE void hw_wkup_disable_key_irq ( void  )

Disable WKUP interrupts.

◆ hw_wkup_emulate_key_hit()

__STATIC_INLINE void hw_wkup_emulate_key_hit ( void  )

Emulate key hit.

Simulate Key event wake up trigger in case debounce time is set to 0

◆ hw_wkup_enable_key_irq()

__STATIC_INLINE void hw_wkup_enable_key_irq ( void  )

Enable WKUP Key interrupts.

Note
Differs from enabling the IRQs reception on M33 side (NVIC_EnableIRQ) that takes place during the hw_wkup_register_key_interrupt().

◆ hw_wkup_freeze_key_timer()

__STATIC_INLINE void hw_wkup_freeze_key_timer ( void  )

Freeze wakeup timer.

◆ hw_wkup_get_gpio_status()

__STATIC_INLINE uint32_t hw_wkup_get_gpio_status ( HW_GPIO_PORT  port)

Get port status on last wake up.

Meaning of bits in returned bitmask is the same as in hw_wkup_set_trigger().

Returns
port pin event state bitmask
See also
hw_wkup_set_trigger

◆ hw_wkup_get_key_debounce_time()

__STATIC_INLINE uint8_t hw_wkup_get_key_debounce_time ( void  )

Get current debounce time.

Returns
debounce time in milliseconds

◆ hw_wkup_get_trigger()

__STATIC_INLINE HW_WKUP_TRIGGER hw_wkup_get_trigger ( HW_GPIO_PORT  port,
HW_GPIO_PIN  pin 
)

Get gpio or key trigger configuration.

Parameters
[in]portport number
[in]pinpin number
Returns
gpio or key trigger settings

◆ hw_wkup_handler()

void hw_wkup_handler ( void  )

Interrupt handler.

◆ hw_wkup_init()

void hw_wkup_init ( const wkup_config cfg)

Initialize peripheral.

Resets Wakeup Controller to initial state, i.e. interrupt is disabled and all pin triggers are disabled.

cfg can be NULL - no configuration is performed in such case.

Parameters
[in]cfgconfiguration

◆ hw_wkup_register_gpio_p0_interrupt()

void hw_wkup_register_gpio_p0_interrupt ( hw_wkup_interrupt_cb  cb,
uint32_t  prio 
)

Register GPIO P0 interrupt handler.

A callback function is registered to be called when an interrupt is generated. Interrupt is automatically enabled after calling this function. Application should reset interrupt in callback function using hw_wkup_clear_gpio_status(). If no callback is specified, interrupt will be automatically cleared by the driver.

Parameters
[in]cbcallback function
[in]priothe priority of the interrupt

◆ hw_wkup_register_gpio_p1_interrupt()

void hw_wkup_register_gpio_p1_interrupt ( hw_wkup_interrupt_cb  cb,
uint32_t  prio 
)

Register GPIO P1 interrupt handler.

A callback function is registered to be called when an interrupt is generated. Interrupt is automatically enabled after calling this function. Application should reset interrupt in callback function using hw_wkup_clear_gpio_status(). If no callback is specified, interrupt will be automatically cleared by the driver.

Parameters
[in]cbcallback function
[in]priothe priority of the interrupt

◆ hw_wkup_register_key_interrupt()

void hw_wkup_register_key_interrupt ( hw_wkup_interrupt_cb  cb,
uint32_t  prio 
)

Register KEY interrupt handler.

A callback function is registered to be called when an interrupt is generated. Interrupt is automatically enabled after calling this function. Application should reset interrupt in callback function using hw_wkup_reset_key_interrupt(). If no callback is specified, interrupt will be automatically cleared by the driver.

Parameters
[in]cbcallback function
[in]priothe priority of the interrupt

◆ hw_wkup_reset_key_interrupt()

__STATIC_INLINE void hw_wkup_reset_key_interrupt ( void  )

Reset key interrupt.

Warning
Function MUST be called by any user-specified key interrupt callback, to clear the interrupt.

◆ hw_wkup_set_key_debounce_time()

__STATIC_INLINE void hw_wkup_set_key_debounce_time ( uint8_t  time_ms)

Set debounce time.

Setting debounce time to 0 will disable hardware debouncing. Maximum debounce time is 63ms.

Parameters
[in]time_msdebounce time in milliseconds

◆ hw_wkup_set_trigger()

void hw_wkup_set_trigger ( HW_GPIO_PORT  port,
HW_GPIO_PIN  pin,
HW_WKUP_TRIGGER  trigger 
)

Configure a gpio or key trigger event.

Parameters
[in]portport number
[in]pinpin number
[in]triggergpio or key trigger setting

◆ hw_wkup_unfreeze_key_timer()

__STATIC_INLINE void hw_wkup_unfreeze_key_timer ( void  )

Unfreeze wakeup controller timer.

◆ hw_wkup_unregister_interrupts()

void hw_wkup_unregister_interrupts ( void  )

Unregister interrupt handlers.

Interrupts are automatically disabled in NVIC after calling this function.