irqs.c 3.1 KB

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