gd32f30x_it.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. extern can_receive_message_struct receive_message;
  34. extern FlagStatus can0_receive_flag;
  35. extern FlagStatus can1_receive_flag;
  36. extern FlagStatus can0_error_flag;
  37. extern FlagStatus can1_error_flag;
  38. /*!
  39. \brief this function handles NMI exception
  40. \param[in] none
  41. \param[out] none
  42. \retval none
  43. */
  44. void NMI_Handler(void)
  45. {
  46. }
  47. /*!
  48. \brief this function handles HardFault exception
  49. \param[in] none
  50. \param[out] none
  51. \retval none
  52. */
  53. void HardFault_Handler(void)
  54. {
  55. /* if Hard Fault exception occurs, go to infinite loop */
  56. while(1){
  57. }
  58. }
  59. /*!
  60. \brief this function handles MemManage exception
  61. \param[in] none
  62. \param[out] none
  63. \retval none
  64. */
  65. void MemManage_Handler(void)
  66. {
  67. /* if Memory Manage exception occurs, go to infinite loop */
  68. while(1){
  69. }
  70. }
  71. /*!
  72. \brief this function handles BusFault exception
  73. \param[in] none
  74. \param[out] none
  75. \retval none
  76. */
  77. void BusFault_Handler(void)
  78. {
  79. /* if Bus Fault exception occurs, go to infinite loop */
  80. while(1){
  81. }
  82. }
  83. /*!
  84. \brief this function handles UsageFault exception
  85. \param[in] none
  86. \param[out] none
  87. \retval none
  88. */
  89. void UsageFault_Handler(void)
  90. {
  91. /* if Usage Fault exception occurs, go to infinite loop */
  92. while(1){
  93. }
  94. }
  95. /*!
  96. \brief this function handles SVC exception
  97. \param[in] none
  98. \param[out] none
  99. \retval none
  100. */
  101. void SVC_Handler(void)
  102. {
  103. }
  104. /*!
  105. \brief this function handles DebugMon exception
  106. \param[in] none
  107. \param[out] none
  108. \retval none
  109. */
  110. void DebugMon_Handler(void)
  111. {
  112. }
  113. /*!
  114. \brief this function handles PendSV exception
  115. \param[in] none
  116. \param[out] none
  117. \retval none
  118. */
  119. void PendSV_Handler(void)
  120. {
  121. }
  122. /*!
  123. \brief this function handles SysTick exception
  124. \param[in] none
  125. \param[out] none
  126. \retval none
  127. */
  128. void SysTick_Handler(void)
  129. {
  130. }
  131. /*!
  132. \brief this function handles CAN0 RX0 exception
  133. \param[in] none
  134. \param[out] none
  135. \retval none
  136. */
  137. void CAN0_RX0_IRQHandler(void)
  138. {
  139. /* check the receive message */
  140. can_message_receive(CAN0, CAN_FIFO0, &receive_message);
  141. if((0x7ab == receive_message.rx_sfid)&&(CAN_FF_STANDARD == receive_message.rx_ff)&&(8 == receive_message.rx_dlen)){
  142. can0_receive_flag = SET;
  143. }else{
  144. can0_error_flag = SET;
  145. }
  146. }
  147. /*!
  148. \brief this function handles CAN1 RX0 exception
  149. \param[in] none
  150. \param[out] none
  151. \retval none
  152. */
  153. void CAN1_RX0_IRQHandler(void)
  154. {
  155. /* check the receive message */
  156. can_message_receive(CAN1, CAN_FIFO0, &receive_message);
  157. if((0x7ab == receive_message.rx_sfid)&&(CAN_FF_STANDARD == receive_message.rx_ff)&&(8 == receive_message.rx_dlen)){
  158. can1_receive_flag = SET;
  159. }else{
  160. can1_error_flag = SET;
  161. }
  162. }