1 /* 2 * Copyright (C) 2017-2019 Alibaba Group Holding Limited 3 */ 4 5 /****************************************************************************** 6 * @file drv_intc.h 7 * @brief header file for intc driver 8 * @version V1.0 9 * @date 02. June 2017 10 * @model intc 11 ******************************************************************************/ 12 13 #ifndef _CSI_INTC_H_ 14 #define _CSI_INTC_H_ 15 16 17 #include <stdint.h> 18 #include <drv/common.h> 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 typedef enum int_trigger_mode_t { 24 INT_MODE_LOW_LEVEL, 25 INT_MODE_HIGH_LEVEL, 26 INT_MODE_RISING_EDGE, 27 INT_MODE_FALLING_EDGE, 28 INT_MODE_DOUBLE_EDGE, 29 } 30 int_trigger_mode_t; 31 32 /** 33 \brief initialize the INTC interrupt controller 34 \param [in] prio_bits the priority bits of INTC interrupt controller. 35 */ 36 void csi_intc_init(void); 37 38 /** 39 \brief Enable External Interrupt 40 \details Enables a device-specific interrupt in the INTC interrupt controller. 41 \param [in] IRQn External interrupt number. Value cannot be negative. 42 */ 43 void csi_intc_enable_irq(int32_t IRQn); 44 45 /** 46 \brief Disable External Interrupt 47 \details Disables a device-specific interrupt in the INTC interrupt controller. 48 \param [in] IRQn External interrupt number. Value cannot be negative. 49 */ 50 void csi_intc_disable_irq(int32_t IRQn); 51 52 /** 53 \brief Get Pending Interrupt 54 \details Reads the pending register in the INTC and returns the pending bit for the specified interrupt. 55 \param [in] IRQn Interrupt number. 56 \return 0 Interrupt status is not pending. 57 \return 1 Interrupt status is pending. 58 */ 59 uint32_t csi_intc_get_pending_irq(int32_t IRQn); 60 61 /** 62 \brief Set Pending Interrupt 63 \details Sets the pending bit of an external interrupt. 64 \param [in] IRQn Interrupt number. Value cannot be negative. 65 */ 66 void csi_intc_set_pending_irq(int32_t IRQn); 67 68 /** 69 \brief Clear Pending Interrupt 70 \details Clears the pending bit of an external interrupt. 71 \param [in] IRQn External interrupt number. Value cannot be negative. 72 */ 73 void csi_intc_clear_pending_irq(int32_t IRQn); 74 75 /** 76 \brief Get Wake up Interrupt 77 \details Reads the wake up register in the INTC and returns the pending bit for the specified interrupt. 78 \param [in] IRQn Interrupt number. 79 \return 0 Interrupt is not set as wake up interrupt. 80 \return 1 Interrupt is set as wake up interrupt. 81 */ 82 uint32_t csi_intc_get_wakeup_irq(int32_t IRQn); 83 84 /** 85 \brief Set Wake up Interrupt 86 \details Sets the wake up bit of an external interrupt. 87 \param [in] IRQn Interrupt number. Value cannot be negative. 88 */ 89 void csi_intc_set_wakeup_irq(int32_t IRQn); 90 91 /** 92 \brief Clear Wake up Interrupt 93 \details Clears the wake up bit of an external interrupt. 94 \param [in] IRQn External interrupt number. Value cannot be negative. 95 */ 96 void csi_intc_clear_wakeup_irq(int32_t IRQn); 97 98 /** 99 \brief Get Active Interrupt 100 \details Reads the active register in the INTC and returns the active bit for the device specific interrupt. 101 \param [in] IRQn Device specific interrupt number. 102 \return 0 Interrupt status is not active. 103 \return 1 Interrupt status is active. 104 \note IRQn must not be negative. 105 */ 106 uint32_t csi_intc_get_active(int32_t IRQn); 107 108 /** 109 \brief Set Threshold register 110 \details set the threshold register in the INTC. 111 \param [in] VectThreshold specific vecter threshold. 112 \param [in] PrioThreshold specific priority threshold. 113 */ 114 void csi_intc_set_threshold(uint32_t VectThreshold, uint32_t PrioThreshold); 115 116 /** 117 \brief Set Interrupt Priority 118 \details Sets the priority of an interrupt. 119 \note The priority cannot be set for every core interrupt. 120 \param [in] IRQn Interrupt number. 121 \param [in] priority Priority to set. 122 */ 123 void csi_intc_set_prio(int32_t IRQn, uint32_t priority); 124 125 /** 126 \brief Get Interrupt Priority 127 \details Reads the priority of an interrupt. 128 The interrupt number can be positive to specify an external (device specific) interrupt, 129 or negative to specify an internal (core) interrupt. 130 \param [in] IRQn Interrupt number. 131 \return Interrupt Priority. 132 Value is aligned automatically to the implemented priority bits of the microcontroller. 133 */ 134 uint32_t csi_intc_get_prio(int32_t IRQn); 135 136 /** 137 \brief funciton is acknowledge the IRQ. this interface is internally used by irq system 138 \param[in] irq irq number to operate 139 \return 0 on success; -1 on failure 140 */ 141 int csi_intc_ack_irq(int32_t IRQn); 142 143 /** 144 \briefThis function is set the attributes of an IRQ. 145 \param[in] irq irq number to operate 146 \param[in] priority interrupt priority 147 \param[in] trigger_mode interrupt trigger_mode 148 \return 0 on success; -1 on failure 149 */ 150 int csi_intc_set_attribute(int32_t IRQn, uint32_t priority, int_trigger_mode_t trigger_mode); 151 152 /** 153 \brief Set interrupt handler 154 \details Set the interrupt handler according to the interrupt num, the handler will be filled in g_irqvector[]. 155 \param [in] IRQn Interrupt number. 156 \param [in] handler Interrupt handler. 157 */ 158 void csi_intc_set_vector(int32_t IRQn, uint32_t handler); 159 160 /** 161 \brief Get interrupt handler 162 \details Get the address of interrupt handler function. 163 \param [in] IRQn Interrupt number. 164 */ 165 uint32_t csi_intc_get_vector(int32_t IRQn); 166 167 #endif /* _CSI_INTC_H_ */ 168 169