gd32f30x_it.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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 uint32_t is_backup_register_clear(void);
  35. /*!
  36. \brief this function handles NMI exception
  37. \param[in] none
  38. \param[out] none
  39. \retval none
  40. */
  41. void NMI_Handler(void)
  42. {
  43. }
  44. /*!
  45. \brief this function handles HardFault exception
  46. \param[in] none
  47. \param[out] none
  48. \retval none
  49. */
  50. void HardFault_Handler(void)
  51. {
  52. /* if Hard Fault exception occurs, go to infinite loop */
  53. while (1);
  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. \brief this function handles BusFault exception
  68. \param[in] none
  69. \param[out] none
  70. \retval none
  71. */
  72. void BusFault_Handler(void)
  73. {
  74. /* if Bus Fault exception occurs, go to infinite loop */
  75. while (1);
  76. }
  77. /*!
  78. \brief this function handles UsageFault exception
  79. \param[in] none
  80. \param[out] none
  81. \retval none
  82. */
  83. void UsageFault_Handler(void)
  84. {
  85. /* if Usage Fault exception occurs, go to infinite loop */
  86. while (1);
  87. }
  88. /*!
  89. \brief this function handles SVC exception
  90. \param[in] none
  91. \param[out] none
  92. \retval none
  93. */
  94. void SVC_Handler(void)
  95. {
  96. }
  97. /*!
  98. \brief this function handles DebugMon exception
  99. \param[in] none
  100. \param[out] none
  101. \retval none
  102. */
  103. void DebugMon_Handler(void)
  104. {
  105. }
  106. /*!
  107. \brief this function handles PendSV exception
  108. \param[in] none
  109. \param[out] none
  110. \retval none
  111. */
  112. void PendSV_Handler(void)
  113. {
  114. }
  115. /*!
  116. \brief this function handles SysTick exception
  117. \param[in] none
  118. \param[out] none
  119. \retval none
  120. */
  121. void SysTick_Handler(void)
  122. {
  123. }
  124. /*!
  125. \brief this function handles Tamper interrupt request
  126. \param[in] none
  127. \param[out] none
  128. \retval none
  129. */
  130. void TAMPER_IRQHandler(void)
  131. {
  132. if(RESET != bkp_interrupt_flag_get(BKP_INT_FLAG_TAMPER))
  133. {
  134. /* a tamper detection event occurred */
  135. /* check if backup data registers are cleared */
  136. if(0 == is_backup_register_clear()){
  137. /* backup data registers are cleared */
  138. /* turn on LED4 */
  139. gd_eval_led_on(LED4);
  140. }else{
  141. /* backup data registers are not cleared */
  142. /* turn on LED5 */
  143. gd_eval_led_on(LED5);
  144. }
  145. /* clear the interrupt bit flag of tamper interrupt */
  146. bkp_interrupt_flag_clear(BKP_INT_FLAG_TAMPER);
  147. /* clear the bit flag of tamper event */
  148. bkp_flag_clear(BKP_FLAG_TAMPER);
  149. /* disable the tamper pin */
  150. bkp_tamper_interrupt_disable();
  151. /* enable the tamper pin */
  152. bkp_tamper_interrupt_enable();
  153. /* tamper pin active level set */
  154. bkp_tamper_active_level_set(TAMPER_PIN_ACTIVE_LOW);
  155. }
  156. }