]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/T-HEAD_CB2201_CDK/csi/csi_driver/include/drv_intc.h
Introduce a port for T-HEAD CK802. A simple demo for T-HEAD CB2201 is also included.
[freertos] / FreeRTOS / Demo / T-HEAD_CB2201_CDK / csi / csi_driver / include / drv_intc.h
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     drv_intc.h
18  * @brief    header file for intc driver
19  * @version  V1.0
20  * @date     02. June 2017
21  ******************************************************************************/
22
23 #ifndef _CSI_INTC_H_
24 #define _CSI_INTC_H_
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 #include <stdint.h>
31 #include <drv_common.h>
32
33 typedef enum int_trigger_mode_t
34 {
35     INT_MODE_LOW_LEVEL,
36     INT_MODE_HIGH_LEVEL,
37     INT_MODE_RISING_EDGE,
38     INT_MODE_FALLING_EDGE,
39     INT_MODE_DOUBLE_EDGE,
40 } int_trigger_mode_t;
41
42 /**
43   \brief   initialize the INTC interrupt controller
44   \param [in]      prio_bits  the priority bits of INTC interrupt controller.
45  */
46 void csi_intc_init(void);
47
48 /**
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.
52  */
53 void csi_intc_enable_irq(int32_t IRQn);
54
55 /**
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.
59  */
60 void csi_intc_disable_irq(int32_t IRQn);
61
62 /**
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.
68  */
69 uint32_t csi_intc_get_pending_irq(int32_t IRQn);
70
71 /**
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.
75  */
76 void csi_intc_set_pending_irq(int32_t IRQn);
77
78 /**
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.
82  */
83 void csi_intc_clear_pending_irq(int32_t IRQn);
84
85 /**
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.
91  */
92 uint32_t csi_intc_get_wakeup_irq(int32_t IRQn);
93
94 /**
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.
98  */
99 void csi_intc_set_wakeup_irq(int32_t IRQn);
100
101 /**
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.
105  */
106 void csi_intc_clear_wakeup_irq(int32_t IRQn);
107
108 /**
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.
115  */
116 uint32_t csi_intc_get_active(int32_t IRQn);
117
118 /**
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.
123  */
124 void csi_intc_set_threshold(uint32_t VectThreshold, uint32_t PrioThreshold);
125
126 /**
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.
132  */
133 void csi_intc_set_prio(int32_t IRQn, uint32_t priority);
134
135 /**
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.
143  */
144 uint32_t csi_intc_get_prio(int32_t IRQn);
145
146 /**
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
150  */
151 int csi_intc_ack_irq(int32_t IRQn);
152
153 /**
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
159 */
160 int csi_intc_set_attribute(int32_t IRQn, uint32_t priority,int_trigger_mode_t trigger_mode);
161
162 #endif /* _CSI_INTC_H_ */
163