gd32f3x0_it.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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 "gd32f3x0_eval.h"
  11. extern uint8_t rxbuffer[64];
  12. extern uint8_t txbuffer[64];
  13. __IO uint8_t txcount = 0;
  14. __IO uint16_t rxcount = 0;
  15. /*!
  16. \brief this function handles NMI exception
  17. \param[in] none
  18. \param[out] none
  19. \retval none
  20. */
  21. void NMI_Handler(void)
  22. {
  23. }
  24. /*!
  25. \brief this function handles HardFault exception
  26. \param[in] none
  27. \param[out] none
  28. \retval none
  29. */
  30. void HardFault_Handler(void)
  31. {
  32. /* if Hard Fault exception occurs, go to infinite loop */
  33. while (1);
  34. }
  35. /*!
  36. \brief this function handles MemManage exception
  37. \param[in] none
  38. \param[out] none
  39. \retval none
  40. */
  41. void MemManage_Handler(void)
  42. {
  43. /* if Memory Manage exception occurs, go to infinite loop */
  44. while (1);
  45. }
  46. /*!
  47. \brief this function handles BusFault exception
  48. \param[in] none
  49. \param[out] none
  50. \retval none
  51. */
  52. void BusFault_Handler(void)
  53. {
  54. /* if Bus Fault exception occurs, go to infinite loop */
  55. while (1);
  56. }
  57. /*!
  58. \brief this function handles UsageFault exception
  59. \param[in] none
  60. \param[out] none
  61. \retval none
  62. */
  63. void UsageFault_Handler(void)
  64. {
  65. /* if Usage Fault exception occurs, go to infinite loop */
  66. while (1);
  67. }
  68. /*!
  69. \brief this function handles SVC exception
  70. \param[in] none
  71. \param[out] none
  72. \retval none
  73. */
  74. void SVC_Handler(void)
  75. {
  76. }
  77. /*!
  78. \brief this function handles DebugMon exception
  79. \param[in] none
  80. \param[out] none
  81. \retval none
  82. */
  83. void DebugMon_Handler(void)
  84. {
  85. }
  86. /*!
  87. \brief this function handles PendSV exception
  88. \param[in] none
  89. \param[out] none
  90. \retval none
  91. */
  92. void PendSV_Handler(void)
  93. {
  94. }
  95. /*!
  96. \brief this function handles USART RBNE interrupt request and TBE interrupt request
  97. \param[in] none
  98. \param[out] none
  99. \retval none
  100. */
  101. void USART0_IRQHandler(void)
  102. {
  103. if(RESET != usart_interrupt_flag_get(EVAL_COM1, USART_INT_FLAG_RBNE)){
  104. /* receive data */
  105. rxbuffer[rxcount++] = (usart_data_receive(EVAL_COM1) & 0x7F);
  106. }
  107. if(RESET != usart_interrupt_flag_get(EVAL_COM1, USART_INT_FLAG_TBE)){
  108. /* transmit data */
  109. usart_data_transmit(EVAL_COM1, txbuffer[txcount++]);
  110. if(txcount >= rxcount)
  111. {
  112. usart_interrupt_disable(EVAL_COM1, USART_INT_TBE);
  113. }
  114. }
  115. }