stm32f10x_it.c 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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=%d",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=%d",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=%d",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=%d",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 UART1RxTxISRHandler(void)
  133. //{
  134. // __IO unsigned long temp;
  135. // __IO unsigned char uart_data;
  136. // if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET){
  137. // uart_data=USART_ReceiveData(USART1);
  138. // USART_SendData(USART1,uart_data);
  139. //
  140. // }
  141. // if(USART_GetFlagStatus(USART1,USART_FLAG_ORE)==SET)
  142. // {
  143. // assert_param(IS_USART_CLEAR_FLAG(USART_FLAG_ORE));
  144. // USART_ReceiveData(USART1); //
  145. // USART_ClearFlag(USART1,USART_FLAG_ORE); //
  146. // }
  147. //}
  148. /*******************************************************************************
  149. * Function Name : USART1_IRQHandler
  150. * Description : This function handles USART1 global interrupt request.
  151. * Input : None
  152. * Output : None
  153. * Return : None
  154. *******************************************************************************/
  155. void USART1_IRQHandler(void)
  156. {
  157. UART1RxTxISRHandler();
  158. }
  159. /*******************************************************************************
  160. * Function Name : USART2_IRQHandler
  161. * Description : This function handles USART1 global interrupt request.
  162. * Input : None
  163. * Output : None
  164. * Return : None
  165. *******************************************************************************/
  166. void USART2_IRQHandler(void)
  167. {
  168. UART2RxTxISRHandler(); /* Call uC/OS-II's OSTimeTick() */
  169. }
  170. /*******************************************************************************
  171. * Function Name : USART3_IRQHandler
  172. * Description : This function handles USART1 global interrupt request.
  173. * Input : None
  174. * Output : None
  175. * Return : None
  176. *******************************************************************************/
  177. void USART3_IRQHandler(void)
  178. {
  179. UART3RxTxISRHandler();
  180. }
  181. //void DMA1_Channel7_IRQHandler(void)
  182. //{
  183. // USART2_SendOK_IQ();
  184. //}
  185. //void DMA1_Channel4_IRQHandler(void)
  186. //{
  187. // USART1_SendOK_IQ();
  188. //}
  189. /******************************************************************************/
  190. /* STM32F10x Peripherals Interrupt Handlers */
  191. /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */
  192. /* available peripheral interrupt handler's name please refer to the startup */
  193. /* file (startup_stm32f10x_xx.s). */
  194. /******************************************************************************/
  195. /**
  196. * @brief This function handles PPP interrupt request.
  197. * @param None
  198. * @retval None
  199. */
  200. /*void PPP_IRQHandler(void)
  201. {
  202. }*/
  203. /**
  204. * @}
  205. */
  206. /*******************************************************************************
  207. * Function Name : RTC_IRQHandler
  208. * Description : This function handles RTC global interrupt request.
  209. * Input : None
  210. * Output : None
  211. * Return : None
  212. *******************************************************************************/
  213. //void RTC_IRQHandler(void)
  214. //{
  215. // if (RTC_GetITStatus(RTC_IT_SEC) != RESET)
  216. // {
  217. // RTC_ClearITPendingBit(RTC_IT_SEC); //判断中断标志位是否被置位
  218. // RTC_WaitForLastTask(); //等待上一次配置完成
  219. // //如果加了下面,当关掉主机电源后,计数跑到24:00:00时会被清0,且会停止计数(没掉电是没问题的)
  220. //// if (RTC_GetCounter() > 86398) //走到23:59:59秒时清零, 86400=24*60*60
  221. //// {
  222. //// RTC_SetCounter(0x0);
  223. //// RTC_WaitForLastTask(); //等待上一次配置完成
  224. //// }
  225. // }
  226. //}
  227. void RTCAlarm_IRQHandler(void)
  228. {
  229. if (RTC_GetITStatus(RTC_IT_SEC) != RESET){
  230. RTC_ClearITPendingBit(RTC_IT_SEC);
  231. }
  232. if(RTC_GetITStatus(RTC_IT_ALR) != RESET)
  233. {
  234. SlwTrace(INF,"time coming\r\n",1);
  235. /* Set the RTC alarm flag */
  236. g_bRTCAlarm = 1;
  237. /* Clear EXTI line17 pending bit */
  238. EXTI_ClearITPendingBit(EXTI_Line17);
  239. /* Check if the Wake-Up flag is set */
  240. if(PWR_GetFlagStatus(PWR_FLAG_WU) != RESET)
  241. {
  242. /* Clear Wake Up flag */
  243. PWR_ClearFlag(PWR_FLAG_WU);
  244. }
  245. /* Wait until last write operation on RTC registers has finished */
  246. RTC_WaitForLastTask();
  247. /* Clear RTC Alarm interrupt pending bit */
  248. RTC_ClearITPendingBit(RTC_IT_ALR);
  249. /* Wait until last write operation on RTC registers has finished */
  250. RTC_WaitForLastTask();
  251. }
  252. }
  253. void PVD_IRQHandler(void)
  254. {
  255. if(EXTI_GetITStatus(EXTI_Line16)!=RESET)
  256. {
  257. printf("电量低..........\r\n");
  258. //LED1(ON);
  259. // Sleeping();
  260. SleepMethod2();
  261. }
  262. EXTI_ClearITPendingBit(EXTI_Line16); //?????????
  263. }
  264. /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/