isr.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. * @file isr.c
  18. * @brief source file for the interrupt server route
  19. * @version V1.0
  20. * @date 02. June 2017
  21. ******************************************************************************/
  22. #include <csi_config.h>
  23. #include "wm_regs.h"
  24. #include "../../../../app/port/luat_conf_bsp.h"
  25. extern void systick_handler(void);
  26. extern void socv_SysTick_Handler(void);
  27. extern void xPortSysTickHandler(void);
  28. extern void OSTimeTick(void);
  29. extern void SDIOA_IRQHandler(void);
  30. extern void HSPI_IRQHandler(void);
  31. extern void TIMER0_5_IRQHandler(void);
  32. extern void CRYPTION_IRQHandler(void);
  33. extern void RSA_F_IRQHandler(void);
  34. extern void GPIO_UART0_IRQHandler(void);
  35. extern void tls_wl_mac_isr(void);
  36. extern void tls_wl_rx_isr(void);
  37. extern int csi_kernel_intrpt_enter(void);
  38. extern int csi_kernel_intrpt_exit(void);
  39. extern void PMU_TIMER0_IRQHandler(void);
  40. extern void PMU_TIMER1_IRQHandler(void);
  41. extern void PMU_GPIO_WAKE_IRQHandler(void);
  42. extern void PMU_RTC_IRQHandler(void);
  43. #define ATTRIBUTE_ISR __attribute__((isr))
  44. #define readl(addr) \
  45. ({ unsigned int __v = (*(volatile unsigned int *) (addr)); __v; })
  46. #ifndef CONFIG_KERNEL_NONE
  47. #define CSI_INTRPT_ENTER() csi_kernel_intrpt_enter()
  48. #define CSI_INTRPT_EXIT() csi_kernel_intrpt_exit()
  49. #else
  50. #define CSI_INTRPT_ENTER()
  51. #define CSI_INTRPT_EXIT()
  52. #endif
  53. //static int tick_test = 0;
  54. ATTRIBUTE_ISR void CORET_IRQHandler(void)
  55. {
  56. #if 0
  57. if (1000==tick_test)
  58. {
  59. tick_test = 2000;
  60. tls_watchdog_start_cal_elapsed_time();
  61. }
  62. else if (2000 == tick_test)
  63. {
  64. printf("tick=%u\r\n", tls_watchdog_stop_cal_elapsed_time());
  65. tick_test = 0;
  66. }
  67. else
  68. {
  69. tick_test++;
  70. }
  71. #endif
  72. #ifndef CONFIG_KERNEL_FREERTOS
  73. CSI_INTRPT_ENTER();
  74. #endif
  75. readl(0xE000E010);
  76. /*
  77. #ifdef TLS_CONFIG_FPGA
  78. socv_SysTick_Handler();
  79. #endif
  80. */
  81. #if defined(CONFIG_KERNEL_RHINO)
  82. systick_handler();
  83. #elif defined(CONFIG_KERNEL_FREERTOS)
  84. xPortSysTickHandler();
  85. #elif defined(CONFIG_KERNEL_UCOS)
  86. OSTimeTick();
  87. #endif
  88. #ifndef CONFIG_KERNEL_FREERTOS
  89. CSI_INTRPT_EXIT();
  90. #endif
  91. }
  92. ATTRIBUTE_ISR void SDIO_IRQHandler(void)
  93. {
  94. CSI_INTRPT_ENTER();
  95. #ifndef WM_WIFI_SIMULATION_PROJECT
  96. // SDIOA_IRQHandler();
  97. #endif
  98. CSI_INTRPT_EXIT();
  99. }
  100. ATTRIBUTE_ISR void GPSEC_IRQHandler(void)
  101. {
  102. CSI_INTRPT_ENTER();
  103. CRYPTION_IRQHandler();
  104. CSI_INTRPT_EXIT();
  105. }
  106. ATTRIBUTE_ISR void RSA_IRQHandler(void)
  107. {
  108. CSI_INTRPT_ENTER();
  109. RSA_F_IRQHandler();
  110. CSI_INTRPT_EXIT();
  111. }
  112. ATTRIBUTE_ISR void TIM0_5_IRQHandler(void)
  113. {
  114. CSI_INTRPT_ENTER();
  115. TIMER0_5_IRQHandler();
  116. CSI_INTRPT_EXIT();
  117. }
  118. ATTRIBUTE_ISR void SPI_HS_IRQHandler(void)
  119. {
  120. CSI_INTRPT_ENTER();
  121. #ifndef WM_WIFI_SIMULATION_PROJECT
  122. // HSPI_IRQHandler();
  123. #endif
  124. CSI_INTRPT_EXIT();
  125. }
  126. ATTRIBUTE_ISR void MAC_IRQHandler(void)
  127. {
  128. CSI_INTRPT_ENTER();
  129. #ifdef LUAT_USE_WLAN
  130. tls_wl_mac_isr();
  131. #endif
  132. CSI_INTRPT_EXIT();
  133. }
  134. ATTRIBUTE_ISR void SEC_IRQHandler(void)
  135. {
  136. CSI_INTRPT_ENTER();
  137. #ifdef LUAT_USE_WLAN
  138. tls_wl_rx_isr();
  139. #endif
  140. CSI_INTRPT_EXIT();
  141. }
  142. ATTRIBUTE_ISR void PMU_IRQHandler(void)
  143. {
  144. CSI_INTRPT_ENTER();
  145. #ifndef CONFIG_NO_WIFI
  146. #ifndef WM_WIFI_SIMULATION_PROJECT
  147. if (tls_reg_read32(HR_PMU_INTERRUPT_SRC) & BIT(0))
  148. {
  149. PMU_TIMER0_IRQHandler();
  150. }
  151. if (tls_reg_read32(HR_PMU_INTERRUPT_SRC) & BIT(1)) /* timer1 interrupt */
  152. {
  153. PMU_TIMER1_IRQHandler();
  154. }
  155. if (tls_reg_read32(HR_PMU_INTERRUPT_SRC) & BIT(2)) /* gpio wake interrupt */
  156. {
  157. PMU_GPIO_WAKE_IRQHandler();
  158. }
  159. if (tls_reg_read32(HR_PMU_INTERRUPT_SRC) & BIT(4)) /* rtc interrupt */
  160. {
  161. PMU_RTC_IRQHandler();
  162. }
  163. #endif
  164. #endif
  165. CSI_INTRPT_EXIT();
  166. }