comparison libs/STM32F10x_StdPeriph_Lib_V3.5.0/Project/STM32F10x_StdPeriph_Examples/TIM/InputCapture/stm32f10x_it.c @ 0:c59513fd84fb

Initial commit of STM32 test code.
author Daniel O'Connor <darius@dons.net.au>
date Mon, 03 Oct 2011 21:19:15 +1030
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:c59513fd84fb
1 /**
2 ******************************************************************************
3 * @file TIM/InputCapture/stm32f10x_it.c
4 * @author MCD Application Team
5 * @version V3.5.0
6 * @date 08-April-2011
7 * @brief Main Interrupt Service Routines.
8 * This file provides template for all exceptions handler and
9 * peripherals interrupt service routine.
10 ******************************************************************************
11 * @attention
12 *
13 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
14 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
15 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
16 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
17 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
18 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
19 *
20 * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
21 ******************************************************************************
22 */
23
24 /* Includes ------------------------------------------------------------------*/
25 #include "stm32f10x_it.h"
26
27 /** @addtogroup STM32F10x_StdPeriph_Examples
28 * @{
29 */
30
31 /** @addtogroup TIM_Input_Capture
32 * @{
33 */
34
35 /* Private typedef -----------------------------------------------------------*/
36 /* Private define ------------------------------------------------------------*/
37 /* Private macro -------------------------------------------------------------*/
38 /* Private variables ---------------------------------------------------------*/
39 __IO uint16_t IC3ReadValue1 = 0, IC3ReadValue2 = 0;
40 __IO uint16_t CaptureNumber = 0;
41 __IO uint32_t Capture = 0;
42 __IO uint32_t TIM3Freq = 0;
43
44 /* Private function prototypes -----------------------------------------------*/
45 /* Private functions ---------------------------------------------------------*/
46
47 /******************************************************************************/
48 /* Cortex-M3 Processor Exceptions Handlers */
49 /******************************************************************************/
50
51 /**
52 * @brief This function handles NMI exception.
53 * @param None
54 * @retval None
55 */
56 void NMI_Handler(void)
57 {
58 }
59
60 /**
61 * @brief This function handles Hard Fault exception.
62 * @param None
63 * @retval None
64 */
65 void HardFault_Handler(void)
66 {
67 /* Go to infinite loop when Hard Fault exception occurs */
68 while (1)
69 {}
70 }
71
72 /**
73 * @brief This function handles Memory Manage exception.
74 * @param None
75 * @retval None
76 */
77 void MemManage_Handler(void)
78 {
79 /* Go to infinite loop when Memory Manage exception occurs */
80 while (1)
81 {}
82 }
83
84 /**
85 * @brief This function handles Bus Fault exception.
86 * @param None
87 * @retval None
88 */
89 void BusFault_Handler(void)
90 {
91 /* Go to infinite loop when Bus Fault exception occurs */
92 while (1)
93 {}
94 }
95
96 /**
97 * @brief This function handles Usage Fault exception.
98 * @param None
99 * @retval None
100 */
101 void UsageFault_Handler(void)
102 {
103 /* Go to infinite loop when Usage Fault exception occurs */
104 while (1)
105 {}
106 }
107
108 /**
109 * @brief This function handles Debug Monitor exception.
110 * @param None
111 * @retval None
112 */
113 void DebugMon_Handler(void)
114 {}
115
116 /**
117 * @brief This function handles SVCall exception.
118 * @param None
119 * @retval None
120 */
121 void SVC_Handler(void)
122 {}
123
124 /**
125 * @brief This function handles PendSV_Handler exception.
126 * @param None
127 * @retval None
128 */
129 void PendSV_Handler(void)
130 {}
131
132 /**
133 * @brief This function handles SysTick Handler.
134 * @param None
135 * @retval None
136 */
137 void SysTick_Handler(void)
138 {}
139
140 /******************************************************************************/
141 /* STM32F10x Peripherals Interrupt Handlers */
142 /******************************************************************************/
143 /**
144 * @brief This function handles TIM3 global interrupt request.
145 * @param None
146 * @retval None
147 */
148 void TIM3_IRQHandler(void)
149 {
150 if(TIM_GetITStatus(TIM3, TIM_IT_CC2) == SET)
151 {
152 /* Clear TIM3 Capture compare interrupt pending bit */
153 TIM_ClearITPendingBit(TIM3, TIM_IT_CC2);
154 if(CaptureNumber == 0)
155 {
156 /* Get the Input Capture value */
157 IC3ReadValue1 = TIM_GetCapture2(TIM3);
158 CaptureNumber = 1;
159 }
160 else if(CaptureNumber == 1)
161 {
162 /* Get the Input Capture value */
163 IC3ReadValue2 = TIM_GetCapture2(TIM3);
164
165 /* Capture computation */
166 if (IC3ReadValue2 > IC3ReadValue1)
167 {
168 Capture = (IC3ReadValue2 - IC3ReadValue1);
169 }
170 else
171 {
172 Capture = ((0xFFFF - IC3ReadValue1) + IC3ReadValue2);
173 }
174 /* Frequency computation */
175 TIM3Freq = (uint32_t) SystemCoreClock / Capture;
176 CaptureNumber = 0;
177 }
178 }
179 }
180
181 /******************************************************************************/
182 /* STM32F10x Peripherals Interrupt Handlers */
183 /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */
184 /* available peripheral interrupt handler's name please refer to the startup */
185 /* file (startup_stm32f10x_xx.s). */
186 /******************************************************************************/
187
188 /**
189 * @brief This function handles PPP interrupt request.
190 * @param None
191 * @retval None
192 */
193 /*void PPP_IRQHandler(void)
194 {
195 }*/
196
197 /**
198 * @}
199 */
200
201 /**
202 * @}
203 */
204
205 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/