gd32f30x_it.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*!
  2. \file gd32f30x_it.c
  3. \brief interrupt service routines
  4. \version 2017-02-10, V1.0.0, firmware for GD32F30x
  5. \version 2018-10-10, V1.1.0, firmware for GD32F30x
  6. \version 2018-12-25, V2.0.0, firmware for GD32F30x
  7. */
  8. /*
  9. Copyright (c) 2018, GigaDevice Semiconductor Inc.
  10. All rights reserved.
  11. Redistribution and use in source and binary forms, with or without modification,
  12. are permitted provided that the following conditions are met:
  13. 1. Redistributions of source code must retain the above copyright notice, this
  14. list of conditions and the following disclaimer.
  15. 2. Redistributions in binary form must reproduce the above copyright notice,
  16. this list of conditions and the following disclaimer in the documentation
  17. and/or other materials provided with the distribution.
  18. 3. Neither the name of the copyright holder nor the names of its contributors
  19. may be used to endorse or promote products derived from this software without
  20. specific prior written permission.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  22. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  23. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  24. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  25. INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  26. NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  27. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  28. WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  29. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  30. OF SUCH DAMAGE.
  31. */
  32. #include "gd32f30x.h"
  33. #include "gd32f30x_it.h"
  34. #include "main.h"
  35. #include "FreeRTOS.h"
  36. #include "task.h"
  37. #include "queue.h"
  38. #include "lwip/sys.h"
  39. #include "led.h"
  40. #include "log.h"
  41. extern xSemaphoreHandle g_rx_semaphore;
  42. /*!
  43. \brief this function handles NMI exception
  44. \param[in] none
  45. \param[out] none
  46. \retval none
  47. */
  48. void NMI_Handler(void)
  49. {
  50. }
  51. /*!
  52. \brief this function handles HardFault exception
  53. \param[in] none
  54. \param[out] none
  55. \retval none
  56. */
  57. void HardFault_Handler(void)
  58. {
  59. gd_eval_led_off(LED_DEV);
  60. LogPrint(LOG_ERROR,__FILE__,__FUNCTION__,__LINE__,"HardFault");
  61. /* if Hard Fault exception occurs, go to infinite loop */
  62. while (1)
  63. {
  64. gd_eval_led_off(LED_DEV);
  65. }
  66. }
  67. /*!
  68. \brief this function handles MemManage exception
  69. \param[in] none
  70. \param[out] none
  71. \retval none
  72. */
  73. void MemManage_Handler(void)
  74. {
  75. /* if Memory Manage exception occurs, go to infinite loop */
  76. while (1)
  77. {
  78. }
  79. }
  80. /*!
  81. \brief this function handles BusFault exception
  82. \param[in] none
  83. \param[out] none
  84. \retval none
  85. */
  86. void BusFault_Handler(void)
  87. {
  88. /* if Bus Fault exception occurs, go to infinite loop */
  89. while (1)
  90. {
  91. }
  92. }
  93. /*!
  94. \brief this function handles UsageFault exception
  95. \param[in] none
  96. \param[out] none
  97. \retval none
  98. */
  99. void UsageFault_Handler(void)
  100. {
  101. /* if Usage Fault exception occurs, go to infinite loop */
  102. while (1)
  103. {
  104. }
  105. }
  106. /*!
  107. \brief this function handles ethernet interrupt request
  108. \param[in] none
  109. \param[out] none
  110. \retval none
  111. */
  112. void ENET_IRQHandler(void)
  113. {
  114. portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
  115. /* frame received */
  116. if (SET == enet_interrupt_flag_get(ENET_DMA_INT_FLAG_RS))
  117. {
  118. /* give the semaphore to wakeup LwIP task */
  119. xSemaphoreGiveFromISR(g_rx_semaphore, &xHigherPriorityTaskWoken);
  120. }
  121. /* clear the enet DMA Rx interrupt pending bits */
  122. enet_interrupt_flag_clear(ENET_DMA_INT_FLAG_RS_CLR);
  123. enet_interrupt_flag_clear(ENET_DMA_INT_FLAG_NI_CLR);
  124. /* switch tasks if necessary */
  125. // if(pdFALSE != xHigherPriorityTaskWoken){
  126. // portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);
  127. // }
  128. }