| M480 BSP V3.05.001 The Board Support Package for M480 Series

qei.c
Go to the documentation of this file.
1 /**************************************************************************/
9 #include "NuMicro.h"
10
11
30 void QEI_Close(QEI_T* qei)
31 {
32 /* Reset QEI configuration */
33 qei->CTL = (uint32_t)0;
34 }
35
47 void QEI_DisableInt(QEI_T* qei, uint32_t u32IntSel)
48 {
49 /* Disable QEI specified interrupt */
50 QEI_DISABLE_INT(qei, u32IntSel);
51
52 /* Disable NVIC QEI IRQ */
53 if(qei ==(QEI_T*)QEI0)
54 {
55 NVIC_DisableIRQ((IRQn_Type)QEI0_IRQn);
56 }
57 else
58 {
59 NVIC_DisableIRQ((IRQn_Type)QEI1_IRQn);
60 }
61 }
62
74 void QEI_EnableInt(QEI_T* qei, uint32_t u32IntSel)
75 {
76 /* Enable QEI specified interrupt */
77 QEI_ENABLE_INT(qei, u32IntSel);
78
79 /* Enable NVIC QEI IRQ */
80 if(qei == (QEI_T*)QEI0)
81 {
82 NVIC_EnableIRQ(QEI0_IRQn);
83 }
84 else
85 {
86 NVIC_EnableIRQ(QEI1_IRQn);
87 }
88 }
89
102 void QEI_Open(QEI_T* qei, uint32_t u32Mode, uint32_t u32Value)
103 {
104 /* Set QEI function configuration */
105 /* Set QEI counting mode */
106 /* Enable IDX, QEA and QEB input to QEI controller */
107 qei->CTL = (qei->CTL & (~QEI_CTL_MODE_Msk)) | ((u32Mode) | QEI_CTL_CHAEN_Msk | QEI_CTL_CHBEN_Msk | QEI_CTL_IDXEN_Msk);
108
109 /* Set QEI maximum count value in in compare-counting mode */
110 qei->CNTMAX = u32Value;
111 }
112
119 void QEI_Start(QEI_T* qei)
120 {
121 /* Enable QEI controller function */
122 qei->CTL |= QEI_CTL_QEIEN_Msk;
123 }
124
131 void QEI_Stop(QEI_T* qei)
132 {
133 /* Disable QEI controller function */
134 qei->CTL &= (~QEI_CTL_QEIEN_Msk);
135 }
136
137 /* end of group QEI_EXPORTED_FUNCTIONS */
139 /* end of group QEI_Driver */
141 /* end of group Standard_Driver */
143
144 /*** (C) COPYRIGHT 2016 Nuvoton Technology Corp. ***/
IRQn_Type
enum IRQn IRQn_Type
NuMicro.h
NuMicro peripheral access layer header file.
QEI_CTL_IDXEN_Msk
#define QEI_CTL_IDXEN_Msk
Definition: qei_reg.h:451
QEI_CTL_CHBEN_Msk
#define QEI_CTL_CHBEN_Msk
Definition: qei_reg.h:448
QEI_CTL_CHAEN_Msk
#define QEI_CTL_CHAEN_Msk
Definition: qei_reg.h:445
QEI_Close
void QEI_Close(QEI_T *qei)
Close QEI function.
Definition: qei.c:30
QEI_Start
void QEI_Start(QEI_T *qei)
Start QEI function.
Definition: qei.c:119
QEI0_IRQn
Definition: M480.h:160
QEI_EnableInt
void QEI_EnableInt(QEI_T *qei, uint32_t u32IntSel)
Enable QEI interrupt.
Definition: qei.c:74
QEI_CTL_MODE_Msk
#define QEI_CTL_MODE_Msk
Definition: qei_reg.h:454
QEI1_IRQn
Definition: M480.h:161
QEI_T::CNTMAX
__IO uint32_t CNTMAX
Definition: qei_reg.h:409
QEI_DisableInt
void QEI_DisableInt(QEI_T *qei, uint32_t u32IntSel)
Disable QEI interrupt.
Definition: qei.c:47
QEI_DISABLE_INT
#define QEI_DISABLE_INT(qei, u32IntSel)
Disable QEI interrupt.
Definition: qei.h:176
QEI_Stop
void QEI_Stop(QEI_T *qei)
Stop QEI function.
Definition: qei.c:131
QEI_CTL_QEIEN_Msk
#define QEI_CTL_QEIEN_Msk
Definition: qei_reg.h:502
QEI_T
Definition: qei_reg.h:26
QEI_Open
void QEI_Open(QEI_T *qei, uint32_t u32Mode, uint32_t u32Value)
Open QEI in specified mode and enable input.
Definition: qei.c:102
QEI0
#define QEI0
Definition: M480.h:421
QEI_T::CTL
__IO uint32_t CTL
Definition: qei_reg.h:410
QEI_ENABLE_INT
#define QEI_ENABLE_INT(qei, u32IntSel)
Enable QEI interrupt.
Definition: qei.h:190