gd32f3x0_it.c 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. /*!
  2. \file gd32f3x0_it.c
  3. \brief interrupt service routines
  4. */
  5. /*
  6. Copyright (C) 2017 GigaDevice
  7. 2017-06-06, V1.0.0, firmware for GD32F3x0
  8. */
  9. #include "gd32f3x0_it.h"
  10. #include "systick.h"
  11. __IO uint32_t step = 1;
  12. /*!
  13. \brief this function handles NMI exception
  14. \param[in] none
  15. \param[out] none
  16. \retval none
  17. */
  18. void NMI_Handler(void)
  19. {
  20. }
  21. /*!
  22. \brief this function handles HardFault exception
  23. \param[in] none
  24. \param[out] none
  25. \retval none
  26. */
  27. void HardFault_Handler(void)
  28. {
  29. /* if Hard Fault exception occurs, go to infinite loop */
  30. while (1);
  31. }
  32. /*!
  33. \brief this function handles MemManage exception
  34. \param[in] none
  35. \param[out] none
  36. \retval none
  37. */
  38. void MemManage_Handler(void)
  39. {
  40. /* if Memory Manage exception occurs, go to infinite loop */
  41. while (1);
  42. }
  43. /*!
  44. \brief this function handles BusFault exception
  45. \param[in] none
  46. \param[out] none
  47. \retval none
  48. */
  49. void BusFault_Handler(void)
  50. {
  51. /* if Bus Fault exception occurs, go to infinite loop */
  52. while (1);
  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. while (1);
  64. }
  65. /*!
  66. \brief this function handles SVC exception
  67. \param[in] none
  68. \param[out] none
  69. \retval none
  70. */
  71. void SVC_Handler(void)
  72. {
  73. }
  74. /*!
  75. \brief this function handles DebugMon exception
  76. \param[in] none
  77. \param[out] none
  78. \retval none
  79. */
  80. void DebugMon_Handler(void)
  81. {
  82. }
  83. /*!
  84. \brief this function handles PendSV exception
  85. \param[in] none
  86. \param[out] none
  87. \retval none
  88. */
  89. void PendSV_Handler(void)
  90. {
  91. }
  92. /*!
  93. \brief this function handles SysTick exception
  94. \param[in] none
  95. \param[out] none
  96. \retval none
  97. */
  98. void SysTick_Handler(void)
  99. {
  100. timer_event_software_generate(TIMER0,TIMER_EVENT_SRC_CMTG);
  101. }
  102. /*!
  103. \brief this function handles TIMER0 interrupt request
  104. \param[in] none
  105. \param[out] none
  106. \retval none
  107. */
  108. void TIMER0_BRK_UP_TRG_COM_IRQHandler(void)
  109. {
  110. timer_interrupt_flag_clear(TIMER0, TIMER_INT_FLAG_CMT);
  111. switch(step){
  112. /* next step: step 2 configuration .A-C` breakover---------------------------- */
  113. case 1:
  114. /* channel0 configuration */
  115. timer_channel_output_mode_config(TIMER0,TIMER_CH_0,TIMER_OC_MODE_PWM1);
  116. timer_channel_output_state_config(TIMER0,TIMER_CH_0,TIMER_CCX_ENABLE);
  117. timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_0,TIMER_CCXN_DISABLE);
  118. /* channel1 configuration */
  119. timer_channel_output_state_config(TIMER0,TIMER_CH_1,TIMER_CCX_DISABLE);
  120. timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_1,TIMER_CCXN_DISABLE);
  121. /* channel2 configuration */
  122. timer_channel_output_mode_config(TIMER0,TIMER_CH_2,TIMER_OC_MODE_PWM1);
  123. timer_channel_output_state_config(TIMER0,TIMER_CH_2,TIMER_CCX_DISABLE);
  124. timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_2,TIMER_CCXN_ENABLE);
  125. step++;
  126. break;
  127. /* next step: step 3 configuration .B-C` breakover---------------------------- */
  128. case 2:
  129. /* channel0 configuration */
  130. timer_channel_output_state_config(TIMER0,TIMER_CH_0,TIMER_CCX_DISABLE);
  131. timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_0,TIMER_CCXN_DISABLE);
  132. /* channel1 configuration */
  133. timer_channel_output_mode_config(TIMER0,TIMER_CH_1,TIMER_OC_MODE_PWM1);
  134. timer_channel_output_state_config(TIMER0,TIMER_CH_1,TIMER_CCX_ENABLE);
  135. timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_1,TIMER_CCXN_DISABLE);
  136. /* channel2 configuration */
  137. timer_channel_output_mode_config(TIMER0,TIMER_CH_2,TIMER_OC_MODE_PWM1);
  138. timer_channel_output_state_config(TIMER0,TIMER_CH_2,TIMER_CCX_DISABLE);
  139. timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_2,TIMER_CCXN_ENABLE);
  140. step++;
  141. break;
  142. /* next step: step 4 configuration .B-A` breakover---------------------------- */
  143. case 3:
  144. /* channel0 configuration */
  145. timer_channel_output_mode_config(TIMER0,TIMER_CH_0,TIMER_OC_MODE_PWM1);
  146. timer_channel_output_state_config(TIMER0,TIMER_CH_0,TIMER_CCX_DISABLE);
  147. timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_0,TIMER_CCXN_ENABLE);
  148. /* channel1 configuration */
  149. timer_channel_output_mode_config(TIMER0,TIMER_CH_1,TIMER_OC_MODE_PWM1);
  150. timer_channel_output_state_config(TIMER0,TIMER_CH_1,TIMER_CCX_ENABLE);
  151. timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_1,TIMER_CCXN_DISABLE);
  152. /* channel2 configuration */
  153. timer_channel_output_state_config(TIMER0,TIMER_CH_2,TIMER_CCX_DISABLE);
  154. timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_2,TIMER_CCXN_DISABLE);
  155. step++;
  156. break;
  157. /* next step: step 5 configuration .C-A` breakover---------------------------- */
  158. case 4:
  159. /* channel0 configuration */
  160. timer_channel_output_mode_config(TIMER0,TIMER_CH_0,TIMER_OC_MODE_PWM1);
  161. timer_channel_output_state_config(TIMER0,TIMER_CH_0,TIMER_CCX_DISABLE);
  162. timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_0,TIMER_CCXN_ENABLE);
  163. /* channel1 configuration */
  164. timer_channel_output_state_config(TIMER0,TIMER_CH_1,TIMER_CCX_DISABLE);
  165. timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_1,TIMER_CCXN_DISABLE);
  166. /* channel2 configuration */
  167. timer_channel_output_mode_config(TIMER0,TIMER_CH_2,TIMER_OC_MODE_PWM1);
  168. timer_channel_output_state_config(TIMER0,TIMER_CH_2,TIMER_CCX_ENABLE);
  169. timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_2,TIMER_CCXN_DISABLE);
  170. step++;
  171. break;
  172. /* next step: step 6 configuration .C-B` breakover---------------------------- */
  173. case 5:
  174. /* channel0 configuration */
  175. timer_channel_output_state_config(TIMER0,TIMER_CH_0,TIMER_CCX_DISABLE);
  176. timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_0,TIMER_CCXN_DISABLE);
  177. /* channel1 configuration */
  178. timer_channel_output_mode_config(TIMER0,TIMER_CH_1,TIMER_OC_MODE_PWM1);
  179. timer_channel_output_state_config(TIMER0,TIMER_CH_1,TIMER_CCX_DISABLE);
  180. timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_1,TIMER_CCXN_ENABLE);
  181. /* channel2 configuration */
  182. timer_channel_output_mode_config(TIMER0,TIMER_CH_2,TIMER_OC_MODE_PWM1);
  183. timer_channel_output_state_config(TIMER0,TIMER_CH_2,TIMER_CCX_ENABLE);
  184. timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_2,TIMER_CCXN_DISABLE);
  185. step++;
  186. break;
  187. /* next step: step 1 configuration .A-B` breakover---------------------------- */
  188. case 6:
  189. /* channel0 configuration */
  190. timer_channel_output_mode_config(TIMER0,TIMER_CH_0,TIMER_OC_MODE_PWM1);
  191. timer_channel_output_state_config(TIMER0,TIMER_CH_0,TIMER_CCX_ENABLE);
  192. timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_0,TIMER_CCXN_DISABLE);
  193. /* channel1 configuration */
  194. timer_channel_output_mode_config(TIMER0,TIMER_CH_1,TIMER_OC_MODE_PWM1);
  195. timer_channel_output_state_config(TIMER0,TIMER_CH_1,TIMER_CCX_DISABLE);
  196. timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_1,TIMER_CCXN_ENABLE);
  197. /* channel2 configuration */
  198. timer_channel_output_state_config(TIMER0,TIMER_CH_2,TIMER_CCX_DISABLE);
  199. timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_2,TIMER_CCXN_DISABLE);
  200. step = 1;
  201. break;
  202. }
  203. }