stm32f10x_it.c 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. /**
  2. ******************************************************************************
  3. * @file Project/STM32F10x_StdPeriph_Template/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. /* Includes ------------------------------------------------------------------*/
  24. #include "main.h"
  25. #include "YX5200/YX5200_main.h"
  26. #include "YX5200/YX5200_uart.h"
  27. #include "wifi9113.h"
  28. /** @addtogroup STM32F10x_StdPeriph_Template
  29. * @{
  30. */
  31. /* Private typedef -----------------------------------------------------------*/
  32. /* Private define ------------------------------------------------------------*/
  33. /* Private macro -------------------------------------------------------------*/
  34. /* Private variables ---------------------------------------------------------*/
  35. /* Private function prototypes -----------------------------------------------*/
  36. /* Private functions ---------------------------------------------------------*/
  37. /******************************************************************************/
  38. /* Cortex-M3 Processor Exceptions Handlers */
  39. /******************************************************************************/
  40. /**
  41. * @brief This function handles NMI exception.
  42. * @param None
  43. * @retval None
  44. */
  45. void NMI_Handler ( void )
  46. {
  47. }
  48. /**
  49. * @brief This function handles Hard Fault exception.
  50. * @param None
  51. * @retval None
  52. */
  53. void HardFault_Handler ( void )
  54. {
  55. /* Go to infinite loop when Hard Fault exception occurs */
  56. while ( 1 )
  57. {
  58. }
  59. }
  60. /**
  61. * @brief This function handles Memory Manage exception.
  62. * @param None
  63. * @retval None
  64. */
  65. void MemManage_Handler ( void )
  66. {
  67. /* Go to infinite loop when Memory Manage exception occurs */
  68. while ( 1 )
  69. {
  70. }
  71. }
  72. /**
  73. * @brief This function handles Bus Fault exception.
  74. * @param None
  75. * @retval None
  76. */
  77. void BusFault_Handler ( void )
  78. {
  79. /* Go to infinite loop when Bus Fault exception occurs */
  80. while ( 1 )
  81. {
  82. }
  83. }
  84. /**
  85. * @brief This function handles Usage Fault exception.
  86. * @param None
  87. * @retval None
  88. */
  89. void UsageFault_Handler ( void )
  90. {
  91. /* Go to infinite loop when Usage Fault exception occurs */
  92. while ( 1 )
  93. {
  94. }
  95. }
  96. /**
  97. * @brief This function handles SVCall exception.
  98. * @param None
  99. * @retval None
  100. */
  101. void SVC_Handler ( void )
  102. {
  103. }
  104. /**
  105. * @brief This function handles Debug Monitor exception.
  106. * @param None
  107. * @retval None
  108. */
  109. void DebugMon_Handler ( void )
  110. {
  111. }
  112. /**
  113. * @brief This function handles PendSVC exception.
  114. * @param None
  115. * @retval None
  116. */
  117. void PendSV_Handler ( void )
  118. {
  119. }
  120. /**
  121. * @brief This function handles SysTick Handler.
  122. * @param None
  123. * @retval None
  124. */
  125. bool if_wifi_msg_come = false;
  126. u32 sys_ms = 0;
  127. u32 sys_rtc_time = 0;
  128. int TaskTime = 0;
  129. void SysTick_Handler ( void )
  130. {
  131. sys_ms++;
  132. if ( 0 == ( sys_ms % 1000 ) )
  133. {
  134. sys_rtc_time++;
  135. }
  136. TaskTime++;
  137. if ( TaskTime % 2 == 0 ) System_Flag_2Ms = 1;
  138. if ( TaskTime % 10 == 0 ) System_Flag_10Ms = 1;
  139. if ( TaskTime % 100 == 0 ) System_Flag_100Ms = 1;
  140. if ( TaskTime % 200 == 0 ) System_Flag_200Ms = 1;
  141. if ( TaskTime % 500 == 0 ) System_Flag_500Ms = 1;
  142. if ( TaskTime % 1000 == 0 ) System_Flag_1s = 1;
  143. if ( TaskTime % 8000 == 0 ) System_Flag_8s = 1;
  144. if ( TaskTime % 20000 == 0 ) System_Flag_20s = 1;
  145. WifiTimeReset++;
  146. WifiTimeLed++;
  147. if ( UartRecvACKFlag )
  148. {
  149. if ( UartRecvACK )
  150. UartRecvACK--;
  151. }
  152. }
  153. /******************************************************************************/
  154. /* STM32F10x Peripherals Interrupt Handlers */
  155. /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */
  156. /* available peripheral interrupt handler's name please refer to the startup */
  157. /* file (startup_stm32f10x_xx.s). */
  158. /******************************************************************************/
  159. /**
  160. * @brief This function handles PPP interrupt request.
  161. * @param None
  162. * @retval None
  163. */
  164. /*void PPP_IRQHandler(void)
  165. {
  166. }*/
  167. /**
  168. * @}
  169. */
  170. /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
  171. void USART1_IRQHandler ( void )
  172. {
  173. if ( USART_GetITStatus ( Wifi_UART, USART_IT_RXNE ) != RESET )
  174. {
  175. /* Read one byte from the receive data register */
  176. bAtRecBuff[start] = USART_ReceiveData ( Wifi_UART );
  177. if ( start >= 2 ) //当前是\n,上个如果是\r
  178. {
  179. if ( ( bAtRecBuff[start - 1] == 0x0D ) && ( bAtRecBuff[start] == 0x0A ) ) //start字符个数
  180. {
  181. WifiHaveRecFlag = true;
  182. if_wifi_msg_come = true;
  183. }
  184. }
  185. start++;
  186. // while(USART_GetFlagStatus(USART1, USART_FLAG_RXNE) ==0);
  187. USART_ClearITPendingBit ( Wifi_UART, USART_IT_RXNE );
  188. }
  189. if ( USART_GetITStatus ( Wifi_UART, USART_IT_TXE ) != RESET )
  190. {
  191. /* Write one byte to the transmit data register */
  192. USART_SendData ( Wifi_UART, bAtSentBuff[TxCounterWifi++] );
  193. if ( TxCounterWifi >= WifiDataToXmt )
  194. {
  195. /* Disable the USARTy Transmit interrupt */
  196. USART_ITConfig ( Wifi_UART, USART_IT_TXE, DISABLE );
  197. //USART_ITConfig(Wifi_UART, USART_IT_RXNE, ENABLE); //发送完,开接收中断
  198. }
  199. }
  200. }
  201. void USART2_IRQHandler ( void )
  202. {
  203. if ( USART_GetITStatus ( YX5200_UART, USART_IT_RXNE ) != RESET )
  204. {
  205. RxBufferUart2[RxCounterUart2] = USART_ReceiveData ( YX5200_UART );
  206. if ( RxCounterUart2 >= YX5200_MSGLEN ) //当前是\n,上个如果是\r
  207. {
  208. if ( ( RxBufferUart2[RxCounterUart2 - ( YX5200_MSGLEN - 1 )] == 0x7E ) && \
  209. ( RxBufferUart2[RxCounterUart2] == 0xEF ) )
  210. {
  211. YX5200HaveRecFlag = true;
  212. memcpy ( Recv_buf, & ( RxBufferUart2[RxCounterUart2 - ( YX5200_MSGLEN - 1 )] ), YX5200_MSGLEN );
  213. }
  214. }
  215. RxCounterUart2++;
  216. USART_ClearITPendingBit ( YX5200_UART, USART_IT_RXNE );
  217. }
  218. if ( USART_GetITStatus ( YX5200_UART, USART_IT_TXE ) != RESET )
  219. {
  220. USART_SendData ( YX5200_UART, TxBufferUart2[TxCounterUart2++] );
  221. if ( TxCounterUart2 >= Uart2SendCount )
  222. {
  223. USART_ITConfig ( YX5200_UART, USART_IT_TXE, DISABLE );
  224. }
  225. }
  226. }
  227. //SPI1使用DMA收数据中断服务程序
  228. //SPI1使用DMA发数据中断服务程序
  229. //SPI2使用DMA收数据中断服务程序
  230. //SPI2使用DMA发数据中断服务程序
  231. u32 T1_Val = 0;
  232. void TIM2_IRQHandler(void)
  233. {
  234. if(TIM_GetITStatus(TIM2,TIM_IT_Update)!=RESET)//检查溢出信号
  235. {
  236. TIM_ClearITPendingBit(TIM2,TIM_IT_Update);//清除溢出标志
  237. //Time2us++;
  238. T1_Val++;
  239. }
  240. }
  241. /**
  242. * @brief This function handles SPI3 global interrupt request.
  243. * @param None
  244. * @retval None
  245. */
  246. /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/