1 /******************************************************************************
2 * Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved.
3 *
4 * This software is owned and published by:
5 * Huada Semiconductor Co.,Ltd ("HDSC").
6 *
7 * BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND
8 * BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT.
9 *
10 * This software contains source code for use with HDSC
11 * components. This software is licensed by HDSC to be adapted only
12 * for use in systems utilizing HDSC components. HDSC shall not be
13 * responsible for misuse or illegal use of this software for devices not
14 * supported herein. HDSC is providing this software "AS IS" and will
15 * not be responsible for issues arising from incorrect user implementation
16 * of the software.
17 *
18 * Disclaimer:
19 * HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE,
20 * REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS),
21 * ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING,
22 * WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED
23 * WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED
24 * WARRANTY OF NONINFRINGEMENT.
25 * HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT,
26 * NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT
27 * LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION,
28 * LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR
29 * INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT,
30 * INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA,
31 * SAVINGS OR PROFITS,
32 * EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
33 * YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR
34 * INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED
35 * FROM, THE SOFTWARE.
36 *
37 * This software may be replicated in part or whole for the licensed use,
38 * with the restriction that this Disclaimer and Copyright notice must be
39 * included with each copy of this software, whether used in part or whole,
40 * at all times.
41 */
42 /******************************************************************************/
43 /** \file interrupts_hc32l136.c
44  **
45  ** Interrupt management
46  ** @link Driver Group Some description @endlink
47  **
48  **   - 2018-04-15  1.0  Lux     First version.
49  **
50  **
51  ******************************************************************************/
52 
53 /*******************************************************************************
54  * Include files
55  ******************************************************************************/
56 #include "hc32l196_ddl.h"
57 #include "interrupts_hc32l19x.h"
58 
59 /*******************************************************************************
60  *                       IRQ WEAK DEFINE
61  ******************************************************************************/
62 __WEAK void SysTick_IRQHandler(void);
63 
PortA_IRQHandler(void)64 __WEAK void PortA_IRQHandler(void)
65 {
66 
67 }
68 
PortB_IRQHandler(void)69 __WEAK void PortB_IRQHandler(void)
70 {
71 
72 }
73 
PortC_IRQHandler(void)74 __WEAK void PortC_IRQHandler(void)
75 {
76 
77 }
78 
PortD_IRQHandler(void)79 __WEAK void PortD_IRQHandler(void)
80 {
81 
82 }
83 
PortE_IRQHandler(void)84 __WEAK void PortE_IRQHandler(void)
85 {
86 
87 }
88 
PortF_IRQHandler(void)89 __WEAK void PortF_IRQHandler(void)
90 {
91 
92 }
93 
Dmac_IRQHandler(void)94 __WEAK void Dmac_IRQHandler(void)
95 {
96 
97 }
98 
Tim3_IRQHandler(void)99 __WEAK void Tim3_IRQHandler(void)
100 {
101 
102 }
103 
104 
Uart0_IRQHandler(void)105 __WEAK void Uart0_IRQHandler(void)
106 {
107 
108 }
109 
Uart1_IRQHandler(void)110 __WEAK void Uart1_IRQHandler(void)
111 {
112 
113 }
114 
Uart2_IRQHandler(void)115 __WEAK void Uart2_IRQHandler(void)
116 {
117 
118 }
119 
Uart3_IRQHandler(void)120 __WEAK void Uart3_IRQHandler(void)
121 {
122 
123 }
124 
LpUart0_IRQHandler(void)125 __WEAK void LpUart0_IRQHandler(void)
126 {
127 
128 }
129 
LpUart1_IRQHandler(void)130 __WEAK void LpUart1_IRQHandler(void)
131 {
132 
133 }
134 
Spi0_IRQHandler(void)135 __WEAK void Spi0_IRQHandler(void)
136 {
137 
138 }
139 
Spi1_IRQHandler(void)140 __WEAK void Spi1_IRQHandler(void)
141 {
142 
143 }
144 
I2c0_IRQHandler(void)145 __WEAK void I2c0_IRQHandler(void)
146 {
147 
148 }
149 
I2c1_IRQHandler(void)150 __WEAK void I2c1_IRQHandler(void)
151 {
152 
153 }
154 
Tim0_IRQHandler(void)155 __WEAK void Tim0_IRQHandler(void)
156 {
157 
158 }
159 
Tim1_IRQHandler(void)160 __WEAK void Tim1_IRQHandler(void)
161 {
162 
163 }
164 
Tim2_IRQHandler(void)165 __WEAK void Tim2_IRQHandler(void)
166 {
167 
168 }
169 
LpTim0_IRQHandler(void)170 __WEAK void LpTim0_IRQHandler(void)
171 {
172 
173 }
174 
LpTim1_IRQHandler(void)175 __WEAK void LpTim1_IRQHandler(void)
176 {
177 
178 }
179 
Tim4_IRQHandler(void)180 __WEAK void Tim4_IRQHandler(void)
181 {
182 
183 }
184 
Tim5_IRQHandler(void)185 __WEAK void Tim5_IRQHandler(void)
186 {
187 
188 }
189 
Tim6_IRQHandler(void)190 __WEAK void Tim6_IRQHandler(void)
191 {
192 
193 }
194 
Pca_IRQHandler(void)195 __WEAK void Pca_IRQHandler(void)
196 {
197 
198 }
199 
Wdt_IRQHandler(void)200 __WEAK void Wdt_IRQHandler(void)
201 {
202 
203 }
204 
Rtc_IRQHandler(void)205 __WEAK void Rtc_IRQHandler(void)
206 {
207 
208 }
209 
Adc_IRQHandler(void)210 __WEAK void Adc_IRQHandler(void)
211 {
212 
213 }
214 
Dac_IRQHandler(void)215 __WEAK void Dac_IRQHandler(void)
216 {
217 
218 }
219 
Pcnt_IRQHandler(void)220 __WEAK void Pcnt_IRQHandler(void)
221 {
222 
223 }
224 
Vc0_IRQHandler(void)225 __WEAK void Vc0_IRQHandler(void)
226 {
227 
228 }
229 
Vc1_IRQHandler(void)230 __WEAK void Vc1_IRQHandler(void)
231 {
232 
233 }
234 
Vc2_IRQHandler(void)235 __WEAK void Vc2_IRQHandler(void)
236 {
237 
238 }
239 
Lvd_IRQHandler(void)240 __WEAK void Lvd_IRQHandler(void)
241 {
242 
243 }
244 
Lcd_IRQHandler(void)245 __WEAK void Lcd_IRQHandler(void)
246 {
247 
248 }
249 
Flash_IRQHandler(void)250 __WEAK void Flash_IRQHandler(void)
251 {
252 
253 }
254 
Ram_IRQHandler(void)255 __WEAK void Ram_IRQHandler(void)
256 {
257 
258 }
259 
ClkTrim_IRQHandler(void)260 __WEAK void ClkTrim_IRQHandler(void)
261 {
262 
263 }
264 
265 
266 /**
267  *******************************************************************************
268  ** \brief NVIC 中断使能
269  **
270  ** \param [in]  enIrq          中断号枚举类型
271  ** \param [in]  enLevel        中断优先级枚举类型
272  ** \param [in]  bEn            中断开关
273  ** \retval    Ok       设置成功
274  **            其他值   设置失败
275  ******************************************************************************/
EnableNvic(IRQn_Type enIrq,en_irq_level_t enLevel,boolean_t bEn)276 void EnableNvic(IRQn_Type enIrq, en_irq_level_t enLevel, boolean_t bEn)
277 {
278     NVIC_ClearPendingIRQ(enIrq);
279     NVIC_SetPriority(enIrq, enLevel);
280     if (TRUE == bEn)
281     {
282         NVIC_EnableIRQ(enIrq);
283     }
284     else
285     {
286         NVIC_DisableIRQ(enIrq);
287     }
288 }
289 
290 /**
291  *******************************************************************************
292  ** \brief NVIC hardware fault 中断实现
293  **
294  **
295  ** \retval
296  ******************************************************************************/
297 //void HardFault_Handler(void)
298 //{
299 //    volatile int a = 0;
300 
301 //    while( 0 == a)
302 //    {
303 //        ;
304 //    }
305 //
306 //}
307 
308 
309 /**
310  *******************************************************************************
311  ** \brief NVIC SysTick 中断实现
312  **
313  ** \retval
314  ******************************************************************************/
315 //void SysTick_Handler(void)
316 //{
317 //   SysTick_IRQHandler();
318 //}
319 
320 /**
321  *******************************************************************************
322  ** \brief GPIO PortA 中断处理函数
323  **
324  ** \retval
325  ******************************************************************************/
PORTA_IRQHandler(void)326 void PORTA_IRQHandler(void)
327 {
328 #if (INT_CALLBACK_ON == INT_CALLBACK_PORTA)
329     PortA_IRQHandler();
330 #endif
331 }
332 
333 /**
334  *******************************************************************************
335  ** \brief GPIO PortB 中断处理函数
336  **
337  ** \retval
338  ******************************************************************************/
PORTB_IRQHandler(void)339 void PORTB_IRQHandler(void)
340 {
341 #if (INT_CALLBACK_ON == INT_CALLBACK_PORTB)
342     PortB_IRQHandler();
343 #endif
344 }
345 
346 /**
347  *******************************************************************************
348  ** \brief GPIO PortC/E 中断处理函数
349  **
350  ** \retval
351  ******************************************************************************/
PORTC_E_IRQHandler(void)352 void PORTC_E_IRQHandler(void)
353 {
354 #if (INT_CALLBACK_ON == INT_CALLBACK_PORTC)
355     PortC_IRQHandler();
356 #endif
357 
358 #if (INT_CALLBACK_ON == INT_CALLBACK_PORTE)
359     PortE_IRQHandler();
360 #endif
361 }
362 
363 /**
364  *******************************************************************************
365  ** \brief GPIO PortD/F 中断处理函数
366  **
367  ** \retval
368  ******************************************************************************/
PORTD_F_IRQHandler(void)369 void PORTD_F_IRQHandler(void)
370 {
371 #if (INT_CALLBACK_ON == INT_CALLBACK_PORTD)
372     PortD_IRQHandler();
373 #endif
374 
375 #if (INT_CALLBACK_ON == INT_CALLBACK_PORTF)
376     PortF_IRQHandler();
377 #endif
378 }
379 
380 /**
381  *******************************************************************************
382  ** \brief DMAC  中断处理函数
383  **
384  ** \retval
385  ******************************************************************************/
DMAC_IRQHandler(void)386 void DMAC_IRQHandler(void)
387 {
388 #if (INT_CALLBACK_ON == INT_CALLBACK_DMAC)
389     Dmac_IRQHandler();
390 #endif
391 }
392 
393 /**
394  *******************************************************************************
395  ** \brief TIM3 中断处理函数
396  **
397  ** \retval
398  ******************************************************************************/
TIM3_IRQHandler(void)399 void TIM3_IRQHandler(void)
400 {
401 #if (INT_CALLBACK_ON == INT_CALLBACK_TIM3)
402     Tim3_IRQHandler();
403 #endif
404 }
405 
406 /**
407  *******************************************************************************
408  ** \brief UART0/2 中断处理函数
409  **
410  ** \retval
411  ******************************************************************************/
UART0_2_IRQHandler(void)412 void UART0_2_IRQHandler(void)
413 {
414 #if (INT_CALLBACK_ON == INT_CALLBACK_UART0)
415     Uart0_IRQHandler();
416 #endif
417 
418 #if (INT_CALLBACK_ON == INT_CALLBACK_UART2)
419     Uart2_IRQHandler();
420 #endif
421 }
422 
423 /**
424  *******************************************************************************
425  ** \brief UART1/3 中断处理函数
426  **
427  ** \retval
428  ******************************************************************************/
UART1_3_IRQHandler(void)429 void UART1_3_IRQHandler(void)
430 {
431 #if (INT_CALLBACK_ON == INT_CALLBACK_UART1)
432     Uart1_IRQHandler();
433 #endif
434 
435 #if (INT_CALLBACK_ON == INT_CALLBACK_UART3)
436     Uart3_IRQHandler();
437 #endif
438 }
439 
440 /**
441  *******************************************************************************
442  ** \brief LPUART0 低功耗串口0 中断处理函数
443  **
444  ** \retval
445  ******************************************************************************/
LPUART0_IRQHandler(void)446 void LPUART0_IRQHandler(void)
447 {
448 #if (INT_CALLBACK_ON == INT_CALLBACK_LPUART0)
449     LpUart0_IRQHandler();
450 #endif
451 }
452 
453 /**
454  *******************************************************************************
455  ** \brief LPUART1 低功耗串口1 中断处理函数
456  **
457  ** \retval
458  ******************************************************************************/
LPUART1_IRQHandler(void)459 void LPUART1_IRQHandler(void)
460 {
461 #if (INT_CALLBACK_ON == INT_CALLBACK_LPUART1)
462     LpUart1_IRQHandler();
463 #endif
464 }
465 
466 /**
467  *******************************************************************************
468  ** \brief SPI0 中断处理函数
469  **
470  ** \retval
471  ******************************************************************************/
SPI0_IRQHandler(void)472 void SPI0_IRQHandler(void)
473 {
474 #if (INT_CALLBACK_ON == INT_CALLBACK_SPI0)
475     Spi0_IRQHandler();
476 #endif
477 }
478 
479 /**
480  *******************************************************************************
481  ** \brief SPI1 中断处理函数
482  **
483  ** \retval
484  ******************************************************************************/
SPI1_IRQHandler(void)485 void SPI1_IRQHandler(void)
486 {
487 #if (INT_CALLBACK_ON == INT_CALLBACK_SPI1)
488     Spi1_IRQHandler();
489 #endif
490 }
491 
492 /**
493  *******************************************************************************
494  ** \brief I2C0 中断处理函数
495  **
496  ** \retval
497  ******************************************************************************/
I2C0_IRQHandler(void)498 void I2C0_IRQHandler(void)
499 {
500 #if (INT_CALLBACK_ON == INT_CALLBACK_I2C0)
501     I2c0_IRQHandler();
502 #endif
503 }
504 
505 /**
506  *******************************************************************************
507  ** \brief I2C1 中断处理函数
508  **
509  ** \retval
510  ******************************************************************************/
I2C1_IRQHandler(void)511 void I2C1_IRQHandler(void)
512 {
513 #if (INT_CALLBACK_ON == INT_CALLBACK_I2C1)
514     I2c1_IRQHandler();
515 #endif
516 }
517 
518 /**
519  *******************************************************************************
520  ** \brief TIM0 中断处理函数
521  **
522  ** \retval
523  ******************************************************************************/
TIM0_IRQHandler(void)524 void TIM0_IRQHandler(void)
525 {
526 #if (INT_CALLBACK_ON == INT_CALLBACK_TIM0)
527     Tim0_IRQHandler();
528 #endif
529 }
530 
531 /**
532  *******************************************************************************
533  ** \brief TIM1 中断处理函数
534  **
535  ** \retval
536  ******************************************************************************/
TIM1_IRQHandler(void)537 void TIM1_IRQHandler(void)
538 {
539 #if (INT_CALLBACK_ON == INT_CALLBACK_TIM1)
540     Tim1_IRQHandler();
541 #endif
542 }
543 
544 /**
545  *******************************************************************************
546  ** \brief TIM2 中断处理函数
547  **
548  ** \retval
549  ******************************************************************************/
TIM2_IRQHandler(void)550 void TIM2_IRQHandler(void)
551 {
552 #if (INT_CALLBACK_ON == INT_CALLBACK_TIM2)
553     Tim2_IRQHandler();
554 #endif
555 }
556 
557 /**
558  *******************************************************************************
559  ** \brief LPTIM0/1 低功耗时钟 中断处理函数
560  **
561  ** \retval
562  ******************************************************************************/
LPTIM0_1_IRQHandler(void)563 void LPTIM0_1_IRQHandler(void)
564 {
565 #if (INT_CALLBACK_ON == INT_CALLBACK_LPTIM0)
566     LpTim0_IRQHandler();
567 #endif
568 
569 #if (INT_CALLBACK_ON == INT_CALLBACK_LPTIM1)
570     LpTim1_IRQHandler();
571 #endif
572 }
573 
574 /**
575  *******************************************************************************
576  ** \brief TIM4 中断处理函数
577  **
578  ** \retval
579  ******************************************************************************/
TIM4_IRQHandler(void)580 void TIM4_IRQHandler(void)
581 {
582 #if (INT_CALLBACK_ON == INT_CALLBACK_TIM4)
583     Tim4_IRQHandler();
584 #endif
585 }
586 
587 /**
588  *******************************************************************************
589  ** \brief TIM5 中断处理函数
590  **
591  ** \retval
592  ******************************************************************************/
TIM5_IRQHandler(void)593 void TIM5_IRQHandler(void)
594 {
595 #if (INT_CALLBACK_ON == INT_CALLBACK_TIM5)
596     Tim5_IRQHandler();
597 #endif
598 }
599 
600 /**
601  *******************************************************************************
602  ** \brief TIM6 中断处理函数
603  **
604  ** \retval
605  ******************************************************************************/
TIM6_IRQHandler(void)606 void TIM6_IRQHandler(void)
607 {
608 #if (INT_CALLBACK_ON == INT_CALLBACK_TIM6)
609     Tim6_IRQHandler();
610 #endif
611 }
612 
613 /**
614  *******************************************************************************
615  ** \brief PCA 中断处理函数
616  **
617  ** \retval
618  ******************************************************************************/
PCA_IRQHandler(void)619 void PCA_IRQHandler(void)
620 {
621 #if (INT_CALLBACK_ON == INT_CALLBACK_PCA)
622     Pca_IRQHandler();
623 #endif
624 }
625 
626 /**
627  *******************************************************************************
628  ** \brief WDT 中断处理函数
629  **
630  ** \retval
631  ******************************************************************************/
WDT_IRQHandler(void)632 void WDT_IRQHandler(void)
633 {
634 #if (INT_CALLBACK_ON == INT_CALLBACK_WDT)
635     Wdt_IRQHandler();
636 #endif
637 }
638 
639 /**
640  *******************************************************************************
641  ** \brief RTC 中断处理函数
642  **
643  ** \retval
644  ******************************************************************************/
RTC_IRQHandler(void)645 void RTC_IRQHandler(void)
646 {
647 #if (INT_CALLBACK_ON == INT_CALLBACK_RTC)
648     Rtc_IRQHandler();
649 #endif
650 }
651 
652 /**
653  *******************************************************************************
654  ** \brief ADC/DAC 中断处理函数
655  **
656  ** \retval
657  ******************************************************************************/
ADC_DAC_IRQHandler(void)658 void ADC_DAC_IRQHandler(void)
659 {
660 #if (INT_CALLBACK_ON == INT_CALLBACK_ADC)
661     Adc_IRQHandler();
662 #endif
663 
664 #if (INT_CALLBACK_ON == INT_CALLBACK_DAC)
665     Dac_IRQHandler();
666 #endif
667 }
668 
669 /**
670  *******************************************************************************
671  ** \brief PCNT 中断处理函数
672  **
673  ** \retval
674  ******************************************************************************/
PCNT_IRQHandler(void)675 void PCNT_IRQHandler(void)
676 {
677 #if (INT_CALLBACK_ON == INT_CALLBACK_PCNT)
678     Pcnt_IRQHandler();
679 #endif
680 }
681 
682 /**
683  *******************************************************************************
684  ** \brief VC0 中断处理函数
685  **
686  ** \retval
687  ******************************************************************************/
VC0_IRQHandler(void)688 void VC0_IRQHandler(void)
689 {
690 #if (INT_CALLBACK_ON == INT_CALLBACK_VC0)
691     Vc0_IRQHandler();
692 #endif
693 }
694 
695 /**
696  *******************************************************************************
697  ** \brief VC1/2 中断处理函数
698  **
699  ** \retval
700  ******************************************************************************/
VC1_2_IRQHandler(void)701 void VC1_2_IRQHandler(void)
702 {
703 #if (INT_CALLBACK_ON == INT_CALLBACK_VC1)
704     Vc1_IRQHandler();
705 #endif
706 
707 #if (INT_CALLBACK_ON == INT_CALLBACK_VC2)
708     Vc2_IRQHandler();
709 #endif
710 }
711 
712 /**
713  *******************************************************************************
714  ** \brief LVD 中断处理函数
715  **
716  ** \retval
717  ******************************************************************************/
LVD_IRQHandler(void)718 void LVD_IRQHandler(void)
719 {
720 #if (INT_CALLBACK_ON == INT_CALLBACK_LVD)
721     Lvd_IRQHandler();
722 #endif
723 }
724 
725 /**
726  *******************************************************************************
727  ** \brief LCD 中断处理函数
728  **
729  ** \retval
730  ******************************************************************************/
LCD_IRQHandler(void)731 void LCD_IRQHandler(void)
732 {
733 #if (INT_CALLBACK_ON == INT_CALLBACK_LCD)
734     Lcd_IRQHandler();
735 #endif
736 }
737 
738 /**
739  *******************************************************************************
740  ** \brief FLASH/RAM 中断处理函数
741  **
742  ** \retval
743  ******************************************************************************/
FLASH_RAM_IRQHandler(void)744 void FLASH_RAM_IRQHandler(void)
745 {
746 #if (INT_CALLBACK_ON == INT_CALLBACK_FLASH)
747     Flash_IRQHandler();
748 #endif
749 
750 #if (INT_CALLBACK_ON == INT_CALLBACK_RAM)
751     Ram_IRQHandler();
752 #endif
753 }
754 
755 /**
756  *******************************************************************************
757  ** \brief CLKTRIM 中断处理函数
758  **
759  ** \retval
760  ******************************************************************************/
CLKTRIM_IRQHandler(void)761 void CLKTRIM_IRQHandler(void)
762 {
763 #if (INT_CALLBACK_ON == INT_CALLBACK_CLKTRIM)
764     ClkTrim_IRQHandler();
765 #endif
766 }
767 
768 /******************************************************************************/
769 /* EOF (not truncated)                                                        */
770 /******************************************************************************/
771