Quadrature Encoder#
Introduction#
A Quadrature Encoder (QE), also known as a 2-channel incremental encoder, converts angular displacement into two pulse signals. These two pulses are positioned 90 degrees out of phase. By monitoring both the number of pulses and the relative phase of the two signals, the user code can track the position, direction of rotation, and velocity. The index signal can also be used to reset the position counter.
The quadrature encoder decodes the digital pulses from a quadrature encoder wheel to integrate position over time and determine direction of rotation. Additionally, the QEI can capture the velocity of the encoder wheel. The QEI is present in MCU HP peripherals.
Features of QEI
Tracks encoder wheel position sl_si91x_qei_get_position_counter()
Programmable for 1x, 2x, or 4x position counting, incrementing or decrementing depending on direction sl_si91x_qei_set_encoding_mode()
Includes an index counter for revolution counting sl_si91x_qei_get_index_counter()
Captures velocity using a built-in timer sl_si91x_qei_get_velocity()
Supports position counter reset for rollover/underflow or index pulse sl_si91x_qei_set_configuration()
Provides position, index, and velocity compare registers with interrupts sl_si91x_qei_register_callback()
Allows logically swapping the A and B inputs sl_si91x_qei_swap_a_b()
Accepts decoded signal inputs (clock and direction) in timer mode sl_si91x_qei_configure_timer_mode()
Modules#
Enumerations#
Enumeration for QEI phase swap control.
Enumeration for QEI timer modes.
Enumeration for QEI encoding modes.
Enumeration for QEI direction.
Enumeration for QEI position counting modes.
Enumeration for QEI digital filter settings.
Enumeration for unmasking QEI interrupts.
Enumeration for masking QEI interrupts.
Enumeration for clearing QEI interrupts.
Enumeration for QEI control initialization configuration.
Enumeration for QEI control configuration.
Enumeration for QEI digital filter clock divide select bits.
Typedefs#
Callback function type for QEI events.
Functions#
Initialize the QEI module.
De-initialize the QEI module.
Set the position counter value.
Start the velocity counter.
Get the current position counter value.
Set the encoding mode for the QEI.
Get the current encoding mode.
Set the direction for the QEI.
Get the current direction of the QEI.
Set the index counter value.
Get the current index counter value.
Configure the delta time frequency for velocity calculation.
Set the delta time for velocity calculation.
Get the current delta time.
Configure the stop state for the velocity counter.
Get the current velocity value.
Set the position match value.
Get the current position match value.
Set a value for velocity comparison.
Set the maximum value for the index counter.
Get the current maximum value for the index counter.
Get the current interrupt status.
Swap phases A and B for the QEI.
Configure the QEI to operate in timer mode.
Clear the interrupt set.
Get the current interrupt clear settings.
Get the status of the QEI module.
Set the frequency for the QEI module.
Get the current frequency of the QEI module.
Set the digital filter clock division.
Get the current digital filter clock division.
Register a callback function for QEI events.
Unregister a callback function for QEI events.
Set the maximum position counter value.
Get the current maximum position counter value.
Set configuration parameters for the QEI module.
Get configuration parameters for the QEI module.
To get the API version of the QEI module.
Macros#
software reset of the QEI bit
swapping phase A and B signals bit
position count reset with index signal bit
position count direction bit
position count direction from a register bit
enable index count reset bit
bypass the digital filter bit
setting the timer mode of the QEI bit
starting the velocity counter bit
stop the QEI in idle state bit
selecting the position count mode bit
resetting the position count bit
resetting the index count bit
Encoding mode (2 bits)
Index match value (2 bits)
Digital filter division (4 bits)
Unidirectional velocity (1 bit)
Unidirectional index (1 bit)
Index count initialization (1 bit)
Enumeration Documentation#
sl_qei_control_t#
sl_qei_control_t
Enumeration to control the QEI module.
This enumeration manages the setting and clearing of the module and control configuration registers.
Enumerator | |
---|---|
SL_QEI_RESET | Reset the configurations of the module and control registers. |
SL_QEI_SET | Set the configurations of the module and control registers. |
SL_QEI_STATE_LAST | Last member of the enum for validation purposes. |
sl_qei_swap_ab_t#
sl_qei_swap_ab_t
Enumeration for QEI phase swap control.
This enumeration manages the phase A and phase B input swap select bit.
Enumerator | |
---|---|
SL_QEI_NO_SWAP_AB | No swap for phase A and B. |
SL_QEI_SWAP_AB | Swap phase A and B. |
SL_QEI_SWAP_LAST | Last member of the enum for validation purposes. |
sl_qei_timer_mode_t#
sl_qei_timer_mode_t
Enumeration for QEI timer modes.
This enumeration selects the mode for the quadrature encoder or timer.
Enumerator | |
---|---|
SL_QEI_ENCODER_MODE | Set QEI to encoder mode. |
SL_QEI_TIMER_MODE | Set QEI to timer mode. |
SL_QEI_MODE_LAST | Last member of the enum for validation purposes. |
sl_qei_encoding_mode_t#
sl_qei_encoding_mode_t
Enumeration for QEI encoding modes.
This enumeration controls the encoding modes for programmable 1x, 2x, or 4x position counting.
Enumerator | |
---|---|
SL_QEI_ENCODE_MODE_1X | 1x position counting mode. |
SL_QEI_ENCODE_MODE_2X | 2x position counting mode. |
SL_QEI_ENCODE_MODE_4X | 4x position counting mode. |
SL_QEI_ENCODE_MODE_LAST | Last member of the enum for validation purposes. |
sl_qei_direction_t#
sl_qei_direction_t
Enumeration for QEI direction.
This enumeration defines the possible directions for the Quadrature Encoder Interface (QEI).
Enumerator | |
---|---|
SL_QEI_NEG_DIRECTION | Negative direction of rotation (e.g., counterclockwise). |
SL_QEI_POS_DIRECTION | Positive direction of rotation (e.g., clockwise). |
SL_QEI_DIRECTION_LAST | Last member of the enum for validation purposes. |
sl_qei_pos_cnt_mode_t#
sl_qei_pos_cnt_mode_t
Enumeration for QEI position counting modes.
This enumeration defines the position counting mode(16/32-bit) in the Quadrature Encoder Interface (QEI).
Enumerator | |
---|---|
SL_QEI_POS_CNT_32 | Mode for 32-bit position counting. |
SL_QEI_POS_CNT_16 | Mode for 16-bit position counting. |
SL_QEI_POS_CNT_LAST | Last member of the enum for validation purposes. |
sl_qei_digital_filter_t#
sl_qei_digital_filter_t
Enumeration for QEI digital filter settings.
This enumeration defines the settings for digital filtering in the Quadrature Encoder Interface (QEI).
Enumerator | |
---|---|
SL_QEI_DIGITAL_FILTER | Enable digital filtering. |
SL_QEI_BYPASS_FILTER | digital filtering (bypass mode). |
SL_QEI_DIGITAL_FILTER_LAST | Last member of the enum for validation purposes. |
sl_qei_intr_unmask_config_t#
sl_qei_intr_unmask_config_t
Enumeration for unmasking QEI interrupts.
This enumeration manages the unmasking of QEI interrupts.
Enumerator | |
---|---|
SL_QEI_POS_CNT_RESET_INTR_UNMASK | Unmask position counter reset interrupt. |
SL_QEI_IDX_CNT_MATCH_INTR_UNMASK | Unmask index count match interrupt. |
SL_QEI_POS_CNT_ERR_INTR_UNMASK | Unmask position counter error interrupt. |
SL_QEI_VELOCITY_LESS_INTR_UNMASK | Unmask velocity less than interrupt. |
SL_QEI_POS_CNT_MATCH_INTR_UNMASK | Unmask position count match interrupt. |
SL_QEI_VELOCITY_COMP_OVER_INTR_UNMASK | Unmask velocity computation overflow interrupt. |
SL_QEI_PARAM_UNMASK_LAST | Last member of the enum for validation purposes. |
sl_qei_intr_mask_config_t#
sl_qei_intr_mask_config_t
Enumeration for masking QEI interrupts.
This enumeration manages the masking of QEI interrupts.
Enumerator | |
---|---|
SL_QEI_POS_CNT_RESET_INTR_MASK | Mask position counter reset interrupt. |
SL_QEI_IDX_CNT_MATCH_INTR_MASK | Mask index count match interrupt. |
SL_QEI_POS_CNT_ERR_INTR_MASK | Mask position counter error interrupt. |
SL_QEI_VELOCITY_LESS_INTR_MASK | Mask velocity less than interrupt. |
SL_QEI_POS_CNT_MATCH_INTR_MASK | Mask position count match interrupt. |
SL_QEI_VELOCITY_COMP_OVER_INTR_MASK | Mask velocity computation overflow interrupt. |
SL_QEI_PARAM_MASK_LAST | Last member of the enum for validation purposes. |
sl_qei_intr_clear_config_t#
sl_qei_intr_clear_config_t
Enumeration for clearing QEI interrupts.
This enumeration manages the clearing of QEI interrupts.
Enumerator | |
---|---|
SL_QEI_POS_CNT_RESET_INTR_LVL | Clear position counter reset interrupt. |
SL_QEI_IDX_CNT_MATCH_INTR_LVL | Clear index count match interrupt. |
SL_QEI_POS_CNT_ERR_INTR_LVL | Clear position counter error interrupt. |
SL_QEI_VELOCITY_LESS_INTR_LVL | Clear velocity less than interrupt. |
SL_QEI_POS_CNT_MATCH_INTR_LVL | Clear position count match interrupt. |
SL_QEI_VELOCITY_COMP_OVER_INTR_LVL | Clear velocity computation overflow interrupt. |
SL_QEI_PARAM_CLEAR_LAST | Last member of the enum for validation purposes. |
sl_qei_ctrl_init_config_t#
sl_qei_ctrl_init_config_t
Enumeration for QEI control initialization configuration.
This enumeration specifies the initialization configuration for QEI control.
Enumerator | |
---|---|
SL_QEI_UNIDIRECTIONAL_VELOCITY | Enable unidirectional velocity. |
SL_QEI_UNIDIRECTIONAL_INDEX | Enable unidirectional index. |
SL_QEI_INDEX_COUNT_INIT | Initialize index counter. |
SL_QEI_CTRL_INIT_LAST | Last member of the enum for validation purposes. |
sl_qei_control_config_t#
sl_qei_control_config_t
Enumeration for QEI control configuration.
This enumeration specifies the control configuration parameters for QEI.
Enumerator | |
---|---|
SL_QEI_DIGITAL_FILTER_BYPASS | Bypass digital filter. |
SL_QEI_INDEX_COUNT_RESET | Index counter reset. |
SL_QEI_IDX_CNT_RST_EN | Enable index counter reset. |
SL_QEI_POS_CNT_16_BIT_MDE | Set position counter to 16-bit mode. |
SL_QEI_POS_CNT_DIR_FRM_REG | Set position counter direction from register. |
SL_QEI_POS_CNT_DIR_CTRL | Control direction of the position counter. |
SL_QEI_POS_CNT_RST | Reset position counter. |
SL_QEI_POS_CNT_RST_WITH_IDX_EN | Reset position counter with index enable. |
SL_QEI_START_VELOCITY_CNTR | Start velocity counter. |
SL_QEI_STOP_IN_IDLE | Stop in idle state. |
SL_QEI_SWAP_PHASE_AB_B | Swap phases A and B. |
SL_QEI_INTERFACE_TIMER_MODE | Set to timer mode. |
SL_QEI_CONTROL_CONFIG_LAST | Last member of the enum for validation purposes. |
sl_qei_clk_div_t#
sl_qei_clk_div_t
Enumeration for QEI digital filter clock divide select bits.
This enumeration specifies the control configuration digital filter clock divide parameter for QEI.
Enumerator | |
---|---|
SL_QEI_CLK_DIV_1 | 1:1 Clock divide for Index, position A & B |
SL_QEI_CLK_DIV_2 | 1:2 Clock divide for Index, position A & B |
SL_QEI_CLK_DIV_4 | 1:4 Clock divide for Index, position A & B |
SL_QEI_CLK_DIV_8 | 1:8 Clock divide for Index, position A & B |
SL_QEI_CLK_DIV_16 | 1:16 Clock divide for Index, position A & B |
SL_QEI_CLK_DIV_32 | 1:32 Clock divide for Index, position A & B |
SL_QEI_CLK_DIV_64 | 1:64 Clock divide for Index, position A & B |
SL_QEI_CLK_DIV_128 | 1:128 Clock divide for Index, position A & B |
SL_QEI_CLK_DIV_256 | 1:256 Clock divide for Index, position A & B |
SL_QEI_CLK_DIV_512 | 1:512 Clock divide for Index, position A & B |
SL_QEI_CLK_DIV_1024 | 1:1024 Clock divide for Index, position A & B |
SL_QEI_CLK_DIV_LAST | Last member of the enum for validation purposes. |
Typedef Documentation#
sl_qei_callback_t#
typedef void(* sl_qei_callback_t) (void *callback_flag) )(void *callback_flag)
Callback function type for QEI events.
Function Documentation#
sl_si91x_qei_init#
sl_status_t sl_si91x_qei_init (sl_qei_init_t * qei_init)
Initialize the QEI module.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_qei_init_t * | [in] | qei_init | Pointer to the structure of type sl_qei_init_t. |
This function initializes the QEI module, setting it up for operation. It should be called before using any other QEI functions.
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Success.
SL_STATUS_NULL_POINTER (0x0022) - The parameter is a null pointer.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_deinit#
void sl_si91x_qei_deinit (void )
De-initialize the QEI module.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
Pre-conditions:
This function cleans up and deinitializes the QEI module, ensuring that all resources are released and the module is no longer active.
sl_si91x_qei_set_position_counter#
sl_status_t sl_si91x_qei_set_position_counter (uint32_t pos_cnt_value)
Set the position counter value.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | pos_cnt_value | Position counter value to set. |
This function sets the value of the position counter. The position counter is used to track the current position in applications such as rotary encoders.
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Success.
SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is an invalid argument.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_start_velocity#
sl_status_t sl_si91x_qei_start_velocity (uint32_t period)
Start the velocity counter.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | period | Delta time value to set. This timing information is essential for calculating the velocity of a rotating shaft or moving part by determining how quickly the position changes over a specified period. |
This function starts the velocity counter. This is required for managing when velocity calculations should take place.
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Success.
SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is an invalid argument.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_get_position_counter#
__STATIC_INLINE uint32_t sl_si91x_qei_get_position_counter (void )
Get the current position counter value.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
This function retrieves the current value of the position counter, which reflects the position state of the QEI module.
Returns
Returns the current position counter value.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_set_encoding_mode#
sl_status_t sl_si91x_qei_set_encoding_mode (sl_qei_encoding_mode_t mode)
Set the encoding mode for the QEI.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_qei_encoding_mode_t | [in] | mode | Encoding mode to set of type sl_qei_encoding_mode_t. |
This function configures the encoding mode of the Quadrature Encoder Interface (QEI). Different encoding modes can impact how position and direction are computed.
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Success.
SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is an invalid argument.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_get_encoding_mode#
__STATIC_INLINE sl_qei_encoding_mode_t sl_si91x_qei_get_encoding_mode (void )
Get the current encoding mode.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
This function retrieves the currently configured encoding mode for the QEI. This is useful for understanding how the position and direction are being interpreted.
Returns
Returns the current encoding mode.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_set_pos_direction#
sl_status_t sl_si91x_qei_set_pos_direction (sl_qei_direction_t direction)
Set the direction for the QEI.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_qei_direction_t | [in] | direction | Direction to set of type sl_qei_direction_t. |
This function sets the direction of the QEI. This is critical for applications where direction affects how the position is interpreted (e.g., clockwise vs. counterclockwise).
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Success.
SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is an invalid argument.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_get_direction#
__STATIC_INLINE sl_qei_direction_t sl_si91x_qei_get_direction (void )
Get the current direction of the QEI.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
This function retrieves the current direction setting of the QEI, indicating whether the encoder is configured to interpret movement as forward or backward.
Returns
Returns the current direction.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_set_index_counter#
sl_status_t sl_si91x_qei_set_index_counter (uint32_t index_count)
Set the index counter value.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | index_count | Index counter value to set. |
This function sets the index counter value, which can be used in applications that require indexing or referencing specific positions.
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Success.
SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is an invalid argument.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_get_index_counter#
__STATIC_INLINE uint32_t sl_si91x_qei_get_index_counter (void )
Get the current index counter value.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
This function retrieves the current index counter value, which can be useful for tracking indexed positions or for synchronization purposes.
Returns
Returns the current index counter value.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_configure_delta_time_frequency#
sl_status_t sl_si91x_qei_configure_delta_time_frequency (uint32_t freq, uint32_t period)
Configure the delta time frequency for velocity calculation.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | freq | Frequency for delta time. |
uint32_t | [in] | period | Period for delta time. |
This function sets up the delta time frequency and period to be used in velocity calculations. Proper configuration ensures accurate velocity readings.
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Success.
SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is an invalid argument.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_set_delta_time#
sl_status_t sl_si91x_qei_set_delta_time (uint32_t delta_time)
Set the delta time for velocity calculation.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | delta_time | Delta time to set. |
This function sets the delta time value, which is critical for calculating velocity based on the position changes over time.
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Success.
SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is an invalid argument.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_get_delta_time#
__STATIC_INLINE uint32_t sl_si91x_qei_get_delta_time (void )
Get the current delta time.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
This function retrieves the current delta time value being used for velocity calculations, providing insight into the timing configuration.
Returns
Returns the current delta time.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_stop_velocity#
__STATIC_INLINE void sl_si91x_qei_stop_velocity (void )
Configure the stop state for the velocity counter.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
This function stops the velocity counter.
sl_si91x_qei_get_velocity#
__STATIC_INLINE uint32_t sl_si91x_qei_get_velocity (void )
Get the current velocity value.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
This function retrieves the current calculated velocity, which can be used in applications requiring real-time speed monitoring.
Returns
Returns the current velocity.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_set_position_match#
sl_status_t sl_si91x_qei_set_position_match (uint32_t pos_match)
Set the position match value.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | pos_match | Position match value to set. |
This function sets a specific position match value. The QEI can generate interrupts or events when this position is reached.
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Success.
SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is an invalid argument.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_get_position_match#
__STATIC_INLINE uint32_t sl_si91x_qei_get_position_match (void )
Get the current position match value.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
This function retrieves the currently set position match value, which helps in understanding the QEI's tracking and event generation capabilities.
Returns
Returns the current position match value.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_set_velocity_value_to_compare#
sl_status_t sl_si91x_qei_set_velocity_value_to_compare (uint32_t velocity_value)
Set a value for velocity comparison.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | velocity_value | Velocity value to compare against. |
This function sets a threshold velocity value, which can be used for comparing against the current velocity to trigger events or actions.
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Success.
SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is an invalid argument.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_set_index_maximum_counter#
sl_status_t sl_si91x_qei_set_index_maximum_counter (uint32_t max_index)
Set the maximum value for the index counter.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | max_index | Maximum index counter value to set. |
This function sets the maximum allowable value for the index counter, which can prevent overflow and ensure proper operation.
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Success.
SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is an invalid argument.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_get_index_maximum_counter#
__STATIC_INLINE uint32_t sl_si91x_qei_get_index_maximum_counter (void )
Get the current maximum value for the index counter.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
This function retrieves the current maximum index counter value, which helps in validating the index counter's limits and configuration.
Returns
Returns current maximum index counter value.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_get_interrupt_status#
__STATIC_INLINE uint32_t sl_si91x_qei_get_interrupt_status (void )
Get the current interrupt status.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
This function retrieves the status of the interrupts related to the QEI module, providing insights into any triggered conditions or events.
Returns
Returns the current interrupt status.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_swap_a_b#
sl_status_t sl_si91x_qei_swap_a_b (sl_qei_swap_ab_t swap_select)
Swap phases A and B for the QEI.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_qei_swap_ab_t | [in] | swap_select | Selection for swapping phases of type sl_qei_swap_ab_t |
This function allows swapping the A and B phases of the encoder signals. This can be useful for correcting phase issues without hardware changes.
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Success.
SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is an invalid argument.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_configure_timer_mode#
sl_status_t sl_si91x_qei_configure_timer_mode (sl_qei_timer_mode_t timer_mode)
Configure the QEI to operate in timer mode.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_qei_timer_mode_t | [in] | timer_mode | Timer mode to set of type sl_qei_timer_mode_t |
This function sets the QEI to operate in timer mode, allowing for more precise timing and position tracking applications.
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Success.
SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is an invalid argument.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_clear_interrupt#
sl_status_t sl_si91x_qei_clear_interrupt (uint32_t int_mask)
Clear the interrupt set.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | int_mask | Masked interrupt to clear |
This function clears interrupts in the QEI module.
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Success.
SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is an invalid argument.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_get_interrupt_clear#
__STATIC_INLINE uint32_t sl_si91x_qei_get_interrupt_clear (void )
Get the current interrupt clear settings.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
This function retrieves the current settings for clearing interrupts in the QEI module, useful for managing event handling.
Returns
Returns the current interrupt clear settings.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_get_status#
__STATIC_INLINE uint32_t sl_si91x_qei_get_status (void )
Get the status of the QEI module.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
This function retrieves the operational status of the QEI module, which can be useful for diagnostics and monitoring its state.
Returns
Returns the current module status. This will read direct value from position signal geneartor, position counter direction, counter error status flag.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_set_module_frequency#
sl_status_t sl_si91x_qei_set_module_frequency (uint32_t frequency)
Set the frequency for the QEI module.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | frequency | Frequency value to set. |
This function sets the operational frequency for the QEI module. The frequency affects the responsiveness and timing accuracy of the module.
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Success.
SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is an invalid argument.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_get_module_frequency#
__STATIC_INLINE uint32_t sl_si91x_qei_get_module_frequency (void )
Get the current frequency of the QEI module.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
This function retrieves the current operational frequency for the QEI module, which can help in performance tuning and analysis.
@return Returns the current frequency value.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_set_digital_filter_clock_division#
sl_status_t sl_si91x_qei_set_digital_filter_clock_division (sl_qei_clk_div_t clock_division)
Set the digital filter clock division.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_qei_clk_div_t | [in] | clock_division | Clock division value to set sl_qei_clk_div_t |
This function sets the clock division factor for the digital filter in the QEI module, which can help in reducing noise and improving signal integrity.
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Success.
SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is an invalid argument.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_get_digital_filter_clock_division#
__STATIC_INLINE sl_qei_clk_div_t sl_si91x_qei_get_digital_filter_clock_division (void )
Get the current digital filter clock division.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
This function retrieves the current clock division value for the digital filter in the QEI module, useful for validating filter settings.
@return current clock division value.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_register_callback#
sl_status_t sl_si91x_qei_register_callback (sl_qei_callback_t callback, void * callback_flag_value, sl_qei_intr_unmask_t * intr_flags)
Register a callback function for QEI events.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_qei_callback_t | [in] | callback | Callback function to register of type sl_qei_callback_t |
void * | [in] | callback_flag_value | Pointer to value passed to the callback. |
sl_qei_intr_unmask_t * | [in] | intr_flags | Pointer to interrupt unmask settings of type sl_qei_intr_unmask_t |
This function allows users to register a callback function that will be called on specific QEI events. This is essential for responsive applications that need to react to state changes.
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Success.
SL_STATUS_NULL_POINTER (0x0022) - The parameter is a null pointer.
SL_STATUS_BUSY (0x0004) - Busy
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_unregister_callback#
sl_status_t sl_si91x_qei_unregister_callback (sl_qei_intr_mask_t * intr_mask)
Unregister a callback function for QEI events.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_qei_intr_mask_t * | [in] | intr_mask | Pointer to interrupt mask settings of type sl_qei_intr_mask_t |
This function removes a previously registered callback function, stopping it from being called on QEI events.
Pre-conditions:
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Success.
SL_STATUS_NULL_POINTER (0x0022) - The parameter is a null pointer.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_set_maximum_position_counter#
sl_status_t sl_si91x_qei_set_maximum_position_counter (uint32_t max_pos_cnt)
Set the maximum position counter value.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | max_pos_cnt | Maximum position counter value to set. |
This function sets a maximum value for the position counter, helping to prevent overflow and ensuring reliable operation of the QEI in applications. Position match value to compare the position counter. When it is matched with position counter, interrupt is raised.
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Success.
SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is an invalid argument.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_get_maximum_position_counter#
__STATIC_INLINE uint32_t sl_si91x_qei_get_maximum_position_counter (void )
Get the current maximum position counter value.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
This function retrieves the maximum position counter value that has been set, which can be useful for validating limits and configurations.
@return Returns the current maximum position counter value.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_set_configuration#
sl_status_t sl_si91x_qei_set_configuration (sl_qei_control_t state, sl_qei_config_t * config)
Set configuration parameters for the QEI module.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_qei_control_t | [in] | state | State to reset/set module configurations of type sl_qei_control_t. |
sl_qei_config_t * | [in] | config | Pointer to configuration structure of type sl_qei_config_t. |
This function applies specific configuration parameters to the QEI module, allowing for customized operation based on the needs of the application.
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Success.
SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is an invalid argument.
SL_STATUS_NULL_POINTER (0x0022) - The parameter is a null pointer.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_get_configuration#
sl_status_t sl_si91x_qei_get_configuration (sl_qei_control_t state, sl_qei_config_t * config)
Get configuration parameters for the QEI module.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_qei_control_t | [in] | state | Get module configurations of type sl_qei_control_t. |
sl_qei_config_t * | [out] | config | Pointer to store configuration parameters sl_qei_config_t |
This function retrieves the current configuration parameters of the QEI module, enabling verification of settings and operational parameters.
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Success.
SL_STATUS_INVALID_PARAMETER (0x0021) - The parameter is an invalid argument.
SL_STATUS_NULL_POINTER (0x0022) - The parameter is a null pointer.
For more information on status codes, see SL STATUS DOCUMENTATION.
sl_si91x_qei_get_version#
sl_qei_version_t sl_si91x_qei_get_version (void )
To get the API version of the QEI module.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
This API retrieves the version information of the QEI module, which includes the release, SQA, and DEV version numbers.
Returns
Returns a structure of type sl_qei_version_t.