1 /* 2 * Copyright (C) 2017 C-SKY Microsystems Co., Ltd. All rights reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 /****************************************************************************** 18 * @file isr.c 19 * @brief source file for the interrupt server route 20 * @version V1.0 21 * @date 02. June 2017 22 ******************************************************************************/ 23 #include <csi_config.h> 24 #include "wm_config.h" 25 #include "wm_regs.h" 26 27 extern void systick_handler(void); 28 extern void socv_SysTick_Handler(void); 29 extern void xPortSysTickHandler(void); 30 extern void OSTimeTick(void); 31 extern void SDIOA_IRQHandler(void); 32 extern void HSPI_IRQHandler(void); 33 extern void TIMER0_5_IRQHandler(void); 34 extern void CRYPTION_IRQHandler(void); 35 extern void RSA_F_IRQHandler(void); 36 extern void GPIO_UART0_IRQHandler(void); 37 38 extern void tls_wl_mac_isr(void); 39 extern void tls_wl_rx_isr(void); 40 41 extern int csi_kernel_intrpt_enter(void); 42 extern int csi_kernel_intrpt_exit(void); 43 44 extern void PMU_TIMER0_IRQHandler(void); 45 extern void PMU_TIMER1_IRQHandler(void); 46 extern void PMU_GPIO_WAKE_IRQHandler(void); 47 extern void PMU_RTC_IRQHandler(void); 48 49 #define readl(addr) do { \ 50 unsigned int __v = (*(volatile unsigned int *) (addr)); __v; \ 51 }while (0) 52 53 #ifndef CONFIG_KERNEL_NONE 54 #define CSI_INTRPT_ENTER() csi_kernel_intrpt_enter() 55 #define CSI_INTRPT_EXIT() csi_kernel_intrpt_exit() 56 #else 57 #define CSI_INTRPT_ENTER() 58 #define CSI_INTRPT_EXIT() 59 #endif 60 csi_kernel_intrpt_enter(void)61int csi_kernel_intrpt_enter(void) 62 { 63 return 0; 64 } csi_kernel_intrpt_exit(void)65int csi_kernel_intrpt_exit(void) 66 { 67 return 0; 68 } HalPreInterruptHandler(uint32_t arg)69void HalPreInterruptHandler(uint32_t arg) 70 { 71 if (arg == 57) { 72 readl(0xE000E010); // clear tick irq 73 } 74 } 75 CORET_IRQ_Handler(void)76ATTRIBUTE_ISR void CORET_IRQ_Handler(void) 77 { 78 #ifndef CONFIG_KERNEL_FREERTOS 79 CSI_INTRPT_ENTER(); 80 #endif 81 82 readl(0xE000E010); // clear tick irq 83 84 #if defined(CONFIG_KERNEL_RHINO) 85 systick_handler(); 86 #elif defined(CONFIG_KERNEL_LITEOS) 87 OsTickHandler(); 88 #elif defined(CONFIG_KERNEL_FREERTOS) 89 xPortSysTickHandler(); 90 #elif defined(CONFIG_KERNEL_UCOS) 91 OSTimeTick(); 92 #endif 93 94 #ifndef CONFIG_KERNEL_FREERTOS 95 CSI_INTRPT_EXIT(); 96 #endif 97 } 98 SDIO_IRQ_Handler(void)99ATTRIBUTE_ISR void SDIO_IRQ_Handler(void) 100 { 101 CSI_INTRPT_ENTER(); 102 #ifndef WM_WIFI_SIMULATION_PROJECT 103 #endif 104 CSI_INTRPT_EXIT(); 105 } 106 GPSEC_IRQ_Handler(void)107ATTRIBUTE_ISR void GPSEC_IRQ_Handler(void) 108 { 109 CSI_INTRPT_ENTER(); 110 CRYPTION_IRQHandler(); 111 CSI_INTRPT_EXIT(); 112 } 113 RSA_IRQ_Handler(void)114ATTRIBUTE_ISR void RSA_IRQ_Handler(void) 115 { 116 CSI_INTRPT_ENTER(); 117 RSA_F_IRQHandler(); 118 CSI_INTRPT_EXIT(); 119 } 120 TIM0_5_IRQ_Handler(void)121ATTRIBUTE_ISR void TIM0_5_IRQ_Handler(void) 122 { 123 CSI_INTRPT_ENTER(); 124 TIMER0_5_IRQHandler(); 125 CSI_INTRPT_EXIT(); 126 } 127 SPI_HS_IRQ_Handler(void)128ATTRIBUTE_ISR void SPI_HS_IRQ_Handler(void) 129 { 130 CSI_INTRPT_ENTER(); 131 #ifndef WM_WIFI_SIMULATION_PROJECT 132 #endif 133 CSI_INTRPT_EXIT(); 134 } 135 MAC_IRQ_Handler(void)136ATTRIBUTE_ISR void MAC_IRQ_Handler(void) 137 { 138 CSI_INTRPT_ENTER(); 139 #ifndef CONFIG_NO_WIFI 140 tls_wl_mac_isr(); 141 #endif 142 CSI_INTRPT_EXIT(); 143 } 144 SEC_IRQ_Handler(void)145ATTRIBUTE_ISR void SEC_IRQ_Handler(void) 146 { 147 CSI_INTRPT_ENTER(); 148 #ifndef CONFIG_NO_WIFI 149 tls_wl_rx_isr(); 150 #endif 151 CSI_INTRPT_EXIT(); 152 } 153 PMU_IRQ_Handler(void)154ATTRIBUTE_ISR void PMU_IRQ_Handler(void) 155 { 156 CSI_INTRPT_ENTER(); 157 #ifndef CONFIG_NO_WIFI 158 #ifndef WM_WIFI_SIMULATION_PROJECT 159 if (tls_reg_read32(HR_PMU_INTERRUPT_SRC) & BIT(0)) { 160 PMU_TIMER0_IRQHandler(); 161 } 162 if (tls_reg_read32(HR_PMU_INTERRUPT_SRC) & BIT(1)) { /* timer1 interrupt */ 163 PMU_TIMER1_IRQHandler(); 164 } 165 if (tls_reg_read32(HR_PMU_INTERRUPT_SRC) & BIT(2)) { /* gpio wake interrupt */ 166 PMU_GPIO_WAKE_IRQHandler(); 167 } 168 if (tls_reg_read32(HR_PMU_INTERRUPT_SRC) & BIT(4)) { /* rtc interrupt */ 169 PMU_RTC_IRQHandler(); 170 } 171 #endif 172 #endif 173 CSI_INTRPT_EXIT(); 174 } 175 176