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
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
19 /* Includes ------------------------------------------------------------------*/
\r
20 #include "75x_eic.h"
\r
22 /* Private typedef -----------------------------------------------------------*/
\r
23 /* Private define ------------------------------------------------------------*/
\r
24 #define EIC_IRQEnable_Mask 0x00000001
\r
25 #define EIC_IRQDisable_Mask 0xFFFFFFFE
\r
27 #define EIC_FIQEnable_Mask 0x00000002
\r
28 #define EIC_FIQDisable_Mask 0xFFFFFFFD
\r
30 #define EIC_SIPL_Mask 0x0000000F
\r
31 #define EIC_SIPL_Reset_Mask 0xFFFFFFF0
\r
33 /* Private macro -------------------------------------------------------------*/
\r
34 /* Private variables ---------------------------------------------------------*/
\r
35 /* Private function prototypes -----------------------------------------------*/
\r
36 /* Private functions ---------------------------------------------------------*/
\r
38 /*******************************************************************************
\r
39 * Function Name : EIC_DeInit
\r
40 * Description : Deinitializes the EIC peripheral registers to their default
\r
45 *******************************************************************************/
\r
46 void EIC_DeInit(void)
\r
52 EIC->IPR = 0xFFFFFFFF;
\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
62 *******************************************************************************/
\r
63 void EIC_IRQInit(EIC_IRQInitTypeDef* EIC_IRQInitStruct)
\r
67 if(EIC_IRQInitStruct->EIC_IRQChannelCmd == ENABLE)
\r
69 /* Enable the selected IRQ channel */
\r
70 EIC->IER |= 1 << EIC_IRQInitStruct->EIC_IRQChannel;
\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
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
82 /* Disable the select IRQ channel */
\r
83 EIC->IER &=~ (1 << EIC_IRQInitStruct->EIC_IRQChannel);
\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
94 *******************************************************************************/
\r
95 void EIC_FIQInit(EIC_FIQInitTypeDef* EIC_FIQInitStruct)
\r
97 if(EIC_FIQInitStruct->EIC_FIQChannelCmd == ENABLE)
\r
99 /* Enable the selected FIQ channel */
\r
100 EIC->FIER |= EIC_FIQInitStruct->EIC_FIQChannel ;
\r
104 /* Disable the selected FIQ channel */
\r
105 EIC->FIER &= ~EIC_FIQInitStruct->EIC_FIQChannel;
\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
116 *******************************************************************************/
\r
117 void EIC_IRQStructInit(EIC_IRQInitTypeDef* EIC_IRQInitStruct)
\r
119 EIC_IRQInitStruct->EIC_IRQChannel = 0x1F;
\r
120 EIC_IRQInitStruct->EIC_IRQChannelPriority = 0;
\r
121 EIC_IRQInitStruct->EIC_IRQChannelCmd = DISABLE;
\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
131 *******************************************************************************/
\r
132 void EIC_FIQStructInit(EIC_FIQInitTypeDef* EIC_FIQInitStruct)
\r
134 EIC_FIQInitStruct->EIC_FIQChannel = 0x03;
\r
135 EIC_FIQInitStruct->EIC_FIQChannelCmd = DISABLE;
\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
145 *******************************************************************************/
\r
146 void EIC_IRQCmd(FunctionalState NewState)
\r
148 if(NewState == ENABLE)
\r
150 /* Enable EIC IRQ output request to CPU */
\r
151 EIC->ICR |= EIC_IRQEnable_Mask;
\r
155 /* Disable EIC IRQ output request to CPU */
\r
156 EIC->ICR &= EIC_IRQDisable_Mask;
\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
167 *******************************************************************************/
\r
168 void EIC_FIQCmd(FunctionalState NewState)
\r
170 if(NewState == ENABLE)
\r
172 /* Enable EIC FIQ output request to CPU */
\r
173 EIC->ICR |= EIC_FIQEnable_Mask;
\r
177 /* Disable EIC FIQ output request to CPU */
\r
178 EIC->ICR &= EIC_FIQDisable_Mask;
\r
182 /*******************************************************************************
\r
183 * Function Name : EIC_GetCurrentIRQChannel
\r
184 * Description : Returns the current served IRQ channel identifier.
\r
187 * Return : The current served IRQ channel.
\r
188 *******************************************************************************/
\r
189 u8 EIC_GetCurrentIRQChannel(void)
\r
191 /* Read and return the CIC[4:0] bits of CICR register */
\r
192 return ((u8) (EIC->CICR));
\r
195 /*******************************************************************************
\r
196 * Function Name : EIC_GetCurrentIRQChannelPriority
\r
197 * Description : Returns the priority level of the current served IRQ channel.
\r
200 * Return : The priority level of the current served IRQ channel.
\r
201 *******************************************************************************/
\r
202 u8 EIC_GetCurrentIRQChannelPriority(void)
\r
204 /* Read and return the CIP[3:0] bits of CIPR register */
\r
205 return ((u8) (EIC->CIPR));
\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
214 * Input : NewPriority: new priority value of the IRQ interrupt routine
\r
215 * currently serviced.
\r
218 *******************************************************************************/
\r
219 void EIC_CurrentIRQPriorityConfig(u8 NewPriority)
\r
221 /* Disable EIC IRQ output request to CPU */
\r
222 EIC->ICR &= EIC_IRQDisable_Mask;
\r
224 /* Change the current priority */
\r
225 EIC->CIPR = NewPriority;
\r
227 /* Enable EIC IRQ output request to CPU */
\r
228 EIC->ICR |= EIC_IRQEnable_Mask;
\r
231 /*******************************************************************************
\r
232 * Function Name : EIC_GetCurrentFIQChannel
\r
233 * Description : Returns the current served FIQ channel identifier.
\r
236 * Return : The current served FIQ channel.
\r
237 *******************************************************************************/
\r
238 u8 EIC_GetCurrentFIQChannel(void)
\r
240 /* Read and return the FIP[1:0] bits of FIPR register */
\r
241 return ((u8) (EIC->FIPR));
\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
251 *******************************************************************************/
\r
252 void EIC_ClearFIQPendingBit(u8 EIC_FIQChannel)
\r
254 /* Clear the correspondent FIQ pending bit */
\r
255 EIC->FIPR = EIC_FIQChannel ;
\r
258 /******************* (C) COPYRIGHT 2006 STMicroelectronics *****END OF FILE****/
\r