stm32g0xx_it.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /**
  2. ******************************************************************************
  3. * @file stm32g0xx_it.c
  4. * @brief Interrupt Service Routines.
  5. ******************************************************************************
  6. * @attention
  7. *
  8. * <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
  9. * All rights reserved.</center></h2>
  10. *
  11. * This software component is licensed by ST under BSD 3-Clause license,
  12. * the "License"; You may not use this file except in compliance with the
  13. * License. You may obtain a copy of the License at:
  14. * opensource.org/licenses/BSD-3-Clause
  15. *
  16. ******************************************************************************
  17. */
  18. /* Includes ------------------------------------------------------------------*/
  19. #include "main.h"
  20. #include "stm32g0xx_it.h"
  21. /* Private includes ----------------------------------------------------------*/
  22. /* Private typedef -----------------------------------------------------------*/
  23. /* Private define ------------------------------------------------------------*/
  24. /* Private macro -------------------------------------------------------------*/
  25. /* Private variables ---------------------------------------------------------*/
  26. /* Private function prototypes -----------------------------------------------*/
  27. /* Private user code ---------------------------------------------------------*/
  28. /* External variables --------------------------------------------------------*/
  29. /******************************************************************************/
  30. /* Cortex-M0+ Processor Interruption and Exception Handlers */
  31. /******************************************************************************/
  32. /**
  33. * @brief This function handles Non maskable interrupt.
  34. */
  35. void NMI_Handler(void)
  36. {
  37. while (1)
  38. {
  39. }
  40. }
  41. /**
  42. * @brief This function handles Hard fault interrupt.
  43. */
  44. void HardFault_Handler(void)
  45. {
  46. while (1)
  47. {
  48. }
  49. }
  50. /**
  51. * @brief This function handles System service call via SWI instruction.
  52. */
  53. void SVC_Handler(void)
  54. {
  55. }
  56. /**
  57. * @brief This function handles Pendable request for system service.
  58. */
  59. void PendSV_Handler(void)
  60. {
  61. }
  62. /******************************************************************************/
  63. /* STM32G0xx Peripheral Interrupt Handlers */
  64. /* Add here the Interrupt Handlers for the used peripherals. */
  65. /* For the available peripheral interrupt handler names, */
  66. /* please refer to the startup file (startup_stm32g0xx.s). */
  67. /******************************************************************************/
  68. /**
  69. * @brief This function handles EXTI line 4 to 15 interrupts.
  70. */
  71. void EXTI4_15_IRQHandler(void)
  72. {
  73. if ((EXTI->FPR1 & EXTI_IMR1_IM14) != 0)
  74. {
  75. EXTI->FPR1 = EXTI_IMR1_IM14;
  76. Flag.RTC_IRQ = 1;
  77. ES_PlaceEvent(evNewSecond);
  78. }
  79. }
  80. /**
  81. * @brief This function handles DMA1 channel 1 interrupt.
  82. */
  83. void DMA1_Channel1_IRQHandler(void)
  84. {
  85. if ((DMA1->ISR & DMA_IFCR_CTCIF1) != 0) {
  86. DMA1->IFCR |= DMA_IFCR_CTCIF1; // reset IRQ flag
  87. Flag.SPI_TX_End = 1;
  88. /* Stop SPI-DMA transfer */
  89. DMA1_Channel1->CCR &= ~DMA_CCR_EN;
  90. /* Wait for end SPI transmit */
  91. LATCH_DOWN;
  92. while ((SPI1->SR & SPI_SR_FTLVL) != 0) {};
  93. while ((SPI1->SR & SPI_SR_BSY) != 0) {};
  94. LATCH_UP;
  95. }
  96. }
  97. /**
  98. * @brief This function handles DMA1 channel 2 and channel 3 interrupts.
  99. */
  100. void DMA1_Channel2_3_IRQHandler(void)
  101. {
  102. if ((DMA1->ISR & DMA_ISR_TCIF2) != 0) {
  103. /* reset IRQ flag */
  104. DMA1->IFCR |= DMA_IFCR_CTCIF2;
  105. /* Disable DMA channels for I2C RX */
  106. DMA1_Channel2->CCR &= ~DMA_CCR_EN;
  107. Flag.I2C_RX_End = 1;
  108. }
  109. if ((DMA1->ISR & DMA_ISR_TEIF2) != 0) {
  110. DMA1->IFCR |= DMA_IFCR_CTEIF2;
  111. DMA1_Channel2->CCR &= ~DMA_CCR_EN;
  112. Flag.I2C_RX_End = 1;
  113. Flag.I2C_RX_Err = 1;
  114. }
  115. if ((DMA1->ISR & DMA_ISR_TCIF3) != 0) {
  116. /* reset IRQ flag */
  117. DMA1->IFCR |= DMA_IFCR_CTCIF3;
  118. /* Disable DMA channels for I2C TX */
  119. DMA1_Channel3->CCR &= ~DMA_CCR_EN;
  120. Flag.I2C_TX_End = 1;
  121. }
  122. if ((DMA1->ISR & DMA_ISR_TEIF3) != 0) {
  123. DMA1->IFCR |= DMA_IFCR_CTEIF3;
  124. DMA1_Channel3->CCR &= ~DMA_CCR_EN;
  125. Flag.I2C_TX_End = 1;
  126. Flag.I2C_TX_Err = 1;
  127. }
  128. }
  129. /**
  130. * @brief This function handles TIM14 global interrupt.
  131. */
  132. void TIM14_IRQHandler(void)
  133. {
  134. if ((TIM14->SR & TIM_SR_UIF) != 0) {
  135. /* Update interrupt flag */
  136. TIM14->SR |= TIM_SR_UIF;
  137. }
  138. if ((TIM14->SR & TIM_SR_CC1IF) != 0) {
  139. /* Capture/Compare Interrupt */
  140. TIM14->SR |= TIM_SR_CC1IF;
  141. /* disable unneeded channel */
  142. /*
  143. if (Flag.Blink_1 != 0) {
  144. TUBE_A_OFF;
  145. }
  146. if (Flag.Blink_2 != 0) {
  147. TUBE_B_OFF;
  148. }
  149. if (Flag.Blink_3 != 0) {
  150. TUBE_C_OFF;
  151. }
  152. if (Flag.Blink_4 != 0) {
  153. TUBE_D_OFF;
  154. }
  155. if (Flag.Blink_5 != 0) {
  156. TUBE_E_OFF;
  157. }
  158. */
  159. }
  160. }
  161. /**
  162. * @brief This function handles TIM16 global interrupt.
  163. */
  164. void TIM16_IRQHandler(void)
  165. {
  166. if ((TIM16->SR & TIM_SR_UIF) != 0) {
  167. /* Update interrupt flag */
  168. TIM16->SR |= TIM_SR_UIF;
  169. }
  170. }
  171. /**
  172. * @brief This function handles TIM17 global interrupt.
  173. */
  174. void TIM17_IRQHandler(void)
  175. {
  176. if ((TIM17->SR & TIM_SR_UIF) != 0) {
  177. /* Update interrupt flag */
  178. TIM17->SR |= TIM_SR_UIF;
  179. }
  180. }
  181. /**
  182. * @brief This function handles SPI1 global interrupt.
  183. */
  184. void SPI1_IRQHandler(void)
  185. {
  186. }
  187. /**
  188. * @brief This function handles USART1 global interrupt / USART1 wake-up interrupt through EXTI line 25.
  189. */
  190. void USART1_IRQHandler(void)
  191. {
  192. }
  193. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/