stm32g0xx_it.c 5.5 KB

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