irqs.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. #include "gd32f3x0.h"
  2. #include "nv_storage.h"
  3. extern void system_reboot(void);
  4. /*!
  5. \brief this function handles NMI exception
  6. \param[in] none
  7. \param[out] none
  8. \retval none
  9. */
  10. void NMI_Handler(void)
  11. {
  12. }
  13. /*!
  14. \brief this function handles HardFault exception
  15. \param[in] none
  16. \param[out] none
  17. \retval none
  18. */
  19. void HardFault_Handler(void){
  20. /* if Hard Fault exception occurs, go to infinite loop */
  21. nv_save_all_soc();
  22. while (1){
  23. system_reboot();
  24. }
  25. }
  26. /*!
  27. \brief this function handles MemManage exception
  28. \param[in] none
  29. \param[out] none
  30. \retval none
  31. */
  32. void MemManage_Handler(void)
  33. {
  34. /* if Memory Manage exception occurs, go to infinite loop */
  35. nv_save_all_soc();
  36. while (1){
  37. system_reboot();
  38. }
  39. }
  40. /*!
  41. \brief this function handles BusFault exception
  42. \param[in] none
  43. \param[out] none
  44. \retval none
  45. */
  46. void BusFault_Handler(void)
  47. {
  48. /* if Bus Fault exception occurs, go to infinite loop */
  49. nv_save_all_soc();
  50. while (1){
  51. system_reboot();
  52. }
  53. }
  54. /*!
  55. \brief this function handles UsageFault exception
  56. \param[in] none
  57. \param[out] none
  58. \retval none
  59. */
  60. void UsageFault_Handler(void)
  61. {
  62. /* if Usage Fault exception occurs, go to infinite loop */
  63. nv_save_all_soc();
  64. while (1){
  65. system_reboot();
  66. }
  67. }
  68. /*!
  69. \brief this function handles DebugMon exception
  70. \param[in] none
  71. \param[out] none
  72. \retval none
  73. */
  74. void DebugMon_Handler(void)
  75. {
  76. }
  77. void __weak gpio_key_irq_handler(void) {}
  78. void EXTI0_1_IRQHandler(void){
  79. if(RESET != exti_interrupt_flag_get(EXTI_0)){
  80. exti_interrupt_flag_clear(EXTI_0);
  81. gpio_key_irq_handler();
  82. }
  83. if(RESET != exti_interrupt_flag_get(EXTI_1)){
  84. exti_interrupt_flag_clear(EXTI_1);
  85. }
  86. }
  87. void EXTI2_3_IRQHandler(void){
  88. if(RESET != exti_interrupt_flag_get(EXTI_2)){
  89. exti_interrupt_flag_clear(EXTI_2);
  90. }
  91. if(RESET != exti_interrupt_flag_get(EXTI_3)){
  92. exti_interrupt_flag_clear(EXTI_3);
  93. }
  94. }
  95. void __weak ml5238_irq_handler(void){}
  96. void __weak charger_detect_irq_handler(void){}
  97. void __weak hall1_detect_irq_handler(void){}
  98. void __weak hall2_detect_irq_handler(void){}
  99. void __weak small_current_short_irq_handler(void){}
  100. void __weak dcdc_pwr_detect_irq_handler(void) {}
  101. void EXTI4_15_IRQHandler(void){
  102. if(RESET != exti_flag_get(EXTI_4)){
  103. exti_flag_clear(EXTI_4);
  104. }
  105. if(RESET != exti_flag_get(EXTI_5)){
  106. exti_flag_clear(EXTI_5);
  107. }
  108. if(RESET != exti_flag_get(EXTI_6)){
  109. exti_flag_clear(EXTI_6);
  110. }
  111. if(RESET != exti_flag_get(EXTI_7)){
  112. exti_flag_clear(EXTI_7);
  113. dcdc_pwr_detect_irq_handler();
  114. }
  115. if(RESET != exti_flag_get(EXTI_8)){
  116. exti_flag_clear(EXTI_8);
  117. }
  118. if(RESET != exti_flag_get(EXTI_9)){
  119. exti_flag_clear(EXTI_9);
  120. }
  121. if(RESET != exti_flag_get(EXTI_10)){
  122. exti_flag_clear(EXTI_10);
  123. charger_detect_irq_handler();
  124. }
  125. if(RESET != exti_flag_get(EXTI_11)){
  126. exti_flag_clear(EXTI_11);
  127. small_current_short_irq_handler();
  128. }
  129. //ms5238 irq
  130. if(RESET != exti_flag_get(EXTI_12)){
  131. exti_flag_clear(EXTI_12);
  132. ml5238_irq_handler();
  133. }
  134. if(RESET != exti_flag_get(EXTI_13)){
  135. exti_flag_clear(EXTI_13);
  136. hall2_detect_irq_handler();
  137. }
  138. if(RESET != exti_flag_get(EXTI_14)){
  139. exti_flag_clear(EXTI_14);
  140. }
  141. if(RESET != exti_flag_get(EXTI_15)){
  142. exti_flag_clear(EXTI_15);
  143. hall1_detect_irq_handler();
  144. }
  145. }