| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- #include <Myproject.h>
- /**
- @function LVW_TSD_INT
- @brief 芯片过温 芯片欠压故障中断
- @date 2025-11-01
- */
- void LVW_TSD_INT(void) interrupt 0
- {
- if (ReadBit(LVSR, LVWIF))
- {
- if (ReadBit(LVSR, LVWF))
- {
- FaultProcess();
- ClrBit(LVSR, LVWF);
- }
-
- ClrBit(LVSR, LVWIF);
- }
-
- if (TSDIF)
- { TSDIF = 0; }
- }
- /**
- @function EXTERN_INT0
- @brief 外部中断0 用于预驱故障检测 中断优先级最高
- @date 2025-11-01
- */
- void EXTERN_INT0(void) interrupt 1
- {
- if (IF0)
- {
- FaultProcess();
- mcFaultSource = FaultHardOVCurrent;
- IF0 = 0;
- }
- }
- /* -------------------------------------------------------------------------------------------------
- Function Name : void CMP3_INT(void)
- Description : CMP3:硬件比较器过流保护,关断输出,中断优先级最高
- Input : 无
- Output : 无
- -------------------------------------------------------------------------------------------------*/
- void CMP3_INT(void) interrupt 12
- {
- if (ReadBit(CMP_SR, CMP3IF))
- {
- FaultProcess(); // 关闭输出
- mcFaultSource = FaultHardOVCurrent; // 硬件过流保护
- ClrBit(CMP_SR, CMP3IF);
- }
- }
- /**
- @function DRV_ISR
- @brief FOC中断(Drv中断),每个载波周期执行一次,用于处理响应较高的程序,中断优先级第二。DCEN开了就会产生中断。
- @date 2025-11-01
- */
- void DRV_ISR(void) interrupt 3
- {
- if (ReadBit(DRV_SR, DCIF)) // 比较中断
- {
- Fault_Overcurrent(); //软件过流保护
- DRV_SR = (DRV_SR | SYSTIF) & (~DCIF);
- }
- }
- /**
- @function SYStick_INT
- @brief 定时器中断(SYS TICK中断)
- @date 2025-11-01
- */
- void SYStick_INT(void) interrupt 10
- {
- if (ReadBit(DRV_SR, SYSTIF)) // SYS TICK中断
- {
- IsTick = true;
-
- if (mcFocCtrl.State_Count)
- { mcFocCtrl.State_Count--; }
-
- DRV_SR = (DRV_SR | DCIF) & (~SYSTIF);// 清零标志位
- }
- }
- /**
- @function COM1_INT_Handler
- @brief I2C/UART1 共用此中断
- @date 2025-11-05
- */
- void COM1_INT_Handler(void) interrupt 13
- {
- if (TI)
- { TI = 0; }
-
- if (RI)
- { RI = 0; }
- }
- /**
- @function COM_INT_Handler
- @brief SPI/UART2/LIN 共用此中断
- @date 2025-11-05
- */
- void COM2_INT_Handler(void) interrupt 14
- {
- if (UT2TI)
- { UT2TI = 0; }
-
- if (UT2RI)
- { UT2RI = 0; }
- }
- /**
- @function DAM_INT_Handler
- @brief DMA中断函数
- @date 2025-11-05
- */
- void DAM_INT_Handler(void) interrupt 15
- {
- if (ReadBit(DMA0_CR0, DMAIF))
- {
- memset(&DebugDat, 0, 64);
- ClrBit(DMA0_CR0, DMAIF);
- }
-
- if (ReadBit(DMA1_CR0, DMAIF))
- {
- ClrBit(DMA1_CR0, DMAIF);
- }
- }
|