27 #ifndef LPC17XX_QEI_H_
28 #define LPC17XX_QEI_H_
46 #define QEI_RESET_POS QEI_CON_RESP
47 #define QEI_RESET_POSOnIDX QEI_CON_RESPI
48 #define QEI_RESET_VEL QEI_CON_RESV
49 #define QEI_RESET_IDX QEI_CON_RESI
52 #define QEI_DIRINV_NONE ((uint32_t)(0))
53 #define QEI_DIRINV_CMPL ((uint32_t)(1))
56 #define QEI_SIGNALMODE_QUAD ((uint32_t)(0))
57 #define QEI_SIGNALMODE_CLKDIR ((uint32_t)(1))
60 #define QEI_CAPMODE_2X ((uint32_t)(0))
61 #define QEI_CAPMODE_4X ((uint32_t)(1))
64 #define QEI_INVINX_NONE ((uint32_t)(0))
65 #define QEI_INVINX_EN ((uint32_t)(1))
68 #define QEI_TIMERRELOAD_TICKVAL ((uint8_t)(0))
69 #define QEI_TIMERRELOAD_USVAL ((uint8_t)(1))
72 #define QEI_STATUS_DIR ((uint32_t)(1<<0))
75 #define QEI_COMPPOS_CH_0 ((uint8_t)(0))
76 #define QEI_COMPPOS_CH_1 ((uint8_t)(1))
77 #define QEI_COMPPOS_CH_2 ((uint8_t)(2))
80 #define QEI_INTFLAG_INX_Int ((uint32_t)(1<<0))
81 #define QEI_INTFLAG_TIM_Int ((uint32_t)(1<<1))
82 #define QEI_INTFLAG_VELC_Int ((uint32_t)(1<<2))
83 #define QEI_INTFLAG_DIR_Int ((uint32_t)(1<<3))
84 #define QEI_INTFLAG_ERR_Int ((uint32_t)(1<<4))
85 #define QEI_INTFLAG_ENCLK_Int ((uint32_t)(1<<5))
86 #define QEI_INTFLAG_POS0_Int ((uint32_t)(1<<6))
88 #define QEI_INTFLAG_POS1_Int ((uint32_t)(1<<7))
90 #define QEI_INTFLAG_POS2_Int ((uint32_t)(1<<8))
92 #define QEI_INTFLAG_REV_Int ((uint32_t)(1<<9))
94 #define QEI_INTFLAG_POS0REV_Int ((uint32_t)(1<<10))
95 #define QEI_INTFLAG_POS1REV_Int ((uint32_t)(1<<11))
96 #define QEI_INTFLAG_POS2REV_Int ((uint32_t)(1<<12))
113 #define QEI_CON_RESP ((uint32_t)(1<<0))
114 #define QEI_CON_RESPI ((uint32_t)(1<<1))
115 #define QEI_CON_RESV ((uint32_t)(1<<2))
116 #define QEI_CON_RESI ((uint32_t)(1<<3))
117 #define QEI_CON_BITMASK ((uint32_t)(0x0F))
122 #define QEI_CONF_DIRINV ((uint32_t)(1<<0))
123 #define QEI_CONF_SIGMODE ((uint32_t)(1<<1))
124 #define QEI_CONF_CAPMODE ((uint32_t)(1<<2))
125 #define QEI_CONF_INVINX ((uint32_t)(1<<3))
126 #define QEI_CONF_BITMASK ((uint32_t)(0x0F))
131 #define QEI_STAT_DIR ((uint32_t)(1<<0))
132 #define QEI_STAT_BITMASK ((uint32_t)(1<<0))
138 #define QEI_INTSTAT_INX_Int ((uint32_t)(1<<0))
139 #define QEI_INTSTAT_TIM_Int ((uint32_t)(1<<1))
140 #define QEI_INTSTAT_VELC_Int ((uint32_t)(1<<2))
141 #define QEI_INTSTAT_DIR_Int ((uint32_t)(1<<3))
142 #define QEI_INTSTAT_ERR_Int ((uint32_t)(1<<4))
143 #define QEI_INTSTAT_ENCLK_Int ((uint32_t)(1<<5))
144 #define QEI_INTSTAT_POS0_Int ((uint32_t)(1<<6))
146 #define QEI_INTSTAT_POS1_Int ((uint32_t)(1<<7))
148 #define QEI_INTSTAT_POS2_Int ((uint32_t)(1<<8))
150 #define QEI_INTSTAT_REV_Int ((uint32_t)(1<<9))
152 #define QEI_INTSTAT_POS0REV_Int ((uint32_t)(1<<10))
154 #define QEI_INTSTAT_POS1REV_Int ((uint32_t)(1<<11))
156 #define QEI_INTSTAT_POS2REV_Int ((uint32_t)(1<<12))
158 #define QEI_INTSTAT_BITMASK ((uint32_t)(0x1FFF))
163 #define QEI_INTSET_INX_Int ((uint32_t)(1<<0))
164 #define QEI_INTSET_TIM_Int ((uint32_t)(1<<1))
165 #define QEI_INTSET_VELC_Int ((uint32_t)(1<<2))
166 #define QEI_INTSET_DIR_Int ((uint32_t)(1<<3))
167 #define QEI_INTSET_ERR_Int ((uint32_t)(1<<4))
168 #define QEI_INTSET_ENCLK_Int ((uint32_t)(1<<5))
169 #define QEI_INTSET_POS0_Int ((uint32_t)(1<<6))
171 #define QEI_INTSET_POS1_Int ((uint32_t)(1<<7))
173 #define QEI_INTSET_POS2_Int ((uint32_t)(1<<8))
175 #define QEI_INTSET_REV_Int ((uint32_t)(1<<9))
177 #define QEI_INTSET_POS0REV_Int ((uint32_t)(1<<10))
178 #define QEI_INTSET_POS1REV_Int ((uint32_t)(1<<11))
179 #define QEI_INTSET_POS2REV_Int ((uint32_t)(1<<12))
180 #define QEI_INTSET_BITMASK ((uint32_t)(0x1FFF))
185 #define QEI_INTCLR_INX_Int ((uint32_t)(1<<0))
186 #define QEI_INTCLR_TIM_Int ((uint32_t)(1<<1))
187 #define QEI_INTCLR_VELC_Int ((uint32_t)(1<<2))
188 #define QEI_INTCLR_DIR_Int ((uint32_t)(1<<3))
189 #define QEI_INTCLR_ERR_Int ((uint32_t)(1<<4))
190 #define QEI_INTCLR_ENCLK_Int ((uint32_t)(1<<5))
191 #define QEI_INTCLR_POS0_Int ((uint32_t)(1<<6))
193 #define QEI_INTCLR_POS1_Int ((uint32_t)(1<<7))
195 #define QEI_INTCLR_POS2_Int ((uint32_t)(1<<8))
197 #define QEI_INTCLR_REV_Int ((uint32_t)(1<<9))
199 #define QEI_INTCLR_POS0REV_Int ((uint32_t)(1<<10))
200 #define QEI_INTCLR_POS1REV_Int ((uint32_t)(1<<11))
201 #define QEI_INTCLR_POS2REV_Int ((uint32_t)(1<<12))
202 #define QEI_INTCLR_BITMASK ((uint32_t)(0x1FFF))
207 #define QEI_INTEN_INX_Int ((uint32_t)(1<<0))
208 #define QEI_INTEN_TIM_Int ((uint32_t)(1<<1))
209 #define QEI_INTEN_VELC_Int ((uint32_t)(1<<2))
210 #define QEI_INTEN_DIR_Int ((uint32_t)(1<<3))
211 #define QEI_INTEN_ERR_Int ((uint32_t)(1<<4))
212 #define QEI_INTEN_ENCLK_Int ((uint32_t)(1<<5))
213 #define QEI_INTEN_POS0_Int ((uint32_t)(1<<6))
215 #define QEI_INTEN_POS1_Int ((uint32_t)(1<<7))
217 #define QEI_INTEN_POS2_Int ((uint32_t)(1<<8))
219 #define QEI_INTEN_REV_Int ((uint32_t)(1<<9))
221 #define QEI_INTEN_POS0REV_Int ((uint32_t)(1<<10))
222 #define QEI_INTEN_POS1REV_Int ((uint32_t)(1<<11))
223 #define QEI_INTEN_POS2REV_Int ((uint32_t)(1<<12))
224 #define QEI_INTEN_BITMASK ((uint32_t)(0x1FFF))
229 #define QEI_IESET_INX_Int ((uint32_t)(1<<0))
230 #define QEI_IESET_TIM_Int ((uint32_t)(1<<1))
231 #define QEI_IESET_VELC_Int ((uint32_t)(1<<2))
232 #define QEI_IESET_DIR_Int ((uint32_t)(1<<3))
233 #define QEI_IESET_ERR_Int ((uint32_t)(1<<4))
234 #define QEI_IESET_ENCLK_Int ((uint32_t)(1<<5))
235 #define QEI_IESET_POS0_Int ((uint32_t)(1<<6))
237 #define QEI_IESET_POS1_Int ((uint32_t)(1<<7))
239 #define QEI_IESET_POS2_Int ((uint32_t)(1<<8))
241 #define QEI_IESET_REV_Int ((uint32_t)(1<<9))
243 #define QEI_IESET_POS0REV_Int ((uint32_t)(1<<10))
244 #define QEI_IESET_POS1REV_Int ((uint32_t)(1<<11))
245 #define QEI_IESET_POS2REV_Int ((uint32_t)(1<<12))
246 #define QEI_IESET_BITMASK ((uint32_t)(0x1FFF))
251 #define QEI_IECLR_INX_Int ((uint32_t)(1<<0))
252 #define QEI_IECLR_TIM_Int ((uint32_t)(1<<1))
253 #define QEI_IECLR_VELC_Int ((uint32_t)(1<<2))
254 #define QEI_IECLR_DIR_Int ((uint32_t)(1<<3))
255 #define QEI_IECLR_ERR_Int ((uint32_t)(1<<4))
256 #define QEI_IECLR_ENCLK_Int ((uint32_t)(1<<5))
257 #define QEI_IECLR_POS0_Int ((uint32_t)(1<<6))
259 #define QEI_IECLR_POS1_Int ((uint32_t)(1<<7))
261 #define QEI_IECLR_POS2_Int ((uint32_t)(1<<8))
263 #define QEI_IECLR_REV_Int ((uint32_t)(1<<9))
265 #define QEI_IECLR_POS0REV_Int ((uint32_t)(1<<10))
266 #define QEI_IECLR_POS1REV_Int ((uint32_t)(1<<11))
267 #define QEI_IECLR_POS2REV_Int ((uint32_t)(1<<12))
268 #define QEI_IECLR_BITMASK ((uint32_t)(0x1FFF))
273 #define PARAM_QEIx(n) ((n==LPC_QEI))
276 #define PARAM_QEI_RESET(n) ((n==QEI_CON_RESP) \
277 || (n==QEI_RESET_POSOnIDX) \
278 || (n==QEI_RESET_VEL) \
279 || (n==QEI_RESET_IDX))
282 #define PARAM_QEI_DIRINV(n) ((n==QEI_DIRINV_NONE) || (n==QEI_DIRINV_CMPL))
285 #define PARAM_QEI_SIGNALMODE(n) ((n==QEI_SIGNALMODE_QUAD) || (n==QEI_SIGNALMODE_CLKDIR))
288 #define PARAM_QEI_CAPMODE(n) ((n==QEI_CAPMODE_2X) || (n==QEI_CAPMODE_4X))
291 #define PARAM_QEI_INVINX(n) ((n==QEI_INVINX_NONE) || (n==QEI_INVINX_EN))
294 #define PARAM_QEI_TIMERRELOAD(n) ((n==QEI_TIMERRELOAD_TICKVAL) || (n==QEI_TIMERRELOAD_USVAL))
297 #define PARAM_QEI_STATUS(n) ((n==QEI_STATUS_DIR))
300 #define PARAM_QEI_COMPPOS_CH(n) ((n==QEI_COMPPOS_CH_0) || (n==QEI_COMPPOS_CH_1) || (n==QEI_COMPPOS_CH_2))
303 #define PARAM_QEI_INTFLAG(n) ((n==QEI_INTFLAG_INX_Int) \
304 || (n==QEI_INTFLAG_TIM_Int) \
305 || (n==QEI_INTFLAG_VELC_Int) \
306 || (n==QEI_INTFLAG_DIR_Int) \
307 || (n==QEI_INTFLAG_ERR_Int) \
308 || (n==QEI_INTFLAG_ENCLK_Int) \
309 || (n==QEI_INTFLAG_POS0_Int) \
310 || (n==QEI_INTFLAG_POS1_Int) \
311 || (n==QEI_INTFLAG_POS2_Int) \
312 || (n==QEI_INTFLAG_REV_Int) \
313 || (n==QEI_INTFLAG_POS0REV_Int) \
314 || (n==QEI_INTFLAG_POS1REV_Int) \
315 || (n==QEI_INTFLAG_POS2REV_Int))
329 uint32_t DirectionInvert :1;
333 uint32_t SignalMode :1;
337 uint32_t CaptureMode :1;
341 uint32_t InvertIndex :1;
352 uint8_t ReloadOption;
357 uint32_t ReloadValue;