stm32f4xx_it.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. /**
  2. ******************************************************************************
  3. * @file Project/STM32F4xx_StdPeriph_Templates/stm32f4xx_it.c
  4. * @author MCD Application Team
  5. * @version V1.5.0
  6. * @date 06-March-2015
  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. * <h2><center>&copy; COPYRIGHT 2015 STMicroelectronics</center></h2>
  14. *
  15. * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  16. * You may not use this file except in compliance with the License.
  17. * You may obtain a copy of the License at:
  18. *
  19. * http://www.st.com/software_license_agreement_liberty_v2
  20. *
  21. * Unless required by applicable law or agreed to in writing, software
  22. * distributed under the License is distributed on an "AS IS" BASIS,
  23. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  24. * See the License for the specific language governing permissions and
  25. * limitations under the License.
  26. *
  27. ******************************************************************************
  28. */
  29. /* Includes ------------------------------------------------------------------*/
  30. #include "stm32f4xx_it.h"
  31. //#include "usart.h"
  32. #ifdef OS_FREERTOS
  33. /* Scheduler includes */
  34. #include "FreeRTOS.h"
  35. #include "task.h"
  36. #include "queue.h"
  37. #include "semphr.h"
  38. extern SemaphoreHandle_t s_xSemaphore;
  39. /* We can use Web only with libc stdio (PRINTF=stdlib) */
  40. #include "stm32f4x7_eth.h"
  41. /* lwip includes */
  42. #include "lwip/sys.h"
  43. #endif
  44. #ifdef PRINTF_STDLIB
  45. #include <stdio.h>
  46. #endif
  47. #ifdef PRINTF_CUSTOM
  48. #include "tinystdio.h"
  49. #endif
  50. /** @addtogroup Template_Project
  51. * @{
  52. */
  53. /* Private typedef -----------------------------------------------------------*/
  54. /* Private define ------------------------------------------------------------*/
  55. /* Private macro -------------------------------------------------------------*/
  56. /* Private variables ---------------------------------------------------------*/
  57. /* Private function prototypes -----------------------------------------------*/
  58. /* Private functions ---------------------------------------------------------*/
  59. /******************************************************************************/
  60. /* Cortex-M4 Processor Exceptions Handlers */
  61. /******************************************************************************/
  62. /**
  63. * @brief This function handles NMI exception.
  64. * @param None
  65. * @retval None
  66. */
  67. void NMI_Handler(void)
  68. {
  69. }
  70. void HardFault_Output(uint32_t *sp)
  71. {
  72. uint32_t r0 = sp[0];
  73. uint32_t r1 = sp[1];
  74. uint32_t r2 = sp[2];
  75. uint32_t r3 = sp[3];
  76. uint32_t r12 = sp[4];
  77. uint32_t lr = sp[5];
  78. uint32_t pc = sp[6];
  79. uint32_t psr = sp[7];
  80. printf("HardFault:\n\r");
  81. /* Print CFSR register */
  82. /* Print CPU registers */
  83. printf("\n\rRegisters:\n\r");
  84. printf("SP 0x%08lx\n\r", (uint32_t)sp);
  85. printf("R0 0x%08lx\n\r", r0);
  86. printf("R1 0x%08lx\n\r", r1);
  87. printf("R2 0x%08lx\n\r", r2);
  88. printf("R3 0x%08lx\n\r", r3);
  89. printf("R12 0x%08lx\n\r", r12);
  90. printf("LR 0x%08lx\n\r", lr);
  91. printf("PC 0x%08lx\n\r", pc);
  92. printf("PSR 0x%08lx\n\r", psr);
  93. /* Go to infinite loop when Hard Fault exception occurs */
  94. while(1);
  95. }
  96. /**
  97. * @brief This function handles Hard Fault exception.
  98. * @param None
  99. * @retval None
  100. */
  101. /*__attribute__( (naked) )
  102. void HardFault_Handler(void)
  103. {
  104. __asm volatile
  105. (
  106. "tst lr, #4 \n"
  107. "ite eq \n"
  108. "mrseq r0, msp \n"
  109. "mrsne r0, psp \n"
  110. "ldr r1, debugHardfault_address \n"
  111. "bx r1 \n"
  112. "debugHardfault_address: .word HardFault_Output \n"
  113. );
  114. }*/
  115. /**
  116. * @brief This function handles Memory Manage exception.
  117. * @param None
  118. * @retval None
  119. */
  120. void MemManage_Handler(void)
  121. {
  122. /* Go to infinite loop when Memory Manage exception occurs */
  123. while (1)
  124. {
  125. }
  126. }
  127. void TIM8_UP_TIM13_IRQHandler(void)
  128. {
  129. TIM_ClearITPendingBit(TIM13, TIM_IT_Update);
  130. }
  131. /**
  132. * @brief This function handles Bus Fault exception.
  133. * @param None
  134. * @retval None
  135. */
  136. void BusFault_Handler(void)
  137. {
  138. /* Go to infinite loop when Bus Fault exception occurs */
  139. while (1)
  140. {
  141. }
  142. }
  143. /**
  144. * @brief This function handles Usage Fault exception.
  145. * @param None
  146. * @retval None
  147. */
  148. void UsageFault_Handler(void)
  149. {
  150. /* Go to infinite loop when Usage Fault exception occurs */
  151. while (1)
  152. {
  153. }
  154. }
  155. /**
  156. * @brief This function handles SVCall exception.
  157. * @param None
  158. * @retval None
  159. */
  160. /*
  161. void SVC_Handler(void)
  162. {
  163. }
  164. */
  165. /**
  166. * @brief This function handles Debug Monitor exception.
  167. * @param None
  168. * @retval None
  169. */
  170. void DebugMon_Handler(void)
  171. {
  172. }
  173. /**
  174. * @brief This function handles PendSVC exception.
  175. * @param None
  176. * @retval None
  177. */
  178. /*void PendSV_Handler(void)
  179. {
  180. }
  181. */
  182. /**
  183. * @brief This function handles SysTick Handler.
  184. * @param None
  185. * @retval None
  186. */
  187. /*void SysTick_Handler(void)
  188. {
  189. TimingDelay_Decrement();
  190. }
  191. */
  192. /******************************************************************************/
  193. /* STM32F4xx Peripherals Interrupt Handlers */
  194. /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */
  195. /* available peripheral interrupt handler's name please refer to the startup */
  196. /* file (startup_stm32f4xx.s). */
  197. /******************************************************************************/
  198. /**
  199. * @brief This function handles PPP interrupt request.
  200. * @param None
  201. * @retval None
  202. */
  203. /*void PPP_IRQHandler(void)
  204. {
  205. }*/
  206. void SDIO_IRQHandler(void)
  207. {
  208. /* Process All SDIO Interrupt Sources */
  209. // SD_ProcessIRQSrc();
  210. }
  211. /**
  212. * @brief This function handles DMA2 Stream3 or DMA2 Stream6 global interrupts
  213. * requests.
  214. * @param None
  215. * @retval None
  216. */
  217. void SD_SDIO_DMA_IRQHANDLER(void)
  218. {
  219. /* Process DMA2 Stream3 or DMA2 Stream6 Interrupt Sources */
  220. // SD_ProcessDMAIRQ();
  221. }
  222. #ifdef OS_FREERTOS
  223. /**
  224. * @brief This function handles ethernet DMA interrupt request.
  225. * @param None
  226. * @retval None
  227. */
  228. void ETH_IRQHandler(void)
  229. {
  230. portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
  231. /* Frame received */
  232. if ( ETH_GetDMAFlagStatus(ETH_DMA_FLAG_R) == SET)
  233. {
  234. /* Give the semaphore to wakeup LwIP task */
  235. xSemaphoreGiveFromISR( s_xSemaphore, &xHigherPriorityTaskWoken );
  236. }
  237. /* Clear the interrupt flags. */
  238. /* Clear the Eth DMA Rx IT pending bits */
  239. ETH_DMAClearITPendingBit(ETH_DMA_IT_R);
  240. ETH_DMAClearITPendingBit(ETH_DMA_IT_NIS);
  241. // Switch tasks if necessary. */
  242. if( xHigherPriorityTaskWoken != pdFALSE )
  243. {
  244. portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );
  245. }
  246. }
  247. //#endif
  248. #endif
  249. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/