2 * Copyright (C) 2017 C-SKY Microsystems Co., Ltd. All rights reserved.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 /******************************************************************************
18 * @brief header file for intc driver
21 ******************************************************************************/
31 #include <drv_common.h>
33 typedef enum int_trigger_mode_t
38 INT_MODE_FALLING_EDGE,
43 \brief initialize the INTC interrupt controller
44 \param [in] prio_bits the priority bits of INTC interrupt controller.
46 void csi_intc_init(void);
49 \brief Enable External Interrupt
50 \details Enables a device-specific interrupt in the INTC interrupt controller.
51 \param [in] IRQn External interrupt number. Value cannot be negative.
53 void csi_intc_enable_irq(int32_t IRQn);
56 \brief Disable External Interrupt
57 \details Disables a device-specific interrupt in the INTC interrupt controller.
58 \param [in] IRQn External interrupt number. Value cannot be negative.
60 void csi_intc_disable_irq(int32_t IRQn);
63 \brief Get Pending Interrupt
64 \details Reads the pending register in the INTC and returns the pending bit for the specified interrupt.
65 \param [in] IRQn Interrupt number.
66 \return 0 Interrupt status is not pending.
67 \return 1 Interrupt status is pending.
69 uint32_t csi_intc_get_pending_irq(int32_t IRQn);
72 \brief Set Pending Interrupt
73 \details Sets the pending bit of an external interrupt.
74 \param [in] IRQn Interrupt number. Value cannot be negative.
76 void csi_intc_set_pending_irq(int32_t IRQn);
79 \brief Clear Pending Interrupt
80 \details Clears the pending bit of an external interrupt.
81 \param [in] IRQn External interrupt number. Value cannot be negative.
83 void csi_intc_clear_pending_irq(int32_t IRQn);
86 \brief Get Wake up Interrupt
87 \details Reads the wake up register in the INTC and returns the pending bit for the specified interrupt.
88 \param [in] IRQn Interrupt number.
89 \return 0 Interrupt is not set as wake up interrupt.
90 \return 1 Interrupt is set as wake up interrupt.
92 uint32_t csi_intc_get_wakeup_irq(int32_t IRQn);
95 \brief Set Wake up Interrupt
96 \details Sets the wake up bit of an external interrupt.
97 \param [in] IRQn Interrupt number. Value cannot be negative.
99 void csi_intc_set_wakeup_irq(int32_t IRQn);
102 \brief Clear Wake up Interrupt
103 \details Clears the wake up bit of an external interrupt.
104 \param [in] IRQn External interrupt number. Value cannot be negative.
106 void csi_intc_clear_wakeup_irq(int32_t IRQn);
109 \brief Get Active Interrupt
110 \details Reads the active register in the INTC and returns the active bit for the device specific interrupt.
111 \param [in] IRQn Device specific interrupt number.
112 \return 0 Interrupt status is not active.
113 \return 1 Interrupt status is active.
114 \note IRQn must not be negative.
116 uint32_t csi_intc_get_active(int32_t IRQn);
119 \brief Set Threshold register
120 \details set the threshold register in the INTC.
121 \param [in] VectThreshold specific vecter threshold.
122 \param [in] PrioThreshold specific priority threshold.
124 void csi_intc_set_threshold(uint32_t VectThreshold, uint32_t PrioThreshold);
127 \brief Set Interrupt Priority
128 \details Sets the priority of an interrupt.
129 \note The priority cannot be set for every core interrupt.
130 \param [in] IRQn Interrupt number.
131 \param [in] priority Priority to set.
133 void csi_intc_set_prio(int32_t IRQn, uint32_t priority);
136 \brief Get Interrupt Priority
137 \details Reads the priority of an interrupt.
138 The interrupt number can be positive to specify an external (device specific) interrupt,
139 or negative to specify an internal (core) interrupt.
140 \param [in] IRQn Interrupt number.
141 \return Interrupt Priority.
142 Value is aligned automatically to the implemented priority bits of the microcontroller.
144 uint32_t csi_intc_get_prio(int32_t IRQn);
147 \brief funciton is acknowledge the IRQ. this interface is internally used by irq system
148 \param[in] irq irq number to operate
149 \return 0 on success; -1 on failure
151 int csi_intc_ack_irq(int32_t IRQn);
154 \briefThis function is set the attributes of an IRQ.
155 \param[in] irq irq number to operate
156 \param[in] priority interrupt priority
157 \param[in] trigger_mode interrupt trigger_mode
158 \return 0 on success; -1 on failure
160 int csi_intc_set_attribute(int32_t IRQn, uint32_t priority,int_trigger_mode_t trigger_mode);
162 #endif /* _CSI_INTC_H_ */