Date: March 20, 2011 This library is created from "LPC17xx CMSIS-Compliant Standard Peripheral Firmware Driver Library (GNU, Keil, IAR) (Jan 28, 2011)", available from NXP's website, under "All microcontrollers support documents" [[http://ics.nxp.com/support/documents/microcontrollers/?type=software]] You will need to follow [[/projects/libraries/svn/mbed/trunk/LPC1768/LPC17xx.h]] while using this library Examples provided here [[/users/frank26080115/programs/LPC1700CMSIS_Examples/]] The beautiful thing is that NXP does not place copyright protection on any of the files in here Only a few modifications are made to make it compile with the mbed online compiler, I fixed some warnings as well. This is untested as of March 20, 2011 Forum post about this library: [[/forum/mbed/topic/2030/]]
lpc17xx_qei.c@0:84d7747641aa, 2011-03-20 (annotated)
- Committer:
- frank26080115
- Date:
- Sun Mar 20 18:45:15 2011 +0000
- Revision:
- 0:84d7747641aa
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
frank26080115 | 0:84d7747641aa | 1 | /***********************************************************************//** |
frank26080115 | 0:84d7747641aa | 2 | * @file lpc17xx_qei.c |
frank26080115 | 0:84d7747641aa | 3 | * @brief Contains all functions support for QEI firmware library on LPC17xx |
frank26080115 | 0:84d7747641aa | 4 | * @version 2.0 |
frank26080115 | 0:84d7747641aa | 5 | * @date 21. May. 2010 |
frank26080115 | 0:84d7747641aa | 6 | * @author NXP MCU SW Application Team |
frank26080115 | 0:84d7747641aa | 7 | ************************************************************************** |
frank26080115 | 0:84d7747641aa | 8 | * Software that is described herein is for illustrative purposes only |
frank26080115 | 0:84d7747641aa | 9 | * which provides customers with programming information regarding the |
frank26080115 | 0:84d7747641aa | 10 | * products. This software is supplied "AS IS" without any warranties. |
frank26080115 | 0:84d7747641aa | 11 | * NXP Semiconductors assumes no responsibility or liability for the |
frank26080115 | 0:84d7747641aa | 12 | * use of the software, conveys no license or title under any patent, |
frank26080115 | 0:84d7747641aa | 13 | * copyright, or mask work right to the product. NXP Semiconductors |
frank26080115 | 0:84d7747641aa | 14 | * reserves the right to make changes in the software without |
frank26080115 | 0:84d7747641aa | 15 | * notification. NXP Semiconductors also make no representation or |
frank26080115 | 0:84d7747641aa | 16 | * warranty that such application will be suitable for the specified |
frank26080115 | 0:84d7747641aa | 17 | * use without further testing or modification. |
frank26080115 | 0:84d7747641aa | 18 | **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 19 | |
frank26080115 | 0:84d7747641aa | 20 | /* Peripheral group ----------------------------------------------------------- */ |
frank26080115 | 0:84d7747641aa | 21 | /** @addtogroup QEI |
frank26080115 | 0:84d7747641aa | 22 | * @{ |
frank26080115 | 0:84d7747641aa | 23 | */ |
frank26080115 | 0:84d7747641aa | 24 | |
frank26080115 | 0:84d7747641aa | 25 | /* Includes ------------------------------------------------------------------- */ |
frank26080115 | 0:84d7747641aa | 26 | #include "lpc17xx_qei.h" |
frank26080115 | 0:84d7747641aa | 27 | #include "lpc17xx_clkpwr.h" |
frank26080115 | 0:84d7747641aa | 28 | |
frank26080115 | 0:84d7747641aa | 29 | |
frank26080115 | 0:84d7747641aa | 30 | /* If this source file built with example, the LPC17xx FW library configuration |
frank26080115 | 0:84d7747641aa | 31 | * file in each example directory ("lpc17xx_libcfg.h") must be included, |
frank26080115 | 0:84d7747641aa | 32 | * otherwise the default FW library configuration file must be included instead |
frank26080115 | 0:84d7747641aa | 33 | */ |
frank26080115 | 0:84d7747641aa | 34 | #ifdef __BUILD_WITH_EXAMPLE__ |
frank26080115 | 0:84d7747641aa | 35 | #include "lpc17xx_libcfg.h" |
frank26080115 | 0:84d7747641aa | 36 | #else |
frank26080115 | 0:84d7747641aa | 37 | #include "lpc17xx_libcfg_default.h" |
frank26080115 | 0:84d7747641aa | 38 | #endif /* __BUILD_WITH_EXAMPLE__ */ |
frank26080115 | 0:84d7747641aa | 39 | |
frank26080115 | 0:84d7747641aa | 40 | |
frank26080115 | 0:84d7747641aa | 41 | #ifdef _QEI |
frank26080115 | 0:84d7747641aa | 42 | |
frank26080115 | 0:84d7747641aa | 43 | /* Private Types -------------------------------------------------------------- */ |
frank26080115 | 0:84d7747641aa | 44 | /** @defgroup QEI_Private_Types QEI Private Types |
frank26080115 | 0:84d7747641aa | 45 | * @{ |
frank26080115 | 0:84d7747641aa | 46 | */ |
frank26080115 | 0:84d7747641aa | 47 | |
frank26080115 | 0:84d7747641aa | 48 | /** |
frank26080115 | 0:84d7747641aa | 49 | * @brief QEI configuration union type definition |
frank26080115 | 0:84d7747641aa | 50 | */ |
frank26080115 | 0:84d7747641aa | 51 | typedef union { |
frank26080115 | 0:84d7747641aa | 52 | QEI_CFG_Type bmQEIConfig; |
frank26080115 | 0:84d7747641aa | 53 | uint32_t ulQEIConfig; |
frank26080115 | 0:84d7747641aa | 54 | } QEI_CFGOPT_Type; |
frank26080115 | 0:84d7747641aa | 55 | |
frank26080115 | 0:84d7747641aa | 56 | /** |
frank26080115 | 0:84d7747641aa | 57 | * @} |
frank26080115 | 0:84d7747641aa | 58 | */ |
frank26080115 | 0:84d7747641aa | 59 | |
frank26080115 | 0:84d7747641aa | 60 | |
frank26080115 | 0:84d7747641aa | 61 | /* Public Functions ----------------------------------------------------------- */ |
frank26080115 | 0:84d7747641aa | 62 | /** @addtogroup QEI_Public_Functions |
frank26080115 | 0:84d7747641aa | 63 | * @{ |
frank26080115 | 0:84d7747641aa | 64 | */ |
frank26080115 | 0:84d7747641aa | 65 | |
frank26080115 | 0:84d7747641aa | 66 | /*********************************************************************//** |
frank26080115 | 0:84d7747641aa | 67 | * @brief Resets value for each type of QEI value, such as velocity, |
frank26080115 | 0:84d7747641aa | 68 | * counter, position, etc.. |
frank26080115 | 0:84d7747641aa | 69 | * @param[in] QEIx QEI peripheral, should be LPC_QEI |
frank26080115 | 0:84d7747641aa | 70 | * @param[in] ulResetType QEI Reset Type, should be one of the following: |
frank26080115 | 0:84d7747641aa | 71 | * - QEI_RESET_POS: Reset Position Counter |
frank26080115 | 0:84d7747641aa | 72 | * - QEI_RESET_POSOnIDX: Reset Position Counter on Index signal |
frank26080115 | 0:84d7747641aa | 73 | * - QEI_RESET_VEL: Reset Velocity |
frank26080115 | 0:84d7747641aa | 74 | * - QEI_RESET_IDX: Reset Index Counter |
frank26080115 | 0:84d7747641aa | 75 | * @return None |
frank26080115 | 0:84d7747641aa | 76 | **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 77 | void QEI_Reset(LPC_QEI_TypeDef *QEIx, uint32_t ulResetType) |
frank26080115 | 0:84d7747641aa | 78 | { |
frank26080115 | 0:84d7747641aa | 79 | CHECK_PARAM(PARAM_QEIx(QEIx)); |
frank26080115 | 0:84d7747641aa | 80 | CHECK_PARAM(PARAM_QEI_RESET(ulResetType)); |
frank26080115 | 0:84d7747641aa | 81 | |
frank26080115 | 0:84d7747641aa | 82 | QEIx->QEICON = ulResetType; |
frank26080115 | 0:84d7747641aa | 83 | } |
frank26080115 | 0:84d7747641aa | 84 | |
frank26080115 | 0:84d7747641aa | 85 | /*********************************************************************//** |
frank26080115 | 0:84d7747641aa | 86 | * @brief Initializes the QEI peripheral according to the specified |
frank26080115 | 0:84d7747641aa | 87 | * parameters in the QEI_ConfigStruct. |
frank26080115 | 0:84d7747641aa | 88 | * @param[in] QEIx QEI peripheral, should be LPC_QEI |
frank26080115 | 0:84d7747641aa | 89 | * @param[in] QEI_ConfigStruct Pointer to a QEI_CFG_Type structure |
frank26080115 | 0:84d7747641aa | 90 | * that contains the configuration information for the |
frank26080115 | 0:84d7747641aa | 91 | * specified QEI peripheral |
frank26080115 | 0:84d7747641aa | 92 | * @return None |
frank26080115 | 0:84d7747641aa | 93 | **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 94 | void QEI_Init(LPC_QEI_TypeDef *QEIx, QEI_CFG_Type *QEI_ConfigStruct) |
frank26080115 | 0:84d7747641aa | 95 | { |
frank26080115 | 0:84d7747641aa | 96 | |
frank26080115 | 0:84d7747641aa | 97 | CHECK_PARAM(PARAM_QEIx(QEIx)); |
frank26080115 | 0:84d7747641aa | 98 | CHECK_PARAM(PARAM_QEI_DIRINV(QEI_ConfigStruct->DirectionInvert)); |
frank26080115 | 0:84d7747641aa | 99 | CHECK_PARAM(PARAM_QEI_SIGNALMODE(QEI_ConfigStruct->SignalMode)); |
frank26080115 | 0:84d7747641aa | 100 | CHECK_PARAM(PARAM_QEI_CAPMODE(QEI_ConfigStruct->CaptureMode)); |
frank26080115 | 0:84d7747641aa | 101 | CHECK_PARAM(PARAM_QEI_INVINX(QEI_ConfigStruct->InvertIndex)); |
frank26080115 | 0:84d7747641aa | 102 | |
frank26080115 | 0:84d7747641aa | 103 | /* Set up clock and power for QEI module */ |
frank26080115 | 0:84d7747641aa | 104 | CLKPWR_ConfigPPWR (CLKPWR_PCONP_PCQEI, ENABLE); |
frank26080115 | 0:84d7747641aa | 105 | |
frank26080115 | 0:84d7747641aa | 106 | /* As default, peripheral clock for QEI module |
frank26080115 | 0:84d7747641aa | 107 | * is set to FCCLK / 2 */ |
frank26080115 | 0:84d7747641aa | 108 | CLKPWR_SetPCLKDiv(CLKPWR_PCLKSEL_QEI, CLKPWR_PCLKSEL_CCLK_DIV_1); |
frank26080115 | 0:84d7747641aa | 109 | |
frank26080115 | 0:84d7747641aa | 110 | // Reset all remaining value in QEI peripheral |
frank26080115 | 0:84d7747641aa | 111 | QEIx->QEICON = QEI_CON_RESP | QEI_CON_RESV | QEI_CON_RESI; |
frank26080115 | 0:84d7747641aa | 112 | QEIx->QEIMAXPOS = 0x00; |
frank26080115 | 0:84d7747641aa | 113 | QEIx->CMPOS0 = 0x00; |
frank26080115 | 0:84d7747641aa | 114 | QEIx->CMPOS1 = 0x00; |
frank26080115 | 0:84d7747641aa | 115 | QEIx->CMPOS2 = 0x00; |
frank26080115 | 0:84d7747641aa | 116 | QEIx->INXCMP = 0x00; |
frank26080115 | 0:84d7747641aa | 117 | QEIx->QEILOAD = 0x00; |
frank26080115 | 0:84d7747641aa | 118 | QEIx->VELCOMP = 0x00; |
frank26080115 | 0:84d7747641aa | 119 | QEIx->FILTER = 0x00; |
frank26080115 | 0:84d7747641aa | 120 | // Disable all Interrupt |
frank26080115 | 0:84d7747641aa | 121 | QEIx->QEIIEC = QEI_IECLR_BITMASK; |
frank26080115 | 0:84d7747641aa | 122 | // Clear all Interrupt pending |
frank26080115 | 0:84d7747641aa | 123 | QEIx->QEICLR = QEI_INTCLR_BITMASK; |
frank26080115 | 0:84d7747641aa | 124 | // Set QEI configuration value corresponding to its setting up value |
frank26080115 | 0:84d7747641aa | 125 | QEIx->QEICONF = ((QEI_CFGOPT_Type *)QEI_ConfigStruct)->ulQEIConfig; |
frank26080115 | 0:84d7747641aa | 126 | } |
frank26080115 | 0:84d7747641aa | 127 | |
frank26080115 | 0:84d7747641aa | 128 | |
frank26080115 | 0:84d7747641aa | 129 | /*********************************************************************//** |
frank26080115 | 0:84d7747641aa | 130 | * @brief De-initializes the QEI peripheral registers to their |
frank26080115 | 0:84d7747641aa | 131 | * default reset values. |
frank26080115 | 0:84d7747641aa | 132 | * @param[in] QEIx QEI peripheral, should be LPC_QEI |
frank26080115 | 0:84d7747641aa | 133 | * @return None |
frank26080115 | 0:84d7747641aa | 134 | **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 135 | void QEI_DeInit(LPC_QEI_TypeDef *QEIx) |
frank26080115 | 0:84d7747641aa | 136 | { |
frank26080115 | 0:84d7747641aa | 137 | CHECK_PARAM(PARAM_QEIx(QEIx)); |
frank26080115 | 0:84d7747641aa | 138 | |
frank26080115 | 0:84d7747641aa | 139 | /* Turn off clock and power for QEI module */ |
frank26080115 | 0:84d7747641aa | 140 | CLKPWR_ConfigPPWR (CLKPWR_PCONP_PCQEI, DISABLE); |
frank26080115 | 0:84d7747641aa | 141 | } |
frank26080115 | 0:84d7747641aa | 142 | |
frank26080115 | 0:84d7747641aa | 143 | |
frank26080115 | 0:84d7747641aa | 144 | /*****************************************************************************//** |
frank26080115 | 0:84d7747641aa | 145 | * @brief Fills each QIE_InitStruct member with its default value: |
frank26080115 | 0:84d7747641aa | 146 | * - DirectionInvert = QEI_DIRINV_NONE |
frank26080115 | 0:84d7747641aa | 147 | * - SignalMode = QEI_SIGNALMODE_QUAD |
frank26080115 | 0:84d7747641aa | 148 | * - CaptureMode = QEI_CAPMODE_4X |
frank26080115 | 0:84d7747641aa | 149 | * - InvertIndex = QEI_INVINX_NONE |
frank26080115 | 0:84d7747641aa | 150 | * @param[in] QIE_InitStruct Pointer to a QEI_CFG_Type structure |
frank26080115 | 0:84d7747641aa | 151 | * which will be initialized. |
frank26080115 | 0:84d7747641aa | 152 | * @return None |
frank26080115 | 0:84d7747641aa | 153 | *******************************************************************************/ |
frank26080115 | 0:84d7747641aa | 154 | void QEI_ConfigStructInit(QEI_CFG_Type *QIE_InitStruct) |
frank26080115 | 0:84d7747641aa | 155 | { |
frank26080115 | 0:84d7747641aa | 156 | QIE_InitStruct->CaptureMode = QEI_CAPMODE_4X; |
frank26080115 | 0:84d7747641aa | 157 | QIE_InitStruct->DirectionInvert = QEI_DIRINV_NONE; |
frank26080115 | 0:84d7747641aa | 158 | QIE_InitStruct->InvertIndex = QEI_INVINX_NONE; |
frank26080115 | 0:84d7747641aa | 159 | QIE_InitStruct->SignalMode = QEI_SIGNALMODE_QUAD; |
frank26080115 | 0:84d7747641aa | 160 | } |
frank26080115 | 0:84d7747641aa | 161 | |
frank26080115 | 0:84d7747641aa | 162 | |
frank26080115 | 0:84d7747641aa | 163 | /*********************************************************************//** |
frank26080115 | 0:84d7747641aa | 164 | * @brief Check whether if specified flag status is set or not |
frank26080115 | 0:84d7747641aa | 165 | * @param[in] QEIx QEI peripheral, should be LPC_QEI |
frank26080115 | 0:84d7747641aa | 166 | * @param[in] ulFlagType Status Flag Type, should be one of the following: |
frank26080115 | 0:84d7747641aa | 167 | * - QEI_STATUS_DIR: Direction Status |
frank26080115 | 0:84d7747641aa | 168 | * @return New Status of this status flag (SET or RESET) |
frank26080115 | 0:84d7747641aa | 169 | **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 170 | FlagStatus QEI_GetStatus(LPC_QEI_TypeDef *QEIx, uint32_t ulFlagType) |
frank26080115 | 0:84d7747641aa | 171 | { |
frank26080115 | 0:84d7747641aa | 172 | CHECK_PARAM(PARAM_QEIx(QEIx)); |
frank26080115 | 0:84d7747641aa | 173 | CHECK_PARAM(PARAM_QEI_STATUS(ulFlagType)); |
frank26080115 | 0:84d7747641aa | 174 | return ((QEIx->QEISTAT & ulFlagType) ? SET : RESET); |
frank26080115 | 0:84d7747641aa | 175 | } |
frank26080115 | 0:84d7747641aa | 176 | |
frank26080115 | 0:84d7747641aa | 177 | /*********************************************************************//** |
frank26080115 | 0:84d7747641aa | 178 | * @brief Get current position value in QEI peripheral |
frank26080115 | 0:84d7747641aa | 179 | * @param[in] QEIx QEI peripheral, should be LPC_QEI |
frank26080115 | 0:84d7747641aa | 180 | * @return Current position value of QEI peripheral |
frank26080115 | 0:84d7747641aa | 181 | **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 182 | uint32_t QEI_GetPosition(LPC_QEI_TypeDef *QEIx) |
frank26080115 | 0:84d7747641aa | 183 | { |
frank26080115 | 0:84d7747641aa | 184 | CHECK_PARAM(PARAM_QEIx(QEIx)); |
frank26080115 | 0:84d7747641aa | 185 | return (QEIx->QEIPOS); |
frank26080115 | 0:84d7747641aa | 186 | } |
frank26080115 | 0:84d7747641aa | 187 | |
frank26080115 | 0:84d7747641aa | 188 | /*********************************************************************//** |
frank26080115 | 0:84d7747641aa | 189 | * @brief Set max position value for QEI peripheral |
frank26080115 | 0:84d7747641aa | 190 | * @param[in] QEIx QEI peripheral, should be LPC_QEI |
frank26080115 | 0:84d7747641aa | 191 | * @param[in] ulMaxPos Max position value to set |
frank26080115 | 0:84d7747641aa | 192 | * @return None |
frank26080115 | 0:84d7747641aa | 193 | **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 194 | void QEI_SetMaxPosition(LPC_QEI_TypeDef *QEIx, uint32_t ulMaxPos) |
frank26080115 | 0:84d7747641aa | 195 | { |
frank26080115 | 0:84d7747641aa | 196 | CHECK_PARAM(PARAM_QEIx(QEIx)); |
frank26080115 | 0:84d7747641aa | 197 | QEIx->QEIMAXPOS = ulMaxPos; |
frank26080115 | 0:84d7747641aa | 198 | } |
frank26080115 | 0:84d7747641aa | 199 | |
frank26080115 | 0:84d7747641aa | 200 | /*********************************************************************//** |
frank26080115 | 0:84d7747641aa | 201 | * @brief Set position compare value for QEI peripheral |
frank26080115 | 0:84d7747641aa | 202 | * @param[in] QEIx QEI peripheral, should be LPC_QEI |
frank26080115 | 0:84d7747641aa | 203 | * @param[in] bPosCompCh Compare Position channel, should be: |
frank26080115 | 0:84d7747641aa | 204 | * - QEI_COMPPOS_CH_0: QEI compare position channel 0 |
frank26080115 | 0:84d7747641aa | 205 | * - QEI_COMPPOS_CH_1: QEI compare position channel 1 |
frank26080115 | 0:84d7747641aa | 206 | * - QEI_COMPPOS_CH_2: QEI compare position channel 2 |
frank26080115 | 0:84d7747641aa | 207 | * @param[in] ulPosComp Compare Position value to set |
frank26080115 | 0:84d7747641aa | 208 | * @return None |
frank26080115 | 0:84d7747641aa | 209 | **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 210 | void QEI_SetPositionComp(LPC_QEI_TypeDef *QEIx, uint8_t bPosCompCh, uint32_t ulPosComp) |
frank26080115 | 0:84d7747641aa | 211 | { |
frank26080115 | 0:84d7747641aa | 212 | uint32_t *tmp; |
frank26080115 | 0:84d7747641aa | 213 | |
frank26080115 | 0:84d7747641aa | 214 | CHECK_PARAM(PARAM_QEIx(QEIx)); |
frank26080115 | 0:84d7747641aa | 215 | CHECK_PARAM(PARAM_QEI_COMPPOS_CH(bPosCompCh)); |
frank26080115 | 0:84d7747641aa | 216 | tmp = (uint32_t *) (&(QEIx->CMPOS0) + bPosCompCh * 4); |
frank26080115 | 0:84d7747641aa | 217 | *tmp = ulPosComp; |
frank26080115 | 0:84d7747641aa | 218 | |
frank26080115 | 0:84d7747641aa | 219 | } |
frank26080115 | 0:84d7747641aa | 220 | |
frank26080115 | 0:84d7747641aa | 221 | /*********************************************************************//** |
frank26080115 | 0:84d7747641aa | 222 | * @brief Get current index counter of QEI peripheral |
frank26080115 | 0:84d7747641aa | 223 | * @param[in] QEIx QEI peripheral, should be LPC_QEI |
frank26080115 | 0:84d7747641aa | 224 | * @return Current value of QEI index counter |
frank26080115 | 0:84d7747641aa | 225 | **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 226 | uint32_t QEI_GetIndex(LPC_QEI_TypeDef *QEIx) |
frank26080115 | 0:84d7747641aa | 227 | { |
frank26080115 | 0:84d7747641aa | 228 | CHECK_PARAM(PARAM_QEIx(QEIx)); |
frank26080115 | 0:84d7747641aa | 229 | return (QEIx->INXCNT); |
frank26080115 | 0:84d7747641aa | 230 | } |
frank26080115 | 0:84d7747641aa | 231 | |
frank26080115 | 0:84d7747641aa | 232 | /*********************************************************************//** |
frank26080115 | 0:84d7747641aa | 233 | * @brief Set value for index compare in QEI peripheral |
frank26080115 | 0:84d7747641aa | 234 | * @param[in] QEIx QEI peripheral, should be LPC_QEI |
frank26080115 | 0:84d7747641aa | 235 | * @param[in] ulIndexComp Compare Index Value to set |
frank26080115 | 0:84d7747641aa | 236 | * @return None |
frank26080115 | 0:84d7747641aa | 237 | **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 238 | void QEI_SetIndexComp(LPC_QEI_TypeDef *QEIx, uint32_t ulIndexComp) |
frank26080115 | 0:84d7747641aa | 239 | { |
frank26080115 | 0:84d7747641aa | 240 | CHECK_PARAM(PARAM_QEIx(QEIx)); |
frank26080115 | 0:84d7747641aa | 241 | QEIx->INXCMP = ulIndexComp; |
frank26080115 | 0:84d7747641aa | 242 | } |
frank26080115 | 0:84d7747641aa | 243 | |
frank26080115 | 0:84d7747641aa | 244 | /*********************************************************************//** |
frank26080115 | 0:84d7747641aa | 245 | * @brief Set timer reload value for QEI peripheral. When the velocity timer is |
frank26080115 | 0:84d7747641aa | 246 | * over-flow, the value that set for Timer Reload register will be loaded |
frank26080115 | 0:84d7747641aa | 247 | * into the velocity timer for next period. The calculated velocity in RPM |
frank26080115 | 0:84d7747641aa | 248 | * therefore will be affect by this value. |
frank26080115 | 0:84d7747641aa | 249 | * @param[in] QEIx QEI peripheral, should be LPC_QEI |
frank26080115 | 0:84d7747641aa | 250 | * @param[in] QEIReloadStruct QEI reload structure |
frank26080115 | 0:84d7747641aa | 251 | * @return None |
frank26080115 | 0:84d7747641aa | 252 | **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 253 | void QEI_SetTimerReload(LPC_QEI_TypeDef *QEIx, QEI_RELOADCFG_Type *QEIReloadStruct) |
frank26080115 | 0:84d7747641aa | 254 | { |
frank26080115 | 0:84d7747641aa | 255 | uint64_t pclk; |
frank26080115 | 0:84d7747641aa | 256 | |
frank26080115 | 0:84d7747641aa | 257 | CHECK_PARAM(PARAM_QEIx(QEIx)); |
frank26080115 | 0:84d7747641aa | 258 | CHECK_PARAM(PARAM_QEI_TIMERRELOAD(QEIReloadStruct->ReloadOption)); |
frank26080115 | 0:84d7747641aa | 259 | |
frank26080115 | 0:84d7747641aa | 260 | if (QEIReloadStruct->ReloadOption == QEI_TIMERRELOAD_TICKVAL) { |
frank26080115 | 0:84d7747641aa | 261 | QEIx->QEILOAD = QEIReloadStruct->ReloadValue - 1; |
frank26080115 | 0:84d7747641aa | 262 | } else { |
frank26080115 | 0:84d7747641aa | 263 | pclk = (uint64_t)CLKPWR_GetPCLK(CLKPWR_PCLKSEL_QEI); |
frank26080115 | 0:84d7747641aa | 264 | pclk = (pclk /(1000000/QEIReloadStruct->ReloadValue)) - 1; |
frank26080115 | 0:84d7747641aa | 265 | QEIx->QEILOAD = (uint32_t)pclk; |
frank26080115 | 0:84d7747641aa | 266 | } |
frank26080115 | 0:84d7747641aa | 267 | } |
frank26080115 | 0:84d7747641aa | 268 | |
frank26080115 | 0:84d7747641aa | 269 | /*********************************************************************//** |
frank26080115 | 0:84d7747641aa | 270 | * @brief Get current timer counter in QEI peripheral |
frank26080115 | 0:84d7747641aa | 271 | * @param[in] QEIx QEI peripheral, should be LPC_QEI |
frank26080115 | 0:84d7747641aa | 272 | * @return Current timer counter in QEI peripheral |
frank26080115 | 0:84d7747641aa | 273 | **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 274 | uint32_t QEI_GetTimer(LPC_QEI_TypeDef *QEIx) |
frank26080115 | 0:84d7747641aa | 275 | { |
frank26080115 | 0:84d7747641aa | 276 | CHECK_PARAM(PARAM_QEIx(QEIx)); |
frank26080115 | 0:84d7747641aa | 277 | return (QEIx->QEITIME); |
frank26080115 | 0:84d7747641aa | 278 | } |
frank26080115 | 0:84d7747641aa | 279 | |
frank26080115 | 0:84d7747641aa | 280 | /*********************************************************************//** |
frank26080115 | 0:84d7747641aa | 281 | * @brief Get current velocity pulse counter in current time period |
frank26080115 | 0:84d7747641aa | 282 | * @param[in] QEIx QEI peripheral, should be LPC_QEI |
frank26080115 | 0:84d7747641aa | 283 | * @return Current velocity pulse counter value |
frank26080115 | 0:84d7747641aa | 284 | **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 285 | uint32_t QEI_GetVelocity(LPC_QEI_TypeDef *QEIx) |
frank26080115 | 0:84d7747641aa | 286 | { |
frank26080115 | 0:84d7747641aa | 287 | CHECK_PARAM(PARAM_QEIx(QEIx)); |
frank26080115 | 0:84d7747641aa | 288 | return (QEIx->QEIVEL); |
frank26080115 | 0:84d7747641aa | 289 | } |
frank26080115 | 0:84d7747641aa | 290 | |
frank26080115 | 0:84d7747641aa | 291 | /*********************************************************************//** |
frank26080115 | 0:84d7747641aa | 292 | * @brief Get the most recently measured velocity of the QEI. When |
frank26080115 | 0:84d7747641aa | 293 | * the Velocity timer in QEI is over-flow, the current velocity |
frank26080115 | 0:84d7747641aa | 294 | * value will be loaded into Velocity Capture register. |
frank26080115 | 0:84d7747641aa | 295 | * @param[in] QEIx QEI peripheral, should be LPC_QEI |
frank26080115 | 0:84d7747641aa | 296 | * @return The most recently measured velocity value |
frank26080115 | 0:84d7747641aa | 297 | **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 298 | uint32_t QEI_GetVelocityCap(LPC_QEI_TypeDef *QEIx) |
frank26080115 | 0:84d7747641aa | 299 | { |
frank26080115 | 0:84d7747641aa | 300 | CHECK_PARAM(PARAM_QEIx(QEIx)); |
frank26080115 | 0:84d7747641aa | 301 | return (QEIx->QEICAP); |
frank26080115 | 0:84d7747641aa | 302 | } |
frank26080115 | 0:84d7747641aa | 303 | |
frank26080115 | 0:84d7747641aa | 304 | /*********************************************************************//** |
frank26080115 | 0:84d7747641aa | 305 | * @brief Set Velocity Compare value for QEI peripheral |
frank26080115 | 0:84d7747641aa | 306 | * @param[in] QEIx QEI peripheral, should be LPC_QEI |
frank26080115 | 0:84d7747641aa | 307 | * @param[in] ulVelComp Compare Velocity value to set |
frank26080115 | 0:84d7747641aa | 308 | * @return None |
frank26080115 | 0:84d7747641aa | 309 | **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 310 | void QEI_SetVelocityComp(LPC_QEI_TypeDef *QEIx, uint32_t ulVelComp) |
frank26080115 | 0:84d7747641aa | 311 | { |
frank26080115 | 0:84d7747641aa | 312 | CHECK_PARAM(PARAM_QEIx(QEIx)); |
frank26080115 | 0:84d7747641aa | 313 | QEIx->VELCOMP = ulVelComp; |
frank26080115 | 0:84d7747641aa | 314 | } |
frank26080115 | 0:84d7747641aa | 315 | |
frank26080115 | 0:84d7747641aa | 316 | /*********************************************************************//** |
frank26080115 | 0:84d7747641aa | 317 | * @brief Set value of sampling count for the digital filter in |
frank26080115 | 0:84d7747641aa | 318 | * QEI peripheral |
frank26080115 | 0:84d7747641aa | 319 | * @param[in] QEIx QEI peripheral, should be LPC_QEI |
frank26080115 | 0:84d7747641aa | 320 | * @param[in] ulSamplingPulse Value of sampling count to set |
frank26080115 | 0:84d7747641aa | 321 | * @return None |
frank26080115 | 0:84d7747641aa | 322 | **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 323 | void QEI_SetDigiFilter(LPC_QEI_TypeDef *QEIx, uint32_t ulSamplingPulse) |
frank26080115 | 0:84d7747641aa | 324 | { |
frank26080115 | 0:84d7747641aa | 325 | CHECK_PARAM(PARAM_QEIx(QEIx)); |
frank26080115 | 0:84d7747641aa | 326 | QEIx->FILTER = ulSamplingPulse; |
frank26080115 | 0:84d7747641aa | 327 | } |
frank26080115 | 0:84d7747641aa | 328 | |
frank26080115 | 0:84d7747641aa | 329 | /*********************************************************************//** |
frank26080115 | 0:84d7747641aa | 330 | * @brief Check whether if specified interrupt flag status in QEI |
frank26080115 | 0:84d7747641aa | 331 | * peripheral is set or not |
frank26080115 | 0:84d7747641aa | 332 | * @param[in] QEIx QEI peripheral, should be LPC_QEI |
frank26080115 | 0:84d7747641aa | 333 | * @param[in] ulIntType Interrupt Flag Status type, should be: |
frank26080115 | 0:84d7747641aa | 334 | - QEI_INTFLAG_INX_Int: index pulse was detected interrupt |
frank26080115 | 0:84d7747641aa | 335 | - QEI_INTFLAG_TIM_Int: Velocity timer over flow interrupt |
frank26080115 | 0:84d7747641aa | 336 | - QEI_INTFLAG_VELC_Int: Capture velocity is less than compare interrupt |
frank26080115 | 0:84d7747641aa | 337 | - QEI_INTFLAG_DIR_Int: Change of direction interrupt |
frank26080115 | 0:84d7747641aa | 338 | - QEI_INTFLAG_ERR_Int: An encoder phase error interrupt |
frank26080115 | 0:84d7747641aa | 339 | - QEI_INTFLAG_ENCLK_Int: An encoder clock pulse was detected interrupt |
frank26080115 | 0:84d7747641aa | 340 | - QEI_INTFLAG_POS0_Int: position 0 compare value is equal to the |
frank26080115 | 0:84d7747641aa | 341 | current position interrupt |
frank26080115 | 0:84d7747641aa | 342 | - QEI_INTFLAG_POS1_Int: position 1 compare value is equal to the |
frank26080115 | 0:84d7747641aa | 343 | current position interrupt |
frank26080115 | 0:84d7747641aa | 344 | - QEI_INTFLAG_POS2_Int: position 2 compare value is equal to the |
frank26080115 | 0:84d7747641aa | 345 | current position interrupt |
frank26080115 | 0:84d7747641aa | 346 | - QEI_INTFLAG_REV_Int: Index compare value is equal to the current |
frank26080115 | 0:84d7747641aa | 347 | index count interrupt |
frank26080115 | 0:84d7747641aa | 348 | - QEI_INTFLAG_POS0REV_Int: Combined position 0 and revolution count interrupt |
frank26080115 | 0:84d7747641aa | 349 | - QEI_INTFLAG_POS1REV_Int: Combined position 1 and revolution count interrupt |
frank26080115 | 0:84d7747641aa | 350 | - QEI_INTFLAG_POS2REV_Int: Combined position 2 and revolution count interrupt |
frank26080115 | 0:84d7747641aa | 351 | * @return New State of specified interrupt flag status (SET or RESET) |
frank26080115 | 0:84d7747641aa | 352 | **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 353 | FlagStatus QEI_GetIntStatus(LPC_QEI_TypeDef *QEIx, uint32_t ulIntType) |
frank26080115 | 0:84d7747641aa | 354 | { |
frank26080115 | 0:84d7747641aa | 355 | CHECK_PARAM(PARAM_QEIx(QEIx)); |
frank26080115 | 0:84d7747641aa | 356 | CHECK_PARAM(PARAM_QEI_INTFLAG(ulIntType)); |
frank26080115 | 0:84d7747641aa | 357 | |
frank26080115 | 0:84d7747641aa | 358 | return((QEIx->QEIINTSTAT & ulIntType) ? SET : RESET); |
frank26080115 | 0:84d7747641aa | 359 | } |
frank26080115 | 0:84d7747641aa | 360 | |
frank26080115 | 0:84d7747641aa | 361 | /*********************************************************************//** |
frank26080115 | 0:84d7747641aa | 362 | * @brief Enable/Disable specified interrupt in QEI peripheral |
frank26080115 | 0:84d7747641aa | 363 | * @param[in] QEIx QEI peripheral, should be LPC_QEI |
frank26080115 | 0:84d7747641aa | 364 | * @param[in] ulIntType Interrupt Flag Status type, should be: |
frank26080115 | 0:84d7747641aa | 365 | * - QEI_INTFLAG_INX_Int: index pulse was detected interrupt |
frank26080115 | 0:84d7747641aa | 366 | * - QEI_INTFLAG_TIM_Int: Velocity timer over flow interrupt |
frank26080115 | 0:84d7747641aa | 367 | * - QEI_INTFLAG_VELC_Int: Capture velocity is less than compare interrupt |
frank26080115 | 0:84d7747641aa | 368 | * - QEI_INTFLAG_DIR_Int: Change of direction interrupt |
frank26080115 | 0:84d7747641aa | 369 | * - QEI_INTFLAG_ERR_Int: An encoder phase error interrupt |
frank26080115 | 0:84d7747641aa | 370 | * - QEI_INTFLAG_ENCLK_Int: An encoder clock pulse was detected interrupt |
frank26080115 | 0:84d7747641aa | 371 | * - QEI_INTFLAG_POS0_Int: position 0 compare value is equal to the |
frank26080115 | 0:84d7747641aa | 372 | * current position interrupt |
frank26080115 | 0:84d7747641aa | 373 | * - QEI_INTFLAG_POS1_Int: position 1 compare value is equal to the |
frank26080115 | 0:84d7747641aa | 374 | * current position interrupt |
frank26080115 | 0:84d7747641aa | 375 | * - QEI_INTFLAG_POS2_Int: position 2 compare value is equal to the |
frank26080115 | 0:84d7747641aa | 376 | * current position interrupt |
frank26080115 | 0:84d7747641aa | 377 | * - QEI_INTFLAG_REV_Int: Index compare value is equal to the current |
frank26080115 | 0:84d7747641aa | 378 | * index count interrupt |
frank26080115 | 0:84d7747641aa | 379 | * - QEI_INTFLAG_POS0REV_Int: Combined position 0 and revolution count interrupt |
frank26080115 | 0:84d7747641aa | 380 | * - QEI_INTFLAG_POS1REV_Int: Combined position 1 and revolution count interrupt |
frank26080115 | 0:84d7747641aa | 381 | * - QEI_INTFLAG_POS2REV_Int: Combined position 2 and revolution count interrupt |
frank26080115 | 0:84d7747641aa | 382 | * @param[in] NewState New function state, should be: |
frank26080115 | 0:84d7747641aa | 383 | * - DISABLE |
frank26080115 | 0:84d7747641aa | 384 | * - ENABLE |
frank26080115 | 0:84d7747641aa | 385 | * @return None |
frank26080115 | 0:84d7747641aa | 386 | **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 387 | void QEI_IntCmd(LPC_QEI_TypeDef *QEIx, uint32_t ulIntType, FunctionalState NewState) |
frank26080115 | 0:84d7747641aa | 388 | { |
frank26080115 | 0:84d7747641aa | 389 | CHECK_PARAM(PARAM_QEIx(QEIx)); |
frank26080115 | 0:84d7747641aa | 390 | CHECK_PARAM(PARAM_QEI_INTFLAG(ulIntType)); |
frank26080115 | 0:84d7747641aa | 391 | CHECK_PARAM(PARAM_FUNCTIONALSTATE(NewState)); |
frank26080115 | 0:84d7747641aa | 392 | |
frank26080115 | 0:84d7747641aa | 393 | if (NewState == ENABLE) { |
frank26080115 | 0:84d7747641aa | 394 | QEIx->QEIIES = ulIntType; |
frank26080115 | 0:84d7747641aa | 395 | } else { |
frank26080115 | 0:84d7747641aa | 396 | QEIx->QEIIEC = ulIntType; |
frank26080115 | 0:84d7747641aa | 397 | } |
frank26080115 | 0:84d7747641aa | 398 | } |
frank26080115 | 0:84d7747641aa | 399 | |
frank26080115 | 0:84d7747641aa | 400 | |
frank26080115 | 0:84d7747641aa | 401 | /*********************************************************************//** |
frank26080115 | 0:84d7747641aa | 402 | * @brief Sets (forces) specified interrupt in QEI peripheral |
frank26080115 | 0:84d7747641aa | 403 | * @param[in] QEIx QEI peripheral, should be LPC_QEI |
frank26080115 | 0:84d7747641aa | 404 | * @param[in] ulIntType Interrupt Flag Status type, should be: |
frank26080115 | 0:84d7747641aa | 405 | - QEI_INTFLAG_INX_Int: index pulse was detected interrupt |
frank26080115 | 0:84d7747641aa | 406 | - QEI_INTFLAG_TIM_Int: Velocity timer over flow interrupt |
frank26080115 | 0:84d7747641aa | 407 | - QEI_INTFLAG_VELC_Int: Capture velocity is less than compare interrupt |
frank26080115 | 0:84d7747641aa | 408 | - QEI_INTFLAG_DIR_Int: Change of direction interrupt |
frank26080115 | 0:84d7747641aa | 409 | - QEI_INTFLAG_ERR_Int: An encoder phase error interrupt |
frank26080115 | 0:84d7747641aa | 410 | - QEI_INTFLAG_ENCLK_Int: An encoder clock pulse was detected interrupt |
frank26080115 | 0:84d7747641aa | 411 | - QEI_INTFLAG_POS0_Int: position 0 compare value is equal to the |
frank26080115 | 0:84d7747641aa | 412 | current position interrupt |
frank26080115 | 0:84d7747641aa | 413 | - QEI_INTFLAG_POS1_Int: position 1 compare value is equal to the |
frank26080115 | 0:84d7747641aa | 414 | current position interrupt |
frank26080115 | 0:84d7747641aa | 415 | - QEI_INTFLAG_POS2_Int: position 2 compare value is equal to the |
frank26080115 | 0:84d7747641aa | 416 | current position interrupt |
frank26080115 | 0:84d7747641aa | 417 | - QEI_INTFLAG_REV_Int: Index compare value is equal to the current |
frank26080115 | 0:84d7747641aa | 418 | index count interrupt |
frank26080115 | 0:84d7747641aa | 419 | - QEI_INTFLAG_POS0REV_Int: Combined position 0 and revolution count interrupt |
frank26080115 | 0:84d7747641aa | 420 | - QEI_INTFLAG_POS1REV_Int: Combined position 1 and revolution count interrupt |
frank26080115 | 0:84d7747641aa | 421 | - QEI_INTFLAG_POS2REV_Int: Combined position 2 and revolution count interrupt |
frank26080115 | 0:84d7747641aa | 422 | * @return None |
frank26080115 | 0:84d7747641aa | 423 | **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 424 | void QEI_IntSet(LPC_QEI_TypeDef *QEIx, uint32_t ulIntType) |
frank26080115 | 0:84d7747641aa | 425 | { |
frank26080115 | 0:84d7747641aa | 426 | CHECK_PARAM(PARAM_QEIx(QEIx)); |
frank26080115 | 0:84d7747641aa | 427 | CHECK_PARAM(PARAM_QEI_INTFLAG(ulIntType)); |
frank26080115 | 0:84d7747641aa | 428 | |
frank26080115 | 0:84d7747641aa | 429 | QEIx->QEISET = ulIntType; |
frank26080115 | 0:84d7747641aa | 430 | } |
frank26080115 | 0:84d7747641aa | 431 | |
frank26080115 | 0:84d7747641aa | 432 | /*********************************************************************//** |
frank26080115 | 0:84d7747641aa | 433 | * @brief Clear (force) specified interrupt (pending) in QEI peripheral |
frank26080115 | 0:84d7747641aa | 434 | * @param[in] QEIx QEI peripheral, should be LPC_QEI |
frank26080115 | 0:84d7747641aa | 435 | * @param[in] ulIntType Interrupt Flag Status type, should be: |
frank26080115 | 0:84d7747641aa | 436 | - QEI_INTFLAG_INX_Int: index pulse was detected interrupt |
frank26080115 | 0:84d7747641aa | 437 | - QEI_INTFLAG_TIM_Int: Velocity timer over flow interrupt |
frank26080115 | 0:84d7747641aa | 438 | - QEI_INTFLAG_VELC_Int: Capture velocity is less than compare interrupt |
frank26080115 | 0:84d7747641aa | 439 | - QEI_INTFLAG_DIR_Int: Change of direction interrupt |
frank26080115 | 0:84d7747641aa | 440 | - QEI_INTFLAG_ERR_Int: An encoder phase error interrupt |
frank26080115 | 0:84d7747641aa | 441 | - QEI_INTFLAG_ENCLK_Int: An encoder clock pulse was detected interrupt |
frank26080115 | 0:84d7747641aa | 442 | - QEI_INTFLAG_POS0_Int: position 0 compare value is equal to the |
frank26080115 | 0:84d7747641aa | 443 | current position interrupt |
frank26080115 | 0:84d7747641aa | 444 | - QEI_INTFLAG_POS1_Int: position 1 compare value is equal to the |
frank26080115 | 0:84d7747641aa | 445 | current position interrupt |
frank26080115 | 0:84d7747641aa | 446 | - QEI_INTFLAG_POS2_Int: position 2 compare value is equal to the |
frank26080115 | 0:84d7747641aa | 447 | current position interrupt |
frank26080115 | 0:84d7747641aa | 448 | - QEI_INTFLAG_REV_Int: Index compare value is equal to the current |
frank26080115 | 0:84d7747641aa | 449 | index count interrupt |
frank26080115 | 0:84d7747641aa | 450 | - QEI_INTFLAG_POS0REV_Int: Combined position 0 and revolution count interrupt |
frank26080115 | 0:84d7747641aa | 451 | - QEI_INTFLAG_POS1REV_Int: Combined position 1 and revolution count interrupt |
frank26080115 | 0:84d7747641aa | 452 | - QEI_INTFLAG_POS2REV_Int: Combined position 2 and revolution count interrupt |
frank26080115 | 0:84d7747641aa | 453 | * @return None |
frank26080115 | 0:84d7747641aa | 454 | **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 455 | void QEI_IntClear(LPC_QEI_TypeDef *QEIx, uint32_t ulIntType) |
frank26080115 | 0:84d7747641aa | 456 | { |
frank26080115 | 0:84d7747641aa | 457 | CHECK_PARAM(PARAM_QEIx(QEIx)); |
frank26080115 | 0:84d7747641aa | 458 | CHECK_PARAM(PARAM_QEI_INTFLAG(ulIntType)); |
frank26080115 | 0:84d7747641aa | 459 | |
frank26080115 | 0:84d7747641aa | 460 | QEIx->QEICLR = ulIntType; |
frank26080115 | 0:84d7747641aa | 461 | } |
frank26080115 | 0:84d7747641aa | 462 | |
frank26080115 | 0:84d7747641aa | 463 | |
frank26080115 | 0:84d7747641aa | 464 | /*********************************************************************//** |
frank26080115 | 0:84d7747641aa | 465 | * @brief Calculates the actual velocity in RPM passed via velocity |
frank26080115 | 0:84d7747641aa | 466 | * capture value and Pulse Per Round (of the encoder) value |
frank26080115 | 0:84d7747641aa | 467 | * parameter input. |
frank26080115 | 0:84d7747641aa | 468 | * @param[in] QEIx QEI peripheral, should be LPC_QEI |
frank26080115 | 0:84d7747641aa | 469 | * @param[in] ulVelCapValue Velocity capture input value that can |
frank26080115 | 0:84d7747641aa | 470 | * be got from QEI_GetVelocityCap() function |
frank26080115 | 0:84d7747641aa | 471 | * @param[in] ulPPR Pulse per round of encoder |
frank26080115 | 0:84d7747641aa | 472 | * @return The actual value of velocity in RPM (Round per minute) |
frank26080115 | 0:84d7747641aa | 473 | **********************************************************************/ |
frank26080115 | 0:84d7747641aa | 474 | uint32_t QEI_CalculateRPM(LPC_QEI_TypeDef *QEIx, uint32_t ulVelCapValue, uint32_t ulPPR) |
frank26080115 | 0:84d7747641aa | 475 | { |
frank26080115 | 0:84d7747641aa | 476 | uint64_t rpm, clock, Load, edges; |
frank26080115 | 0:84d7747641aa | 477 | |
frank26080115 | 0:84d7747641aa | 478 | // Get current Clock rate for timer input |
frank26080115 | 0:84d7747641aa | 479 | clock = (uint64_t)CLKPWR_GetPCLK(CLKPWR_PCLKSEL_QEI); |
frank26080115 | 0:84d7747641aa | 480 | // Get Timer load value (velocity capture period) |
frank26080115 | 0:84d7747641aa | 481 | Load = (uint64_t)(QEIx->QEILOAD + 1); |
frank26080115 | 0:84d7747641aa | 482 | // Get Edge |
frank26080115 | 0:84d7747641aa | 483 | edges = (uint64_t)((QEIx->QEICONF & QEI_CONF_CAPMODE) ? 4 : 2); |
frank26080115 | 0:84d7747641aa | 484 | // Calculate RPM |
frank26080115 | 0:84d7747641aa | 485 | rpm = ((clock * ulVelCapValue * 60) / (Load * ulPPR * edges)); |
frank26080115 | 0:84d7747641aa | 486 | |
frank26080115 | 0:84d7747641aa | 487 | return (uint32_t)(rpm); |
frank26080115 | 0:84d7747641aa | 488 | } |
frank26080115 | 0:84d7747641aa | 489 | |
frank26080115 | 0:84d7747641aa | 490 | |
frank26080115 | 0:84d7747641aa | 491 | /** |
frank26080115 | 0:84d7747641aa | 492 | * @} |
frank26080115 | 0:84d7747641aa | 493 | */ |
frank26080115 | 0:84d7747641aa | 494 | |
frank26080115 | 0:84d7747641aa | 495 | #endif /* _QEI */ |
frank26080115 | 0:84d7747641aa | 496 | |
frank26080115 | 0:84d7747641aa | 497 | /** |
frank26080115 | 0:84d7747641aa | 498 | * @} |
frank26080115 | 0:84d7747641aa | 499 | */ |
frank26080115 | 0:84d7747641aa | 500 | |
frank26080115 | 0:84d7747641aa | 501 | /* --------------------------------- End Of File ------------------------------ */ |
frank26080115 | 0:84d7747641aa | 502 |