1 /******************** (C) COPYRIGHT 2006 STMicroelectronics ********************
2 * File Name : 75x_eic.c
3 * Author : MCD Application Team
4 * Date First Issued : 03/10/2006
5 * Description : This file provides all the EIC software functions.
6 ********************************************************************************
10 ********************************************************************************
11 * THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
13 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
14 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
15 * CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
16 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 *******************************************************************************/
19 /* Includes ------------------------------------------------------------------*/
22 /* Private typedef -----------------------------------------------------------*/
23 /* Private define ------------------------------------------------------------*/
24 #define EIC_IRQEnable_Mask 0x00000001
25 #define EIC_IRQDisable_Mask 0xFFFFFFFE
27 #define EIC_FIQEnable_Mask 0x00000002
28 #define EIC_FIQDisable_Mask 0xFFFFFFFD
30 #define EIC_SIPL_Mask 0x0000000F
31 #define EIC_SIPL_Reset_Mask 0xFFFFFFF0
33 /* Private macro -------------------------------------------------------------*/
34 /* Private variables ---------------------------------------------------------*/
35 /* Private function prototypes -----------------------------------------------*/
36 /* Private functions ---------------------------------------------------------*/
38 /*******************************************************************************
39 * Function Name : EIC_DeInit
40 * Description : Deinitializes the EIC peripheral registers to their default
45 *******************************************************************************/
52 EIC->IPR = 0xFFFFFFFF;
55 /*******************************************************************************
56 * Function Name : EIC_IRQInit
57 * Description : Configures the IRQ channels according to the specified
58 * parameters in the EIC_IRQInitStruct.
59 * Input : EIC_IRQInitStruct: pointer to a EIC_IRQInitTypeDef structure.
62 *******************************************************************************/
63 void EIC_IRQInit(EIC_IRQInitTypeDef* EIC_IRQInitStruct)
67 if(EIC_IRQInitStruct->EIC_IRQChannelCmd == ENABLE)
69 /* Enable the selected IRQ channel */
70 EIC->IER |= 1 << EIC_IRQInitStruct->EIC_IRQChannel;
72 /* Configure the selected IRQ channel priority ***************************/
73 /* Clear SIPL[3:0] bits */
74 EIC->SIRn[EIC_IRQInitStruct->EIC_IRQChannel] &= EIC_SIPL_Reset_Mask;
76 /* Configure SIPL[3:0] bits according to EIC_IRQChannelPriority parameter */
77 Tmp = EIC_IRQInitStruct->EIC_IRQChannelPriority & EIC_SIPL_Mask;
78 EIC->SIRn[EIC_IRQInitStruct->EIC_IRQChannel] |= Tmp;
82 /* Disable the select IRQ channel */
83 EIC->IER &=~ (1 << EIC_IRQInitStruct->EIC_IRQChannel);
87 /*******************************************************************************
88 * Function Name : EIC_FIQInit
89 * Description : Configures the FIQ channels according to the specified
90 * parameters in the EIC_FIQInitStruct.
91 * Input : EIC_FIQInitStruct: pointer to a EIC_FIQInitTypeDef structure.
94 *******************************************************************************/
95 void EIC_FIQInit(EIC_FIQInitTypeDef* EIC_FIQInitStruct)
97 if(EIC_FIQInitStruct->EIC_FIQChannelCmd == ENABLE)
99 /* Enable the selected FIQ channel */
100 EIC->FIER |= EIC_FIQInitStruct->EIC_FIQChannel ;
104 /* Disable the selected FIQ channel */
105 EIC->FIER &= ~EIC_FIQInitStruct->EIC_FIQChannel;
109 /*******************************************************************************
110 * Function Name : EIC_IRQStructInit
111 * Description : Fills each EIC_IRQInitStruct member with its default value.
112 * Input : EIC_IRQInitStruct: pointer to a EIC_IRQInitTypeDef structure
113 * which will be initialized.
116 *******************************************************************************/
117 void EIC_IRQStructInit(EIC_IRQInitTypeDef* EIC_IRQInitStruct)
119 EIC_IRQInitStruct->EIC_IRQChannel = 0x1F;
120 EIC_IRQInitStruct->EIC_IRQChannelPriority = 0;
121 EIC_IRQInitStruct->EIC_IRQChannelCmd = DISABLE;
124 /*******************************************************************************
125 * Function Name : EIC_FIQStructInit
126 * Description : Fills each EIC_FIQInitStruct member with its default value.
127 * Input : EIC_FIQInitStruct: pointer to a EIC_FIQInitTypeDef structure
128 * which will be initialized.
131 *******************************************************************************/
132 void EIC_FIQStructInit(EIC_FIQInitTypeDef* EIC_FIQInitStruct)
134 EIC_FIQInitStruct->EIC_FIQChannel = 0x03;
135 EIC_FIQInitStruct->EIC_FIQChannelCmd = DISABLE;
138 /*******************************************************************************
139 * Function Name : EIC_IRQCmd
140 * Description : Enables or disables EIC IRQ output request to CPU.
141 * Input : NewState: new state of the EIC IRQ output request to CPU.
142 * This parameter can be: ENABLE or DISABLE.
145 *******************************************************************************/
146 void EIC_IRQCmd(FunctionalState NewState)
148 if(NewState == ENABLE)
150 /* Enable EIC IRQ output request to CPU */
151 EIC->ICR |= EIC_IRQEnable_Mask;
155 /* Disable EIC IRQ output request to CPU */
156 EIC->ICR &= EIC_IRQDisable_Mask;
160 /*******************************************************************************
161 * Function Name : EIC_FIQCmd
162 * Description : Enables or disables EIC FIQ output request to CPU.
163 * Input : NewState: new state of the EIC FIQ output request to CPU.
164 * This parameter can be: ENABLE or DISABLE.
167 *******************************************************************************/
168 void EIC_FIQCmd(FunctionalState NewState)
170 if(NewState == ENABLE)
172 /* Enable EIC FIQ output request to CPU */
173 EIC->ICR |= EIC_FIQEnable_Mask;
177 /* Disable EIC FIQ output request to CPU */
178 EIC->ICR &= EIC_FIQDisable_Mask;
182 /*******************************************************************************
183 * Function Name : EIC_GetCurrentIRQChannel
184 * Description : Returns the current served IRQ channel identifier.
187 * Return : The current served IRQ channel.
188 *******************************************************************************/
189 u8 EIC_GetCurrentIRQChannel(void)
191 /* Read and return the CIC[4:0] bits of CICR register */
192 return ((u8) (EIC->CICR));
195 /*******************************************************************************
196 * Function Name : EIC_GetCurrentIRQChannelPriority
197 * Description : Returns the priority level of the current served IRQ channel.
200 * Return : The priority level of the current served IRQ channel.
201 *******************************************************************************/
202 u8 EIC_GetCurrentIRQChannelPriority(void)
204 /* Read and return the CIP[3:0] bits of CIPR register */
205 return ((u8) (EIC->CIPR));
208 /*******************************************************************************
209 * Function Name : EIC_CurrentIRQPriorityConfig
210 * Description : Changes the priority of the current served IRQ channel.
211 * The new priority value must be higher, or equal, than the
212 * priority value associated to the interrupt channel currently
214 * Input : NewPriority: new priority value of the IRQ interrupt routine
215 * currently serviced.
218 *******************************************************************************/
219 void EIC_CurrentIRQPriorityConfig(u8 NewPriority)
221 /* Disable EIC IRQ output request to CPU */
222 EIC->ICR &= EIC_IRQDisable_Mask;
224 /* Change the current priority */
225 EIC->CIPR = NewPriority;
227 /* Enable EIC IRQ output request to CPU */
228 EIC->ICR |= EIC_IRQEnable_Mask;
231 /*******************************************************************************
232 * Function Name : EIC_GetCurrentFIQChannel
233 * Description : Returns the current served FIQ channel identifier.
236 * Return : The current served FIQ channel.
237 *******************************************************************************/
238 u8 EIC_GetCurrentFIQChannel(void)
240 /* Read and return the FIP[1:0] bits of FIPR register */
241 return ((u8) (EIC->FIPR));
244 /*******************************************************************************
245 * Function Name : EIC_ClearFIQPendingBit
246 * Description : Clears the pending bit of the selected FIQ Channel.
247 * Input : EIC_FIQChannel: specifies the FIQ channel to clear its
251 *******************************************************************************/
252 void EIC_ClearFIQPendingBit(u8 EIC_FIQChannel)
254 /* Clear the correspondent FIQ pending bit */
255 EIC->FIPR = EIC_FIQChannel ;
258 /******************* (C) COPYRIGHT 2006 STMicroelectronics *****END OF FILE****/