stm32f10x_it.c 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. /**
  2. ******************************************************************************
  3. * @file Project/STM32F10x_StdPeriph_Template/stm32f10x_it.c
  4. * @author MCD Application Team
  5. * @version V3.4.0
  6. * @date 10/15/2010
  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 2010 STMicroelectronics</center></h2>
  21. */
  22. /* Includes ------------------------------------------------------------------*/
  23. #include <includes.h>
  24. /* Private typedef -----------------------------------------------------------*/
  25. /* Private define ------------------------------------------------------------*/
  26. /* Private macro -------------------------------------------------------------*/
  27. /* Private variables ---------------------------------------------------------*/
  28. /* Private function prototypes -----------------------------------------------*/
  29. /* Private functions ---------------------------------------------------------*/
  30. /******************************************************************************/
  31. /* Cortex-M3 Processor Exceptions Handlers */
  32. /******************************************************************************/
  33. /**
  34. * @brief This function handles NMI exception.
  35. * @param None
  36. * @retval None
  37. */
  38. void NMI_Handler(void)
  39. {
  40. }
  41. /**
  42. * @brief This function handles Hard Fault exception.
  43. * @param None
  44. * @retval None
  45. */
  46. void HardFault_Handler(void)
  47. {
  48. /* Go to infinite loop when Hard Fault exception occurs */
  49. #ifdef USE_RUNNING_MAKE
  50. printf("\r\n[HFH]F=%d,L=%lu",g_usFileID,g_ulFileLine);
  51. #endif
  52. while (1)
  53. {
  54. }
  55. }
  56. /**
  57. * @brief This function handles Memory Manage exception.
  58. * @param None
  59. * @retval None
  60. */
  61. void MemManage_Handler(void)
  62. {
  63. /* Go to infinite loop when Memory Manage exception occurs */
  64. #ifdef USE_RUNNING_MAKE
  65. printf("\r\n[MMH]F=%d,L=%lu",g_usFileID,g_ulFileLine);
  66. #endif
  67. while (1)
  68. {
  69. }
  70. }
  71. /**
  72. * @brief This function handles Bus Fault exception.
  73. * @param None
  74. * @retval None
  75. */
  76. void BusFault_Handler(void)
  77. {
  78. /* Go to infinite loop when Bus Fault exception occurs */
  79. #ifdef USE_RUNNING_MAKE
  80. printf("\r\n[BFH]F=%d,L=%lu",g_usFileID,g_ulFileLine);
  81. #endif
  82. while (1)
  83. {
  84. }
  85. }
  86. /**
  87. * @brief This function handles Usage Fault exception.
  88. * @param None
  89. * @retval None
  90. */
  91. void UsageFault_Handler(void)
  92. {
  93. /* Go to infinite loop when Usage Fault exception occurs */
  94. #ifdef USE_RUNNING_MAKE
  95. printf("\r\n[UFH]F=%d,L=%lu",g_usFileID,g_ulFileLine);
  96. #endif
  97. while (1)
  98. {
  99. }
  100. }
  101. /**
  102. * @brief This function handles SVCall exception.
  103. * @param None
  104. * @retval None
  105. */
  106. //void SVC_Handler(void)
  107. //{
  108. //}
  109. /**
  110. * @brief This function handles Debug Monitor exception.
  111. * @param None
  112. * @retval None
  113. */
  114. void DebugMon_Handler(void)
  115. {
  116. }
  117. /**
  118. * @brief This function handles SysTick Handler.
  119. * @param None
  120. * @retval None
  121. */
  122. //static int siSecCt=0;
  123. //void SysTick_Handler(void)
  124. //{
  125. // //sutSysMsg.Tick10ms=1;
  126. // if(++siSecCt>=50){
  127. // siSecCt=0;
  128. // //sutSysMsg.Tick500ms=1;
  129. // }
  130. //
  131. //}
  132. //void TIM2_IRQHandler(void)
  133. //{
  134. // if (TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET)
  135. // {
  136. // /* Clear TIM2 Capture Compare1 interrupt pending bit*/
  137. // TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
  138. // //每ms加1
  139. // g_ulSysTick++;
  140. // }
  141. // }
  142. /*******************************************************************************
  143. * Function Name : USART1_IRQHandler
  144. * Description : This function handles USART1 global interrupt request.
  145. * Input : None
  146. * Output : None
  147. * Return : None
  148. *******************************************************************************/
  149. void USART1_IRQHandler(void)
  150. {
  151. RS485_DIR_LOW;
  152. UART1RxTxISRHandler();
  153. }
  154. /*******************************************************************************
  155. * Function Name : USART2_IRQHandler
  156. * Description : This function handles USART2 global interrupt request.
  157. * Input : None
  158. * Output : None
  159. * Return : None
  160. *******************************************************************************/
  161. void USART2_IRQHandler(void)
  162. {
  163. UART2RxTxISRHandler();
  164. }
  165. /*******************************************************************************
  166. * Function Name : USART3_IRQHandler
  167. * Description : This function handles USART1 global interrupt request.
  168. * Input : None
  169. * Output : None
  170. * Return : None
  171. *******************************************************************************/
  172. void USART3_IRQHandler(void)
  173. {
  174. UART3RxTxISRHandler();
  175. }
  176. void DMA1_Channel2_IRQHandler(void)
  177. {
  178. //USART3_SendOK_IQ();
  179. }
  180. void DMA1_Channel4_IRQHandler(void)
  181. {
  182. USART1_SendOK_IQ();
  183. }
  184. //unsigned char g_ucRX_START=0;
  185. //unsigned char g_ucRX_STOP=0;
  186. //char RecvBuf[1024];
  187. //int RecvBufCt=0;
  188. /*
  189. 用于RTC计算 50ms调用一次,1秒=20次
  190. */
  191. void TIM2_IRQHandler(void)
  192. {
  193. //__IO static unsigned char ct=0;
  194. if(TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET){
  195. TIM_ClearITPendingBit(TIM2,TIM_FLAG_Update);
  196. // if(++ct>19){
  197. // ct=0;
  198. // RTCIncSecond();
  199. // }
  200. }
  201. }
  202. void TIM3_IRQHandler(void)
  203. {
  204. // if(TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET){
  205. // g_ucRecvStat++;
  206. // if(g_ucRecvStat == COM_STOP_BIT){
  207. // TIM_Cmd(TIM3, DISABLE);
  208. // TIM_ClearITPendingBit(TIM3,TIM_FLAG_Update);
  209. // RecvBuf[RecvBufCt]=g_ucRecvData;
  210. // RecvBufCt++;
  211. // g_ucRX_STOP=1;
  212. // TIM_Cmd(TIM4,ENABLE);
  213. // return;
  214. // }
  215. // if(COM_RX_STAT){ //'1'
  216. // g_ucRecvData |= (1 << (g_ucRecvStat - 1));
  217. // }
  218. // else{ //'0'
  219. // g_ucRecvData &= ~(1 <<(g_ucRecvStat - 1));
  220. // }
  221. // TIM_ClearITPendingBit(TIM3,TIM_FLAG_Update);
  222. // }
  223. }
  224. void TIM4_IRQHandler(void)
  225. {
  226. // if(TIM_GetITStatus(TIM4, TIM_IT_Update) != RESET){
  227. // if(g_ucRX_START==1 && g_ucRX_STOP==1){
  228. // g_ucRX_START=0;
  229. // g_ucRX_STOP=0;
  230. //// printf("%s\r\n",RecvBuf);//此处RecvBuf已接收完整,可以取出
  231. // RecvBufCt=0;
  232. // memset(RecvBuf,0,sizeof(RecvBuf));
  233. // TIM_Cmd(TIM4,DISABLE);
  234. // }
  235. // TIM_ClearITPendingBit(TIM4,TIM_FLAG_Update);
  236. // }
  237. }
  238. void EXTI15_10_IRQHandler(void)
  239. {
  240. // if(EXTI_GetITStatus(EXTI_Line13)!=RESET)
  241. // {
  242. // if(!COM_RX_STAT)
  243. // {
  244. // if(g_ucRecvStat == COM_STOP_BIT)
  245. // {
  246. // g_ucRecvStat = COM_START_BIT;
  247. // COM_RX_Start_Delay(g_iCOMRXDelayCt);
  248. // TIM_Cmd(TIM3, ENABLE);
  249. // g_ucRX_START=1;
  250. // g_ucRX_STOP=0;
  251. // TIM_Cmd(TIM4,DISABLE);
  252. // }
  253. // }
  254. // EXTI_ClearITPendingBit(EXTI_Line13);
  255. // }
  256. }
  257. /******************************************************************************/
  258. /* STM32F10x Peripherals Interrupt Handlers */
  259. /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */
  260. /* available peripheral interrupt handler's name please refer to the startup */
  261. /* file (startup_stm32f10x_xx.s). */
  262. /******************************************************************************/
  263. /**
  264. * @brief This function handles PPP interrupt request.
  265. * @param None
  266. * @retval None
  267. */
  268. /*void PPP_IRQHandler(void)
  269. {
  270. }*/
  271. /**
  272. * @}
  273. */
  274. /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/