nrfx 3.3
Modules | Data Structures | Macros | Typedefs | Functions
QDEC driver

Quadrature Decoder (QDEC) peripheral driver. More...

Modules

 QDEC peripheral driver configuration
 

Data Structures

struct  nrfx_qdec_t
 Data structure of the Quadrature Decoder (QDEC) driver instance. More...
 
struct  nrfx_qdec_config_t
 QDEC driver instance configuration structure. More...
 
struct  nrfx_qdec_sample_data_evt_t
 QDEC sample event data. More...
 
struct  nrfx_qdec_report_data_evt_t
 QDEC report event data. More...
 
struct  nrfx_qdec_event_t
 QDEC event handler structure. More...
 

Macros

#define NRFX_QDEC_INSTANCE(id)
 Macro for creating an instance of the QDEC driver.
 
#define NRFX_QDEC_DEFAULT_CONFIG(_pin_a, _pin_b, _pin_led)
 QDEC driver default configuration.
 

Typedefs

typedef void(* nrfx_qdec_event_handler_t) (nrfx_qdec_event_t event, void *p_context)
 QDEC event handler.
 

Functions

nrfx_err_t nrfx_qdec_init (nrfx_qdec_t const *p_instance, nrfx_qdec_config_t const *p_config, nrfx_qdec_event_handler_t handler, void *p_context)
 Function for initializing QDEC.
 
nrfx_err_t nrfx_qdec_reconfigure (nrfx_qdec_t const *p_instance, nrfx_qdec_config_t const *p_config)
 Function for reconfiguring QDEC.
 
void nrfx_qdec_uninit (nrfx_qdec_t const *p_instance)
 Function for uninitializing QDEC.
 
bool nrfx_qdec_init_check (nrfx_qdec_t const *p_instance)
 Function for checking if the QDEC driver instance is initialized.
 
void nrfx_qdec_enable (nrfx_qdec_t const *p_instance)
 Function for enabling QDEC.
 
void nrfx_qdec_disable (nrfx_qdec_t const *p_instance)
 Function for disabling QDEC.
 
void nrfx_qdec_accumulators_read (nrfx_qdec_t const *p_instance, int32_t *p_acc, uint32_t *p_accdbl)
 Function for reading accumulated transitions from the QDEC peripheral.
 
NRFX_STATIC_INLINE uint32_t nrfx_qdec_task_address_get (nrfx_qdec_t const *p_instance, nrf_qdec_task_t task)
 Function for returning the address of the specified QDEC task.
 
NRFX_STATIC_INLINE uint32_t nrfx_qdec_event_address_get (nrfx_qdec_t const *p_instance, nrf_qdec_event_t event)
 Function for returning the address of the specified QDEC event.
 

Detailed Description

Quadrature Decoder (QDEC) peripheral driver.

Macro Definition Documentation

◆ NRFX_QDEC_DEFAULT_CONFIG

#define NRFX_QDEC_DEFAULT_CONFIG (   _pin_a,
  _pin_b,
  _pin_led 
)
Value:
{ \
.reportper = NRF_QDEC_REPORTPER_10, \
.psela = _pin_a, \
.pselb = _pin_b, \
.pselled = _pin_led, \
.ledpre = 500, \
.sample_inten = false, \
.reportper_inten = true, \
.interrupt_priority = NRFX_QDEC_DEFAULT_CONFIG_IRQ_PRIORITY, \
}
@ NRF_QDEC_LEPOL_ACTIVE_HIGH
Definition: nrf_qdec.h:121
@ NRF_QDEC_DBFEN_DISABLE
Definition: nrf_qdec.h:113
@ NRF_QDEC_SAMPLEPER_16384US
Definition: nrf_qdec.h:134
@ NRF_QDEC_REPORTPER_10
Definition: nrf_qdec.h:143

QDEC driver default configuration.

This configuration sets up QDEC with the following options:

  • report period: 10 samples
  • sampling period: 16384 us
  • LED enabled for 500 us before sampling
  • LED polarity: active high
  • debouncing filter disabled
  • sample ready interrupt disabled
Parameters
[in]_pin_aPin for A encoder channel input.
[in]_pin_bPin for B encoder channel input.
[in]_pin_ledPin for LED output.

◆ NRFX_QDEC_INSTANCE

#define NRFX_QDEC_INSTANCE (   id)
Value:
{ \
.p_reg = NRF_QDEC##id, \
.drv_inst_idx = NRFX_CONCAT_3(NRFX_QDEC, id, _INST_IDX), \
}
#define NRFX_CONCAT_3(p1, p2, p3)
Macro for concatenating three tokens in macro expansion.
Definition: nrfx_common.h:155

Macro for creating an instance of the QDEC driver.

Typedef Documentation

◆ nrfx_qdec_event_handler_t

typedef void(* nrfx_qdec_event_handler_t) (nrfx_qdec_event_t event, void *p_context)

QDEC event handler.

Parameters
[in]eventQDEC event structure.
[in]p_contextContext passed to event handler.

Function Documentation

◆ nrfx_qdec_accumulators_read()

void nrfx_qdec_accumulators_read ( nrfx_qdec_t const *  p_instance,
int32_t *  p_acc,
uint32_t *  p_accdbl 
)

Function for reading accumulated transitions from the QDEC peripheral.

Note
Function asserts if module is not enabled.
Accumulators are cleared after reading.
Parameters
[in]p_instancePointer to the driver instance structure.
[out]p_accPointer to store the accumulated transitions.
[out]p_accdblPointer to store the accumulated double transitions.

◆ nrfx_qdec_disable()

void nrfx_qdec_disable ( nrfx_qdec_t const *  p_instance)

Function for disabling QDEC.

Note
Function asserts if module is uninitialized or disabled.
Parameters
[in]p_instancePointer to the driver instance structure.

◆ nrfx_qdec_enable()

void nrfx_qdec_enable ( nrfx_qdec_t const *  p_instance)

Function for enabling QDEC.

Note
Function asserts if module is uninitialized or enabled.
Parameters
[in]p_instancePointer to the driver instance structure.

◆ nrfx_qdec_event_address_get()

NRFX_STATIC_INLINE uint32_t nrfx_qdec_event_address_get ( nrfx_qdec_t const *  p_instance,
nrf_qdec_event_t  event 
)

Function for returning the address of the specified QDEC event.

Parameters
[in]p_instancePointer to the driver instance structure.
[in]eventQDEC event.
Returns
Event address.

◆ nrfx_qdec_init()

nrfx_err_t nrfx_qdec_init ( nrfx_qdec_t const *  p_instance,
nrfx_qdec_config_t const *  p_config,
nrfx_qdec_event_handler_t  handler,
void *  p_context 
)

Function for initializing QDEC.

Parameters
[in]p_instancePointer to the driver instance structure.
[in]p_configPointer to the structure with the initial configuration.
[in]handlerEvent handler provided by the user. Must not be NULL.
[in]p_contextContext passed to event handler.
Return values
NRFX_SUCCESSInitialization was successful.
NRFX_ERROR_ALREADYThe driver is already initialized.
NRFX_ERROR_INVALID_STATEThe driver is already initialized. Deprecated - use NRFX_ERROR_ALREADY instead.

◆ nrfx_qdec_init_check()

bool nrfx_qdec_init_check ( nrfx_qdec_t const *  p_instance)

Function for checking if the QDEC driver instance is initialized.

Parameters
[in]p_instancePointer to the driver instance structure.
Return values
trueInstance is already initialized.
falseInstance is not initialized.

◆ nrfx_qdec_reconfigure()

nrfx_err_t nrfx_qdec_reconfigure ( nrfx_qdec_t const *  p_instance,
nrfx_qdec_config_t const *  p_config 
)

Function for reconfiguring QDEC.

Parameters
[in]p_instancePointer to the driver instance structure.
[in]p_configPointer to the structure with the configuration.
Return values
NRFX_SUCCESSReconfiguration was successful.
NRFX_ERROR_BUSYThe driver is enabled and cannot be reconfigured.
NRFX_ERROR_INVALID_STATEThe driver is uninitialized.

◆ nrfx_qdec_task_address_get()

NRFX_STATIC_INLINE uint32_t nrfx_qdec_task_address_get ( nrfx_qdec_t const *  p_instance,
nrf_qdec_task_t  task 
)

Function for returning the address of the specified QDEC task.

Parameters
[in]p_instancePointer to the driver instance structure.
[in]taskQDEC task.
Returns
Task address.

◆ nrfx_qdec_uninit()

void nrfx_qdec_uninit ( nrfx_qdec_t const *  p_instance)

Function for uninitializing QDEC.

Note
Function asserts if module is uninitialized.
Parameters
[in]p_instancePointer to the driver instance structure.

Documentation feedback | Developer Zone | Subscribe | Updated