OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [ARM7_STR75x_GCC/] [STLibrary/] [src/] [75x_eic.c] - Blame information for rev 584

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 577 jeremybenn
/******************** (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
********************************************************************************
7
* History:
8
* 07/17/2006 : V1.0
9
* 03/10/2006 : V0.1
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
*******************************************************************************/
18
 
19
/* Includes ------------------------------------------------------------------*/
20
#include "75x_eic.h"
21
 
22
/* Private typedef -----------------------------------------------------------*/
23
/* Private define ------------------------------------------------------------*/
24
#define EIC_IRQEnable_Mask     0x00000001
25
#define EIC_IRQDisable_Mask    0xFFFFFFFE
26
 
27
#define EIC_FIQEnable_Mask     0x00000002
28
#define EIC_FIQDisable_Mask    0xFFFFFFFD
29
 
30
#define EIC_SIPL_Mask          0x0000000F
31
#define EIC_SIPL_Reset_Mask    0xFFFFFFF0
32
 
33
/* Private macro -------------------------------------------------------------*/
34
/* Private variables ---------------------------------------------------------*/
35
/* Private function prototypes -----------------------------------------------*/
36
/* Private functions ---------------------------------------------------------*/
37
 
38
/*******************************************************************************
39
* Function Name  : EIC_DeInit
40
* Description    : Deinitializes the EIC peripheral registers to their default
41
*                  reset values.
42
* Input          : None
43
* Output         : None
44
* Return         : None
45
*******************************************************************************/
46
void EIC_DeInit(void)
47
{
48
  EIC->ICR = 0x00;
49
  EIC->CIPR = 0x00;
50
  EIC->FIR = 0x0C;
51
  EIC->IER = 0x00;
52
  EIC->IPR = 0xFFFFFFFF;
53
}
54
 
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.
60
* Output         : None
61
* Return         : None
62
*******************************************************************************/
63
void EIC_IRQInit(EIC_IRQInitTypeDef* EIC_IRQInitStruct)
64
{
65
  u32 Tmp = 0;
66
 
67
  if(EIC_IRQInitStruct->EIC_IRQChannelCmd == ENABLE)
68
  {
69
    /* Enable the selected IRQ channel */
70
    EIC->IER |= 1 << EIC_IRQInitStruct->EIC_IRQChannel;
71
 
72
    /* Configure the selected IRQ channel priority ***************************/
73
    /* Clear SIPL[3:0] bits */
74
    EIC->SIRn[EIC_IRQInitStruct->EIC_IRQChannel] &= EIC_SIPL_Reset_Mask;
75
 
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;
79
  }
80
  else
81
  {
82
    /* Disable the select IRQ channel */
83
    EIC->IER &=~ (1 << EIC_IRQInitStruct->EIC_IRQChannel);
84
  }
85
}
86
 
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.
92
* Output         : None
93
* Return         : None
94
*******************************************************************************/
95
void EIC_FIQInit(EIC_FIQInitTypeDef* EIC_FIQInitStruct)
96
{
97
  if(EIC_FIQInitStruct->EIC_FIQChannelCmd == ENABLE)
98
  {
99
    /* Enable the selected FIQ channel */
100
    EIC->FIER |= EIC_FIQInitStruct->EIC_FIQChannel ;
101
  }
102
  else
103
  {
104
    /* Disable the selected FIQ channel */
105
    EIC->FIER &= ~EIC_FIQInitStruct->EIC_FIQChannel;
106
  }
107
}
108
 
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.
114
* Output         : None
115
* Return         : None
116
*******************************************************************************/
117
void EIC_IRQStructInit(EIC_IRQInitTypeDef* EIC_IRQInitStruct)
118
{
119
  EIC_IRQInitStruct->EIC_IRQChannel = 0x1F;
120
  EIC_IRQInitStruct->EIC_IRQChannelPriority = 0;
121
  EIC_IRQInitStruct->EIC_IRQChannelCmd = DISABLE;
122
}
123
 
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.
129
* Output         : None
130
* Return         : None
131
*******************************************************************************/
132
void EIC_FIQStructInit(EIC_FIQInitTypeDef* EIC_FIQInitStruct)
133
{
134
  EIC_FIQInitStruct->EIC_FIQChannel = 0x03;
135
  EIC_FIQInitStruct->EIC_FIQChannelCmd = DISABLE;
136
}
137
 
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.
143
* Output         : None
144
* Return         : None
145
*******************************************************************************/
146
void EIC_IRQCmd(FunctionalState NewState)
147
{
148
  if(NewState == ENABLE)
149
  {
150
    /* Enable EIC IRQ output request to CPU */
151
    EIC->ICR |= EIC_IRQEnable_Mask;
152
  }
153
  else
154
  {
155
    /* Disable EIC IRQ output request to CPU */
156
    EIC->ICR &= EIC_IRQDisable_Mask;
157
  }
158
}
159
 
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.
165
* Output         : None
166
* Return         : None
167
*******************************************************************************/
168
void EIC_FIQCmd(FunctionalState NewState)
169
{
170
  if(NewState == ENABLE)
171
  {
172
    /* Enable EIC FIQ output request to CPU */
173
    EIC->ICR |= EIC_FIQEnable_Mask;
174
  }
175
  else
176
  {
177
    /* Disable EIC FIQ output request to CPU */
178
    EIC->ICR &= EIC_FIQDisable_Mask;
179
  }
180
}
181
 
182
/*******************************************************************************
183
* Function Name  : EIC_GetCurrentIRQChannel
184
* Description    : Returns the current served IRQ channel identifier.
185
* Input          : None
186
* Output         : None
187
* Return         : The current served IRQ channel.
188
*******************************************************************************/
189
u8 EIC_GetCurrentIRQChannel(void)
190
{
191
  /* Read and return the CIC[4:0] bits of CICR register */
192
  return ((u8) (EIC->CICR));
193
}
194
 
195
/*******************************************************************************
196
* Function Name  : EIC_GetCurrentIRQChannelPriority
197
* Description    : Returns the priority level of the current served IRQ channel.
198
* Input          : None
199
* Output         : None
200
* Return         : The priority level of the current served IRQ channel.
201
*******************************************************************************/
202
u8 EIC_GetCurrentIRQChannelPriority(void)
203
{
204
  /* Read and return the CIP[3:0] bits of CIPR register */
205
  return ((u8) (EIC->CIPR));
206
}
207
 
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
213
*                  serviced.
214
* Input          : NewPriority: new priority value of the IRQ interrupt routine
215
*                  currently serviced.
216
* Output         : None
217
* Return         : None
218
*******************************************************************************/
219
void EIC_CurrentIRQPriorityConfig(u8 NewPriority)
220
{
221
  /* Disable EIC IRQ output request to CPU */
222
  EIC->ICR &= EIC_IRQDisable_Mask;
223
 
224
  /* Change the current priority */
225
  EIC->CIPR = NewPriority;
226
 
227
  /* Enable EIC IRQ output request to CPU  */
228
  EIC->ICR |= EIC_IRQEnable_Mask;
229
}
230
 
231
/*******************************************************************************
232
* Function Name  : EIC_GetCurrentFIQChannel
233
* Description    : Returns the current served FIQ channel identifier.
234
* Input          : None
235
* Output         : None
236
* Return         : The current served FIQ channel.
237
*******************************************************************************/
238
u8 EIC_GetCurrentFIQChannel(void)
239
{
240
  /* Read and return the FIP[1:0] bits of FIPR register */
241
  return ((u8) (EIC->FIPR));
242
}
243
 
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
248
*                  pending bit.
249
* Output         : None
250
* Return         : None
251
*******************************************************************************/
252
void EIC_ClearFIQPendingBit(u8 EIC_FIQChannel)
253
{
254
  /* Clear the correspondent FIQ pending bit */
255
  EIC->FIPR = EIC_FIQChannel ;
256
}
257
 
258
/******************* (C) COPYRIGHT 2006 STMicroelectronics *****END OF FILE****/

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.