PageRenderTime 59ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 0ms

/taxi_v1.2/Project/Examples/TIM/TimeBase/stm32f10x_it.c

https://github.com/ymqqqqdx/n2_taximeter
C | 213 lines | 68 code | 26 blank | 119 comment | 12 complexity | 3e8cc472e632304899e544200feb9203 MD5 | raw file
  1. /**
  2. ******************************************************************************
  3. * @file TIM/TimeBase/stm32f10x_it.c
  4. * @author MCD Application Team
  5. * @version V3.0.0
  6. * @date 04/06/2009
  7. * @brief Main Interrupt Service Routines.
  8. * This file provides template for all exceptions handler and
  9. * peripherals interrupt service routine.
  10. ******************************************************************************
  11. * @copy
  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 2009 STMicroelectronics</center></h2>
  21. */
  22. /* Includes ------------------------------------------------------------------*/
  23. #include "stm32f10x_it.h"
  24. /** @addtogroup StdPeriph_Examples
  25. * @{
  26. */
  27. /** @addtogroup TIM_TimeBase
  28. * @{
  29. */
  30. /* Private typedef -----------------------------------------------------------*/
  31. /* Private define ------------------------------------------------------------*/
  32. /* Private macro -------------------------------------------------------------*/
  33. /* Private variables ---------------------------------------------------------*/
  34. uint16_t capture = 0;
  35. extern __IO uint16_t CCR1_Val;
  36. extern __IO uint16_t CCR2_Val;
  37. extern __IO uint16_t CCR3_Val;
  38. extern __IO uint16_t CCR4_Val;
  39. /* Private function prototypes -----------------------------------------------*/
  40. /* Private functions ---------------------------------------------------------*/
  41. /******************************************************************************/
  42. /* Cortex-M3 Processor Exceptions Handlers */
  43. /******************************************************************************/
  44. /**
  45. * @brief This function handles NMI exception.
  46. * @param None
  47. * @retval : None
  48. */
  49. void NMI_Handler(void)
  50. {
  51. }
  52. /**
  53. * @brief This function handles Hard Fault exception.
  54. * @param None
  55. * @retval : None
  56. */
  57. void HardFault_Handler(void)
  58. {
  59. /* Go to infinite loop when Hard Fault exception occurs */
  60. while (1)
  61. {}
  62. }
  63. /**
  64. * @brief This function handles Memory Manage exception.
  65. * @param None
  66. * @retval : None
  67. */
  68. void MemManage_Handler(void)
  69. {
  70. /* Go to infinite loop when Memory Manage exception occurs */
  71. while (1)
  72. {}
  73. }
  74. /**
  75. * @brief This function handles Bus Fault exception.
  76. * @param None
  77. * @retval : None
  78. */
  79. void BusFault_Handler(void)
  80. {
  81. /* Go to infinite loop when Bus Fault exception occurs */
  82. while (1)
  83. {}
  84. }
  85. /**
  86. * @brief This function handles Usage Fault exception.
  87. * @param None
  88. * @retval : None
  89. */
  90. void UsageFault_Handler(void)
  91. {
  92. /* Go to infinite loop when Usage Fault exception occurs */
  93. while (1)
  94. {}
  95. }
  96. /**
  97. * @brief This function handles Debug Monitor exception.
  98. * @param None
  99. * @retval : None
  100. */
  101. void DebugMon_Handler(void)
  102. {}
  103. /**
  104. * @brief This function handles SVCall exception.
  105. * @param None
  106. * @retval : None
  107. */
  108. void SVC_Handler(void)
  109. {}
  110. /**
  111. * @brief This function handles PendSV_Handler exception.
  112. * @param None
  113. * @retval : None
  114. */
  115. void PendSV_Handler(void)
  116. {}
  117. /**
  118. * @brief This function handles SysTick Handler.
  119. * @param None
  120. * @retval : None
  121. */
  122. void SysTick_Handler(void)
  123. {}
  124. /******************************************************************************/
  125. /* STM32F10x Peripherals Interrupt Handlers */
  126. /******************************************************************************/
  127. /**
  128. * @brief This function handles TIM2 global interrupt request.
  129. * @param None
  130. * @retval : None
  131. */
  132. void TIM2_IRQHandler(void)
  133. {
  134. if (TIM_GetITStatus(TIM2, TIM_IT_CC1) != RESET)
  135. {
  136. TIM_ClearITPendingBit(TIM2, TIM_IT_CC1);
  137. /* Pin PC.06 toggling with frequency = 73.24 Hz */
  138. GPIO_WriteBit(GPIOC, GPIO_Pin_6, (BitAction)(1 - GPIO_ReadOutputDataBit(GPIOC, GPIO_Pin_6)));
  139. capture = TIM_GetCapture1(TIM2);
  140. TIM_SetCompare1(TIM2, capture + CCR1_Val);
  141. }
  142. else if (TIM_GetITStatus(TIM2, TIM_IT_CC2) != RESET)
  143. {
  144. TIM_ClearITPendingBit(TIM2, TIM_IT_CC2);
  145. /* Pin PC.07 toggling with frequency = 109.8 Hz */
  146. GPIO_WriteBit(GPIOC, GPIO_Pin_7, (BitAction)(1 - GPIO_ReadOutputDataBit(GPIOC, GPIO_Pin_7)));
  147. capture = TIM_GetCapture2(TIM2);
  148. TIM_SetCompare2(TIM2, capture + CCR2_Val);
  149. }
  150. else if (TIM_GetITStatus(TIM2, TIM_IT_CC3) != RESET)
  151. {
  152. TIM_ClearITPendingBit(TIM2, TIM_IT_CC3);
  153. /* Pin PC.08 toggling with frequency = 219.7 Hz */
  154. GPIO_WriteBit(GPIOC, GPIO_Pin_8, (BitAction)(1 - GPIO_ReadOutputDataBit(GPIOC, GPIO_Pin_8)));
  155. capture = TIM_GetCapture3(TIM2);
  156. TIM_SetCompare3(TIM2, capture + CCR3_Val);
  157. }
  158. else
  159. {
  160. TIM_ClearITPendingBit(TIM2, TIM_IT_CC4);
  161. /* Pin PC.09 toggling with frequency = 439.4 Hz */
  162. GPIO_WriteBit(GPIOC, GPIO_Pin_9, (BitAction)(1 - GPIO_ReadOutputDataBit(GPIOC, GPIO_Pin_9)));
  163. capture = TIM_GetCapture4(TIM2);
  164. TIM_SetCompare4(TIM2, capture + CCR4_Val);
  165. }
  166. }
  167. /******************************************************************************/
  168. /* STM32F10x Peripherals Interrupt Handlers */
  169. /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */
  170. /* available peripheral interrupt handler's name please refer to the startup */
  171. /* file (startup_stm32f10x_xx.s). */
  172. /******************************************************************************/
  173. /**
  174. * @brief This function handles PPP interrupt request.
  175. * @param None
  176. * @retval : None
  177. */
  178. /*void PPP_IRQHandler(void)
  179. {
  180. }*/
  181. /**
  182. * @}
  183. */
  184. /**
  185. * @}
  186. */
  187. /******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/