QDEC HALY

group nrfy_qdec

Hardware access layer with cache and barrier support for managing the QDEC peripheral.

Functions

NRFY_STATIC_INLINE void nrfy_qdec_periph_configure(NRF_QDEC_Type *p_reg, nrfy_qdec_config_t const *p_config)

Function for configuring the QDEC.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • p_config[in] Pointer to the peripheral configuration structure.

NRFY_STATIC_INLINE void nrfy_qdec_int_init(NRF_QDEC_Type *p_reg, uint32_t mask, uint8_t irq_priority, bool enable)

Function for initializing the specified QDEC interrupts.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Mask of interrupts to be initialized.

  • irq_priority[in] Interrupt priority.

  • enable[in] True if the interrupts are to be enabled, false otherwise.

NRFY_STATIC_INLINE void nrfy_qdec_int_uninit(NRF_QDEC_Type *p_reg)

Function for uninitializing the QDEC interrupts.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

NRFY_STATIC_INLINE uint32_t nrfy_qdec_events_process(NRF_QDEC_Type *p_reg, uint32_t mask)

Function for processing the specified QDEC events.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Mask of events to be processed, created by NRFY_EVENT_TO_INT_BITMASK().

Returns:

Mask of events that were generated and processed. To be checked against the result of NRFY_EVENT_TO_INT_BITMASK().

NRFY_STATIC_INLINE void nrfy_qdec_accumulators_read(NRF_QDEC_Type const *p_reg, int32_t *p_acc, uint32_t *p_accdbl)

Function for reading QDEC accumulators.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • p_acc[in] Pointer to store the accumulated transitions

  • p_accdbl[in] Pointer to store the accumulated double transitions.

NRFY_STATIC_INLINE void nrfy_qdec_pins_get(NRF_QDEC_Type const *p_reg, nrfy_qdec_pins_t *p_pins)

Function for reading QDEC pins.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • p_pins[in] Pointer to the QDEC pin configurartion structure.

NRFY_STATIC_INLINE void nrfy_qdec_pins_set(NRF_QDEC_Type *p_reg, nrfy_qdec_pins_t const *p_pins)

Function for setting QDEC pins.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • p_pins[in] Pointer to the QDEC pin configurartion structure.

NRFY_STATIC_INLINE void nrfy_qdec_enable(NRF_QDEC_Type *p_reg)

See also

nrf_qdec_enable Function for enabling QDEC.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

NRFY_STATIC_INLINE void nrfy_qdec_disable(NRF_QDEC_Type *p_reg)

See also

nrf_qdec_disable Function for disabling QDEC.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

NRFY_STATIC_INLINE uint32_t nrfy_qdec_enable_get(NRF_QDEC_Type const *p_reg)

See also

nrf_qdec_enable_get Function for returning the enable state of QDEC.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

State of the register.

NRFY_STATIC_INLINE void nrfy_qdec_int_enable(NRF_QDEC_Type *p_reg, uint32_t mask)

See also

nrf_qdec_int_enable Function for enabling QDEC interrupts by mask.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Mask of interrupts to be enabled. Use nrf_qdec_int_mask_t values for bit masking.

NRFY_STATIC_INLINE void nrfy_qdec_int_disable(NRF_QDEC_Type *p_reg, uint32_t mask)

See also

nrf_qdec_int_disable Function for disabling QDEC interrupts by mask.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Mask of interrupts to be disabled. Use nrf_qdec_int_mask_t values for bit masking.

NRFY_STATIC_INLINE uint32_t nrfy_qdec_int_enable_check(NRF_QDEC_Type const *p_reg, uint32_t mask)

See also

nrf_qdec_int_enable_check Function for checking if the specified interrupts are enabled.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Mask of interrupts to be checked. Use nrf_qdec_int_mask_t values for bit masking.

Returns:

Mask of enabled interrupts.

NRFY_STATIC_INLINE void nrfy_qdec_dbfen_enable(NRF_QDEC_Type *p_reg)

See also

nrf_qdec_dbfen_enable Function for enabling the QDEC debouncing filter.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

NRFY_STATIC_INLINE void nrfy_qdec_dbfen_disable(NRF_QDEC_Type *p_reg)

See also

nrf_qdec_dbfen_disable Function for disabling the QDEC debouncing filter.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

NRFY_STATIC_INLINE uint32_t nrfy_qdec_dbfen_get(NRF_QDEC_Type const *p_reg)

See also

nrf_qdec_dbfen_get Function for getting the state of the QDEC debouncing filter.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Return values:
  • NRF_QDEC_DBFEN_DISABLE – The debouncing filter is disabled.

  • NRF_QDEC_DBFEN_ENABLE – The debouncing filter is enabled.

NRFY_STATIC_INLINE uint32_t nrfy_qdec_a_pin_get(NRF_QDEC_Type const *p_reg)

See also

nrf_qdec_phase_a_pin_get Function for getting the Phase A pin selection.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

Phase A pin selection.

NRFY_STATIC_INLINE uint32_t nrfy_qdec_b_pin_get(NRF_QDEC_Type const *p_reg)

See also

nrf_qdec_phase_b_pin_get Function for getting the Phase B pin selection.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

Phase B pin selection.

NRFY_STATIC_INLINE uint32_t nrfy_qdec_led_pin_get(NRF_QDEC_Type const *p_reg)

See also

nrf_qdec_led_pin_get Function for getting the LED pin selection.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

LED pin selection.

NRFY_STATIC_INLINE void nrfy_qdec_task_trigger(NRF_QDEC_Type *p_reg, nrf_qdec_task_t task)

See also

nrf_qdec_task_trigger Function for setting the specified QDEC task.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • task[in] QDEC task to be triggered.

NRFY_STATIC_INLINE uint32_t nrfy_qdec_task_address_get(NRF_QDEC_Type const *p_reg, nrf_qdec_task_t task)

See also

nrf_qdec_task_address_get Function for retrieving the address of a QDEC task register.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • task[in] QDEC task to get its address.

Returns:

Address of the specified QDEC task.

NRFY_STATIC_INLINE void nrfy_qdec_event_clear(NRF_QDEC_Type *p_reg, nrf_qdec_event_t event)

See also

nrf_qdec_event_clear Function for clearing the specified QDEC event.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • event[in] QDEC event to be cleared.

NRFY_STATIC_INLINE bool nrfy_qdec_event_check(NRF_QDEC_Type const *p_reg, nrf_qdec_event_t event)

See also

nrf_qdec_event_check Function for getting the state of the specified QDEC event.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • event[in] QDEC event to be checked.

Returns:

State of the specified QDEC event.

NRFY_STATIC_INLINE uint32_t nrfy_qdec_event_address_get(NRF_QDEC_Type const *p_reg, nrf_qdec_event_t event)

See also

nrf_qdec_event_address_get Function for retrieving the address of the specified QDEC event register.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • event[in] QDEC event to get its address.

Returns:

Address of the specified QDEC event.

NRFY_STATIC_INLINE void nrfy_qdec_shorts_enable(NRF_QDEC_Type *p_reg, uint32_t mask)

See also

nrf_qdec_shorts_enable Function for setting QDEC shortcuts.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Mask of QDEC shortcuts to be set.

NRFY_STATIC_INLINE void nrfy_qdec_shorts_disable(NRF_QDEC_Type *p_reg, uint32_t mask)

See also

nrf_qdec_shorts_disable Function for clearing shortcuts of the QDEC by mask.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Mask of QDEC shortcuts to be cleared.

NRFY_STATIC_INLINE uint32_t nrfy_qdec_sampleper_to_value(nrf_qdec_sampleper_t sampleper)

See also

nrf_qdec_sampleper_to_value Function for converting return value of the nrf_qdec_sampleper_get function to microseconds.

Parameters:
  • sampleper[in] The sampling period.

Returns:

Period in microseconds.

NRFY_STATIC_INLINE void nrfy_qdec_sampleper_set(NRF_QDEC_Type *p_reg, nrf_qdec_sampleper_t sampleper)

See also

nrf_qdec_sampleper_set Function for setting value of the QDEC sampling period.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • sampleper[in] The sampling period.

NRFY_STATIC_INLINE nrf_qdec_sampleper_t nrfy_qdec_sampleper_get(NRF_QDEC_Type const *p_reg)

See also

nrf_qdec_sampleper_get Function for retrieving value of the QDEC sampling period.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

Sampling period.

NRFY_STATIC_INLINE int32_t nrfy_qdec_sample_get(NRF_QDEC_Type const *p_reg)

See also

nrf_qdec_sample_get Function for retrieving value of the QDEC SAMPLE register.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

Value of the SAMPLE register.

NRFY_STATIC_INLINE int32_t nrfy_qdec_acc_get(NRF_QDEC_Type const *p_reg)

See also

nrf_qdec_acc_get Function for retrieving value of the QDEC ACC register.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

Value of the ACC register.

NRFY_STATIC_INLINE int32_t nrfy_qdec_accread_get(NRF_QDEC_Type const *p_reg)

See also

nrf_qdec_accread_get Function for retrieving value of the QDEC ACCREAD register.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

Value of the ACCREAD register.

NRFY_STATIC_INLINE uint32_t nrfy_qdec_accdbl_get(NRF_QDEC_Type const *p_reg)

See also

nrf_qdec_accdbl_get Function for retrieving value of the QDEC ACCDBL register.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

Value of the ACCDBL register.

NRFY_STATIC_INLINE uint32_t nrfy_qdec_accdblread_get(NRF_QDEC_Type const *p_reg)

See also

nrf_qdec_accdblread_get Function for retrieving value of the QDEC ACCDBLREAD register.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

Value of the ACCDBLREAD register.

NRFY_STATIC_INLINE void nrfy_qdec_ledpre_set(NRF_QDEC_Type *p_reg, uint32_t time_us)

See also

nrf_qdec_ledpre_set Function for setting delay time between setting LED active state and start sampling.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • time_us[in] Delay time (in microseconds) between setting LED active state and start sampling.

NRFY_STATIC_INLINE uint32_t nrfy_qdec_ledpre_get(NRF_QDEC_Type const *p_reg)

See also

nrf_qdec_ledpre_get Function for retrieving how long the LED is switched on before sampling.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

The gap in time in microseconds between switched LED to active state and start sampling.

NRFY_STATIC_INLINE void nrfy_qdec_ledpol_set(NRF_QDEC_Type *p_reg, nrf_qdec_ledpol_t pol)

See also

nrf_qdec_ledpol_set Function for setting the active level for the LED.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • pol[in] Level of the active signal of the LED.

NRFY_STATIC_INLINE uint32_t nrfy_qdec_ledpol_get(NRF_QDEC_Type const *p_reg)

See also

nrf_qdec_ledpol_get Function for retrieving the active level for the LED.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

Level of the active signal of the LED.

NRFY_STATIC_INLINE void nrfy_qdec_reportper_set(NRF_QDEC_Type *p_reg, nrf_qdec_reportper_t reportper)

See also

nrf_qdec_reportper_set Function for setting the report period (in samples).

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • reportper[in] The number of samples.

NRFY_STATIC_INLINE nrf_qdec_reportper_t nrfy_qdec_reportper_get(NRF_QDEC_Type const *p_reg)

See also

nrf_qdec_reportper_get Function for retrieving the report period.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

The report period.

NRFY_STATIC_INLINE uint32_t nrfy_qdec_reportper_to_value(nrf_qdec_reportper_t reportper)

See also

nrf_qdec_reportper_to_value Function for retrieving the value of QDEC SAMPLEPER register.

Parameters:
  • reportper[in] Reportper to be converted to amount of samples per report.

Returns:

Number of samples per report.

struct nrfy_qdec_pins_t
#include <nrfy_qdec.h>

Configuration structure for QDEC pins.

Public Members

uint32_t a_pin

Pin number for A input.

uint32_t b_pin

Pin number for B input.

uint32_t led_pin

Pin number for LED output.

struct nrfy_qdec_config_t
#include <nrfy_qdec.h>

QDEC configuration structure.

Public Members

nrf_qdec_reportper_t reportper

Report period in samples.

nrf_qdec_sampleper_t sampleper

Sampling period in microseconds.

nrfy_qdec_pins_t pins

Pin configuration structure.

uint32_t ledpre

Time (in microseconds) how long LED is switched on before sampling.

nrf_qdec_ledpol_t ledpol

Active LED polarity.

bool dbfen

State of debouncing filter.

bool skip_psel_cfg

Skip pin selection configuration. When set to true, the driver does not modify pin select registers in the peripheral. Those registers are supposed to be set up externally before the driver is initialized.

Note

When both GPIO configuration and pin selection are to be skipped, the structure fields that specify pins can be omitted, as they are ignored anyway.