nrfx 4.5.0
Loading...
Searching...
No Matches
QDEC driver

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

Topics

 QDEC peripheral driver configuration
 

Data Structures

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...
 
struct  nrfx_qdec_t
 PWM driver instance data structure. More...
 

Macros

#define NRFX_QDEC_DEFAULT_CONFIG(_pin_a, _pin_b, _pin_led)
 QDEC driver default configuration.
 
#define NRFX_QDEC_INSTANCE(reg)
 Macro for creating a QDEC driver instance.
 

Typedefs

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

Functions

int nrfx_qdec_init (nrfx_qdec_t *p_instance, nrfx_qdec_config_t const *p_config, nrfx_qdec_event_handler_t handler, void *p_context)
 Function for initializing QDEC.
 
int nrfx_qdec_reconfigure (nrfx_qdec_t *p_instance, nrfx_qdec_config_t const *p_config)
 Function for reconfiguring QDEC.
 
void nrfx_qdec_uninit (nrfx_qdec_t *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 *p_instance)
 Function for enabling QDEC.
 
void nrfx_qdec_disable (nrfx_qdec_t *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.
 
void nrfx_qdec_irq_handler (nrfx_qdec_t *p_instance)
 Driver interrupt handler.
 

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:161
@ NRF_QDEC_DBFEN_DISABLE
Definition nrf_qdec.h:153
@ NRF_QDEC_SAMPLEPER_16384US
Definition nrf_qdec.h:174
@ NRF_QDEC_REPORTPER_10
Definition nrf_qdec.h:188

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 ( reg)
Value:
{ \
.p_reg = (NRF_QDEC_Type *)reg, \
.cb = {0}, \
}

Macro for creating a QDEC driver instance.

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 * 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 * 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()

int nrfx_qdec_init ( nrfx_qdec_t * 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
0Initialization was successful.
-EALREADYThe driver is already initialized.

◆ 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_irq_handler()

void nrfx_qdec_irq_handler ( nrfx_qdec_t * p_instance)

Driver interrupt handler.

Parameters
[in]p_instancePointer to the driver instance structure.

◆ nrfx_qdec_reconfigure()

int nrfx_qdec_reconfigure ( nrfx_qdec_t * 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
0Reconfiguration was successful.
-EBUSYThe driver is enabled and cannot be reconfigured.
-EINPROGRESSThe 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 * p_instance)

Function for uninitializing QDEC.

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