gd32f30x_it.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*!
  2. \file gd32f30x_it.c
  3. \brief interrupt service routines
  4. \version 2021-12-30, V1.0.0, firmware for GD32F30x
  5. */
  6. /*
  7. Copyright (c) 2021, GigaDevice Semiconductor Inc.
  8. Redistribution and use in source and binary forms, with or without modification,
  9. are permitted provided that the following conditions are met:
  10. 1. Redistributions of source code must retain the above copyright notice, this
  11. list of conditions and the following disclaimer.
  12. 2. Redistributions in binary form must reproduce the above copyright notice,
  13. this list of conditions and the following disclaimer in the documentation
  14. and/or other materials provided with the distribution.
  15. 3. Neither the name of the copyright holder nor the names of its contributors
  16. may be used to endorse or promote products derived from this software without
  17. specific prior written permission.
  18. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  19. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  21. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  22. INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  23. NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  24. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  25. WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  26. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  27. OF SUCH DAMAGE.
  28. */
  29. #include "gd32f30x_it.h"
  30. #include "systick.h"
  31. #include "main.h"
  32. /*!
  33. \brief this function handles NMI exception
  34. \param[in] none
  35. \param[out] none
  36. \retval none
  37. */
  38. void NMI_Handler(void)
  39. {
  40. }
  41. /*!
  42. \brief this function handles HardFault exception
  43. \param[in] none
  44. \param[out] none
  45. \retval none
  46. */
  47. void HardFault_Handler(void)
  48. {
  49. /* if Hard Fault exception occurs, go to infinite loop */
  50. while(1){
  51. }
  52. }
  53. /*!
  54. \brief this function handles MemManage exception
  55. \param[in] none
  56. \param[out] none
  57. \retval none
  58. */
  59. void MemManage_Handler(void)
  60. {
  61. /* if Memory Manage exception occurs, go to infinite loop */
  62. while(1){
  63. }
  64. }
  65. /*!
  66. \brief this function handles BusFault exception
  67. \param[in] none
  68. \param[out] none
  69. \retval none
  70. */
  71. void BusFault_Handler(void)
  72. {
  73. /* if Bus Fault exception occurs, go to infinite loop */
  74. while(1){
  75. }
  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. /*!
  90. \brief this function handles SVC exception
  91. \param[in] none
  92. \param[out] none
  93. \retval none
  94. */
  95. void SVC_Handler(void)
  96. {
  97. }
  98. /*!
  99. \brief this function handles DebugMon exception
  100. \param[in] none
  101. \param[out] none
  102. \retval none
  103. */
  104. void DebugMon_Handler(void)
  105. {
  106. }
  107. /*!
  108. \brief this function handles PendSV exception
  109. \param[in] none
  110. \param[out] none
  111. \retval none
  112. */
  113. void PendSV_Handler(void)
  114. {
  115. }
  116. /*!
  117. \brief this function handles SysTick exception
  118. \param[in] none
  119. \param[out] none
  120. \retval none
  121. */
  122. void SysTick_Handler(void)
  123. {
  124. delay_decrement();
  125. }
  126. /*!
  127. \brief this function handles RTC alarm interrupt request
  128. \param[in] none
  129. \param[out] none
  130. \retval none
  131. */
  132. void RTC_Alarm_IRQHandler(void)
  133. {
  134. if(RESET != rtc_flag_get(RTC_FLAG_ALARM)){
  135. /* clear the RTC alarm and EXTI_17 interrupt flags */
  136. rtc_flag_clear(RTC_FLAG_ALARM);
  137. exti_interrupt_flag_clear(EXTI_17);
  138. /* update RTC alarm time */
  139. rtc_register_sync_wait();
  140. /* wait until last write operation on RTC registers has finished */
  141. rtc_lwoff_wait();
  142. rtc_counter_set(0U);
  143. /* wait until last write operation on RTC registers has finished */
  144. rtc_lwoff_wait();
  145. rtc_alarm_config(ALARM_TIME_INTERVAL);
  146. /* wait until last write operation on RTC registers has finished */
  147. rtc_lwoff_wait();
  148. /* feed dog */
  149. fwdgt_counter_reload();
  150. }
  151. }