gd32f30x_it.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. \version 2020-09-30, V2.1.0, firmware for GD32F30x
  8. */
  9. /*
  10. Copyright (c) 2020, GigaDevice Semiconductor Inc.
  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_it.h"
  33. #include "gd32f307c_eval.h"
  34. extern uint8_t rx_count;
  35. extern uint8_t receive_flag;
  36. /*!
  37. \brief this function handles NMI exception
  38. \param[in] none
  39. \param[out] none
  40. \retval none
  41. */
  42. void NMI_Handler(void)
  43. {
  44. }
  45. /*!
  46. \brief this function handles HardFault exception
  47. \param[in] none
  48. \param[out] none
  49. \retval none
  50. */
  51. void HardFault_Handler(void)
  52. {
  53. /* if Hard Fault exception occurs, go to infinite loop */
  54. while (1){
  55. }
  56. }
  57. /*!
  58. \brief this function handles MemManage exception
  59. \param[in] none
  60. \param[out] none
  61. \retval none
  62. */
  63. void MemManage_Handler(void)
  64. {
  65. /* if Memory Manage exception occurs, go to infinite loop */
  66. while (1){
  67. }
  68. }
  69. /*!
  70. \brief this function handles BusFault exception
  71. \param[in] none
  72. \param[out] none
  73. \retval none
  74. */
  75. void BusFault_Handler(void)
  76. {
  77. /* if Bus Fault exception occurs, go to infinite loop */
  78. while (1){
  79. }
  80. }
  81. /*!
  82. \brief this function handles UsageFault exception
  83. \param[in] none
  84. \param[out] none
  85. \retval none
  86. */
  87. void UsageFault_Handler(void)
  88. {
  89. /* if Usage Fault exception occurs, go to infinite loop */
  90. while (1){
  91. }
  92. }
  93. /*!
  94. \brief this function handles SVC exception
  95. \param[in] none
  96. \param[out] none
  97. \retval none
  98. */
  99. void SVC_Handler(void)
  100. {
  101. }
  102. /*!
  103. \brief this function handles DebugMon exception
  104. \param[in] none
  105. \param[out] none
  106. \retval none
  107. */
  108. void DebugMon_Handler(void)
  109. {
  110. }
  111. /*!
  112. \brief this function handles PendSV exception
  113. \param[in] none
  114. \param[out] none
  115. \retval none
  116. */
  117. void PendSV_Handler(void)
  118. {
  119. }
  120. /*!
  121. \brief this function handles USART interrupt request
  122. \param[in] none
  123. \param[out] none
  124. \retval none
  125. */
  126. void USART0_IRQHandler(void)
  127. {
  128. if(RESET != usart_interrupt_flag_get(USART0, USART_INT_FLAG_IDLE)){
  129. /* clear IDLE flag */
  130. usart_data_receive(USART0);
  131. /* toggle the LED2 */
  132. gd_eval_led_toggle(LED2);
  133. /* number of data received */
  134. rx_count = 256 - (dma_transfer_number_get(DMA0, DMA_CH4));
  135. receive_flag = 1;
  136. /* disable DMA and reconfigure */
  137. dma_channel_disable(DMA0, DMA_CH4);
  138. dma_transfer_number_config(DMA0, DMA_CH4, 256);
  139. dma_channel_enable(DMA0, DMA_CH4);
  140. }
  141. }