isr.c 4.3 KB

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