stm32f10x_it.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  1. /******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
  2. * File Name : stm32f10x_it.c
  3. * Author : MCD Application Team
  4. * Version : V1.1.2
  5. * Date : 09/22/2008
  6. * Description : Main Interrupt Service Routines.
  7. * This file provides template for all exceptions handler
  8. * and peripherals interrupt service routine.
  9. ********************************************************************************
  10. * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  11. * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
  12. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
  13. * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
  14. * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
  15. * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  16. *******************************************************************************/
  17. /* Includes ------------------------------------------------------------------*/
  18. #include <rtthread.h>
  19. #include <serial.h>
  20. #include "board.h"
  21. /* Private typedef -----------------------------------------------------------*/
  22. /* Private define ------------------------------------------------------------*/
  23. /* Private macro -------------------------------------------------------------*/
  24. /* Private variables ---------------------------------------------------------*/
  25. /* Private function prototypes -----------------------------------------------*/
  26. /* Private functions ---------------------------------------------------------*/
  27. extern void rt_hw_timer_handler(void);
  28. extern void rt_hw_interrupt_thread_switch(void);
  29. /*******************************************************************************
  30. * Function Name : NMIException
  31. * Description : This function handles NMI exception.
  32. * Input : None
  33. * Output : None
  34. * Return : None
  35. *******************************************************************************/
  36. void NMIException(void)
  37. {
  38. }
  39. /*******************************************************************************
  40. * Function Name : HardFaultException
  41. * Description : This function handles Hard Fault exception.
  42. * Input : None
  43. * Output : None
  44. * Return : None
  45. *******************************************************************************/
  46. void HardFaultException(void)
  47. {
  48. /* Go to infinite loop when Hard Fault exception occurs */
  49. rt_kprintf("hard fault exception\n");
  50. while (1)
  51. {
  52. }
  53. }
  54. /*******************************************************************************
  55. * Function Name : MemManageException
  56. * Description : This function handles Memory Manage exception.
  57. * Input : None
  58. * Output : None
  59. * Return : None
  60. *******************************************************************************/
  61. void MemManageException(void)
  62. {
  63. /* Go to infinite loop when Memory Manage exception occurs */
  64. rt_kprintf("memory manage exception\n");
  65. while (1)
  66. {
  67. }
  68. }
  69. /*******************************************************************************
  70. * Function Name : BusFaultException
  71. * Description : This function handles Bus Fault exception.
  72. * Input : None
  73. * Output : None
  74. * Return : None
  75. *******************************************************************************/
  76. void BusFaultException(void)
  77. {
  78. /* Go to infinite loop when Bus Fault exception occurs */
  79. rt_kprintf("bus fault exception\n");
  80. while (1)
  81. {
  82. }
  83. }
  84. /*******************************************************************************
  85. * Function Name : UsageFaultException
  86. * Description : This function handles Usage Fault exception.
  87. * Input : None
  88. * Output : None
  89. * Return : None
  90. *******************************************************************************/
  91. void UsageFaultException(void)
  92. {
  93. /* Go to infinite loop when Usage Fault exception occurs */
  94. rt_kprintf("usage fault exception\n");
  95. while (1)
  96. {
  97. }
  98. }
  99. /*******************************************************************************
  100. * Function Name : DebugMonitor
  101. * Description : This function handles Debug Monitor exception.
  102. * Input : None
  103. * Output : None
  104. * Return : None
  105. *******************************************************************************/
  106. void DebugMonitor(void)
  107. {
  108. }
  109. /*******************************************************************************
  110. * Function Name : SVCHandler
  111. * Description : This function handles SVCall exception.
  112. * Input : None
  113. * Output : None
  114. * Return : None
  115. *******************************************************************************/
  116. void SVCHandler(void)
  117. {
  118. }
  119. /*******************************************************************************
  120. * Function Name : SysTickHandler
  121. * Description : This function handles SysTick Handler.
  122. * Input : None
  123. * Output : None
  124. * Return : None
  125. *******************************************************************************/
  126. void SysTickHandler(void)
  127. {
  128. /* handle os tick */
  129. rt_hw_timer_handler();
  130. }
  131. /*******************************************************************************
  132. * Function Name : WWDG_IRQHandler
  133. * Description : This function handles WWDG interrupt request.
  134. * Input : None
  135. * Output : None
  136. * Return : None
  137. *******************************************************************************/
  138. void WWDG_IRQHandler(void)
  139. {
  140. }
  141. /*******************************************************************************
  142. * Function Name : PVD_IRQHandler
  143. * Description : This function handles PVD interrupt request.
  144. * Input : None
  145. * Output : None
  146. * Return : None
  147. *******************************************************************************/
  148. void PVD_IRQHandler(void)
  149. {
  150. }
  151. /*******************************************************************************
  152. * Function Name : TAMPER_IRQHandler
  153. * Description : This function handles Tamper interrupt request.
  154. * Input : None
  155. * Output : None
  156. * Return : None
  157. *******************************************************************************/
  158. void TAMPER_IRQHandler(void)
  159. {
  160. }
  161. /*******************************************************************************
  162. * Function Name : RTC_IRQHandler
  163. * Description : This function handles RTC global interrupt request.
  164. * Input : None
  165. * Output : None
  166. * Return : None
  167. *******************************************************************************/
  168. void RTC_IRQHandler(void)
  169. {
  170. if (RTC_GetITStatus(RTC_IT_SEC) != RESET)
  171. {
  172. /* Clear the RTC Second interrupt */
  173. RTC_ClearITPendingBit(RTC_IT_SEC);
  174. /* Wait until last write operation on RTC registers has finished */
  175. RTC_WaitForLastTask();
  176. /* Reset RTC Counter when Time is 23:59:59 */
  177. if (RTC_GetCounter() == 0x00015180)
  178. {
  179. RTC_SetCounter(0x0);
  180. /* Wait until last write operation on RTC registers has finished */
  181. RTC_WaitForLastTask();
  182. }
  183. }
  184. }
  185. /*******************************************************************************
  186. * Function Name : FLASH_IRQHandler
  187. * Description : This function handles Flash interrupt request.
  188. * Input : None
  189. * Output : None
  190. * Return : None
  191. *******************************************************************************/
  192. void FLASH_IRQHandler(void)
  193. {
  194. }
  195. /*******************************************************************************
  196. * Function Name : RCC_IRQHandler
  197. * Description : This function handles RCC interrupt request.
  198. * Input : None
  199. * Output : None
  200. * Return : None
  201. *******************************************************************************/
  202. void RCC_IRQHandler(void)
  203. {
  204. }
  205. /*******************************************************************************
  206. * Function Name : EXTI0_IRQHandler
  207. * Description : This function handles External interrupt Line 0 request.
  208. * Input : None
  209. * Output : None
  210. * Return : None
  211. *******************************************************************************/
  212. void EXTI0_IRQHandler(void)
  213. {
  214. }
  215. /*******************************************************************************
  216. * Function Name : EXTI1_IRQHandler
  217. * Description : This function handles External interrupt Line 1 request.
  218. * Input : None
  219. * Output : None
  220. * Return : None
  221. *******************************************************************************/
  222. void EXTI1_IRQHandler(void)
  223. {
  224. }
  225. /*******************************************************************************
  226. * Function Name : EXTI2_IRQHandler
  227. * Description : This function handles External interrupt Line 2 request.
  228. * Input : None
  229. * Output : None
  230. * Return : None
  231. *******************************************************************************/
  232. void EXTI2_IRQHandler(void)
  233. {
  234. }
  235. /*******************************************************************************
  236. * Function Name : EXTI3_IRQHandler
  237. * Description : This function handles External interrupt Line 3 request.
  238. * Input : None
  239. * Output : None
  240. * Return : None
  241. *******************************************************************************/
  242. void EXTI3_IRQHandler(void)
  243. {
  244. }
  245. /*******************************************************************************
  246. * Function Name : EXTI4_IRQHandler
  247. * Description : This function handles External interrupt Line 4 request.
  248. * Input : None
  249. * Output : None
  250. * Return : None
  251. *******************************************************************************/
  252. void EXTI4_IRQHandler(void)
  253. {
  254. #ifdef RT_USING_LWIP
  255. extern void rt_dm9000_isr(void);
  256. /* enter interrupt */
  257. rt_interrupt_enter();
  258. rt_dm9000_isr();
  259. /* Clear the Key Button EXTI line pending bit */
  260. EXTI_ClearITPendingBit(EXTI_Line4);
  261. /* leave interrupt */
  262. rt_interrupt_leave();
  263. rt_hw_interrupt_thread_switch();
  264. #endif
  265. }
  266. /*******************************************************************************
  267. * Function Name : DMA1_Channel1_IRQHandler
  268. * Description : This function handles DMA1 Channel 1 interrupt request.
  269. * Input : None
  270. * Output : None
  271. * Return : None
  272. *******************************************************************************/
  273. void DMA1_Channel1_IRQHandler(void)
  274. {
  275. }
  276. /*******************************************************************************
  277. * Function Name : DMA1_Channel2_IRQHandler
  278. * Description : This function handles DMA1 Channel 2 interrupt request.
  279. * Input : None
  280. * Output : None
  281. * Return : None
  282. *******************************************************************************/
  283. void DMA1_Channel2_IRQHandler(void)
  284. {
  285. #ifdef RT_USING_UART3
  286. extern struct rt_device uart3_device;
  287. /* enter interrupt */
  288. rt_interrupt_enter();
  289. if (DMA_GetITStatus(DMA1_IT_TC2))
  290. {
  291. /* transmission complete, invoke serial dma tx isr */
  292. rt_hw_serial_dma_tx_isr(&uart3_device);
  293. }
  294. /* clear DMA flag */
  295. DMA_ClearFlag(DMA1_FLAG_TC2 | DMA1_FLAG_TE2);
  296. /* leave interrupt */
  297. rt_interrupt_leave();
  298. rt_hw_interrupt_thread_switch();
  299. #endif
  300. }
  301. /*******************************************************************************
  302. * Function Name : DMA1_Channel3_IRQHandler
  303. * Description : This function handles DMA1 Channel 3 interrupt request.
  304. * Input : None
  305. * Output : None
  306. * Return : None
  307. *******************************************************************************/
  308. void DMA1_Channel3_IRQHandler(void)
  309. {
  310. }
  311. /*******************************************************************************
  312. * Function Name : DMA1_Channel4_IRQHandler
  313. * Description : This function handles DMA1 Channel 4 interrupt request.
  314. * Input : None
  315. * Output : None
  316. * Return : None
  317. *******************************************************************************/
  318. void DMA1_Channel4_IRQHandler(void)
  319. {
  320. }
  321. #if CODEC_VERSION == 1
  322. /*******************************************************************************
  323. * Function Name : DMA1_Channel5_IRQHandler
  324. * Description : This function handles DMA1 Channel 5 interrupt request.
  325. * Input : None
  326. * Output : None
  327. * Return : None
  328. *******************************************************************************/
  329. void DMA1_Channel5_IRQHandler(void)
  330. {
  331. extern void codec_dma_isr(void);
  332. /* enter interrupt */
  333. rt_interrupt_enter();
  334. if (DMA_GetITStatus(DMA1_IT_TC5))
  335. {
  336. /* clear DMA flag */
  337. DMA_ClearFlag(DMA1_FLAG_TC5 | DMA1_FLAG_TE5);
  338. // rt_kprintf("DMA\n");
  339. /* transmission complete, invoke serial dma tx isr */
  340. codec_dma_isr();
  341. }
  342. /* leave interrupt */
  343. rt_interrupt_leave();
  344. }
  345. #endif
  346. /*******************************************************************************
  347. * Function Name : DMA1_Channel6_IRQHandler
  348. * Description : This function handles DMA1 Channel 6 interrupt request.
  349. * Input : None
  350. * Output : None
  351. * Return : None
  352. *******************************************************************************/
  353. void DMA1_Channel6_IRQHandler(void)
  354. {
  355. #ifdef RT_USING_UART2
  356. extern struct rt_device uart2_device;
  357. /* enter interrupt */
  358. rt_interrupt_enter();
  359. /* clear DMA flag */
  360. DMA_ClearFlag(DMA1_FLAG_TC6 | DMA1_FLAG_TE6);
  361. rt_hw_serial_dma_rx_isr(&uart2_device);
  362. /* leave interrupt */
  363. rt_interrupt_leave();
  364. rt_hw_interrupt_thread_switch();
  365. #endif
  366. }
  367. /*******************************************************************************
  368. * Function Name : EXTI9_5_IRQHandler
  369. * Description : This function handles External lines 9 to 5 interrupt request.
  370. * Input : None
  371. * Output : None
  372. * Return : None
  373. *******************************************************************************/
  374. void EXTI9_5_IRQHandler(void)
  375. {
  376. #ifdef RT_USING_LWIP
  377. extern void rt_dm9000_isr(void);
  378. /* enter interrupt */
  379. rt_interrupt_enter();
  380. rt_dm9000_isr();
  381. /* Clear the Key Button EXTI line pending bit */
  382. EXTI_ClearITPendingBit(EXTI_Line7);
  383. /* leave interrupt */
  384. rt_interrupt_leave();
  385. rt_hw_interrupt_thread_switch();
  386. #endif
  387. }
  388. #if CODEC_VERSION == 1
  389. /*******************************************************************************
  390. * Function Name : SPI2_IRQHandler
  391. * Description : This function handles SPI2 global interrupt request.
  392. * Input : None
  393. * Output : None
  394. * Return : None
  395. *******************************************************************************/
  396. void SPI2_IRQHandler(void)
  397. {
  398. extern void codec_isr(void);
  399. /* enter interrupt */
  400. rt_interrupt_enter();
  401. codec_isr();
  402. /* leave interrupt */
  403. rt_interrupt_leave();
  404. }
  405. #endif
  406. /*******************************************************************************
  407. * Function Name : USART1_IRQHandler
  408. * Description : This function handles USART1 global interrupt request.
  409. * Input : None
  410. * Output : None
  411. * Return : None
  412. *******************************************************************************/
  413. void USART1_IRQHandler(void)
  414. {
  415. #ifdef RT_USING_UART1
  416. extern struct rt_device uart1_device;
  417. /* enter interrupt */
  418. rt_interrupt_enter();
  419. rt_hw_serial_isr(&uart1_device);
  420. /* leave interrupt */
  421. rt_interrupt_leave();
  422. rt_hw_interrupt_thread_switch();
  423. #endif
  424. }
  425. /*******************************************************************************
  426. * Function Name : USART2_IRQHandler
  427. * Description : This function handles USART2 global interrupt request.
  428. * Input : None
  429. * Output : None
  430. * Return : None
  431. *******************************************************************************/
  432. void USART2_IRQHandler(void)
  433. {
  434. #ifdef RT_USING_UART2
  435. extern struct rt_device uart2_device;
  436. /* enter interrupt */
  437. rt_interrupt_enter();
  438. rt_hw_serial_isr(&uart2_device);
  439. /* leave interrupt */
  440. rt_interrupt_leave();
  441. rt_hw_interrupt_thread_switch();
  442. #endif
  443. }
  444. /*******************************************************************************
  445. * Function Name : USART3_IRQHandler
  446. * Description : This function handles USART3 global interrupt request.
  447. * Input : None
  448. * Output : None
  449. * Return : None
  450. *******************************************************************************/
  451. void USART3_IRQHandler(void)
  452. {
  453. #ifdef RT_USING_UART3
  454. extern struct rt_device uart3_device;
  455. /* enter interrupt */
  456. rt_interrupt_enter();
  457. rt_hw_serial_isr(&uart3_device);
  458. /* leave interrupt */
  459. rt_interrupt_leave();
  460. rt_hw_interrupt_thread_switch();
  461. #endif
  462. }
  463. /*******************************************************************************
  464. * Function Name : EXTI15_10_IRQHandler
  465. * Description : This function handles External lines 15 to 10 interrupt request.
  466. * Input : None
  467. * Output : None
  468. * Return : None
  469. *******************************************************************************/
  470. void EXTI15_10_IRQHandler(void)
  471. {
  472. }
  473. /*******************************************************************************
  474. * Function Name : RTCAlarm_IRQHandler
  475. * Description : This function handles RTC Alarm interrupt request.
  476. * Input : None
  477. * Output : None
  478. * Return : None
  479. *******************************************************************************/
  480. void RTCAlarm_IRQHandler(void)
  481. {
  482. }
  483. /*******************************************************************************
  484. * Function Name : USBWakeUp_IRQHandler
  485. * Description : This function handles USB WakeUp interrupt request.
  486. * Input : None
  487. * Output : None
  488. * Return : None
  489. *******************************************************************************/
  490. void USBWakeUp_IRQHandler(void)
  491. {
  492. }
  493. /*******************************************************************************
  494. * Function Name : TIM8_BRK_IRQHandler
  495. * Description : This function handles TIM8 Break interrupt request.
  496. * Input : None
  497. * Output : None
  498. * Return : None
  499. *******************************************************************************/
  500. void TIM8_BRK_IRQHandler(void)
  501. {
  502. }
  503. /*******************************************************************************
  504. * Function Name : TIM8_UP_IRQHandler
  505. * Description : This function handles TIM8 overflow and update interrupt
  506. * request.
  507. * Input : None
  508. * Output : None
  509. * Return : None
  510. *******************************************************************************/
  511. void TIM8_UP_IRQHandler(void)
  512. {
  513. }
  514. /*******************************************************************************
  515. * Function Name : TIM8_TRG_COM_IRQHandler
  516. * Description : This function handles TIM8 Trigger and commutation interrupts
  517. * requests.
  518. * Input : None
  519. * Output : None
  520. * Return : None
  521. *******************************************************************************/
  522. void TIM8_TRG_COM_IRQHandler(void)
  523. {
  524. }
  525. /*******************************************************************************
  526. * Function Name : TIM8_CC_IRQHandler
  527. * Description : This function handles TIM8 capture compare interrupt request.
  528. * Input : None
  529. * Output : None
  530. * Return : None
  531. *******************************************************************************/
  532. void TIM8_CC_IRQHandler(void)
  533. {
  534. }
  535. /*******************************************************************************
  536. * Function Name : ADC3_IRQHandler
  537. * Description : This function handles ADC3 global interrupt request.
  538. * Input : None
  539. * Output : None
  540. * Return : None
  541. *******************************************************************************/
  542. void ADC3_IRQHandler(void)
  543. {
  544. }
  545. /*******************************************************************************
  546. * Function Name : FSMC_IRQHandler
  547. * Description : This function handles FSMC global interrupt request.
  548. * Input : None
  549. * Output : None
  550. * Return : None
  551. *******************************************************************************/
  552. void FSMC_IRQHandler(void)
  553. {
  554. }
  555. /*******************************************************************************
  556. * Function Name : SDIO_IRQHandler
  557. * Description : This function handles SDIO global interrupt request.
  558. * Input : None
  559. * Output : None
  560. * Return : None
  561. *******************************************************************************/
  562. void SDIO_IRQHandler(void)
  563. {
  564. #ifdef RT_USING_DFS
  565. extern int SD_ProcessIRQSrc(void);
  566. /* enter interrupt */
  567. rt_interrupt_enter();
  568. /* Process All SDIO Interrupt Sources */
  569. SD_ProcessIRQSrc();
  570. /* leave interrupt */
  571. rt_interrupt_leave();
  572. rt_hw_interrupt_thread_switch();
  573. #endif
  574. }
  575. #if CODEC_VERSION == 2
  576. /*******************************************************************************
  577. * Function Name : SPI3_IRQHandler
  578. * Description : This function handles SPI3 global interrupt request.
  579. * Input : None
  580. * Output : None
  581. * Return : None
  582. *******************************************************************************/
  583. void SPI3_IRQHandler(void)
  584. {
  585. extern void wm8978_isr(void);
  586. /* enter interrupt */
  587. rt_interrupt_enter();
  588. wm8978_isr();
  589. /* leave interrupt */
  590. rt_interrupt_leave();
  591. }
  592. /*******************************************************************************
  593. * Function Name : DMA2_Channel2_IRQHandler
  594. * Description : This function handles DMA2 Channel 2 interrupt request.
  595. * Input : None
  596. * Output : None
  597. * Return : None
  598. *******************************************************************************/
  599. void DMA2_Channel2_IRQHandler(void)
  600. {
  601. extern void wm8978_dma_isr(void);
  602. /* enter interrupt */
  603. rt_interrupt_enter();
  604. if (DMA_GetITStatus(DMA2_IT_TC2))
  605. {
  606. /* clear DMA flag */
  607. DMA_ClearFlag(DMA2_FLAG_TC2 | DMA2_FLAG_TE2);
  608. /* transmission complete, invoke serial dma tx isr */
  609. wm8978_dma_isr();
  610. }
  611. /* leave interrupt */
  612. rt_interrupt_leave();
  613. }
  614. #endif
  615. /* add on 2009-12-31 for usb */
  616. extern void CTR_HP(void);
  617. extern void USB_Istr(void);
  618. void USB_HP_CAN1_TX_IRQHandler(void)
  619. {
  620. CTR_HP();
  621. }
  622. void USB_LP_CAN1_RX0_IRQHandler(void)
  623. {
  624. USB_Istr();
  625. }
  626. /* add on 2010-01-02 for remote */
  627. extern void remote_isr(void);
  628. void TIM5_IRQHandler(void)
  629. {
  630. remote_isr();
  631. }