gd_int.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. /*!
  2. *******************************************************************************
  3. **
  4. ** \file gd_int.h
  5. **
  6. ** \brief INT (interrupt) driver
  7. **
  8. ** This driver provides functions and structures required to
  9. ** access the GK6202 interrupt engine.
  10. **
  11. ** Copyright: 2012 - 2013 (C) GoKe Microelectronics ShangHai Branch
  12. **
  13. ** \attention THIS SAMPLE CODE IS PROVIDED AS IS. GOKE MICROELECTRONICS
  14. ** ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR
  15. ** OMMISSIONS.
  16. **
  17. ** \version
  18. **
  19. ******************************************************************************/
  20. #ifndef GD_INT_H
  21. #define GD_INT_H
  22. #include <gtypes.h>
  23. #include <gmodids.h>
  24. #define GD_VIC_INSTANCES 2
  25. #define GD_INT_VEC_OFFSET 32
  26. /*---------------------------------------------------------------------------*/
  27. /* constants and macros */
  28. /*---------------------------------------------------------------------------*/
  29. #define GD_INT_ERR_BASE (GD_INT_MODULE_ID<<16) //!< The INT base error code.
  30. /*!
  31. *******************************************************************************
  32. **
  33. ** \anchor int_defines
  34. ** \name interrupt driver specific macros
  35. **
  36. ** This section defines various macros required to control interrupts.
  37. **
  38. ******************************************************************************/
  39. /*@{*/
  40. #define GD_INT_NO_INVERT_IRQ 0 //!< The IRQ signal is not inverted.
  41. #define GD_INT_INVERT_IRQ 1 //!< The IRQ signal is inverted.
  42. #define GD_INT_LOW_PRIORITY 0 //!< Fast Interrupt Request (FIQ) for fast, low latency interrupt handling
  43. #define GD_INT_MID_PRIORITY 1 //!< Interrupt Request (IRQ) for more general interrupts
  44. #define GD_INT_DISABLED 0 //!< Interrupts are disabled.
  45. #define GD_INT_ENABLED 1 //!< Interrupts are enabled.
  46. /*@}*/
  47. #define GD_INT_RISING_EDGE 0
  48. #define GD_INT_FALLING_EDGE 1
  49. #define GD_INT_BOTH_EDGES 2
  50. #define GD_INT_LEVEL_LOW 3
  51. #define GD_INT_LEVEL_HIGH 4
  52. /*!
  53. *******************************************************************************
  54. **
  55. ** \brief Interrupt vectors
  56. **
  57. ** The list below describes all available interrupt sources,
  58. ** a table containing the real interrupt service routines can
  59. ** be stored in the ARC aux. register 0x0203.
  60. **
  61. ** The first three interrupt vectors are non-maskable, their
  62. ** priorty is high.
  63. ** All other interrupts are maskable and the priority can be set
  64. ** either to medium (1) or low (2).
  65. **
  66. ******************************************************************************/
  67. enum
  68. {
  69. GD_INT_RESERVED1_00_IRQ = 0, //!<
  70. GD_INT_ETH_IRQ = 1, //!< level, Ethernet 1
  71. GD_INT_IDSP_ERROR_IRQ = 2, //!< edge, iDSP error
  72. GD_INT_XIU_TIMEOUT_IRQ = 3, //!< edge
  73. GD_INT_RESERVED1_04_IRQ = 4, //!<
  74. GD_INT_RESERVED1_05_IRQ = 5, //!<
  75. GD_INT_RESERVED1_06_IRQ = 6, //!<
  76. GD_INT_CODING_ORC_VOUT1_IRQ =7, //!< edge, Coding Orc VOUT1
  77. GD_INT_SD_CONTROLLER_IRQ = 8, //!< level, SD controller
  78. GD_INT_IDC_IRQ = 9, //!< level, i2c read/write, I2C0
  79. GD_INT_SSI_SPI_IRQ = 10, //!< level, Synchronous Serial Interface (SSI, SPI)
  80. GD_INT_WDT_IRQ = 11, //!< edge, Watchdog (WDT)
  81. GD_INT_RESERVED1_12_IRQ = 12, //!<
  82. GD_INT_SD2_CARD_DETECT_IRQ = 13, //!<
  83. GD_INT_SD_CARD_DETECT_IRQ = 14, //!< Both edges, SD card detect (state of SMIO5 pin)
  84. GD_INT_UART1_IRQ = 15, //!< level, uart read/write, UART1
  85. GD_INT_GPIO0_IRQ = 16, //!< level, GPIO0
  86. GD_INT_RESERVED1_17_IRQ = 17, //!< level, UART2
  87. GD_INT_TIMER1_IRQ = 18, //!< edge, timer#1
  88. GD_INT_TIMER2_IRQ = 19, //!< edge, timer#2
  89. GD_INT_TIMER3_IRQ = 20, //!< edge, timer#3
  90. GD_INT_DMA_IRQ = 21, //!< level, DMA
  91. GD_INT_SD2_CONTROLLER_IRQ = 22, //!< level, SD2 controller
  92. GD_INT_RESERVED1_23_IRQ = 23, //!<
  93. GD_INT_CODING_ORC_VIN_IRQ = 24, //!< edge, Coding Orc VIN
  94. GD_INT_CORDING_ORC_VDSP_IRQ = 25, //!< edge, Cording Orc vDSP
  95. GD_INT_USB_IRQ = 26, //!< level, USB
  96. GD_INT_UART2_IRQ = 27, //!<
  97. GD_INT_RESERVED1_28_IRQ = 28, //!<
  98. GD_INT_AUDIO_I2S_TX_IRQ = 29, //!< level, Audio (I2S) TX
  99. GD_INT_AUDIO_I2S_RX_IRQ = 30, //!< level, Audio (I2S) RX
  100. GD_INT_UART_IRQ = 31, //!< level, UART0
  101. #if (GD_VIC_INSTANCES >= 2)
  102. GD_INT_RESERVED2_00_IRQ = ( 0 + 32), //!<
  103. GD_INT_RESERVED2_01_IRQ = ( 1 + 32), //!<
  104. GD_INT_RESERVED2_02_IRQ = ( 2 + 32), //!<
  105. GD_INT_RESERVED2_03_IRQ = ( 3 + 32), //!<
  106. GD_INT_RESERVED2_04_IRQ = ( 4 + 32), //!<
  107. GD_INT_RESERVED2_05_IRQ = ( 5 + 32), //!<
  108. GD_INT_RESERVED2_06_IRQ = ( 6 + 32), //!<
  109. GD_INT_RESERVED2_07_IRQ = ( 7 + 32), //!<
  110. GD_INT_AUDIO_PHY_TX_IRQ = ( 8 + 32), //!<level, Audio PHY TX INT
  111. GD_INT_AUDIO_PHY_RX_IRQ = ( 9 + 32), //!<level, Audio PHY RX INT
  112. GD_INT_RESERVED2_10_IRQ = (10 + 32), //!<
  113. GD_INT_RESERVED2_11_IRQ = (11 + 32), //!<
  114. GD_INT_RESERVED2_12_IRQ = (12 + 32), //!<
  115. GD_INT_RESERVED2_13_IRQ = (13 + 32), //!<
  116. GD_INT_RESERVED2_14_IRQ = (14 + 32), //!<
  117. GD_INT_RESERVED2_15_IRQ = (15 + 32), //!<
  118. GD_INT_RESERVED2_16_IRQ = (16 + 32), //!<
  119. GD_INT_RESERVED2_17_IRQ = (17 + 32), //!<*/
  120. GD_INT_CODING_ORC_VOUT0_IRQ=(18 + 32), //!< edge, Coding Orc VOUT0
  121. GD_INT_AES_OUTPUT_READY_IRQ=(19 + 32), //!< edge, AES output ready from Crypt block--AES finished
  122. GD_INT_DES_OUTPUT_READY_IRQ=(20 + 32), //!< edge, DES output ready from Crypt block--DES finished
  123. GD_INT_RESERVED2_21_IRQ = (21 + 32), //!<
  124. GD_INT_GDMA_COMPLETION_IRQ = (22 + 32), //!<edge, GDMA Completion
  125. GD_INT_RESERVED2_23_IRQ = (23 + 32), //!<
  126. GD_INT_ADC_LEVEL_CHANGE_IRQ=(24 + 32), //!< level, ADC level change
  127. GD_INT_RESERVED2_25_IRQ = (25 + 32), //!<
  128. GD_INT_IDC2_IRQ = (26 + 32), //!< level, IDC2
  129. GD_INT_IDSP_LAST_PIXEL_IRQ= (27 + 32), //!< edge, iDSP last pixel
  130. GD_INT_IDSP_VSYNC_IRQ = (28 + 32), //!< edge, iDSP Vsync (VIN on master mode)
  131. GD_INT_IDSP_SENSOR_VSYNC_IRQ=(29+ 32), //!< edge, iDSP sensor Vsync (VIN on slave mode)
  132. GD_INT_PMU_IRQ = (30 + 32), //!< level, PMU
  133. GD_INT_SSI2_IRQ = (31 + 32), //!< level, SSI2
  134. #endif
  135. };
  136. // modify for rtos
  137. #define GD_INT_LAST_IRQ (31 + 32)
  138. /*---------------------------------------------------------------------------*/
  139. /* types, enums and structures */
  140. /*---------------------------------------------------------------------------*/
  141. /*!
  142. *******************************************************************************
  143. **
  144. ** \brief Interrupt initialization parameter structure.
  145. **
  146. ** \sa GD_INT_Init()
  147. **
  148. ******************************************************************************/
  149. typedef struct
  150. {
  151. void (*resetFct)(void); //!< The reset handler.
  152. void (*memExceptionFct)(void); //!< The memory exception handler.
  153. void (*instructErrorFct)(void); //!< The Instruction Error handler.
  154. } GD_INT_INIT_PARAMS_S;
  155. /*!
  156. *******************************************************************************
  157. **
  158. ** \brief Interrupt driver open parameter structure.
  159. **
  160. ** \sa GD_INT_Open()
  161. **
  162. ******************************************************************************/
  163. typedef struct
  164. {
  165. S8 type; //!< the interrupt vector to access
  166. S8 active; //!< activation, either GD_INT_INVERT_IRQ or GD_INT_NO_INVERT_IRQ
  167. S8 sensitivity; //!< sensitivity, GD_INT_RISING_EDGE or GD_INT_FALLING_EDGE
  168. //!< or GD_INT_BOTH_EDGES or GD_INT_LEVEL_LOW or GD_INT_LEVEL_HIGH
  169. S8 priority; //!< priority, either GD_INT_MID_PRIORITY or GD_INT_LOW_PRIORITY
  170. union
  171. {
  172. GISR1 (*lowPrio)(void);
  173. GISR2 (*midPrio)(void);
  174. }isrFct; //!< the interrupt service function
  175. } GD_INT_OPEN_PARAMS_S;
  176. /*!
  177. *******************************************************************************
  178. **
  179. ** \brief Interrupt processor function type.
  180. **
  181. ******************************************************************************/
  182. /*! Pointer to the interrupt handler function of the driver. */
  183. typedef GISR1(*GD_ARM_INTR_IsrFuncT)(void);
  184. /*! //!< Pointer to the processing function of the driver. */
  185. typedef void(*GD_INT_PROCESSOR_F)(void* data);
  186. /*!
  187. *******************************************************************************
  188. **
  189. ** \brief Interrupt driver data structure
  190. **
  191. ******************************************************************************/
  192. typedef struct
  193. {
  194. U32 length; //!< The length of the driver data in bytes.
  195. void* data; //!< Pointer to driver specific data structure.
  196. GD_INT_PROCESSOR_F processor; //!< Pointer to interrupt processing function.
  197. } GD_INT_DATA_S;
  198. /*!
  199. *******************************************************************************
  200. **
  201. ** \brief Interrupt handler function type
  202. **
  203. ******************************************************************************/
  204. /*! Pointer to the interrupt handler function of the driver. */
  205. typedef GD_INT_DATA_S*(*GD_INT_HANDLER_F)(void);
  206. /*---------------------------------------------------------------------------*/
  207. /* function prototypes */
  208. /*---------------------------------------------------------------------------*/
  209. #ifdef __cplusplus
  210. extern "C" {
  211. #endif
  212. void GD_INT_Close(GD_HANDLE *handleP);
  213. GERR GD_INT_Init(GD_INT_INIT_PARAMS_S *initParams);
  214. GERR GD_INT_Open(GD_INT_OPEN_PARAMS_S *openParams, GD_HANDLE *handle);
  215. void GD_INT_GetIrqSettings(S8 type, S8 *prio, S8 *act, S8 *sens, S8 *mask);
  216. U32 GD_INT_GetUsedIrqs(void);
  217. void GD_INT_SetInterruptTrigger(S8 vec);
  218. void GD_INT_SetVector(S8 vector, void (*target)());
  219. void GD_INT_SetHandler(S8 vector, GD_INT_HANDLER_F handler);
  220. GD_INT_HANDLER_F GD_INT_GetHandler(S8 vector);
  221. void GD_INT_InvalidateDataCache(void);
  222. void GD_INT_InvalidateInstructionCache(void);
  223. void GD_INT_Enable(GD_HANDLE *handleP,U8 enable);
  224. void GD_INT_DisableAllInterrupts(void);
  225. void GD_INT_EnableAllInterrupts(void);
  226. void GD_IRQ_ISR(void);
  227. void GD_FIQ_ISR(void);
  228. #ifdef __cplusplus
  229. }
  230. #endif
  231. #endif
  232. /* end of gd_int.h */