![]() |
MCUXpresso SDK API Reference Manual
Rev 2.16.000
NXP Semiconductors
|
This document consists of sections titled with Driver Overview, Data Structures, Enumerations, Functions, etc., each with an overview list and detailed documentation. It is recommended to read the Driver Overview first for it includes a comprehensive description of the peripheral, driver and driver changes. Other sections give detailed information for APIs, enums, macros, etc., for your further reference.
Modules | |
QDC Peripheral and Driver Overview | |
Content including 1) peripheral features, work logic and work method; 2) driver design logic and use method. | |
The Driver Change Log | |
The current QDC driver version is 2.1.0. | |
Data Structures | |
struct | qdc_config_t |
Define user configuration structure for QDC module. More... | |
Macros | |
#define | QDC_CTRL_W1C_FLAGS (QDC_CTRL_HIRQ_MASK | QDC_CTRL_XIRQ_MASK | QDC_CTRL_DIRQ_MASK) |
W1C bits in QDC CTRL registers. More... | |
#define | QDC_CTRL2_W1C_FLAGS (QDC_CTRL2_ROIRQ_MASK | QDC_CTRL2_RUIRQ_MASK) |
W1C bits in QDC CTRL2 registers. More... | |
#define | QDC_CTRL_INT_EN (QDC_CTRL_HIE_MASK | QDC_CTRL_XIE_MASK | QDC_CTRL_DIE_MASK) |
W1C bits in QDC CTRL3 registers. More... | |
#define | QDC_CTRL2_INT_EN (QDC_CTRL2_ROIE_MASK | QDC_CTRL2_RUIE_MASK) |
Interrupt enable bits in QDC CTRL2 registers. More... | |
#define | QDC_CTRL_INT_FLAGS (QDC_CTRL_HIRQ_MASK | QDC_CTRL_XIRQ_MASK | QDC_CTRL_DIRQ_MASK) |
Interrupt enable bits in QDC CTRL3 registers. More... | |
#define | QDC_CTRL2_INT_FLAGS (QDC_CTRL2_ROIRQ_MASK | QDC_CTRL2_RUIRQ_MASK) |
Interrupt flag bits in QDC CTRL2 registers. More... | |
Driver version | |
#define | FSL_QDC_DRIVER_VERSION (MAKE_VERSION(2, 1, 0)) |
QDC driver version. More... | |
Initialization and deinitialization Interfaces | |
void | QDC_Init (QDC_Type *base, const qdc_config_t *psConfig) |
Initializes the QDC module. More... | |
void | QDC_GetDefaultConfig (qdc_config_t *psConfig) |
Gets an available pre-defined configuration. More... | |
void | QDC_Deinit (QDC_Type *base) |
De-initializes the QDC module. More... | |
Watchdog | |
static void | QDC_EnableWatchdog (QDC_Type *base, bool bEnable) |
Enable watchdog for QDC module. More... | |
static void | QDC_SetWatchdogTimeout (QDC_Type *base, uint16_t u16Timeout) |
Set watchdog timeout value. More... | |
Status | |
static uint16_t | QDC_GetStatusFlags (QDC_Type *base) |
Get the status flags. More... | |
static void | QDC_ClearStatusFlags (QDC_Type *base, uint16_t u16Flags) |
Clear the status flags. More... | |
static uint16_t | QDC_GetSignalStatusFlags (QDC_Type *base) |
Get the signals' real-time status. More... | |
static qdc_count_direction_flag_t | QDC_GetLastCountDirection (QDC_Type *base) |
Get the direction of the last count. More... | |
Interrupts | |
static void | QDC_EnableInterrupts (QDC_Type *base, uint16_t u16Interrupts) |
Enable the interrupts. More... | |
static void | QDC_DisableInterrupts (QDC_Type *base, uint16_t u16Interrupts) |
Disable the interrupts. More... | |
Counter Operation | |
static void | QDC_DoSoftwareLoadInitialPositionValue (QDC_Type *base) |
Load the initial position value to position counter. More... | |
static void | QDC_SetInitialPositionValue (QDC_Type *base, uint32_t u32PositionInitValue) |
Set initial position value for QDC module. More... | |
static void | QDC_SetPositionCounterValue (QDC_Type *base, uint32_t u32PositionCounterValue) |
Set position counter value. More... | |
static void | QDC_SetPositionModulusValue (QDC_Type *base, uint32_t u32PositionModulusValue) |
Set position counter modulus value. More... | |
static void | QDC_SetPositionCompareValue (QDC_Type *base, uint32_t u32PositionCompValue) |
Set position counter compare value. More... | |
static uint32_t | QDC_GetPosition (QDC_Type *base) |
Get the current position counter's value. More... | |
static uint32_t | QDC_GetHoldPosition (QDC_Type *base) |
Get the hold position counter's value. More... | |
static uint16_t | QDC_GetPositionDifference (QDC_Type *base) |
Get the position difference counter's value. More... | |
static uint16_t | QDC_GetHoldPositionDifference (QDC_Type *base) |
Get the hold position difference counter's value. More... | |
static uint16_t | QDC_GetRevolution (QDC_Type *base) |
Get the revolution counter's value. More... | |
static uint16_t | QDC_GetHoldRevolution (QDC_Type *base) |
Get the hold revolution counter's value. More... | |
struct qdc_config_t |
Data Fields | |
bool | bEnableReverseDirection |
Enable reverse direction counting. More... | |
qdc_decoder_work_mode_t | eDecoderWorkMode |
Use standard quadrature decoder mode or signal phase count mode. More... | |
qdc_home_init_pos_counter_mode_t | eHomeInitPosCounterMode |
Select how HOME signal used to initialize position counters. More... | |
qdc_index_init_pos_counter_mode_t | eIndexInitPosCounterMode |
Select how INDEX signal used to initialize position counters. More... | |
bool | bEnableTriggerInitPositionCounter |
Initialize position counter with initial register(UINIT, LINIT) value on TRIGGER's rising edge. More... | |
bool | bEnableTriggerClearPositionRegisters |
Clear position counter(POS), revolution counter(REV), position difference counter (POSD) on TRIGGER's rising edge. More... | |
bool | bEnableTriggerHoldPositionRegisters |
Load position counter(POS), revolution counter(REV), position difference counter (POSD) values to hold registers on TRIGGER's rising edge. More... | |
bool | bEnableWatchdog |
Enable the watchdog to detect if the target is moving or not. More... | |
uint16_t | u16WatchdogTimeoutValue |
Watchdog timeout count value. More... | |
qdc_filter_sample_count_t | eFilterSampleCount |
Input Filter Sample Count. More... | |
uint8_t | u8FilterSamplePeriod |
Input Filter Sample Period. More... | |
qdc_output_pulse_mode_t | eOutputPulseMode |
The condition of POSMATCH pulses. More... | |
uint32_t | u32PositionCompareValue |
Position compare value. More... | |
uint32_t | u32PositionCompare1Value |
Position compare 1 value. More... | |
qdc_revolution_count_condition_t | eRevolutionCountCondition |
Revolution Counter Modulus Enable. More... | |
bool | bEnableModuloCountMode |
Enable Modulo Counting. More... | |
uint32_t | u32PositionModulusValue |
Position modulus value. More... | |
uint32_t | u32PositionInitialValue |
Position initial value. More... | |
uint32_t | u32PositionCounterValue |
Position counter value. More... | |
bool | bEnablePeriodMeasurement |
Enable period measurement. More... | |
qdc_prescaler_t | ePrescaler |
Prescaler. More... | |
uint16_t | u16EnabledInterruptsMask |
Mask of interrupts to be enabled, should be OR'ed value of _qdc_interrupt_enable. More... | |
bool qdc_config_t::bEnableReverseDirection |
qdc_decoder_work_mode_t qdc_config_t::eDecoderWorkMode |
qdc_home_init_pos_counter_mode_t qdc_config_t::eHomeInitPosCounterMode |
qdc_index_init_pos_counter_mode_t qdc_config_t::eIndexInitPosCounterMode |
bool qdc_config_t::bEnableTriggerInitPositionCounter |
bool qdc_config_t::bEnableTriggerClearPositionRegisters |
bool qdc_config_t::bEnableTriggerHoldPositionRegisters |
bool qdc_config_t::bEnableWatchdog |
uint16_t qdc_config_t::u16WatchdogTimeoutValue |
It stores the timeout count for the quadrature decoder module watchdog timer.
qdc_filter_sample_count_t qdc_config_t::eFilterSampleCount |
This value should be chosen to reduce the probability of noisy samples causing an incorrect transition to be recognized. The value represent the number of consecutive samples that must agree prior to the input filter accepting an input transition.
uint8_t qdc_config_t::u8FilterSamplePeriod |
This value should be set such that the sampling period is larger than the period of the expected noise. This value represents the sampling period (in IPBus clock cycles) of the decoder input signals. The available range is 0 - 255.
qdc_output_pulse_mode_t qdc_config_t::eOutputPulseMode |
uint32_t qdc_config_t::u32PositionCompareValue |
The available value is a 32-bit number.
uint32_t qdc_config_t::u32PositionCompare1Value |
The available value is a 32-bit number.
qdc_revolution_count_condition_t qdc_config_t::eRevolutionCountCondition |
bool qdc_config_t::bEnableModuloCountMode |
uint32_t qdc_config_t::u32PositionModulusValue |
Only used when bEnableModuloCountMode is true. The available value is a 32-bit number.
uint32_t qdc_config_t::u32PositionInitialValue |
The available value is a 32-bit number.
uint32_t qdc_config_t::u32PositionCounterValue |
When Modulo mode enabled, the u32PositionCounterValue should be in the range of u32PositionInitialValue and u32PositionModulusValue.
bool qdc_config_t::bEnablePeriodMeasurement |
When enabled, the position difference hold register (POSDH) is only updated when position difference register (POSD) is read.
qdc_prescaler_t qdc_config_t::ePrescaler |
uint16_t qdc_config_t::u16EnabledInterruptsMask |
#define FSL_QDC_DRIVER_VERSION (MAKE_VERSION(2, 1, 0)) |
#define QDC_CTRL_W1C_FLAGS (QDC_CTRL_HIRQ_MASK | QDC_CTRL_XIRQ_MASK | QDC_CTRL_DIRQ_MASK) |
#define QDC_CTRL2_W1C_FLAGS (QDC_CTRL2_ROIRQ_MASK | QDC_CTRL2_RUIRQ_MASK) |
#define QDC_CTRL_INT_EN (QDC_CTRL_HIE_MASK | QDC_CTRL_XIE_MASK | QDC_CTRL_DIE_MASK) |
Interrupt enable bits in QDC CTRL registers.
#define QDC_CTRL2_INT_EN (QDC_CTRL2_ROIE_MASK | QDC_CTRL2_RUIE_MASK) |
#define QDC_CTRL_INT_FLAGS (QDC_CTRL_HIRQ_MASK | QDC_CTRL_XIRQ_MASK | QDC_CTRL_DIRQ_MASK) |
Interrupt flag bits in QDC CTRL registers.
#define QDC_CTRL2_INT_FLAGS (QDC_CTRL2_ROIRQ_MASK | QDC_CTRL2_RUIRQ_MASK) |
enum _qdc_status_flags |
QDC status flags, these flags indicate the counter's events.
enum _qdc_signal_status |
In normal work mode uses the standard quadrature decoder with PHASEA and PHASEB. In signal phase count mode, a positive transition of the PHASEA input generates a count signal while the PHASEB input and the reverse direction control the counter direction. If the reverse direction is not enabled, PHASEB = 0 means counting up and PHASEB = 1 means counting down. If the reverse direction is enabled, PHASEB = 0 means counting down and PHASEB = 1 means counting up.
The Input Filter Sample Count represents the number of consecutive samples that must agree, before the input filter accepts an input transition
enum qdc_prescaler_t |
void QDC_Init | ( | QDC_Type * | base, |
const qdc_config_t * | psConfig | ||
) |
This function initializes the QDC by:
base | QDC peripheral base address. |
psConfig | Pointer to configuration structure. |
void QDC_GetDefaultConfig | ( | qdc_config_t * | psConfig | ) |
The default value are:
psConfig | Pointer to configuration structure. |
void QDC_Deinit | ( | QDC_Type * | base | ) |
This function deinitializes the QDC by:
base | QDC peripheral base address. |
|
inlinestatic |
base | QDC peripheral base address |
bEnable | Enables or disables the watchdog |
|
inlinestatic |
base | QDC peripheral base address |
u16Timeout | Number of clock cycles, plus one clock cycle that the watchdog timer counts before timing out |
|
inlinestatic |
base | QDC peripheral base address. |
|
inlinestatic |
base | QDC peripheral base address. |
u16Flags | Logical OR'ed value of the flags to clear, _qdc_status_flags. |
|
inlinestatic |
base | QDC peripheral base address. |
|
inlinestatic |
base | QDC peripheral base address. |
|
inlinestatic |
base | QDC peripheral base address. |
u16Interrupts | Logical OR'ed value of the interrupts, _qdc_interrupt_enable. |
|
inlinestatic |
base | QDC peripheral base address. |
u16Interrupts | Logical OR'ed value of the interrupts, _qdc_interrupt_enable. |
|
inlinestatic |
Software trigger to load the initial position value (UINIT and LINIT) contents to position counter (UPOS and LPOS), so that to provide the consistent operation the position counter registers.
base | QDC peripheral base address. |
|
inlinestatic |
Set the position counter initial value (INIT or UINIT, LINIT).
base | QDC peripheral base address |
u32PositionInitValue | Position initial value |
|
inlinestatic |
Set the position counter value (POS or UPOS, LPOS).
base | QDC peripheral base address |
u32PositionCounterValue | Position counter value |
|
inlinestatic |
Set the position counter modulus value (MOD or UMOD, LMOD).
base | QDC peripheral base address |
u32PositionModulusValue | Position modulus value |
|
inlinestatic |
Set the position counter compare value (COMP or UCOMP, LCOMP).
base | QDC peripheral base address |
u32PositionCompValue | Position modulus value |
|
inlinestatic |
base | QDC peripheral base address. |
|
inlinestatic |
The position counter (POS or UPOS, LPOS) value is loaded to hold position (POSH or UPOSH, LPOSH) when:
base | QDC peripheral base address. |
|
inlinestatic |
base | QDC peripheral base address. |
|
inlinestatic |
The position difference (POSD) value is loaded to hold position difference (POSDH) when:
base | QDC peripheral base address. |
|
inlinestatic |
Get the revolution counter (REV) value.
base | QDC peripheral base address. |
|
inlinestatic |
The revolution counter (REV) value is loaded to hold revolution (REVH) when:
base | QDC peripheral base address. |