gd32e23x_it.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*!
  2. \file gd32e23x_it.c
  3. \brief interrupt service routines
  4. \version 2024-02-22, V2.1.0, firmware for GD32E23x
  5. */
  6. /*
  7. Copyright (c) 2024, 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 "gd32e23x_it.h"
  30. #include "main.h"
  31. #include "systick.h"
  32. /*!
  33. \brief this function handles NMI exception
  34. \param[in] none
  35. \param[out] none
  36. \retval none
  37. */
  38. enum {
  39. ERROR_NONE = 0,
  40. ERROR_NMI,
  41. ERROR_HardFault,
  42. ERROR_MemManage,
  43. ERROR_BusFault,
  44. ERROR_UsageFault,
  45. ERROR_SVC,
  46. ERROR_DebugMon,
  47. ERROR_PendSV,
  48. };
  49. //extern META_DATA_S meta_data;
  50. //extern uint32_t normal_running_time;
  51. //extern void flash_erase_meta();
  52. //extern void flash_write_meta(const META_DATA_S *meta_data);
  53. inline static void set_error(uint8_t error)
  54. {
  55. // meta_data.errno = error;
  56. // meta_data.error_count ++;
  57. // meta_data.recent_running_time = normal_running_time;
  58. // flash_erase_meta();
  59. // flash_write_meta(&meta_data);
  60. // NVIC_SystemReset();
  61. }
  62. void NMI_Handler(void)
  63. {
  64. /* if NMI exception occurs, go to infinite loop */
  65. set_error(ERROR_NMI);
  66. while(1) {
  67. }
  68. }
  69. /*!
  70. \brief this function handles HardFault exception
  71. \param[in] none
  72. \param[out] none
  73. \retval none
  74. */
  75. void HardFault_Handler(void)
  76. {
  77. /* if Hard Fault exception occurs, go to infinite loop */
  78. set_error(ERROR_HardFault);
  79. while(1) {
  80. }
  81. }
  82. /*!
  83. \brief this function handles SVC exception
  84. \param[in] none
  85. \param[out] none
  86. \retval none
  87. */
  88. void SVC_Handler(void)
  89. {
  90. /* if SVC exception occurs, go to infinite loop */
  91. set_error(ERROR_SVC);
  92. while(1) {
  93. }
  94. }
  95. /*!
  96. \brief this function handles PendSV exception
  97. \param[in] none
  98. \param[out] none
  99. \retval none
  100. */
  101. void PendSV_Handler(void)
  102. {
  103. /* if PendSV exception occurs, go to infinite loop */
  104. set_error(ERROR_PendSV);
  105. while(1) {
  106. }
  107. }
  108. /*!
  109. \brief this function handles SysTick exception
  110. \param[in] none
  111. \param[out] none
  112. \retval none
  113. */
  114. //void SysTick_Handler(void)
  115. //{
  116. // //led_spark();
  117. // //delay_decrement();
  118. //}