STM32F0xx Standard Peripherals Firmware Library: stm32f0xx_it.c Source File

STM32F0xx Standard Peripherals Library

STM32F0xx_StdPeriph_Examples/TIM/TIM_InputCapture/stm32f0xx_it.c
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    TIM/TIM_InputCapture/stm32f0xx_it.c 
00004   * @author  MCD Application Team
00005   * @version V1.4.0
00006   * @date    24-July-2014
00007   * @brief   Main Interrupt Service Routines.
00008   *          This file provides template for all exceptions handler and 
00009   *          peripherals interrupt service routine.
00010   ******************************************************************************
00011   * @attention
00012   *
00013   * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
00014   *
00015   * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
00016   * You may not use this file except in compliance with the License.
00017   * You may obtain a copy of the License at:
00018   *
00019   *        http://www.st.com/software_license_agreement_liberty_v2
00020   *
00021   * Unless required by applicable law or agreed to in writing, software 
00022   * distributed under the License is distributed on an "AS IS" BASIS, 
00023   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00024   * See the License for the specific language governing permissions and
00025   * limitations under the License.
00026   *
00027   ******************************************************************************
00028   */
00029 
00030 /* Includes ------------------------------------------------------------------*/
00031 #include "stm32f0xx_it.h"
00032 
00033 /** @addtogroup STM32F0xx_StdPeriph_Examples
00034   * @{
00035   */
00036 
00037 /** @addtogroup TIM_Input_Capture
00038   * @{
00039   */
00040 
00041 /* Private typedef -----------------------------------------------------------*/
00042 /* Private define ------------------------------------------------------------*/
00043 /* Private macro -------------------------------------------------------------*/
00044 /* Private variables ---------------------------------------------------------*/
00045 uint16_t IC3ReadValue1 = 0, IC3ReadValue2 = 0;
00046 uint16_t CaptureNumber = 0;
00047 uint32_t Capture = 0;
00048 uint32_t TIM1Freq = 0;
00049 
00050 /* Private function prototypes -----------------------------------------------*/
00051 /* Private functions ---------------------------------------------------------*/
00052 
00053 /******************************************************************************/
00054 /*            Cortex-M0 Processor Exceptions Handlers                         */
00055 /******************************************************************************/
00056 
00057 /**
00058   * @brief  This function handles NMI exception.
00059   * @param  None
00060   * @retval None
00061   */
00062 void NMI_Handler(void)
00063 {
00064 }
00065 
00066 /**
00067   * @brief  This function handles Hard Fault exception.
00068   * @param  None
00069   * @retval None
00070   */
00071 void HardFault_Handler(void)
00072 {
00073   /* Go to infinite loop when Hard Fault exception occurs */
00074   while (1)
00075   {
00076   }
00077 }
00078 
00079 /**
00080   * @brief  This function handles SVCall exception.
00081   * @param  None
00082   * @retval None
00083   */
00084 void SVC_Handler(void)
00085 {
00086 }
00087 
00088 /**
00089   * @brief  This function handles PendSVC exception.
00090   * @param  None
00091   * @retval None
00092   */
00093 void PendSV_Handler(void)
00094 {
00095 }
00096 
00097 /**
00098   * @brief  This function handles SysTick Handler.
00099   * @param  None
00100   * @retval None
00101   */
00102 void SysTick_Handler(void)
00103 {
00104 }
00105 
00106 /******************************************************************************/
00107 /*                 STM32F0xx Peripherals Interrupt Handlers                   */
00108 /*  Add here the Interrupt Handler for the used peripheral(s) (PPP), for the  */
00109 /*  available peripheral interrupt handler's name please refer to the startup */
00110 /*  file (startup_stm32f0xx.s).                                               */
00111 /******************************************************************************/
00112 /**
00113   * @brief  This function handles TIM1 Capture Compare interrupt request.
00114   * @param  None
00115   * @retval None
00116   */
00117 void TIM1_CC_IRQHandler(void)
00118 { 
00119   if(TIM_GetITStatus(TIM1, TIM_IT_CC2) == SET) 
00120   {
00121     /* Clear TIM1 Capture compare interrupt pending bit */
00122     TIM_ClearITPendingBit(TIM1, TIM_IT_CC2);
00123     if(CaptureNumber == 0)
00124     {
00125       /* Get the Input Capture value */
00126       IC3ReadValue1 = TIM_GetCapture2(TIM1);
00127       CaptureNumber = 1;
00128     }
00129     else if(CaptureNumber == 1)
00130     {
00131       /* Get the Input Capture value */
00132       IC3ReadValue2 = TIM_GetCapture2(TIM1); 
00133       
00134       /* Capture computation */
00135       if (IC3ReadValue2 > IC3ReadValue1)
00136       {
00137         Capture = (IC3ReadValue2 - IC3ReadValue1); 
00138       }
00139       else if (IC3ReadValue2 < IC3ReadValue1)
00140       {
00141         Capture = ((0xFFFF - IC3ReadValue1) + IC3ReadValue2); 
00142       }
00143       else
00144       {
00145         Capture = 0;
00146       }
00147       /* Frequency computation */ 
00148       TIM1Freq = (uint32_t) SystemCoreClock / Capture;
00149       CaptureNumber = 0;
00150     }
00151   }
00152 }
00153 
00154 /**
00155   * @brief  This function handles PPP interrupt request.
00156   * @param  None
00157   * @retval None
00158   */
00159 /*void PPP_IRQHandler(void)
00160 {
00161 }*/
00162 
00163 /**
00164   * @}
00165   */
00166 
00167 /**
00168   * @}
00169   */
00170 
00171 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
STM32L1xx Standard Peripherals Library: Footer

 

 

 For complete documentation on STM32 Microcontrollers visit www.st.com/STM32