stm32g0xx_it.c 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * @file stm32g0xx_it.c
  5. * @brief Interrupt Service Routines.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST 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. */
  19. /* USER CODE END Header */
  20. /* Includes ------------------------------------------------------------------*/
  21. #include "main.h"
  22. #include "stm32g0xx_it.h"
  23. /* Private includes ----------------------------------------------------------*/
  24. /* USER CODE BEGIN Includes */
  25. /* USER CODE END Includes */
  26. /* Private typedef -----------------------------------------------------------*/
  27. /* USER CODE BEGIN TD */
  28. /* USER CODE END TD */
  29. /* Private define ------------------------------------------------------------*/
  30. /* USER CODE BEGIN PD */
  31. /* USER CODE END PD */
  32. /* Private macro -------------------------------------------------------------*/
  33. /* USER CODE BEGIN PM */
  34. /* USER CODE END PM */
  35. /* Private variables ---------------------------------------------------------*/
  36. /* USER CODE BEGIN PV */
  37. /* USER CODE END PV */
  38. /* Private function prototypes -----------------------------------------------*/
  39. /* USER CODE BEGIN PFP */
  40. /* USER CODE END PFP */
  41. /* Private user code ---------------------------------------------------------*/
  42. /* USER CODE BEGIN 0 */
  43. /* USER CODE END 0 */
  44. /* External variables --------------------------------------------------------*/
  45. /* USER CODE BEGIN EV */
  46. /* USER CODE END EV */
  47. /******************************************************************************/
  48. /* Cortex-M0+ Processor Interruption and Exception Handlers */
  49. /******************************************************************************/
  50. /**
  51. * @brief This function handles Non maskable interrupt.
  52. */
  53. void NMI_Handler(void)
  54. {
  55. /* USER CODE BEGIN NonMaskableInt_IRQn 0 */
  56. /* USER CODE END NonMaskableInt_IRQn 0 */
  57. /* USER CODE BEGIN NonMaskableInt_IRQn 1 */
  58. while (1)
  59. {
  60. }
  61. /* USER CODE END NonMaskableInt_IRQn 1 */
  62. }
  63. /**
  64. * @brief This function handles Hard fault interrupt.
  65. */
  66. void HardFault_Handler(void)
  67. {
  68. /* USER CODE BEGIN HardFault_IRQn 0 */
  69. /* USER CODE END HardFault_IRQn 0 */
  70. while (1)
  71. {
  72. /* USER CODE BEGIN W1_HardFault_IRQn 0 */
  73. /* USER CODE END W1_HardFault_IRQn 0 */
  74. }
  75. }
  76. /**
  77. * @brief This function handles System service call via SWI instruction.
  78. */
  79. void SVC_Handler(void)
  80. {
  81. /* USER CODE BEGIN SVC_IRQn 0 */
  82. /* USER CODE END SVC_IRQn 0 */
  83. /* USER CODE BEGIN SVC_IRQn 1 */
  84. /* USER CODE END SVC_IRQn 1 */
  85. }
  86. /**
  87. * @brief This function handles Pendable request for system service.
  88. */
  89. void PendSV_Handler(void)
  90. {
  91. /* USER CODE BEGIN PendSV_IRQn 0 */
  92. /* USER CODE END PendSV_IRQn 0 */
  93. /* USER CODE BEGIN PendSV_IRQn 1 */
  94. /* USER CODE END PendSV_IRQn 1 */
  95. }
  96. #ifdef DONT_USE_SHED
  97. /**
  98. * @brief This function handles System tick timer.
  99. */
  100. void SysTick_Handler(void)
  101. {
  102. /* USER CODE BEGIN SysTick_IRQn 0 */
  103. /* USER CODE END SysTick_IRQn 0 */
  104. /* USER CODE BEGIN SysTick_IRQn 1 */
  105. /* USER CODE END SysTick_IRQn 1 */
  106. }
  107. #endif /* DONT_USE_SHED */
  108. /******************************************************************************/
  109. /* STM32G0xx Peripheral Interrupt Handlers */
  110. /* Add here the Interrupt Handlers for the used peripherals. */
  111. /* For the available peripheral interrupt handler names, */
  112. /* please refer to the startup file (startup_stm32g0xx.s). */
  113. /******************************************************************************/
  114. /**
  115. * @brief This function handles RCC global interrupt.
  116. */
  117. void RCC_IRQHandler(void)
  118. {
  119. /* USER CODE BEGIN RCC_IRQn 0 */
  120. /* USER CODE END RCC_IRQn 0 */
  121. /* USER CODE BEGIN RCC_IRQn 1 */
  122. /* USER CODE END RCC_IRQn 1 */
  123. }
  124. /**
  125. * @brief This function handles EXTI line 4 to 15 interrupts.
  126. */
  127. void EXTI4_15_IRQHandler(void)
  128. {
  129. /* USER CODE BEGIN EXTI4_15_IRQn 0 */
  130. //if ((EXTI->RPR1 & 1<<14) != 0)
  131. /* USER CODE END EXTI4_15_IRQn 0 */
  132. if (LL_EXTI_IsActiveRisingFlag_0_31(LL_EXTI_LINE_14) != RESET)
  133. {
  134. LL_EXTI_ClearRisingFlag_0_31(LL_EXTI_LINE_14);
  135. /* USER CODE BEGIN LL_EXTI_LINE_14_RISING */
  136. //EXTI->RPR1 = 1<<14;
  137. Flag.RTC_IRQ = 1;
  138. /* USER CODE END LL_EXTI_LINE_14_RISING */
  139. }
  140. /* USER CODE BEGIN EXTI4_15_IRQn 1 */
  141. /* USER CODE END EXTI4_15_IRQn 1 */
  142. }
  143. /**
  144. * @brief This function handles DMA1 channel 1 interrupt.
  145. */
  146. void DMA1_Channel1_IRQHandler(void)
  147. {
  148. /* USER CODE BEGIN DMA1_Channel1_IRQn 0 */
  149. if (LL_DMA_IsActiveFlag_TC1(DMA1) != 0) {
  150. DMA1->IFCR |= DMA_IFCR_CTCIF1; // reset IRQ flag
  151. Flag.SPI_TX_End = 1;
  152. /* Stop SPI-DMA transfer */
  153. LL_DMA_DisableChannel(DMA1, LL_DMA_CHANNEL_1);
  154. /* Wait for end SPI transmit */
  155. LATCH_DOWN;
  156. while ((SPI1->SR & SPI_SR_FTLVL) != 0) {};
  157. while ((SPI1->SR & SPI_SR_BSY) != 0) {};
  158. LATCH_UP;
  159. }
  160. /* USER CODE END DMA1_Channel1_IRQn 0 */
  161. /* USER CODE BEGIN DMA1_Channel1_IRQn 1 */
  162. /* USER CODE END DMA1_Channel1_IRQn 1 */
  163. }
  164. /**
  165. * @brief This function handles DMA1 channel 2 and channel 3 interrupts.
  166. */
  167. void DMA1_Channel2_3_IRQHandler(void)
  168. {
  169. /* USER CODE BEGIN DMA1_Channel2_3_IRQn 0 */
  170. if (LL_DMA_IsActiveFlag_TC2(DMA1) != 0) {
  171. /* reset IRQ flag */
  172. DMA1->IFCR |= DMA_IFCR_CTCIF2;
  173. /* Disable DMA channels for I2C RX */
  174. DMA1_Channel2->CCR &= ~DMA_CCR_EN;
  175. Flag.I2C_RX_End = 1;
  176. }
  177. if (LL_DMA_IsActiveFlag_TE2(DMA1) != 0) {
  178. DMA1->IFCR |= DMA_IFCR_CTEIF2;
  179. DMA1_Channel2->CCR &= ~DMA_CCR_EN;
  180. Flag.I2C_RX_End = 1;
  181. Flag.I2C_RX_Err = 1;
  182. }
  183. /* USER CODE END DMA1_Channel2_3_IRQn 0 */
  184. /* USER CODE BEGIN DMA1_Channel2_3_IRQn 1 */
  185. if (LL_DMA_IsActiveFlag_TC3(DMA1) != 0) {
  186. /* reset IRQ flag */
  187. DMA1->IFCR |= DMA_IFCR_CTCIF3;
  188. /* Disable DMA channels for I2C TX */
  189. DMA1_Channel3->CCR &= ~DMA_CCR_EN;
  190. Flag.I2C_TX_End = 1;
  191. }
  192. if (LL_DMA_IsActiveFlag_TE3(DMA1) != 0) {
  193. DMA1->IFCR |= DMA_IFCR_CTEIF3;
  194. DMA1_Channel3->CCR &= ~DMA_CCR_EN;
  195. Flag.I2C_TX_End = 1;
  196. Flag.I2C_TX_Err = 1;
  197. }
  198. /* USER CODE END DMA1_Channel2_3_IRQn 1 */
  199. }
  200. /**
  201. * @brief This function handles TIM14 global interrupt.
  202. */
  203. void TIM14_IRQHandler(void)
  204. {
  205. /* USER CODE BEGIN TIM14_IRQn 0 */
  206. /* USER CODE END TIM14_IRQn 0 */
  207. /* USER CODE BEGIN TIM14_IRQn 1 */
  208. /* USER CODE END TIM14_IRQn 1 */
  209. }
  210. /**
  211. * @brief This function handles TIM16 global interrupt.
  212. */
  213. void TIM16_IRQHandler(void)
  214. {
  215. /* USER CODE BEGIN TIM16_IRQn 0 */
  216. /* USER CODE END TIM16_IRQn 0 */
  217. /* USER CODE BEGIN TIM16_IRQn 1 */
  218. /* USER CODE END TIM16_IRQn 1 */
  219. }
  220. /**
  221. * @brief This function handles TIM17 global interrupt.
  222. */
  223. void TIM17_IRQHandler(void)
  224. {
  225. /* USER CODE BEGIN TIM17_IRQn 0 */
  226. /* USER CODE END TIM17_IRQn 0 */
  227. /* USER CODE BEGIN TIM17_IRQn 1 */
  228. /* USER CODE END TIM17_IRQn 1 */
  229. }
  230. /**
  231. * @brief This function handles SPI1 global interrupt.
  232. */
  233. void SPI1_IRQHandler(void)
  234. {
  235. /* USER CODE BEGIN SPI1_IRQn 0 */
  236. /* USER CODE END SPI1_IRQn 0 */
  237. /* USER CODE BEGIN SPI1_IRQn 1 */
  238. /* USER CODE END SPI1_IRQn 1 */
  239. }
  240. /**
  241. * @brief This function handles USART1 global interrupt / USART1 wake-up interrupt through EXTI line 25.
  242. */
  243. void USART1_IRQHandler(void)
  244. {
  245. /* USER CODE BEGIN USART1_IRQn 0 */
  246. /* USER CODE END USART1_IRQn 0 */
  247. /* USER CODE BEGIN USART1_IRQn 1 */
  248. /* USER CODE END USART1_IRQn 1 */
  249. }
  250. /* USER CODE BEGIN 1 */
  251. /* USER CODE END 1 */
  252. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/