ch32v20x_it.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /********************************** (C) COPYRIGHT *******************************
  2. * File Name : ch32v20x_it.c
  3. * Author : WCH
  4. * Version : V1.0.0
  5. * Date : 2022/06/16
  6. * Description : Main Interrupt Service Routines.
  7. *********************************************************************************
  8. * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
  9. * Attention: This software (modified or not) and binary are used for
  10. * microcontroller manufactured by Nanjing Qinheng Microelectronics.
  11. *******************************************************************************/
  12. /*********************************************************************
  13. * INCLUDES
  14. */
  15. #include <user_config.h>
  16. #include "ch32v20x_it.h"
  17. #include "user_nfc.h"
  18. #include "user_adc.h"
  19. #include "user_can.h"
  20. /*********************************************************************
  21. * LOCAL FUNCTIONS
  22. */
  23. void NMI_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
  24. void HardFault_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
  25. void BB_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
  26. void DMA1_Channel1_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
  27. void USB_LP_CAN1_RX0_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
  28. /*********************************************************************
  29. * @fn NMI_Handler
  30. *
  31. * @brief This function handles NMI exception.
  32. *
  33. * @return None
  34. */
  35. void NMI_Handler(void)
  36. {
  37. }
  38. /*********************************************************************
  39. * @fn HardFault_Handler
  40. *
  41. * @brief This function handles Hard Fault exception.
  42. *
  43. * @return None
  44. */
  45. void HardFault_Handler(void)
  46. {
  47. while(1)
  48. {
  49. }
  50. }
  51. /*********************************************************************
  52. * @fn BB_IRQHandler
  53. *
  54. * @brief BB Interrupt for BLE.
  55. *
  56. * @return None
  57. */
  58. void BB_IRQHandler(void)
  59. {
  60. BB_IRQLibHandler();
  61. }
  62. ///*********************************************************************
  63. // * @fn LLE_IRQHandler
  64. // *
  65. // * @brief LLE Interrupt for BLE.
  66. // *
  67. // * @return None
  68. // */
  69. //void LLE_IRQHandler(void)
  70. //{
  71. // LLE_IRQLibHandler();
  72. //}
  73. void DMA1_Channel1_IRQHandler(void)
  74. {
  75. if(DMA_GetITStatus(DMA1_IT_TC1))
  76. {
  77. DMA_ClearITPendingBit(DMA1_IT_TC1);
  78. vUser_adc_dma_finish();
  79. }
  80. }
  81. // CAN接收中断服务函数
  82. void USB_LP_CAN1_RX0_IRQHandler(void)
  83. {
  84. if(CAN_GetITStatus(CAN1, CAN_IT_FMP0)) // 检查FIFO0消息挂起中断
  85. {
  86. CanRxMsg RxMessage;
  87. CAN_Receive(CAN_TYPE, CAN_FIFO0, &RxMessage);
  88. vUser_can_recv_data(&RxMessage);
  89. // 清除中断标志
  90. CAN_ClearITPendingBit(CAN1, CAN_IT_FMP0);
  91. }
  92. }