ch32v20x_it.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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_can.h"
  19. #include "ws2812b_spi.h"
  20. #include "user_ws2812b.h"
  21. /*********************************************************************
  22. * LOCAL FUNCTIONS
  23. */
  24. void NMI_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
  25. void HardFault_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
  26. void BB_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
  27. void USB_LP_CAN1_RX0_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
  28. void USER_WS2812B_DMA_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
  29. /*********************************************************************
  30. * @fn NMI_Handler
  31. *
  32. * @brief This function handles NMI exception.
  33. *
  34. * @return None
  35. */
  36. void NMI_Handler(void)
  37. {
  38. }
  39. /*********************************************************************
  40. * @fn HardFault_Handler
  41. *
  42. * @brief This function handles Hard Fault exception.
  43. *
  44. * @return None
  45. */
  46. void HardFault_Handler(void)
  47. {
  48. while(1)
  49. {
  50. }
  51. }
  52. /*********************************************************************
  53. * @fn BB_IRQHandler
  54. *
  55. * @brief BB Interrupt for BLE.
  56. *
  57. * @return None
  58. */
  59. void BB_IRQHandler(void)
  60. {
  61. BB_IRQLibHandler();
  62. }
  63. ///*********************************************************************
  64. // * @fn LLE_IRQHandler
  65. // *
  66. // * @brief LLE Interrupt for BLE.
  67. // *
  68. // * @return None
  69. // */
  70. //void LLE_IRQHandler(void)
  71. //{
  72. // LLE_IRQLibHandler();
  73. //}
  74. // CAN接收中断服务函数
  75. void USB_LP_CAN1_RX0_IRQHandler(void)
  76. {
  77. if(CAN_GetITStatus(CAN1, CAN_IT_FMP0)) // 检查FIFO0消息挂起中断
  78. {
  79. CanRxMsg RxMessage;
  80. CAN_Receive(CAN_TYPE, CAN_FIFO0, &RxMessage);
  81. vUser_can_recv_data(&RxMessage);
  82. // 清除中断标志
  83. CAN_ClearITPendingBit(CAN1, CAN_IT_FMP0);
  84. }
  85. }
  86. void USER_WS2812B_DMA_IRQHandler(void)
  87. {
  88. if(DMA_GetITStatus(USER_WS2812B_DMA_IT_TC))
  89. {
  90. // 清除中断标志
  91. DMA_ClearITPendingBit(USER_WS2812B_DMA_IT_TC);
  92. DMA_Cmd(USER_WS2812B_DMA_CHANNEL, DISABLE);
  93. SPI_I2S_DMACmd(USER_WS2812B_SPI, SPI_I2S_DMAReq_Tx, DISABLE);
  94. // 在这里处理传输完成逻辑
  95. // 例如: 设置标志、准备下一次传输等
  96. vUser_ws2812b_set_tx_stat(false);
  97. }
  98. }