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

Quadrature Decoder. More...

Files

file  hw_quad_v2.h
 Definition of API for the Quad Decoder Low Level Driver.
 

Data Structures

struct  hw_quad_values_t
 Local Quadrature Decoder Counter and Deltas repository definition. More...
 
struct  hw_quad_config_t
 Initialization Struct for use with "hw_quad_init()". More...
 

Typedefs

typedef void(* hw_quad_handler_cb) (const volatile hw_quad_values_t *quad_values, void *user_data)
 Quadrature Decoder Interrupt Callback. More...
 

Enumerations

enum  HW_QUAD_REG_CLK
 Quadrature Decoder CTRL Clock Enable Status. More...
 
enum  HW_QUAD_REG_CTRL_IRQ_STATUS
 Quadrature Decoder CTRL Register IRQ Status.
 
enum  HW_QUAD_REG_CTRL_EVENT_CNT_CLR
 Quadrature Decoder CTRL Register Event Counter Clear.
 
enum  HW_QUAD_REG_CTRL_IRQ_EN
 Quadrature Decoder CTRL Register IRQ Status.
 
enum  HW_QUAD_REG_CTRL2_CHANNEL_EVENT_MODE
 Quadrature Decoder CTRL2 Register Channel X-Y-Z Event Mode.
 
enum  HW_QUAD_GPIO_INPUT
 Quadrature Decoder CTRL2 Register Channel X-Y-Z Port Selection.
 
enum  HW_QUAD_REG_CLOCKDIV_PRESCALER
 Quadrature Decoder CLOCKDIV Register Prescaler.
 

Functions

__STATIC_FORCEINLINE int16_t hw_quad_get_xcnt_reg (void)
 Get XCNT Register. More...
 
__STATIC_FORCEINLINE int16_t hw_quad_get_ycnt_reg (void)
 Get YCNT Register. More...
 
__STATIC_FORCEINLINE int16_t hw_quad_get_zcnt_reg (void)
 Get ZCNT Register. More...
 
__STATIC_FORCEINLINE uint8_t hw_quad_get_event_cnt_reg (void)
 Get Event Count Register. More...
 
__STATIC_FORCEINLINE void hw_quad_qdec_clk_en (HW_QUAD_REG_CLK enable)
 Quadrature Decoder Clock Enable/Disable. More...
 
__STATIC_FORCEINLINE void hw_quad_clr_event_cnt (void)
 Clear Event Count Register. More...
 
__STATIC_FORCEINLINE void hw_quad_clr_irq_status (void)
 Clear IRQ. More...
 
__STATIC_FORCEINLINE HW_QUAD_REG_CTRL_IRQ_EN hw_quad_return_irq_status (void)
 Return IRQ Status. More...
 
void hw_quad_interrupt_enable_and_register (hw_quad_handler_cb cb, uint8_t thres_num, void *user_data_p)
 Enable Interrupt. More...
 
void hw_quad_interrupt_disable_and_unregister (void)
 Disable Interrupt. More...
 
void hw_quad_start (void)
 Start Quadrature Decoder. More...
 
void hw_quad_stop (void)
 Stop Quadrature Decoder. More...
 
void hw_quad_disable (void)
 Disable Quadrature Decoder. More...
 
void hw_quad_init (const hw_quad_config_t *init_data)
 Initialize Quadrature Decoder. More...
 

Detailed Description

Quadrature Decoder.

Typedef Documentation

◆ hw_quad_handler_cb

typedef void(* hw_quad_handler_cb) (const volatile hw_quad_values_t *quad_values, void *user_data)

Quadrature Decoder Interrupt Callback.

Parameters
[in]user_datapointer to additional user data

Enumeration Type Documentation

◆ HW_QUAD_REG_CLK

Quadrature Decoder CTRL Clock Enable Status.

Note
The clock is enabled/disabled through the QDEC_CLK_ENABLE single-bit field.
If the clock is disabled, no interaction with the QUADEC registers is possible.

Function Documentation

◆ hw_quad_clr_event_cnt()

__STATIC_FORCEINLINE void hw_quad_clr_event_cnt ( void  )

Clear Event Count Register.

Clears the QDEC_EVENT_CNT_REG. Please note that when an interrupt has been raised the QDEC_EVENT_CNT_REG will continue to count events. No further interrupts will be generated unless the Event Count Register has been cleared.

◆ hw_quad_clr_irq_status()

__STATIC_FORCEINLINE void hw_quad_clr_irq_status ( void  )

Clear IRQ.

Clears pending interrupts.

◆ hw_quad_disable()

void hw_quad_disable ( void  )

Disable Quadrature Decoder.

Disables the quadrature decoder block.

See also
hw_quad_init

◆ hw_quad_get_event_cnt_reg()

__STATIC_FORCEINLINE uint8_t hw_quad_get_event_cnt_reg ( void  )

Get Event Count Register.

Returns the contents of the Quadrature Decoder Event Count Register (QDEC_EVENT_CNT_REG).

◆ hw_quad_get_xcnt_reg()

__STATIC_FORCEINLINE int16_t hw_quad_get_xcnt_reg ( void  )

Get XCNT Register.

Returns the contents of the Quadrature Decoder XCNT Register (QDEC_XCNT_REG).

◆ hw_quad_get_ycnt_reg()

__STATIC_FORCEINLINE int16_t hw_quad_get_ycnt_reg ( void  )

Get YCNT Register.

Returns the contents of the Quadrature Decoder YCNT Register (QDEC_YCNT_REG).

◆ hw_quad_get_zcnt_reg()

__STATIC_FORCEINLINE int16_t hw_quad_get_zcnt_reg ( void  )

Get ZCNT Register.

Returns the contents of the Quadrature Decoder ZCNT Register (QDEC_ZCNT_REG).

◆ hw_quad_init()

void hw_quad_init ( const hw_quad_config_t init_data)

Initialize Quadrature Decoder.

Initializes the quadrature decoder block.

Note
"hw_quad_start()" required for the Quadrature Decoder to begin
Parameters
[in]init_datadefines the initialization struct
See also
hw_quad_disable

◆ hw_quad_interrupt_disable_and_unregister()

void hw_quad_interrupt_disable_and_unregister ( void  )

Disable Interrupt.

Clears QDEC_CTRL_REG pending IRQ and Event Counter, disables IRQ,s in both QDEC_CTRL_REG and NVIC (unregisters callback)

See also
hw_quad_interrupt_enable_and_register

◆ hw_quad_interrupt_enable_and_register()

void hw_quad_interrupt_enable_and_register ( hw_quad_handler_cb  cb,
uint8_t  thres_num,
void *  user_data_p 
)

Enable Interrupt.

Sets the Control Register (QDEC_CTRL_REG) and registers callback.

Note
Not to be called before "hw_quad_init" or at least "hw_quad_qdec_clk_en". QDEC will be uninitialized and the block will be without clock. No QDEC-related registers will be updated whatsoever.
Parameters
[in]cbdefines the callback intended to be registered.
[in]thres_numdefines the number of events on either counter (X or Y or Z) that need to be reached before an interrupt is generated. Events are equal to irq_thres + 1 and are monitored through QDEC_EVENT_CNT_REG.
[in]user_data_ppointer to additional user data
See also
hw_quad_interrupt_disable_and_unregister_interrupt

◆ hw_quad_qdec_clk_en()

__STATIC_FORCEINLINE void hw_quad_qdec_clk_en ( HW_QUAD_REG_CLK  enable)

Quadrature Decoder Clock Enable/Disable.

Enables or Disables the Quadrature Decoder clock (CRG_TOP, CLK_AMBA_REG, QDEC_CLK_ENABLE).

Note
If the clock is NOT enabled, no interaction with the Quadrature Decoder Registers is possible.
Parameters
[in]enabledefines whether the clock will be enabled or disabled.

◆ hw_quad_return_irq_status()

__STATIC_FORCEINLINE HW_QUAD_REG_CTRL_IRQ_EN hw_quad_return_irq_status ( void  )

Return IRQ Status.

Returns whether an interrupt has occurred or not.

◆ hw_quad_start()

void hw_quad_start ( void  )

Start Quadrature Decoder.

Sets QDEC_CTRL2_REG Pin Input pairs according to X-Y-Z stored port pairs in hw_x_axis_ports, hw_y_axis_ports and hw_z_axis_ports respectively.

Note
Function Requires QUAD clock to be ON (e.g. through "hw_quad_init")
See also
hw_quad_init

◆ hw_quad_stop()

void hw_quad_stop ( void  )

Stop Quadrature Decoder.

Disables QDEC_CTRL2_REG Pin Input pairs, resets counter variables in QDEC_XCNT_REG, QDEC_YCNT_REG. QDEC_ZCNT_REG.

See also
hw_quad_init