stm32f4xx_it.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  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. #if defined ( __GNUC__ )
  102. __attribute__( (naked) )
  103. void HardFault_Handler(void)
  104. {
  105. __asm volatile
  106. (
  107. "tst lr, #4 \n"
  108. "ite eq \n"
  109. "mrseq r0, msp \n"
  110. "mrsne r0, psp \n"
  111. "ldr r1, debugHardfault_address \n"
  112. "bx r1 \n"
  113. "debugHardfault_address: .word HardFault_Output \n"
  114. );
  115. }
  116. #endif
  117. /**
  118. * @brief This function handles Memory Manage exception.
  119. * @param None
  120. * @retval None
  121. */
  122. void MemManage_Handler(void)
  123. {
  124. /* Go to infinite loop when Memory Manage exception occurs */
  125. while (1)
  126. {
  127. }
  128. }
  129. /*void TIM8_UP_TIM13_IRQHandler(void)
  130. {
  131. TIM_ClearITPendingBit(TIM13, TIM_IT_Update);
  132. }*/
  133. /**
  134. * @brief This function handles Bus Fault exception.
  135. * @param None
  136. * @retval None
  137. */
  138. void BusFault_Handler(void)
  139. {
  140. /* Go to infinite loop when Bus Fault exception occurs */
  141. while (1)
  142. {
  143. }
  144. }
  145. /**
  146. * @brief This function handles Usage Fault exception.
  147. * @param None
  148. * @retval None
  149. */
  150. void UsageFault_Handler(void)
  151. {
  152. /* Go to infinite loop when Usage Fault exception occurs */
  153. while (1)
  154. {
  155. }
  156. }
  157. /**
  158. * @brief This function handles SVCall exception.
  159. * @param None
  160. * @retval None
  161. */
  162. /*
  163. void SVC_Handler(void)
  164. {
  165. }
  166. */
  167. /**
  168. * @brief This function handles Debug Monitor exception.
  169. * @param None
  170. * @retval None
  171. */
  172. void DebugMon_Handler(void)
  173. {
  174. }
  175. /**
  176. * @brief This function handles PendSVC exception.
  177. * @param None
  178. * @retval None
  179. */
  180. /*void PendSV_Handler(void)
  181. {
  182. }
  183. */
  184. /**
  185. * @brief This function handles SysTick Handler.
  186. * @param None
  187. * @retval None
  188. */
  189. /*void SysTick_Handler(void)
  190. {
  191. TimingDelay_Decrement();
  192. }
  193. */
  194. /******************************************************************************/
  195. /* STM32F4xx Peripherals Interrupt Handlers */
  196. /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */
  197. /* available peripheral interrupt handler's name please refer to the startup */
  198. /* file (startup_stm32f4xx.s). */
  199. /******************************************************************************/
  200. /**
  201. * @brief This function handles PPP interrupt request.
  202. * @param None
  203. * @retval None
  204. */
  205. /*void PPP_IRQHandler(void)
  206. {
  207. }*/
  208. void SDIO_IRQHandler(void)
  209. {
  210. /* Process All SDIO Interrupt Sources */
  211. // SD_ProcessIRQSrc();
  212. }
  213. /**
  214. * @brief This function handles DMA2 Stream3 or DMA2 Stream6 global interrupts
  215. * requests.
  216. * @param None
  217. * @retval None
  218. */
  219. void SD_SDIO_DMA_IRQHANDLER(void)
  220. {
  221. /* Process DMA2 Stream3 or DMA2 Stream6 Interrupt Sources */
  222. // SD_ProcessDMAIRQ();
  223. }
  224. //#ifdef OS_FREERTOS
  225. /**
  226. * @brief This function handles ethernet DMA interrupt request.
  227. * @param None
  228. * @retval None
  229. */
  230. void ETH_IRQHandler(void)
  231. {
  232. portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
  233. /* Frame received */
  234. if ( ETH_GetDMAFlagStatus(ETH_DMA_FLAG_R) == SET)
  235. {
  236. /* Give the semaphore to wakeup LwIP task */
  237. xSemaphoreGiveFromISR( s_xSemaphore, &xHigherPriorityTaskWoken );
  238. }
  239. /* Clear the interrupt flags. */
  240. /* Clear the Eth DMA Rx IT pending bits */
  241. ETH_DMAClearITPendingBit(ETH_DMA_IT_R);
  242. ETH_DMAClearITPendingBit(ETH_DMA_IT_NIS);
  243. // Switch tasks if necessary. */
  244. if( xHigherPriorityTaskWoken != pdFALSE )
  245. {
  246. portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );
  247. }
  248. }
  249. //#endif
  250. //#endif
  251. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/