ch32v20x_it.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /********************************** (C) COPYRIGHT *******************************
  2. * File Name : ch32v20x_it.c
  3. * Author : WCH
  4. * Version : V1.0.0
  5. * Date : 2023/12/29
  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. #include "ch32v20x_it.h"
  13. #include "ws2812b_spi.h"
  14. #include "user_ws2812b.h"
  15. #include "user_led.h"
  16. #include "download.h"
  17. #include "upload.h"
  18. void NMI_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
  19. void HardFault_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
  20. void USER_WS2812B_DMA_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
  21. void SysTick_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
  22. /*********************************************************************
  23. * @fn NMI_Handler
  24. *
  25. * @brief This function handles NMI exception.
  26. *
  27. * @return none
  28. */
  29. void NMI_Handler(void)
  30. {
  31. while (1)
  32. {
  33. }
  34. }
  35. /*********************************************************************
  36. * @fn HardFault_Handler
  37. *
  38. * @brief This function handles Hard Fault exception.
  39. *
  40. * @return none
  41. */
  42. void HardFault_Handler(void)
  43. {
  44. NVIC_SystemReset();
  45. while (1)
  46. {
  47. }
  48. }
  49. void USER_WS2812B_DMA_IRQHandler(void)
  50. {
  51. if(DMA_GetITStatus(USER_WS2812B_DMA_IT_TC))
  52. {
  53. // 清除中断标志
  54. DMA_ClearITPendingBit(USER_WS2812B_DMA_IT_TC);
  55. DMA_Cmd(USER_WS2812B_DMA_CHANNEL, DISABLE);
  56. SPI_I2S_DMACmd(USER_WS2812B_SPI, SPI_I2S_DMAReq_Tx, DISABLE);
  57. // 在这里处理传输完成逻辑
  58. // 例如: 设置标志、准备下一次传输等
  59. vUser_ws2812b_set_tx_stat(false);
  60. }
  61. }
  62. /*********************************************************************
  63. * @fn ADC1_IRQHandler
  64. *
  65. * @brief ADC1_2 Interrupt Service Function.
  66. *
  67. * @return none
  68. */
  69. void SysTick_Handler(void)
  70. {
  71. // printf("Systick\r\n");
  72. SysTick->SR = 0;
  73. vDownload_tick();
  74. vUpload_tick();
  75. led_task_tick();
  76. vWs2812b_task_tick();
  77. }