gd32f10x_it.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*!
  2. \file gd32f10x_it.c
  3. \brief interrupt service routines
  4. \version 2014-12-26, V1.0.0, firmware for GD32F10x
  5. \version 2017-06-20, V2.0.0, firmware for GD32F10x
  6. \version 2018-07-31, V2.1.0, firmware for GD32F10x
  7. \version 2020-09-30, V2.2.0, firmware for GD32F10x
  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 "gd32f10x_it.h"
  33. #include "usart.h"
  34. /*!
  35. \brief this function handles NMI exception
  36. \param[in] none
  37. \param[out] none
  38. \retval none
  39. */
  40. void NMI_Handler(void)
  41. {
  42. }
  43. /*!
  44. \brief this function handles HardFault exception
  45. \param[in] none
  46. \param[out] none
  47. \retval none
  48. */
  49. void HardFault_Handler(void)
  50. {
  51. /* if Hard Fault exception occurs, go to infinite loop */
  52. while(1){
  53. }
  54. }
  55. /*!
  56. \brief this function handles MemManage exception
  57. \param[in] none
  58. \param[out] none
  59. \retval none
  60. */
  61. void MemManage_Handler(void)
  62. {
  63. /* if Memory Manage exception occurs, go to infinite loop */
  64. while(1){
  65. }
  66. }
  67. /*!
  68. \brief this function handles BusFault exception
  69. \param[in] none
  70. \param[out] none
  71. \retval none
  72. */
  73. void BusFault_Handler(void)
  74. {
  75. /* if Bus Fault exception occurs, go to infinite loop */
  76. while(1){
  77. }
  78. }
  79. /*!
  80. \brief this function handles UsageFault exception
  81. \param[in] none
  82. \param[out] none
  83. \retval none
  84. */
  85. void UsageFault_Handler(void)
  86. {
  87. /* if Usage Fault exception occurs, go to infinite loop */
  88. while(1){
  89. }
  90. }
  91. /*!
  92. \brief this function handles SVC exception
  93. \param[in] none
  94. \param[out] none
  95. \retval none
  96. */
  97. void SVC_Handler(void)
  98. {
  99. }
  100. /*!
  101. \brief this function handles DebugMon exception
  102. \param[in] none
  103. \param[out] none
  104. \retval none
  105. */
  106. void DebugMon_Handler(void)
  107. {
  108. }
  109. /*!
  110. \brief this function handles PendSV exception
  111. \param[in] none
  112. \param[out] none
  113. \retval none
  114. */
  115. void PendSV_Handler(void)
  116. {
  117. }
  118. /*!
  119. \brief this function handles SysTick exception
  120. \param[in] none
  121. \param[out] none
  122. \retval none
  123. */
  124. void SysTick_Handler(void)
  125. {
  126. }
  127. // 4G模块
  128. void USART0_IRQHandler(void)
  129. {
  130. if (RESET != usart_interrupt_flag_get(USART0, USART_INT_FLAG_IDLE)) // 空闲中断
  131. {
  132. usart_interrupt_flag_clear(USART0, USART_INT_FLAG_IDLE); /* 清除空闲中断标志位 */
  133. usart_data_receive(USART0); /* 清除接收完成标志位 */
  134. dma_channel_disable(DMA0, DMA_CH4); /* 关闭DMA传输 */
  135. // UART0_RX_NUM = sizeof(UART0_RX_BUF) - dma_transfer_number_get(DMA0, DMA_CH4);
  136. // UART0_RX_BUF[UART0_RX_NUM] = '\0'; /* 添加字符串结束符 */
  137. UART0_RX_STAT = 0x01; /* 接受状态 0x01:已接收到数据 */
  138. // dma_memory_address_config(DMA0, DMA_CH4, (uint32_t)UART0_RX_BUF);
  139. // dma_transfer_number_config(DMA0, DMA_CH4, sizeof(UART0_RX_BUF));
  140. dma_channel_enable(DMA0, DMA_CH4);
  141. }
  142. }
  143. void DMA0_Channel4_IRQHandler(void)
  144. {
  145. dma_interrupt_flag_clear(DMA0, DMA_CH4, DMA_INT_FLAG_G);
  146. }