py32f002b_it.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /**
  2. ******************************************************************************
  3. * @file py32f002b_it.c
  4. * @author MCU Application Team
  5. * @brief Interrupt Service Routines.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2023 Puya Semiconductor Co.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by Puya under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. * @attention
  19. *
  20. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
  21. * All rights reserved.</center></h2>
  22. *
  23. * This software component is licensed by ST under BSD 3-Clause license,
  24. * the "License"; You may not use this file except in compliance with the
  25. * License. You may obtain a copy of the License at:
  26. * opensource.org/licenses/BSD-3-Clause
  27. *
  28. ******************************************************************************
  29. */
  30. /* Includes ------------------------------------------------------------------*/
  31. #include "main.h"
  32. #include "py32f002b_it.h"
  33. /* Private includes ----------------------------------------------------------*/
  34. /* Private typedef -----------------------------------------------------------*/
  35. /* Private define ------------------------------------------------------------*/
  36. /* Private macro -------------------------------------------------------------*/
  37. /* Private variables ---------------------------------------------------------*/
  38. extern unsigned int ADC_RE[];
  39. extern unsigned char flag;
  40. extern unsigned int ADC_CH1_RE;
  41. extern unsigned int ADC_CH2_RE;
  42. extern unsigned int ADC_CH3_RE;
  43. extern unsigned int ADC_CH4_RE;
  44. extern unsigned int State;
  45. unsigned char i = 0;
  46. unsigned char j = 0;
  47. unsigned char *pBuffPtr = 0;
  48. unsigned short int XferCount = 0;
  49. /* Private function prototypes -----------------------------------------------*/
  50. /* Private user code ---------------------------------------------------------*/
  51. /* External variables --------------------------------------------------------*/
  52. /******************************************************************************/
  53. /* Cortex-M0+ Processor Interruption and Exception Handlers */
  54. /******************************************************************************/
  55. void ADC_COMP_IRQHandler(void)
  56. {
  57. /* Clear ADC EOC IT flag */
  58. LL_ADC_ClearFlag_EOC(ADC1);
  59. ADC_RE[i++]=ADC1->DR;
  60. if(i >= 4){
  61. i = 0;
  62. }
  63. }
  64. /**
  65. * @brief This function handles Non maskable interrupt.
  66. */
  67. void NMI_Handler(void)
  68. {
  69. }
  70. /**
  71. * @brief This function handles Hard fault interrupt.
  72. */
  73. void HardFault_Handler(void)
  74. {
  75. while (1)
  76. {
  77. }
  78. }
  79. /**
  80. * @brief This function handles System service call via SWI instruction.
  81. */
  82. void SVC_Handler(void)
  83. {
  84. }
  85. /**
  86. * @brief This function handles Pendable request for system service.
  87. */
  88. void PendSV_Handler(void)
  89. {
  90. }
  91. /**
  92. * @brief This function handles System tick timer.
  93. */
  94. void SysTick_Handler(void)
  95. {
  96. }
  97. /******************************************************************************/
  98. /* PY32F002B Peripheral Interrupt Handlers */
  99. /* Add here the Interrupt Handlers for the used peripherals. */
  100. /* For the available peripheral interrupt handler names, */
  101. /* please refer to the startup file. */
  102. /******************************************************************************/
  103. /************************ (C) COPYRIGHT Puya *****END OF FILE******************/
  104. /******************************************************************************/
  105. /* PY32F002B Peripheral Interrupt Handlers */
  106. /* Add here the Interrupt Handlers for the used peripherals. */
  107. /* For the available peripheral interrupt handler names, */
  108. /* please refer to the startup file. */
  109. /******************************************************************************/
  110. /**
  111. * @brief This function handles SPI1.
  112. */
  113. void SPI1_IRQHandler(void)
  114. {
  115. /* Check RXNE bit if is set */
  116. if(LL_SPI_IsActiveFlag_RXNE(SPI1))
  117. {
  118. /* Call receive callback */
  119. APP_SpiRxCallback();
  120. }
  121. /* Check TxE bit if is set */
  122. else if(LL_SPI_IsActiveFlag_TXE(SPI1))
  123. {
  124. /* Call send callback */
  125. APP_SpiTxCallback();
  126. }
  127. /* Check OVR bit if is set */
  128. else if(LL_SPI_IsActiveFlag_OVR(SPI1))
  129. {
  130. /* Call error callback */
  131. APP_SpiTransferErrorCallback();
  132. }
  133. }
  134. /******************************************************************************/
  135. /* PY32F002B Peripheral Interrupt Handlers */
  136. /* Add here the Interrupt Handlers for the used peripherals. */
  137. /* For the available peripheral interrupt handler names, */
  138. /* please refer to the startup file. */
  139. /******************************************************************************/
  140. /**
  141. * @brief This function handles EXTI4_15 interrupt.
  142. // */
  143. void EXTI0_1_IRQHandler(void)
  144. {
  145. /* Handle EXTI interrupt request */
  146. if(LL_EXTI_IsActiveFlag(LL_EXTI_LINE_1))
  147. {
  148. LL_EXTI_ClearFlag(LL_EXTI_LINE_1);
  149. if(LL_GPIO_IsInputPinSet(GPIOB, LL_GPIO_PIN_1)){
  150. LL_SPI_Disable(SPI1);
  151. APP_Spi_CS_EN(0);
  152. }else{
  153. LL_SPI_Enable(SPI1);
  154. APP_Spi_CS_EN(1);
  155. }
  156. }
  157. }