NXP's driver library for LPC17xx, ported to mbed's online compiler. Not tested! I had to fix a lot of warings and found a couple of pretty obvious bugs, so the chances are there are more. Original: http://ics.nxp.com/support/documents/microcontrollers/zip/lpc17xx.cmsis.driver.library.zip
lpc17xx_qei.c
00001 /** 00002 * @file : lpc17xx_qei.c 00003 * @brief : Contains all functions support for QEI firmware library on LPC17xx 00004 * @version : 1.0 00005 * @date : 26. May. 2009 00006 * @author : HieuNguyen 00007 ************************************************************************** 00008 * Software that is described herein is for illustrative purposes only 00009 * which provides customers with programming information regarding the 00010 * products. This software is supplied "AS IS" without any warranties. 00011 * NXP Semiconductors assumes no responsibility or liability for the 00012 * use of the software, conveys no license or title under any patent, 00013 * copyright, or mask work right to the product. NXP Semiconductors 00014 * reserves the right to make changes in the software without 00015 * notification. NXP Semiconductors also make no representation or 00016 * warranty that such application will be suitable for the specified 00017 * use without further testing or modification. 00018 **********************************************************************/ 00019 00020 /* Peripheral group ----------------------------------------------------------- */ 00021 /** @addtogroup QEI 00022 * @{ 00023 */ 00024 00025 /* Includes ------------------------------------------------------------------- */ 00026 #include "lpc17xx_qei.h" 00027 #include "lpc17xx_clkpwr.h" 00028 00029 00030 /* If this source file built with example, the LPC17xx FW library configuration 00031 * file in each example directory ("lpc17xx_libcfg.h") must be included, 00032 * otherwise the default FW library configuration file must be included instead 00033 */ 00034 #ifdef __BUILD_WITH_EXAMPLE__ 00035 #include "lpc17xx_libcfg.h" 00036 #else 00037 #include "lpc17xx_libcfg_default.h" 00038 #endif /* __BUILD_WITH_EXAMPLE__ */ 00039 00040 00041 #ifdef _QEI 00042 00043 /* Private Types -------------------------------------------------------------- */ 00044 /** @defgroup QEI_Private_Types 00045 * @{ 00046 */ 00047 00048 /** 00049 * @brief QEI configuration union type definition 00050 */ 00051 typedef union { 00052 QEI_CFG_Type bmQEIConfig; 00053 uint32_t ulQEIConfig; 00054 } QEI_CFGOPT_Type; 00055 00056 /** 00057 * @} 00058 */ 00059 00060 00061 /* Public Functions ----------------------------------------------------------- */ 00062 /** @addtogroup QEI_Public_Functions 00063 * @{ 00064 */ 00065 00066 /*********************************************************************//** 00067 * @brief Resets value for each type of QEI value, such as velocity, 00068 * counter, position, etc.. 00069 * @param[in] QEIx QEI peripheral, should be QEI 00070 * @param[in] ulResetType QEI Reset Type, should be one of the following: 00071 * - QEI_RESET_POS: Reset Position Counter 00072 * - QEI_RESET_POSOnIDX: Reset Position Counter on Index signal 00073 * - QEI_RESET_VEL: Reset Velocity 00074 * - QEI_RESET_IDX: Reset Index Counter 00075 * @return None 00076 **********************************************************************/ 00077 void QEI_Reset(LPC_QEI_TypeDef *QEIx, uint32_t ulResetType) 00078 { 00079 CHECK_PARAM(PARAM_QEIx(QEIx)); 00080 CHECK_PARAM(PARAM_QEI_RESET(ulResetType)); 00081 00082 QEIx->QEICON = ulResetType; 00083 } 00084 00085 /*********************************************************************//** 00086 * @brief Initializes the QEI peripheral according to the specified 00087 * parameters in the QEI_ConfigStruct. 00088 * @param[in] QEIx QEI peripheral, should be QEI 00089 * @param[in] QEI_ConfigStruct Pointer to a QEI_CFG_Type structure 00090 * that contains the configuration information for the 00091 * specified QEI peripheral 00092 * @return None 00093 **********************************************************************/ 00094 void QEI_Init(LPC_QEI_TypeDef *QEIx, QEI_CFG_Type *QEI_ConfigStruct) 00095 { 00096 00097 CHECK_PARAM(PARAM_QEIx(QEIx)); 00098 CHECK_PARAM(PARAM_QEI_DIRINV(QEI_ConfigStruct->DirectionInvert)); 00099 CHECK_PARAM(PARAM_QEI_SIGNALMODE(QEI_ConfigStruct->SignalMode)); 00100 CHECK_PARAM(PARAM_QEI_CAPMODE(QEI_ConfigStruct->CaptureMode)); 00101 CHECK_PARAM(PARAM_QEI_INVINX(QEI_ConfigStruct->InvertIndex)); 00102 00103 /* Set up clock and power for QEI module */ 00104 CLKPWR_ConfigPPWR (CLKPWR_PCONP_PCQEI, ENABLE); 00105 00106 /* As default, peripheral clock for QEI module 00107 * is set to FCCLK / 2 */ 00108 CLKPWR_SetPCLKDiv(CLKPWR_PCLKSEL_QEI, CLKPWR_PCLKSEL_CCLK_DIV_1); 00109 00110 // Reset all remaining value in QEI peripheral 00111 QEIx->QEICON = QEI_CON_RESP | QEI_CON_RESV | QEI_CON_RESI; 00112 QEIx->QEIMAXPOS = 0x00; 00113 QEIx->CMPOS0 = 0x00; 00114 QEIx->CMPOS1 = 0x00; 00115 QEIx->CMPOS2 = 0x00; 00116 QEIx->INXCMP = 0x00; 00117 QEIx->QEILOAD = 0x00; 00118 QEIx->VELCOMP = 0x00; 00119 QEIx->FILTER = 0x00; 00120 // Disable all Interrupt 00121 QEIx->QEIIEC = QEI_IECLR_BITMASK; 00122 // Clear all Interrupt pending 00123 QEIx->QEICLR = QEI_INTCLR_BITMASK; 00124 // Set QEI configuration value corresponding to its setting up value 00125 QEIx->QEICONF = ((QEI_CFGOPT_Type *)QEI_ConfigStruct)->ulQEIConfig; 00126 } 00127 00128 00129 /*********************************************************************//** 00130 * @brief De-initializes the QEI peripheral registers to their 00131 * default reset values. 00132 * @param[in] QEIx QEI peripheral, should be QEI 00133 * @return None 00134 **********************************************************************/ 00135 void QEI_DeInit(LPC_QEI_TypeDef *QEIx) 00136 { 00137 CHECK_PARAM(PARAM_QEIx(QEIx)); 00138 00139 /* Turn off clock and power for QEI module */ 00140 CLKPWR_ConfigPPWR (CLKPWR_PCONP_PCQEI, DISABLE); 00141 } 00142 00143 00144 /*****************************************************************************//** 00145 * @brief Fills each QIE_InitStruct member with its default value: 00146 * - DirectionInvert = QEI_DIRINV_NONE 00147 * - SignalMode = QEI_SIGNALMODE_QUAD 00148 * - CaptureMode = QEI_CAPMODE_4X 00149 * - InvertIndex = QEI_INVINX_NONE 00150 * @param[in] QIE_InitStruct Pointer to a QEI_CFG_Type structure 00151 * which will be initialized. 00152 * @return None 00153 *******************************************************************************/ 00154 void QEI_ConfigStructInit(QEI_CFG_Type *QIE_InitStruct) 00155 { 00156 QIE_InitStruct->CaptureMode = QEI_CAPMODE_4X; 00157 QIE_InitStruct->DirectionInvert = QEI_DIRINV_NONE; 00158 QIE_InitStruct->InvertIndex = QEI_INVINX_NONE; 00159 QIE_InitStruct->SignalMode = QEI_SIGNALMODE_QUAD; 00160 } 00161 00162 00163 /*********************************************************************//** 00164 * @brief Check whether if specified flag status is set or not 00165 * @param[in] QEIx QEI peripheral, should be QEI 00166 * @param[in] ulFlagType Status Flag Type, should be one of the following: 00167 * - QEI_STATUS_DIR: Direction Status 00168 * @return New Status of this status flag (SET or RESET) 00169 **********************************************************************/ 00170 FlagStatus QEI_GetStatus(LPC_QEI_TypeDef *QEIx, uint32_t ulFlagType) 00171 { 00172 CHECK_PARAM(PARAM_QEIx(QEIx)); 00173 CHECK_PARAM(PARAM_QEI_STATUS(ulFlagType)); 00174 return ((QEIx->QEISTAT & ulFlagType) ? SET : RESET); 00175 } 00176 00177 /*********************************************************************//** 00178 * @brief Get current position value in QEI peripheral 00179 * @param[in] QEIx QEI peripheral, should be QEI 00180 * @return Current position value of QEI peripheral 00181 **********************************************************************/ 00182 uint32_t QEI_GetPosition(LPC_QEI_TypeDef *QEIx) 00183 { 00184 CHECK_PARAM(PARAM_QEIx(QEIx)); 00185 return (QEIx->QEIPOS); 00186 } 00187 00188 /*********************************************************************//** 00189 * @brief Set max position value for QEI peripheral 00190 * @param[in] QEIx QEI peripheral, should be QEI 00191 * @param[in] ulMaxPos Max position value to set 00192 * @return None 00193 **********************************************************************/ 00194 void QEI_SetMaxPosition(LPC_QEI_TypeDef *QEIx, uint32_t ulMaxPos) 00195 { 00196 CHECK_PARAM(PARAM_QEIx(QEIx)); 00197 QEIx->QEIMAXPOS = ulMaxPos; 00198 } 00199 00200 /*********************************************************************//** 00201 * @brief Set position compare value for QEI peripheral 00202 * @param[in] QEIx QEI peripheral, should be QEI 00203 * @param[in] bPosCompCh Compare Position channel, should be: 00204 * - QEI_COMPPOS_CH_0: QEI compare position channel 0 00205 * - QEI_COMPPOS_CH_1: QEI compare position channel 1 00206 * - QEI_COMPPOS_CH_2: QEI compare position channel 2 00207 * @param[in] ulPosComp Compare Position value to set 00208 * @return None 00209 **********************************************************************/ 00210 void QEI_SetPositionComp(LPC_QEI_TypeDef *QEIx, uint8_t bPosCompCh, uint32_t ulPosComp) 00211 { 00212 uint32_t *tmp; 00213 00214 CHECK_PARAM(PARAM_QEIx(QEIx)); 00215 CHECK_PARAM(PARAM_QEI_COMPPOS_CH(bPosCompCh)); 00216 tmp = (uint32_t *) (&(QEIx->CMPOS0) + bPosCompCh * 4); 00217 *tmp = ulPosComp; 00218 00219 } 00220 00221 /*********************************************************************//** 00222 * @brief Get current index counter of QEI peripheral 00223 * @param[in] QEIx QEI peripheral, should be QEI 00224 * @return Current value of QEI index counter 00225 **********************************************************************/ 00226 uint32_t QEI_GetIndex(LPC_QEI_TypeDef *QEIx) 00227 { 00228 CHECK_PARAM(PARAM_QEIx(QEIx)); 00229 return (QEIx->INXCNT); 00230 } 00231 00232 /*********************************************************************//** 00233 * @brief Set value for index compare in QEI peripheral 00234 * @param[in] QEIx QEI peripheral, should be QEI 00235 * @param[in] ulIndexComp Compare Index Value to set 00236 * @return None 00237 **********************************************************************/ 00238 void QEI_SetIndexComp(LPC_QEI_TypeDef *QEIx, uint32_t ulIndexComp) 00239 { 00240 CHECK_PARAM(PARAM_QEIx(QEIx)); 00241 QEIx->INXCMP = ulIndexComp; 00242 } 00243 00244 /*********************************************************************//** 00245 * @brief Set timer reload value for QEI peripheral. When the velocity timer is 00246 * over-flow, the value that set for Timer Reload register will be loaded 00247 * into the velocity timer for next period. The calculated velocity in RPM 00248 * therefore will be affect by this value. 00249 * @param[in] QEIx QEI peripheral, should be QEI 00250 * @param[in] QEIReloadStruct QEI reload structure 00251 * @return None 00252 **********************************************************************/ 00253 void QEI_SetTimerReload(LPC_QEI_TypeDef *QEIx, QEI_RELOADCFG_Type *QEIReloadStruct) 00254 { 00255 uint64_t pclk; 00256 00257 CHECK_PARAM(PARAM_QEIx(QEIx)); 00258 CHECK_PARAM(PARAM_QEI_TIMERRELOAD(QEIReloadStruct->ReloadOption)); 00259 00260 if (QEIReloadStruct->ReloadOption == QEI_TIMERRELOAD_TICKVAL) { 00261 QEIx->QEILOAD = QEIReloadStruct->ReloadValue - 1; 00262 } else { 00263 pclk = (uint64_t)CLKPWR_GetPCLK(CLKPWR_PCLKSEL_QEI); 00264 pclk = (pclk /(1000000/QEIReloadStruct->ReloadValue)) - 1; 00265 QEIx->QEILOAD = (uint32_t)pclk; 00266 } 00267 } 00268 00269 /*********************************************************************//** 00270 * @brief Get current timer counter in QEI peripheral 00271 * @param[in] QEIx QEI peripheral, should be QEI 00272 * @return Current timer counter in QEI peripheral 00273 **********************************************************************/ 00274 uint32_t QEI_GetTimer(LPC_QEI_TypeDef *QEIx) 00275 { 00276 CHECK_PARAM(PARAM_QEIx(QEIx)); 00277 return (QEIx->QEITIME); 00278 } 00279 00280 /*********************************************************************//** 00281 * @brief Get current velocity pulse counter in current time period 00282 * @param[in] QEIx QEI peripheral, should be QEI 00283 * @return Current velocity pulse counter value 00284 **********************************************************************/ 00285 uint32_t QEI_GetVelocity(LPC_QEI_TypeDef *QEIx) 00286 { 00287 CHECK_PARAM(PARAM_QEIx(QEIx)); 00288 return (QEIx->QEIVEL); 00289 } 00290 00291 /*********************************************************************//** 00292 * @brief Get the most recently measured velocity of the QEI. When 00293 * the Velocity timer in QEI is over-flow, the current velocity 00294 * value will be loaded into Velocity Capture register. 00295 * @param[in] QEIx QEI peripheral, should be QEI 00296 * @return The most recently measured velocity value 00297 **********************************************************************/ 00298 uint32_t QEI_GetVelocityCap(LPC_QEI_TypeDef *QEIx) 00299 { 00300 CHECK_PARAM(PARAM_QEIx(QEIx)); 00301 return (QEIx->QEICAP); 00302 } 00303 00304 /*********************************************************************//** 00305 * @brief Set Velocity Compare value for QEI peripheral 00306 * @param[in] QEIx QEI peripheral, should be QEI 00307 * @param[in] ulVelComp Compare Velocity value to set 00308 * @return None 00309 **********************************************************************/ 00310 void QEI_SetVelocityComp(LPC_QEI_TypeDef *QEIx, uint32_t ulVelComp) 00311 { 00312 CHECK_PARAM(PARAM_QEIx(QEIx)); 00313 QEIx->VELCOMP = ulVelComp; 00314 } 00315 00316 /*********************************************************************//** 00317 * @brief Set value of sampling count for the digital filter in 00318 * QEI peripheral 00319 * @param[in] QEIx QEI peripheral, should be QEI 00320 * @param[in] ulSamplingPulse Value of sampling count to set 00321 * @return None 00322 **********************************************************************/ 00323 void QEI_SetDigiFilter(LPC_QEI_TypeDef *QEIx, uint32_t ulSamplingPulse) 00324 { 00325 CHECK_PARAM(PARAM_QEIx(QEIx)); 00326 QEIx->FILTER = ulSamplingPulse; 00327 } 00328 00329 /*********************************************************************//** 00330 * @brief Check whether if specified interrupt flag status in QEI 00331 * peripheral is set or not 00332 * @param[in] QEIx QEI peripheral, should be QEI 00333 * @param[in] ulIntType Interrupt Flag Status type, should be: 00334 - QEI_INTFLAG_INX_Int: index pulse was detected interrupt 00335 - QEI_INTFLAG_TIM_Int: Velocity timer over flow interrupt 00336 - QEI_INTFLAG_VELC_Int: Capture velocity is less than compare interrupt 00337 - QEI_INTFLAG_DIR_Int: Change of direction interrupt 00338 - QEI_INTFLAG_ERR_Int: An encoder phase error interrupt 00339 - QEI_INTFLAG_ENCLK_Int: An encoder clock pulse was detected interrupt 00340 - QEI_INTFLAG_POS0_Int: position 0 compare value is equal to the 00341 current position interrupt 00342 - QEI_INTFLAG_POS1_Int: position 1 compare value is equal to the 00343 current position interrupt 00344 - QEI_INTFLAG_POS2_Int: position 2 compare value is equal to the 00345 current position interrupt 00346 - QEI_INTFLAG_REV_Int: Index compare value is equal to the current 00347 index count interrupt 00348 - QEI_INTFLAG_POS0REV_Int: Combined position 0 and revolution count interrupt 00349 - QEI_INTFLAG_POS1REV_Int: Combined position 1 and revolution count interrupt 00350 - QEI_INTFLAG_POS2REV_Int: Combined position 2 and revolution count interrupt 00351 * @return New State of specified interrupt flag status (SET or RESET) 00352 **********************************************************************/ 00353 FlagStatus QEI_GetIntStatus(LPC_QEI_TypeDef *QEIx, uint32_t ulIntType) 00354 { 00355 CHECK_PARAM(PARAM_QEIx(QEIx)); 00356 CHECK_PARAM(PARAM_QEI_INTFLAG(ulIntType)); 00357 00358 return((QEIx->QEIINTSTAT & ulIntType) ? SET : RESET); 00359 } 00360 00361 /*********************************************************************//** 00362 * @brief Enable/Disable specified interrupt in QEI peripheral 00363 * @param[in] QEIx QEI peripheral, should be QEI 00364 * @param[in] ulIntType Interrupt Flag Status type, should be: 00365 * - QEI_INTFLAG_INX_Int: index pulse was detected interrupt 00366 * - QEI_INTFLAG_TIM_Int: Velocity timer over flow interrupt 00367 * - QEI_INTFLAG_VELC_Int: Capture velocity is less than compare interrupt 00368 * - QEI_INTFLAG_DIR_Int: Change of direction interrupt 00369 * - QEI_INTFLAG_ERR_Int: An encoder phase error interrupt 00370 * - QEI_INTFLAG_ENCLK_Int: An encoder clock pulse was detected interrupt 00371 * - QEI_INTFLAG_POS0_Int: position 0 compare value is equal to the 00372 * current position interrupt 00373 * - QEI_INTFLAG_POS1_Int: position 1 compare value is equal to the 00374 * current position interrupt 00375 * - QEI_INTFLAG_POS2_Int: position 2 compare value is equal to the 00376 * current position interrupt 00377 * - QEI_INTFLAG_REV_Int: Index compare value is equal to the current 00378 * index count interrupt 00379 * - QEI_INTFLAG_POS0REV_Int: Combined position 0 and revolution count interrupt 00380 * - QEI_INTFLAG_POS1REV_Int: Combined position 1 and revolution count interrupt 00381 * - QEI_INTFLAG_POS2REV_Int: Combined position 2 and revolution count interrupt 00382 * @param[in] NewState New function state, should be: 00383 * - DISABLE 00384 * - ENABLE 00385 * @return None 00386 **********************************************************************/ 00387 void QEI_IntCmd(LPC_QEI_TypeDef *QEIx, uint32_t ulIntType, FunctionalState NewState) 00388 { 00389 CHECK_PARAM(PARAM_QEIx(QEIx)); 00390 CHECK_PARAM(PARAM_QEI_INTFLAG(ulIntType)); 00391 CHECK_PARAM(PARAM_FUNCTIONALSTATE(NewState)); 00392 00393 if (NewState == ENABLE) { 00394 QEIx->QEIIES = ulIntType; 00395 } else { 00396 QEIx->QEIIEC = ulIntType; 00397 } 00398 } 00399 00400 00401 /*********************************************************************//** 00402 * @brief Sets (forces) specified interrupt in QEI peripheral 00403 * @param[in] QEIx QEI peripheral, should be QEI 00404 * @param[in] ulIntType Interrupt Flag Status type, should be: 00405 - QEI_INTFLAG_INX_Int: index pulse was detected interrupt 00406 - QEI_INTFLAG_TIM_Int: Velocity timer over flow interrupt 00407 - QEI_INTFLAG_VELC_Int: Capture velocity is less than compare interrupt 00408 - QEI_INTFLAG_DIR_Int: Change of direction interrupt 00409 - QEI_INTFLAG_ERR_Int: An encoder phase error interrupt 00410 - QEI_INTFLAG_ENCLK_Int: An encoder clock pulse was detected interrupt 00411 - QEI_INTFLAG_POS0_Int: position 0 compare value is equal to the 00412 current position interrupt 00413 - QEI_INTFLAG_POS1_Int: position 1 compare value is equal to the 00414 current position interrupt 00415 - QEI_INTFLAG_POS2_Int: position 2 compare value is equal to the 00416 current position interrupt 00417 - QEI_INTFLAG_REV_Int: Index compare value is equal to the current 00418 index count interrupt 00419 - QEI_INTFLAG_POS0REV_Int: Combined position 0 and revolution count interrupt 00420 - QEI_INTFLAG_POS1REV_Int: Combined position 1 and revolution count interrupt 00421 - QEI_INTFLAG_POS2REV_Int: Combined position 2 and revolution count interrupt 00422 * @return None 00423 **********************************************************************/ 00424 void QEI_IntSet(LPC_QEI_TypeDef *QEIx, uint32_t ulIntType) 00425 { 00426 CHECK_PARAM(PARAM_QEIx(QEIx)); 00427 CHECK_PARAM(PARAM_QEI_INTFLAG(ulIntType)); 00428 00429 QEIx->QEISET = ulIntType; 00430 } 00431 00432 /*********************************************************************//** 00433 * @brief Clear (force) specified interrupt (pending) in QEI peripheral 00434 * @param[in] QEIx QEI peripheral, should be QEI 00435 * @param[in] ulIntType Interrupt Flag Status type, should be: 00436 - QEI_INTFLAG_INX_Int: index pulse was detected interrupt 00437 - QEI_INTFLAG_TIM_Int: Velocity timer over flow interrupt 00438 - QEI_INTFLAG_VELC_Int: Capture velocity is less than compare interrupt 00439 - QEI_INTFLAG_DIR_Int: Change of direction interrupt 00440 - QEI_INTFLAG_ERR_Int: An encoder phase error interrupt 00441 - QEI_INTFLAG_ENCLK_Int: An encoder clock pulse was detected interrupt 00442 - QEI_INTFLAG_POS0_Int: position 0 compare value is equal to the 00443 current position interrupt 00444 - QEI_INTFLAG_POS1_Int: position 1 compare value is equal to the 00445 current position interrupt 00446 - QEI_INTFLAG_POS2_Int: position 2 compare value is equal to the 00447 current position interrupt 00448 - QEI_INTFLAG_REV_Int: Index compare value is equal to the current 00449 index count interrupt 00450 - QEI_INTFLAG_POS0REV_Int: Combined position 0 and revolution count interrupt 00451 - QEI_INTFLAG_POS1REV_Int: Combined position 1 and revolution count interrupt 00452 - QEI_INTFLAG_POS2REV_Int: Combined position 2 and revolution count interrupt 00453 * @return None 00454 **********************************************************************/ 00455 void QEI_IntClear(LPC_QEI_TypeDef *QEIx, uint32_t ulIntType) 00456 { 00457 CHECK_PARAM(PARAM_QEIx(QEIx)); 00458 CHECK_PARAM(PARAM_QEI_INTFLAG(ulIntType)); 00459 00460 QEIx->QEICLR = ulIntType; 00461 } 00462 00463 00464 /*********************************************************************//** 00465 * @brief Calculates the actual velocity in RPM passed via velocity 00466 * capture value and Pulse Per Round (of the encoder) value 00467 * parameter input. 00468 * @param[in] QEIx QEI peripheral, should be QEI 00469 * @param[in] ulVelCapValue Velocity capture input value that can 00470 * be got from QEI_GetVelocityCap() function 00471 * @param[in] ulPPR Pulse per round of encoder 00472 * @return The actual value of velocity in RPM (Round per minute) 00473 **********************************************************************/ 00474 uint32_t QEI_CalculateRPM(LPC_QEI_TypeDef *QEIx, uint32_t ulVelCapValue, uint32_t ulPPR) 00475 { 00476 uint64_t rpm, clock, Load, edges; 00477 00478 // Get current Clock rate for timer input 00479 clock = (uint64_t)CLKPWR_GetPCLK(CLKPWR_PCLKSEL_QEI); 00480 // Get Timer load value (velocity capture period) 00481 Load = (uint64_t)(QEIx->QEILOAD + 1); 00482 // Get Edge 00483 edges = (uint64_t)((QEIx->QEICONF & QEI_CONF_CAPMODE) ? 4 : 2); 00484 // Calculate RPM 00485 rpm = ((clock * ulVelCapValue * 60) / (Load * ulPPR * edges)); 00486 00487 return (uint32_t)(rpm); 00488 } 00489 00490 00491 /** 00492 * @} 00493 */ 00494 00495 #endif /* _QEI */ 00496 00497 /** 00498 * @} 00499 */ 00500 00501 /* --------------------------------- End Of File ------------------------------ */ 00502
Generated on Tue Jul 12 2022 17:06:02 by 1.7.2