12 #include "hpm_qei_regs.h"
20 #define QEI_EVENT_WDOG_FLAG_MASK (1U << 31)
21 #define QEI_EVENT_HOME_FLAG_MASK (1U << 30)
22 #define QEI_EVENT_POSITIVE_COMPARE_FLAG_MASK (1U << 29)
23 #define QEI_EVENT_Z_PHASE_FLAG_MASK (1U << 28)
154 qei_x->
TRGOEN |= event_mask;
169 qei_x->
TRGOEN &= ~event_mask;
184 qei_x->
READEN |= event_mask;
199 qei_x->
READEN &= ~event_mask;
284 if ((qei_x->
SR & mask) == mask) {
303 qei_x->
IRQEN |= mask;
318 qei_x->
IRQEN &= ~mask;
333 qei_x->
DMAEN |= mask;
348 qei_x->
DMAEN &= ~mask;
480 uint32_t counter_mask)
482 qei_x->
CR |= counter_mask << 16;
495 uint32_t counter_mask)
497 qei_x->
CR |= counter_mask << 12;
#define QEI_PHCFG_PHMAX_SET(x)
Definition: hpm_qei_regs.h:205
#define QEI_SPDHIS_SPDHIS0
Definition: hpm_qei_regs.h:630
#define QEI_COUNT_READ
Definition: hpm_qei_regs.h:625
#define QEI_COUNT_PH_PHCNT_GET(x)
Definition: hpm_qei_regs.h:558
#define QEI_PHCFG_ZCNTCFG_SET(x)
Definition: hpm_qei_regs.h:185
#define QEI_SPDHIS_SPDHIS0_GET(x)
Definition: hpm_qei_regs.h:619
#define QEI_CR_ENCTYP_MASK
Definition: hpm_qei_regs.h:171
#define QEI_PHCMP_PHCMP_SET(x)
Definition: hpm_qei_regs.h:372
#define QEI_COUNT_PH_BSTAT_GET(x)
Definition: hpm_qei_regs.h:549
#define QEI_COUNT_SNAP1
Definition: hpm_qei_regs.h:627
#define QEI_CR_ENCTYP_SET(x)
Definition: hpm_qei_regs.h:173
#define QEI_CR_RSTCNT_MASK
Definition: hpm_qei_regs.h:161
#define QEI_SPDHIS_SPDHIS3
Definition: hpm_qei_regs.h:633
#define QEI_COUNT_PH_ASTAT_GET(x)
Definition: hpm_qei_regs.h:539
#define QEI_PHCFG_PHCALIZ_SET(x)
Definition: hpm_qei_regs.h:195
#define QEI_SPDHIS_SPDHIS2
Definition: hpm_qei_regs.h:632
#define QEI_PHCMP_ZCMPDIS_SET(x)
Definition: hpm_qei_regs.h:341
#define QEI_WDGCFG_WDGEN_MASK
Definition: hpm_qei_regs.h:214
#define QEI_CR_READ_MASK
Definition: hpm_qei_regs.h:41
#define QEI_COUNT_SNAP0
Definition: hpm_qei_regs.h:626
#define QEI_ZCMP_ZCMP_SET(x)
Definition: hpm_qei_regs.h:330
#define QEI_CR_SNAPEN_MASK
Definition: hpm_qei_regs.h:151
#define QEI_PHIDX_PHIDX_SET(x)
Definition: hpm_qei_regs.h:237
#define QEI_PHCMP_DIRCMPDIS_MASK
Definition: hpm_qei_regs.h:349
#define QEI_SPDHIS_SPDHIS1
Definition: hpm_qei_regs.h:631
#define QEI_SPDCMP_SPDCMP_SET(x)
Definition: hpm_qei_regs.h:383
#define QEI_PHCMP_DIRCMP_SET(x)
Definition: hpm_qei_regs.h:362
#define QEI_WDGCFG_WDGEN_SET(x)
Definition: hpm_qei_regs.h:216
#define QEI_COUNT_CURRENT
Definition: hpm_qei_regs.h:624
#define QEI_WDGCFG_WDGTO_SET(x)
Definition: hpm_qei_regs.h:226
#define QEI_COUNT_PH_DIR_GET(x)
Definition: hpm_qei_regs.h:529
static void qei_output_trigger_event_enable(QEI_Type *qei_x, uint32_t event_mask)
enable trigger event
Definition: hpm_qei_drv.h:152
static void qei_wdog_disable(QEI_Type *qei_x)
disable qei watchdog
Definition: hpm_qei_drv.h:95
static void qei_wdog_config(QEI_Type *qei_x, uint32_t timeout, bool enable)
config watchdog
Definition: hpm_qei_drv.h:109
static void qei_output_trigger_event_disable(QEI_Type *qei_x, uint32_t event_mask)
disable trigger event
Definition: hpm_qei_drv.h:167
static uint32_t qei_get_count_on_read_event(QEI_Type *qei_x, qei_counter_type_t type)
get read event count value
Definition: hpm_qei_drv.h:415
static void qei_counter_reset_release(QEI_Type *qei_x)
qei counter reset release
Definition: hpm_qei_drv.h:535
enum qei_counter_type qei_counter_type_t
counter type
static uint32_t qei_get_count_on_snap0_event(QEI_Type *qei_x, qei_counter_type_t type)
read the value of each phase snapshot 0 counter
Definition: hpm_qei_drv.h:428
static void qei_phase_cmp_set(QEI_Type *qei_x, uint32_t cmp, bool cmp_z, qei_rotation_dir_cmp_t rotation_dir)
set Phase comparator value
Definition: hpm_qei_drv.h:232
static void qei_load_counter_to_read_registers(QEI_Type *qei_x)
load phcnt, zcnt, spdcnt and tmrcnt into their read registers
Definition: hpm_qei_drv.h:465
static void qei_reset_counter_on_h_assert(QEI_Type *qei_x, uint32_t counter_mask)
reset spdcnt/phcnt/zcnt
Definition: hpm_qei_drv.h:479
static void qei_irq_enable(QEI_Type *qei_x, uint32_t mask)
enable qei irq
Definition: hpm_qei_drv.h:301
static uint32_t qei_get_current_phase_phcnt(QEI_Type *qei_x)
get current phcnt value
Definition: hpm_qei_drv.h:370
qei_z_count_inc_mode
counting mode of Z-phase counter
Definition: hpm_qei_drv.h:29
static uint32_t qei_get_status(QEI_Type *qei_x)
get qei status
Definition: hpm_qei_drv.h:266
static void qei_speed_cmp_set(QEI_Type *qei_x, uint32_t cmp)
set spdcnt position compare value
Definition: hpm_qei_drv.h:219
static void qei_z_cmp_set(QEI_Type *qei_x, uint32_t cmp)
set zcnt postion compare value
Definition: hpm_qei_drv.h:208
static uint32_t qei_get_count_on_snap1_event(QEI_Type *qei_x, qei_counter_type_t type)
read the value of each phase snapshot 1 counter
Definition: hpm_qei_drv.h:441
static void qei_pause_counter_on_pause(QEI_Type *qei_x, uint32_t counter_mask)
pause spdcnt when PAUSE assert
Definition: hpm_qei_drv.h:494
qei_rotation_dir_cmp
motor rotation direction
Definition: hpm_qei_drv.h:38
enum qei_work_mode qei_work_mode_t
qei work mode
static void qei_load_read_trigger_event_enable(QEI_Type *qei_x, uint32_t event_mask)
enable load read trigger event
Definition: hpm_qei_drv.h:182
static void qei_clear_status(QEI_Type *qei_x, uint32_t mask)
clear qei status register
Definition: hpm_qei_drv.h:251
static void qei_dma_request_disable(QEI_Type *qei_x, uint32_t mask)
disable qei dma
Definition: hpm_qei_drv.h:346
static uint32_t qei_get_current_count(QEI_Type *qei_x, qei_counter_type_t type)
get current counter value
Definition: hpm_qei_drv.h:358
qei_speed_his_type
speed history type
Definition: hpm_qei_drv.h:69
static void qei_snap_enable(QEI_Type *qei_x)
load phcnt, zcnt, spdcnt and tmrcnt into their snap registers
Definition: hpm_qei_drv.h:505
static bool qei_get_current_phase_astat(QEI_Type *qei_x)
get current a phase status
Definition: hpm_qei_drv.h:381
static bool qei_get_current_phase_dir(QEI_Type *qei_x)
get current phase dir
Definition: hpm_qei_drv.h:403
qei_work_mode
qei work mode
Definition: hpm_qei_drv.h:59
static bool qei_get_bit_status(QEI_Type *qei_x, uint32_t mask)
get qei bit status
Definition: hpm_qei_drv.h:282
static uint32_t qei_get_speed_history(QEI_Type *qei_x, qei_speed_his_type_t hist_index)
get speed history
Definition: hpm_qei_drv.h:455
static void qei_counter_reset_assert(QEI_Type *qei_x)
reset zcnt, spdcnt and tmrcnt to 0
Definition: hpm_qei_drv.h:525
static bool qei_get_current_phase_bstat(QEI_Type *qei_x)
get current b phase status
Definition: hpm_qei_drv.h:392
enum qei_speed_his_type qei_speed_his_type_t
speed history type
static void qei_set_work_mode(QEI_Type *qei_x, qei_work_mode_t mode)
set work mode
Definition: hpm_qei_drv.h:546
static void qei_wdog_enable(QEI_Type *qei_x)
enable qei watchdog
Definition: hpm_qei_drv.h:85
static void qei_dma_request_enable(QEI_Type *qei_x, uint32_t mask)
enable dma request
Definition: hpm_qei_drv.h:331
static void qei_snap_disable(QEI_Type *qei_x)
disable snap
Definition: hpm_qei_drv.h:515
enum qei_rotation_dir_cmp qei_rotation_dir_cmp_t
motor rotation direction
static void qei_phase_set_index(QEI_Type *qei_x, uint32_t phase_index)
set phase index
Definition: hpm_qei_drv.h:137
static void qei_phase_config(QEI_Type *qei_x, uint32_t phase_count, qei_z_count_inc_mode_t mode, bool z_calibrate)
Definition: hpm_qei_drv.h:124
enum qei_z_count_inc_mode qei_z_count_inc_mode_t
counting mode of Z-phase counter
qei_counter_type
counter type
Definition: hpm_qei_drv.h:48
static void qei_irq_disable(QEI_Type *qei_x, uint32_t mask)
disable qei irq
Definition: hpm_qei_drv.h:316
static void qei_load_read_trigger_event_disable(QEI_Type *qei_x, uint32_t event_mask)
disable load read trigger event
Definition: hpm_qei_drv.h:197
@ qei_z_count_inc_on_phase_count_max
Definition: hpm_qei_drv.h:31
@ qei_z_count_inc_on_z_input_assert
Definition: hpm_qei_drv.h:30
@ qei_rotation_dir_cmp_negative
Definition: hpm_qei_drv.h:40
@ qei_rotation_dir_cmp_ignore
Definition: hpm_qei_drv.h:41
@ qei_rotation_dir_cmp_positive
Definition: hpm_qei_drv.h:39
@ qei_speed_his3
Definition: hpm_qei_drv.h:73
@ qei_speed_his0
Definition: hpm_qei_drv.h:70
@ qei_speed_his2
Definition: hpm_qei_drv.h:72
@ qei_speed_his1
Definition: hpm_qei_drv.h:71
@ qei_work_mode_abz
Definition: hpm_qei_drv.h:60
@ qei_work_mode_ud
Definition: hpm_qei_drv.h:62
@ qei_work_mode_pd
Definition: hpm_qei_drv.h:61
@ qei_counter_type_speed
Definition: hpm_qei_drv.h:51
@ qei_counter_type_timer
Definition: hpm_qei_drv.h:52
@ qei_counter_type_phase
Definition: hpm_qei_drv.h:50
@ qei_counter_type_z
Definition: hpm_qei_drv.h:49
Definition: hpm_qei_regs.h:12
__RW uint32_t Z
Definition: hpm_qei_regs.h:26
__R uint32_t SPDHIS[4]
Definition: hpm_qei_regs.h:31
__RW uint32_t TRGOEN
Definition: hpm_qei_regs.h:17
__RW uint32_t PHCFG
Definition: hpm_qei_regs.h:14
__RW uint32_t IRQEN
Definition: hpm_qei_regs.h:24
__RW uint32_t CR
Definition: hpm_qei_regs.h:13
struct QEI_Type::@396 COUNT[4]
__RW uint32_t READEN
Definition: hpm_qei_regs.h:18
__RW uint32_t PHCMP
Definition: hpm_qei_regs.h:20
__RW uint32_t SR
Definition: hpm_qei_regs.h:23
__RW uint32_t ZCMP
Definition: hpm_qei_regs.h:19
__RW uint32_t SPDCMP
Definition: hpm_qei_regs.h:21
__RW uint32_t WDGCFG
Definition: hpm_qei_regs.h:15
__RW uint32_t PHIDX
Definition: hpm_qei_regs.h:16
__RW uint32_t DMAEN
Definition: hpm_qei_regs.h:22