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

qei.h
Go to the documentation of this file.
1 /**************************************************************************/
9 #ifndef __QEI_H__
10 #define __QEI_H__
11
12 #ifdef __cplusplus
13 extern "C"
14 {
15 #endif
16
17
30 /*---------------------------------------------------------------------------------------------------------*/
31 /* QEI counting mode selection constants definitions */
32 /*---------------------------------------------------------------------------------------------------------*/
33 #define QEI_CTL_X4_FREE_COUNTING_MODE (0x0<<QEI_CTL_MODE_Pos)
34 #define QEI_CTL_X2_FREE_COUNTING_MODE (0x1<<QEI_CTL_MODE_Pos)
35 #define QEI_CTL_X4_COMPARE_COUNTING_MODE (0x2<<QEI_CTL_MODE_Pos)
36 #define QEI_CTL_X2_COMPARE_COUNTING_MODE (0x3<<QEI_CTL_MODE_Pos)
38 /*---------------------------------------------------------------------------------------------------------*/
39 /* QEI noise filter clock pre-divide selection constants definitions */
40 /*---------------------------------------------------------------------------------------------------------*/
41 #define QEI_CTL_NFCLKSEL_DIV1 (0x0<<QEI_CTL_NFCLKSEL_Pos)
42 #define QEI_CTL_NFCLKSEL_DIV2 (0x1<<QEI_CTL_NFCLKSEL_Pos)
43 #define QEI_CTL_NFCLKSEL_DIV4 (0x2<<QEI_CTL_NFCLKSEL_Pos)
44 #define QEI_CTL_NFCLKSEL_DIV16 (0x3<<QEI_CTL_NFCLKSEL_Pos)
45 #define QEI_CTL_NFCLKSEL_DIV32 (0x4<<QEI_CTL_NFCLKSEL_Pos)
46 #define QEI_CTL_NFCLKSEL_DIV64 (0x5<<QEI_CTL_NFCLKSEL_Pos)
51 /* end of group QEI_EXPORTED_CONSTANTS */
52
53
65 #define QEI_DISABLE_CNT_CMP(qei) ((qei)->CTL &= (~QEI_CTL_CMPEN_Msk))
66
74 #define QEI_ENABLE_CNT_CMP(qei) ((qei)->CTL |= QEI_CTL_CMPEN_Msk)
75
83 #define QEI_DISABLE_INDEX_LATCH(qei) ((qei)->CTL &= (~QEI_CTL_IDXLATEN_Msk))
84
92 #define QEI_ENABLE_INDEX_LATCH(qei) ((qei)->CTL |= QEI_CTL_IDXLATEN_Msk)
93
101 #define QEI_DISABLE_INDEX_RELOAD(qei) ((qei)->CTL &= (~QEI_CTL_IDXRLDEN_Msk))
102
110 #define QEI_ENABLE_INDEX_RELOAD(qei) ((qei)->CTL |= QEI_CTL_IDXRLDEN_Msk)
111
123 #define QEI_DISABLE_INPUT(qei, u32InputType) ((qei)->CTL &= ~(u32InputType))
124
136 #define QEI_ENABLE_INPUT(qei, u32InputType) ((qei)->CTL |= (u32InputType))
137
149 #define QEI_DISABLE_INPUT_INV(qei, u32InputType) ((qei)->CTL &= ~(u32InputType))
150
162 #define QEI_ENABLE_INPUT_INV(qei, u32InputType) ((qei)->CTL |= (u32InputType))
163
176 #define QEI_DISABLE_INT(qei, u32IntSel) ((qei)->CTL &= ~(u32IntSel))
177
190 #define QEI_ENABLE_INT(qei, u32IntSel) ((qei)->CTL |= (u32IntSel))
191
199 #define QEI_DISABLE_NOISE_FILTER(qei) ((qei)->CTL |= QEI_CTL_NFDIS_Msk)
200
215 #define QEI_ENABLE_NOISE_FILTER(qei, u32ClkSel) ((qei)->CTL = ((qei)->CTL & (~(QEI_CTL_NFDIS_Msk|QEI_CTL_NFCLKSEL_Msk))) | (u32ClkSel))
216
224 #define QEI_GET_CNT_VALUE(qei) ((qei)->CNT)
225
234 #define QEI_GET_DIR(qei) (((qei)->STATUS & (QEI_STATUS_DIRF_Msk))?1:0)
235
243 #define QEI_GET_HOLD_VALUE(qei) ((qei)->CNTHOLD)
244
252 #define QEI_GET_INDEX_LATCH_VALUE(qei) ((qei)->CNTLATCH)
253
262 #define QEI_SET_INDEX_LATCH_VALUE(qei,u32Val) ((qei)->CNTLATCH = (u32Val))
263
278 #define QEI_GET_INT_FLAG(qei, u32IntSel) (((qei)->STATUS & (u32IntSel))?1:0)
279
280
293 #define QEI_CLR_INT_FLAG(qei, u32IntSel) ((qei)->STATUS = (u32IntSel))
294
303 #define QEI_SET_CNT_CMP(qei, u32Value) ((qei)->CNTCMP = (u32Value))
304
313 #define QEI_SET_CNT_VALUE(qei, u32Value) ((qei)->CNT = (u32Value))
314
328 #define QEI_ENABLE_HOLD_TRG_SRC(qei, u32Type) ((qei)->CTL |= (u32Type))
329
343 #define QEI_DISABLE_HOLD_TRG_SRC(qei, u32Type) ((qei)->CTL &= ~(u32Type))
344
353 #define QEI_SET_CNT_MAX(qei, u32Value) ((qei)->CNTMAX = (u32Value))
354
367 #define QEI_SET_CNT_MODE(qei, u32Mode) ((qei)->CTL = ((qei)->CTL & (~QEI_CTL_MODE_Msk)) | (u32Mode))
368
369
370 void QEI_Close(QEI_T* qei);
371 void QEI_DisableInt(QEI_T* qei, uint32_t u32IntSel);
372 void QEI_EnableInt(QEI_T* qei, uint32_t u32IntSel);
373 void QEI_Open(QEI_T* qei, uint32_t u32Mode, uint32_t u32Value);
374 void QEI_Start(QEI_T* qei);
375 void QEI_Stop(QEI_T* qei);
376
377 /* end of group QEI_EXPORTED_FUNCTIONS */
379 /* end of group QEI_Driver */
381 /* end of group Standard_Driver */
383
384 #ifdef __cplusplus
385 }
386 #endif
387
388 #endif /* __QEI_H__ */
389
390 /*** (C) COPYRIGHT 2016 Nuvoton Technology Corp. ***/
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
QEI_EnableInt
void QEI_EnableInt(QEI_T *qei, uint32_t u32IntSel)
Enable QEI interrupt.
Definition: qei.c:74
QEI_DisableInt
void QEI_DisableInt(QEI_T *qei, uint32_t u32IntSel)
Disable QEI interrupt.
Definition: qei.c:47
QEI_Stop
void QEI_Stop(QEI_T *qei)
Stop QEI function.
Definition: qei.c:131
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