gd32f3x0_it.c 2.7 KB

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