Advertisement
Guest User

it.c

a guest
Dec 16th, 2019
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.02 KB | None | 0 0
  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * @file stm32f4xx_it.c
  5. * @brief Interrupt Service Routines.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2019 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.  
  21. /* Includes ------------------------------------------------------------------*/
  22. #include "main.h"
  23. #include "stm32f4xx_it.h"
  24. /* Private includes ----------------------------------------------------------*/
  25. /* USER CODE BEGIN Includes */
  26. /* USER CODE END Includes */
  27.  
  28. /* Private typedef -----------------------------------------------------------*/
  29. /* USER CODE BEGIN TD */
  30.  
  31. /* USER CODE END TD */
  32.  
  33. /* Private define ------------------------------------------------------------*/
  34. /* USER CODE BEGIN PD */
  35.  
  36. /* USER CODE END PD */
  37.  
  38. /* Private macro -------------------------------------------------------------*/
  39. /* USER CODE BEGIN PM */
  40.  
  41. /* USER CODE END PM */
  42.  
  43. /* Private variables ---------------------------------------------------------*/
  44. /* USER CODE BEGIN PV */
  45.  
  46. /* USER CODE END PV */
  47.  
  48. /* Private function prototypes -----------------------------------------------*/
  49. /* USER CODE BEGIN PFP */
  50.  
  51. /* USER CODE END PFP */
  52.  
  53. /* Private user code ---------------------------------------------------------*/
  54. /* USER CODE BEGIN 0 */
  55.  
  56. /* USER CODE END 0 */
  57.  
  58. /* External variables --------------------------------------------------------*/
  59.  
  60. /* USER CODE BEGIN EV */
  61.  
  62. /* USER CODE END EV */
  63.  
  64. /******************************************************************************/
  65. /* Cortex-M4 Processor Interruption and Exception Handlers */
  66. /******************************************************************************/
  67. /**
  68. * @brief This function handles Non maskable interrupt.
  69. */
  70. void NMI_Handler(void)
  71. {
  72. /* USER CODE BEGIN NonMaskableInt_IRQn 0 */
  73.  
  74. /* USER CODE END NonMaskableInt_IRQn 0 */
  75. /* USER CODE BEGIN NonMaskableInt_IRQn 1 */
  76.  
  77. /* USER CODE END NonMaskableInt_IRQn 1 */
  78. }
  79.  
  80. /**
  81. * @brief This function handles Hard fault interrupt.
  82. */
  83. void HardFault_Handler(void)
  84. {
  85. /* USER CODE BEGIN HardFault_IRQn 0 */
  86.  
  87. /* USER CODE END HardFault_IRQn 0 */
  88. while (1)
  89. {
  90. /* USER CODE BEGIN W1_HardFault_IRQn 0 */
  91. /* USER CODE END W1_HardFault_IRQn 0 */
  92. }
  93. }
  94.  
  95. /**
  96. * @brief This function handles Memory management fault.
  97. */
  98. void MemManage_Handler(void)
  99. {
  100. /* USER CODE BEGIN MemoryManagement_IRQn 0 */
  101.  
  102. /* USER CODE END MemoryManagement_IRQn 0 */
  103. while (1)
  104. {
  105. /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */
  106. /* USER CODE END W1_MemoryManagement_IRQn 0 */
  107. }
  108. }
  109.  
  110. /**
  111. * @brief This function handles Pre-fetch fault, memory access fault.
  112. */
  113. void BusFault_Handler(void)
  114. {
  115. /* USER CODE BEGIN BusFault_IRQn 0 */
  116.  
  117. /* USER CODE END BusFault_IRQn 0 */
  118. while (1)
  119. {
  120. /* USER CODE BEGIN W1_BusFault_IRQn 0 */
  121. /* USER CODE END W1_BusFault_IRQn 0 */
  122. }
  123. }
  124.  
  125. /**
  126. * @brief This function handles Undefined instruction or illegal state.
  127. */
  128. void UsageFault_Handler(void)
  129. {
  130. /* USER CODE BEGIN UsageFault_IRQn 0 */
  131.  
  132. /* USER CODE END UsageFault_IRQn 0 */
  133. while (1)
  134. {
  135. /* USER CODE BEGIN W1_UsageFault_IRQn 0 */
  136. /* USER CODE END W1_UsageFault_IRQn 0 */
  137. }
  138. }
  139.  
  140. /**
  141. * @brief This function handles System service call via SWI instruction.
  142. */
  143. void SVC_Handler(void)
  144. {
  145. /* USER CODE BEGIN SVCall_IRQn 0 */
  146.  
  147. /* USER CODE END SVCall_IRQn 0 */
  148. /* USER CODE BEGIN SVCall_IRQn 1 */
  149.  
  150. /* USER CODE END SVCall_IRQn 1 */
  151. }
  152.  
  153. /**
  154. * @brief This function handles Debug monitor.
  155. */
  156. void DebugMon_Handler(void)
  157. {
  158. /* USER CODE BEGIN DebugMonitor_IRQn 0 */
  159.  
  160. /* USER CODE END DebugMonitor_IRQn 0 */
  161. /* USER CODE BEGIN DebugMonitor_IRQn 1 */
  162.  
  163. /* USER CODE END DebugMonitor_IRQn 1 */
  164. }
  165.  
  166. /**
  167. * @brief This function handles Pendable request for system service.
  168. */
  169. void PendSV_Handler(void)
  170. {
  171. /* USER CODE BEGIN PendSV_IRQn 0 */
  172.  
  173. /* USER CODE END PendSV_IRQn 0 */
  174. /* USER CODE BEGIN PendSV_IRQn 1 */
  175.  
  176. /* USER CODE END PendSV_IRQn 1 */
  177. }
  178.  
  179. /**
  180. * @brief This function handles System tick timer.
  181. */
  182. extern UART_HandleTypeDef uart;
  183. volatile int timer = 0;
  184. volatile int mode = 0;
  185.  
  186. void SysTick_Handler(void)
  187. {
  188. /* USER CODE BEGIN SysTick_IRQn 0 */
  189.  
  190. /* USER CODE END SysTick_IRQn 0 */
  191. HAL_IncTick();
  192. if(timer < 500) {
  193. if(mode == 0) {
  194. uint8_t buf = "S1";
  195. HAL_UART_Transmit_IT(&uart, buf , sizeof(buf));
  196. }
  197. else if(mode == 1){
  198. uint8_t buf = "S2";
  199. HAL_UART_Transmit_IT(&uart, buf , sizeof(buf));
  200. }
  201. else if(mode == 2){
  202. uint8_t buf = "R1";
  203. HAL_UART_Transmit_IT(&uart, buf , sizeof(buf));
  204. }
  205. else {
  206. uint8_t buf = "R2";
  207. HAL_UART_Transmit_IT(&uart, buf , sizeof(buf));
  208. }
  209. /* USER CODE BEGIN SysTick_IRQn 1 */
  210. }
  211. else {
  212. if(timer == 500)
  213. timer = 0;
  214. else
  215. timer++;
  216. }
  217.  
  218. /* USER CODE END SysTick_IRQn 1 */
  219. }
  220.  
  221. /******************************************************************************/
  222. /* STM32F4xx Peripheral Interrupt Handlers */
  223. /* Add here the Interrupt Handlers for the used peripherals. */
  224. /* For the available peripheral interrupt handler names, */
  225. /* please refer to the startup file (startup_stm32f4xx.s). */
  226. /******************************************************************************/
  227.  
  228. /* USER CODE BEGIN 1 */
  229.  
  230. /* USER CODE END 1 */
  231. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement