QDEC driver
- group nrfx_qdec
Quadrature Decoder (QDEC) peripheral driver.
Defines
-
NRFX_QDEC_DEFAULT_CONFIG(_pin_a, _pin_b, _pin_led)
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
_pin_a – [in] Pin for A encoder channel input.
_pin_b – [in] Pin for B encoder channel input.
_pin_led – [in] Pin for LED output.
Typedefs
-
typedef void (*nrfx_qdec_event_handler_t)(nrfx_qdec_event_t event)
QDEC event handler.
- Param event
[in] QDEC event structure.
Functions
-
nrfx_err_t nrfx_qdec_init(nrfx_qdec_config_t const *p_config, nrfx_qdec_event_handler_t event_handler)
Function for initializing QDEC.
- Parameters
p_config – [in] Pointer to the structure with the initial configuration.
event_handler – [in] Event handler provided by the user. Must not be NULL.
- Return values
NRFX_SUCCESS – Initialization was successful.
NRFX_ERROR_INVALID_STATE – The QDEC was already initialized.
-
void nrfx_qdec_uninit(void)
Function for uninitializing QDEC.
Note
Function asserts if module is uninitialized.
-
void nrfx_qdec_enable(void)
Function for enabling QDEC.
Note
Function asserts if module is uninitialized or enabled.
-
void nrfx_qdec_disable(void)
Function for disabling QDEC.
Note
Function asserts if module is uninitialized or disabled.
-
void nrfx_qdec_accumulators_read(int16_t *p_acc, int16_t *p_accdbl)
Function for reading accumulated transitions from the QDEC peripheral.
Note
Function asserts if module is not enabled.
Note
Accumulators are cleared after reading.
- Parameters
p_acc – [out] Pointer to store the accumulated transitions.
p_accdbl – [out] Pointer to store the accumulated double transitions.
-
NRFX_STATIC_INLINE uint32_t nrfx_qdec_task_address_get(nrf_qdec_task_t task)
Function for returning the address of the specified QDEC task.
- Parameters
task – QDEC task.
- Returns
Task address.
-
NRFX_STATIC_INLINE uint32_t nrfx_qdec_event_address_get(nrf_qdec_event_t event)
Function for returning the address of the specified QDEC event.
- Parameters
event – QDEC event.
- Returns
Event address.
-
struct nrfx_qdec_config_t
- #include <nrfx_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.
-
uint32_t psela
Pin number for A input.
-
uint32_t pselb
Pin number for B input.
-
uint32_t pselled
Pin number for LED output.
-
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 sample_inten
Enabling sample ready interrupt.
-
uint8_t interrupt_priority
QDEC interrupt priority.
-
bool skip_gpio_cfg
Skip GPIO configuration of pins.
When set to true, the driver does not modify any GPIO parameters of the used pins. Those parameters are supposed to be configured externally before the driver is initialized.
-
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.
-
nrf_qdec_reportper_t reportper
-
struct nrfx_qdec_sample_data_evt_t
- #include <nrfx_qdec.h>
QDEC sample event data.
Public Members
-
int8_t value
Sample value.
-
int8_t value
-
struct nrfx_qdec_report_data_evt_t
- #include <nrfx_qdec.h>
QDEC report event data.
-
struct nrfx_qdec_event_t
- #include <nrfx_qdec.h>
QDEC event handler structure.
Public Members
-
nrf_qdec_event_t type
Event type.
-
nrfx_qdec_sample_data_evt_t sample
Sample event data.
-
nrfx_qdec_report_data_evt_t report
Report event data.
-
union nrfx_qdec_event_t.[anonymous] data
Union to store event data.
-
nrf_qdec_event_t type
-
NRFX_QDEC_DEFAULT_CONFIG(_pin_a, _pin_b, _pin_led)