stm32f4xx_it.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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. /* Scheduler includes */
  33. #include "FreeRTOS.h"
  34. #include "task.h"
  35. #include "queue.h"
  36. #include "semphr.h"
  37. extern SemaphoreHandle_t s_xSemaphore;
  38. /* We can use Web only with libc stdio (PRINTF=stdlib) */
  39. #include "stm32f4x7_eth.h"
  40. /* lwip includes */
  41. #include "lwip/sys.h"
  42. #ifdef PRINTF_STDLIB
  43. #include <stdio.h>
  44. #endif
  45. #ifdef PRINTF_CUSTOM
  46. #include "tinystdio.h"
  47. #endif
  48. /** @addtogroup Template_Project
  49. * @{
  50. */
  51. /* Private typedef -----------------------------------------------------------*/
  52. /* Private define ------------------------------------------------------------*/
  53. /* Private macro -------------------------------------------------------------*/
  54. /* Private variables ---------------------------------------------------------*/
  55. /* Private function prototypes -----------------------------------------------*/
  56. /* Private functions ---------------------------------------------------------*/
  57. /******************************************************************************/
  58. /* Cortex-M4 Processor Exceptions Handlers */
  59. /******************************************************************************/
  60. /**
  61. * @brief This function handles NMI exception.
  62. * @param None
  63. * @retval None
  64. */
  65. void NMI_Handler(void)
  66. {
  67. }
  68. void HardFault_Output(uint32_t *sp)
  69. {
  70. uint32_t r0 = sp[0];
  71. uint32_t r1 = sp[1];
  72. uint32_t r2 = sp[2];
  73. uint32_t r3 = sp[3];
  74. uint32_t r12 = sp[4];
  75. uint32_t lr = sp[5];
  76. uint32_t pc = sp[6];
  77. uint32_t psr = sp[7];
  78. printf("HardFault:\n\r");
  79. /* Print CFSR register */
  80. /* Print CPU registers */
  81. printf("\n\rRegisters:\n\r");
  82. printf("SP 0x%08lx\n\r", (uint32_t)sp);
  83. printf("R0 0x%08lx\n\r", r0);
  84. printf("R1 0x%08lx\n\r", r1);
  85. printf("R2 0x%08lx\n\r", r2);
  86. printf("R3 0x%08lx\n\r", r3);
  87. printf("R12 0x%08lx\n\r", r12);
  88. printf("LR 0x%08lx\n\r", lr);
  89. printf("PC 0x%08lx\n\r", pc);
  90. printf("PSR 0x%08lx\n\r", psr);
  91. /* Go to infinite loop when Hard Fault exception occurs */
  92. while(1);
  93. }
  94. /**
  95. * @brief This function handles Hard Fault exception.
  96. * @param None
  97. * @retval None
  98. */
  99. #if defined ( __GNUC__ )
  100. __attribute__( (naked) )
  101. void HardFault_Handler(void)
  102. {
  103. __asm volatile
  104. (
  105. "tst lr, #4 \n"
  106. "ite eq \n"
  107. "mrseq r0, msp \n"
  108. "mrsne r0, psp \n"
  109. "ldr r1, debugHardfault_address \n"
  110. "bx r1 \n"
  111. "debugHardfault_address: .word HardFault_Output \n"
  112. );
  113. }
  114. #endif
  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****/