You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

122 lines
2.4 KiB

  1. /**
  2. * @file stm32f4xx_it.c
  3. * @brief STM32F407 中断服务程序。
  4. * @version 2.0
  5. * @author zengbingjie
  6. * @date 2026-07-29
  7. * @copyright 版权所有 (c) 2026 Xinje Electric。
  8. * @note 修改记录:2.0 适配 uC/OS-II 和 USART1 Modbus 中断。
  9. */
  10. #include "main.h"
  11. #include "stm32f4xx_it.h"
  12. /**
  13. * @brief 处理不可屏蔽中断。
  14. */
  15. void NMI_Handler(void)
  16. {
  17. while (1) {
  18. }
  19. }
  20. /**
  21. * @brief 处理硬件错误中断。
  22. */
  23. void HardFault_Handler(void)
  24. {
  25. while (1) {
  26. }
  27. }
  28. /**
  29. * @brief 处理内存管理错误中断。
  30. */
  31. void MemManage_Handler(void)
  32. {
  33. while (1) {
  34. }
  35. }
  36. /**
  37. * @brief 处理总线错误中断。
  38. */
  39. void BusFault_Handler(void)
  40. {
  41. while (1) {
  42. }
  43. }
  44. /**
  45. * @brief 处理用法错误中断。
  46. */
  47. void UsageFault_Handler(void)
  48. {
  49. while (1) {
  50. }
  51. }
  52. /**
  53. * @brief 处理系统服务调用中断。
  54. */
  55. void SVC_Handler(void)
  56. {
  57. }
  58. /**
  59. * @brief 处理调试监控中断。
  60. */
  61. void DebugMon_Handler(void)
  62. {
  63. }
  64. /**
  65. * @brief 处理 PendSV 上下文切换中断。
  66. */
  67. void PendSV_Handler(void)
  68. {
  69. }
  70. /**
  71. * @brief 处理 1 ms 系统节拍中断。
  72. * @note OS_CPU_SysTickHandler 封装了 uC/OS-II 的中断进入、节拍和退出顺序;
  73. * 不得在此处改为手工调用 OSIntEnter、OSTimeTick 和 OSIntExit。
  74. */
  75. void SysTick_Handler(void)
  76. {
  77. /* HAL 维护毫秒级时间基准,uC/OS-II 维护任务延时和超时。
  78. * OS 移植层封装了这个共享节拍所需的中断嵌套和调度记录。 */
  79. HAL_IncTick();
  80. if (OSRunning == OS_TRUE)
  81. {
  82. OS_CPU_SysTickHandler();
  83. }
  84. }
  85. /**
  86. * @brief 处理 Modbus RTU T1.5/T3.5 单次静默计时中断。
  87. * @note 中断仅推进帧边界状态机;完整帧通过信号量交给 Modbus 任务处理。
  88. */
  89. void TIM5_IRQHandler(void)
  90. {
  91. /* TIM5 中断只推进 RTU T1.5/T3.5 帧边界状态机。在这里解析帧或访问应用数据,
  92. * 会使中断执行时间不可控。 */
  93. OSIntEnter();
  94. AppModbusRtuTimerIrqHandler();
  95. OSIntExit();
  96. }
  97. /**
  98. * @brief 处理 USART1 的 Modbus 收发中断。
  99. * @note HAL 回调只接收字节或登记恢复请求,不在中断上下文解析协议或等待发送。
  100. */
  101. void USART1_IRQHandler(void)
  102. {
  103. /* HAL 会分发接收完成、发送完成和 UART 错误回调。回调只记录状态并通知任务,
  104. * 不阻塞,也不解析 ADU。 */
  105. OSIntEnter();
  106. HAL_UART_IRQHandler(&Uart1Handle);
  107. OSIntExit();
  108. }