]> git.sur5r.net Git - freertos/blob - Demo/ARM7_STR75x_IAR/STLibrary/src/75x_eic.c
Start to re-arrange files to include FreeRTOS+ in main download.
[freertos] / Demo / ARM7_STR75x_IAR / STLibrary / src / 75x_eic.c
1 /******************** (C) COPYRIGHT 2006 STMicroelectronics ********************\r
2 * File Name          : 75x_eic.c\r
3 * Author             : MCD Application Team\r
4 * Date First Issued  : 03/10/2006\r
5 * Description        : This file provides all the EIC software functions.\r
6 ********************************************************************************\r
7 * History:\r
8 * 07/17/2006 : V1.0\r
9 * 03/10/2006 : V0.1\r
10 ********************************************************************************\r
11 * THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS\r
12 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.\r
13 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,\r
14 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE\r
15 * CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING\r
16 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.\r
17 *******************************************************************************/\r
18 \r
19 /* Includes ------------------------------------------------------------------*/\r
20 #include "75x_eic.h"\r
21 \r
22 /* Private typedef -----------------------------------------------------------*/\r
23 /* Private define ------------------------------------------------------------*/\r
24 #define EIC_IRQEnable_Mask     0x00000001\r
25 #define EIC_IRQDisable_Mask    0xFFFFFFFE\r
26 \r
27 #define EIC_FIQEnable_Mask     0x00000002\r
28 #define EIC_FIQDisable_Mask    0xFFFFFFFD\r
29 \r
30 #define EIC_SIPL_Mask          0x0000000F\r
31 #define EIC_SIPL_Reset_Mask    0xFFFFFFF0\r
32 \r
33 /* Private macro -------------------------------------------------------------*/\r
34 /* Private variables ---------------------------------------------------------*/\r
35 /* Private function prototypes -----------------------------------------------*/\r
36 /* Private functions ---------------------------------------------------------*/\r
37 \r
38 /*******************************************************************************\r
39 * Function Name  : EIC_DeInit\r
40 * Description    : Deinitializes the EIC peripheral registers to their default\r
41 *                  reset values.\r
42 * Input          : None\r
43 * Output         : None\r
44 * Return         : None\r
45 *******************************************************************************/\r
46 void EIC_DeInit(void)\r
47 {\r
48   EIC->ICR = 0x00;\r
49   EIC->CIPR = 0x00;\r
50   EIC->FIR = 0x0C;\r
51   EIC->IER = 0x00;\r
52   EIC->IPR = 0xFFFFFFFF;\r
53 }\r
54 \r
55 /*******************************************************************************\r
56 * Function Name  : EIC_IRQInit\r
57 * Description    : Configures the IRQ channels according to the specified\r
58 *                  parameters in the EIC_IRQInitStruct.\r
59 * Input          : EIC_IRQInitStruct: pointer to a EIC_IRQInitTypeDef structure.\r
60 * Output         : None\r
61 * Return         : None\r
62 *******************************************************************************/\r
63 void EIC_IRQInit(EIC_IRQInitTypeDef* EIC_IRQInitStruct)\r
64 {\r
65   u32 Tmp = 0;\r
66 \r
67   if(EIC_IRQInitStruct->EIC_IRQChannelCmd == ENABLE)\r
68   {\r
69     /* Enable the selected IRQ channel */\r
70     EIC->IER |= 1 << EIC_IRQInitStruct->EIC_IRQChannel;\r
71 \r
72     /* Configure the selected IRQ channel priority ***************************/\r
73     /* Clear SIPL[3:0] bits */\r
74     EIC->SIRn[EIC_IRQInitStruct->EIC_IRQChannel] &= EIC_SIPL_Reset_Mask;\r
75 \r
76     /* Configure SIPL[3:0] bits according to EIC_IRQChannelPriority parameter */\r
77     Tmp = EIC_IRQInitStruct->EIC_IRQChannelPriority & EIC_SIPL_Mask;\r
78     EIC->SIRn[EIC_IRQInitStruct->EIC_IRQChannel] |= Tmp;\r
79   }\r
80   else\r
81   {\r
82     /* Disable the select IRQ channel */\r
83     EIC->IER &=~ (1 << EIC_IRQInitStruct->EIC_IRQChannel);\r
84   }\r
85 }\r
86 \r
87 /*******************************************************************************\r
88 * Function Name  : EIC_FIQInit\r
89 * Description    : Configures the FIQ channels according to the specified\r
90 *                  parameters in the EIC_FIQInitStruct.\r
91 * Input          : EIC_FIQInitStruct: pointer to a EIC_FIQInitTypeDef structure.\r
92 * Output         : None\r
93 * Return         : None\r
94 *******************************************************************************/\r
95 void EIC_FIQInit(EIC_FIQInitTypeDef* EIC_FIQInitStruct)\r
96 {\r
97   if(EIC_FIQInitStruct->EIC_FIQChannelCmd == ENABLE)\r
98   {\r
99     /* Enable the selected FIQ channel */\r
100     EIC->FIER |= EIC_FIQInitStruct->EIC_FIQChannel ;\r
101   }\r
102   else\r
103   {\r
104     /* Disable the selected FIQ channel */\r
105     EIC->FIER &= ~EIC_FIQInitStruct->EIC_FIQChannel;\r
106   }\r
107 }\r
108 \r
109 /*******************************************************************************\r
110 * Function Name  : EIC_IRQStructInit\r
111 * Description    : Fills each EIC_IRQInitStruct member with its default value.\r
112 * Input          : EIC_IRQInitStruct: pointer to a EIC_IRQInitTypeDef structure\r
113 *                  which will be initialized.\r
114 * Output         : None\r
115 * Return         : None\r
116 *******************************************************************************/\r
117 void EIC_IRQStructInit(EIC_IRQInitTypeDef* EIC_IRQInitStruct)\r
118 {\r
119   EIC_IRQInitStruct->EIC_IRQChannel = 0x1F;\r
120   EIC_IRQInitStruct->EIC_IRQChannelPriority = 0;\r
121   EIC_IRQInitStruct->EIC_IRQChannelCmd = DISABLE;\r
122 }\r
123 \r
124 /*******************************************************************************\r
125 * Function Name  : EIC_FIQStructInit\r
126 * Description    : Fills each EIC_FIQInitStruct member with its default value.\r
127 * Input          : EIC_FIQInitStruct: pointer to a EIC_FIQInitTypeDef structure\r
128 *                  which will be initialized.\r
129 * Output         : None\r
130 * Return         : None\r
131 *******************************************************************************/\r
132 void EIC_FIQStructInit(EIC_FIQInitTypeDef* EIC_FIQInitStruct)\r
133 {\r
134   EIC_FIQInitStruct->EIC_FIQChannel = 0x03;\r
135   EIC_FIQInitStruct->EIC_FIQChannelCmd = DISABLE;\r
136 }\r
137 \r
138 /*******************************************************************************\r
139 * Function Name  : EIC_IRQCmd\r
140 * Description    : Enables or disables EIC IRQ output request to CPU.\r
141 * Input          : NewState: new state of the EIC IRQ output request to CPU.\r
142 *                  This parameter can be: ENABLE or DISABLE.\r
143 * Output         : None\r
144 * Return         : None\r
145 *******************************************************************************/\r
146 void EIC_IRQCmd(FunctionalState NewState)\r
147 {\r
148   if(NewState == ENABLE)\r
149   {\r
150     /* Enable EIC IRQ output request to CPU */\r
151     EIC->ICR |= EIC_IRQEnable_Mask;\r
152   }\r
153   else\r
154   {\r
155     /* Disable EIC IRQ output request to CPU */\r
156     EIC->ICR &= EIC_IRQDisable_Mask;\r
157   }\r
158 }\r
159 \r
160 /*******************************************************************************\r
161 * Function Name  : EIC_FIQCmd\r
162 * Description    : Enables or disables EIC FIQ output request to CPU.\r
163 * Input          : NewState: new state of the EIC FIQ output request to CPU.\r
164 *                  This parameter can be: ENABLE or DISABLE.\r
165 * Output         : None\r
166 * Return         : None\r
167 *******************************************************************************/\r
168 void EIC_FIQCmd(FunctionalState NewState)\r
169 {\r
170   if(NewState == ENABLE)\r
171   {\r
172     /* Enable EIC FIQ output request to CPU */\r
173     EIC->ICR |= EIC_FIQEnable_Mask;\r
174   }\r
175   else\r
176   {\r
177     /* Disable EIC FIQ output request to CPU */\r
178     EIC->ICR &= EIC_FIQDisable_Mask;\r
179   }\r
180 }\r
181 \r
182 /*******************************************************************************\r
183 * Function Name  : EIC_GetCurrentIRQChannel\r
184 * Description    : Returns the current served IRQ channel identifier.\r
185 * Input          : None\r
186 * Output         : None\r
187 * Return         : The current served IRQ channel.\r
188 *******************************************************************************/\r
189 u8 EIC_GetCurrentIRQChannel(void)\r
190 {\r
191   /* Read and return the CIC[4:0] bits of CICR register */\r
192   return ((u8) (EIC->CICR));\r
193 }\r
194 \r
195 /*******************************************************************************\r
196 * Function Name  : EIC_GetCurrentIRQChannelPriority\r
197 * Description    : Returns the priority level of the current served IRQ channel.\r
198 * Input          : None\r
199 * Output         : None\r
200 * Return         : The priority level of the current served IRQ channel.\r
201 *******************************************************************************/\r
202 u8 EIC_GetCurrentIRQChannelPriority(void)\r
203 {\r
204   /* Read and return the CIP[3:0] bits of CIPR register */\r
205   return ((u8) (EIC->CIPR));\r
206 }\r
207 \r
208 /*******************************************************************************\r
209 * Function Name  : EIC_CurrentIRQPriorityConfig\r
210 * Description    : Changes the priority of the current served IRQ channel.\r
211 *                  The new priority value must be higher, or equal, than the\r
212 *                  priority value associated to the interrupt channel currently\r
213 *                  serviced.\r
214 * Input          : NewPriority: new priority value of the IRQ interrupt routine\r
215 *                  currently serviced.\r
216 * Output         : None\r
217 * Return         : None\r
218 *******************************************************************************/\r
219 void EIC_CurrentIRQPriorityConfig(u8 NewPriority)\r
220 {\r
221   /* Disable EIC IRQ output request to CPU */\r
222   EIC->ICR &= EIC_IRQDisable_Mask;\r
223 \r
224   /* Change the current priority */\r
225   EIC->CIPR = NewPriority;\r
226 \r
227   /* Enable EIC IRQ output request to CPU  */\r
228   EIC->ICR |= EIC_IRQEnable_Mask;\r
229 }\r
230 \r
231 /*******************************************************************************\r
232 * Function Name  : EIC_GetCurrentFIQChannel\r
233 * Description    : Returns the current served FIQ channel identifier.\r
234 * Input          : None\r
235 * Output         : None\r
236 * Return         : The current served FIQ channel.\r
237 *******************************************************************************/\r
238 u8 EIC_GetCurrentFIQChannel(void)\r
239 {\r
240   /* Read and return the FIP[1:0] bits of FIPR register */\r
241   return ((u8) (EIC->FIPR));\r
242 }\r
243 \r
244 /*******************************************************************************\r
245 * Function Name  : EIC_ClearFIQPendingBit\r
246 * Description    : Clears the pending bit of the selected FIQ Channel.\r
247 * Input          : EIC_FIQChannel: specifies the FIQ channel to clear its\r
248 *                  pending bit.\r
249 * Output         : None\r
250 * Return         : None\r
251 *******************************************************************************/\r
252 void EIC_ClearFIQPendingBit(u8 EIC_FIQChannel)\r
253 {\r
254   /* Clear the correspondent FIQ pending bit */\r
255   EIC->FIPR = EIC_FIQChannel ;\r
256 }\r
257 \r
258 /******************* (C) COPYRIGHT 2006 STMicroelectronics *****END OF FILE****/\r