Subversion Repositories NaviCtrl

Rev

Rev 1 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
196 killagreg 1
/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
1 ingob 2
* File Name          : 91x_wiu.c
3
* Author             : MCD Application Team
196 killagreg 4
* Version            : V2.1
5
* Date               : 12/22/2008
6
* Description        : This file provides all the WIU firmware functions.
1 ingob 7
**********************************************************************************
8
* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH
9
* CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
10
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
11
* OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
12
* OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
13
* CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
14
*********************************************************************************/
15
 
16
/* Standard include ----------------------------------------------------------*/
17
#include "91x_wiu.h"
18
#include "91x_scu.h"
19
 
20
/* Include of other module interface headers ---------------------------------*/
21
/* Local includes ------------------------------------------------------------*/
22
/* Private typedef -----------------------------------------------------------*/
23
/* Private define ------------------------------------------------------------*/
24
 
25
 
26
/* WIU Masks "used" only in this module */
27
#define WIU_Enable        0x02
28
 
29
 
30
/* Private macro -------------------------------------------------------------*/
31
/* Private variables ---------------------------------------------------------*/
32
/* Private function prototypes -----------------------------------------------*/
33
/* Interface functions -------------------------------------------------------*/
34
/* Private functions ---------------------------------------------------------*/
35
/******************************************************************************
36
* Function Name  : WIU_Init
37
* Description    : Initializes the WIU unit according to the specified parameters
38
*                  in the WIU_InitTypeDef structure.
39
* Input          : WIU_InitStruct: pointer to a WIU_InitTypeDef structure that
40
*                  contains the configuration information for the WIU peripheral.
41
* Output         : None
42
* Return         : None
43
******************************************************************************/
44
void WIU_Init(WIU_InitTypeDef* WIU_InitStruct)
45
{
46
  /* select the Wake-up line to be used */
47
  WIU->MR |= WIU_InitStruct->WIU_Line;
48
 
49
  /* configure the triggering edge */
50
  if(WIU_InitStruct->WIU_TriggerEdge == WIU_RisingEdge)
51
  {
52
    /* trigger on rising edge */
53
    WIU->TR |= WIU_InitStruct->WIU_Line;
54
  }
55
  else
56
  {
57
    /* trigger on falling edge */
58
    WIU->TR &= ~WIU_InitStruct->WIU_Line;
59
  }
60
 
61
}
62
 
63
/******************************************************************************
64
* Function Name  : WIU_DeInit
65
* Description    : Deinitializes the WIU registers to their default reset values.
66
* Input          : None
67
* Output         : None
68
* Return         : None
69
******************************************************************************/
70
void WIU_DeInit(void)
71
{
72
  /* initialize the WIU registers to their reset value */
73
  SCU_APBPeriphReset(__WIU, ENABLE);
74
  SCU_APBPeriphReset(__WIU, DISABLE);
75
}
76
 
77
/******************************************************************************
78
* Function Name  : WIU_StructInit
79
* Description    : Fills in a WIU_InitTypeDef structure with the reset value of
80
*                  each parameter.
81
* Input          : WIU_InitStruct : pointer to a WIU_InitTypeDef structure
82
*                  which will be initialized.
83
* Output         : None
84
* Return         : None
85
******************************************************************************/
86
void WIU_StructInit(WIU_InitTypeDef* WIU_InitStruct)
87
{
88
  /* initialize the WIU_InitStruct fields to their reset values */
89
  WIU_InitStruct->WIU_Line = 0x0 ;
90
  WIU_InitStruct->WIU_TriggerEdge = WIU_FallingEdge ;
91
}
92
 
93
/*******************************************************************************
94
* Function Name  : WIU_Cmd
95
* Description    : Enables or disables the WIU peripheral.
96
* Input          : NewState: new state of the WIU peripheral (Newstate can be
97
*                  ENABLE or DISABLE)
98
* Output         : None
99
* Return         : None
100
*******************************************************************************/
101
void WIU_Cmd(FunctionalState NewState )
102
{
103
     if(NewState == ENABLE)
104
  {
105
      /* Enable the Wake-up Unit (for interrupts and wake-up from low power modes) */
106
      WIU->CTRL |= WIU_Enable ;
107
  }
108
    else
109
  {
110
        /* Disable the Wake-up Unit (for interrupts and wake-up from low power modes) */
111
 
196 killagreg 112
     WIU->CTRL &= ~WIU_Enable ;
1 ingob 113
  }
114
}
115
 
116
/*******************************************************************************
117
* Function Name  : WIU_GenerateSWInterrupt
118
* Description    : Generates a Software interrupt.
119
* Input          : - WIU_Line: specifies the WIU lines to be enabled or
120
*                    disabled. This parameter can be:
121
*                     - WIU_Linex: External interrupt line x where x(0..31)
122
* Output         : None
123
* Return         : None
124
*******************************************************************************/
125
void WIU_GenerateSWInterrupt(u32 WIU_Line)
126
{
127
  WIU->INTR |= WIU_Line;
128
}
129
 
130
/*******************************************************************************
131
* Function Name  : WIU_GetFlagStatus
132
* Description    : Checks whether the specified WIU line flag is set or not.
133
* Input          : - WIU_Line: specifies the WIU lines flag to check.
134
*                    This parameter can be:
135
*                     - WIU_Linex: External interrupt line x where x(0..31)
136
* Output         : None
137
* Return         : The new state of WIU_Line (SET or RESET).
138
*******************************************************************************/
139
FlagStatus WIU_GetFlagStatus(u32 WIU_Line)
140
{
141
  if((WIU->PR & WIU_Line) != RESET)
142
  {
143
    return SET;
144
  }
145
  else
146
  {
147
    return RESET;
148
  }
149
}
150
 
151
/*******************************************************************************
152
* Function Name  : WIU_ClearFlag
153
* Description    : Clears the WIU’s line pending flags.
154
* Input          : - WIU_Line: specifies the WIU lines flags to clear.
155
*                    This parameter can be:
156
*                     - WIU_Linex: External interrupt line x where x(0..31)
157
* Output         : None
158
* Return         : None
159
*******************************************************************************/
160
void WIU_ClearFlag(u32 WIU_Line)
161
{
162
  WIU->PR = WIU_Line;
163
}
164
 
165
/*******************************************************************************
166
* Function Name  : WIU_GetITStatus
167
* Description    : Checks whether the specified WIU line is asserted or not.
168
* Input          : - WIU_Line: specifies the WIU lines to check.
169
*                    This parameter can be:
170
*                     - WIU_Linex: External interrupt line x where x(0..31)
171
* Output         : None
172
* Return         : The new state of WIU_Line (SET or RESET).
173
*******************************************************************************/
174
ITStatus WIU_GetITStatus(u32 WIU_Line)
175
{
176
  if(((WIU->PR & WIU_Line) != RESET)&& ((WIU->MR & WIU_Line) != RESET))
177
  {
178
    return SET;
179
  }
180
  else
181
  {
182
    return RESET;
183
  }
184
}
185
 
186
/*******************************************************************************
187
* Function Name  : WIU_ClearITPendingBit
188
* Description    : Clears the WIU’s line pending bits.
189
* Input          : - WIU_Line: specifies the WIU lines to clear.
190
*                    This parameter can be:
191
*                     - WIU_Linex: External interrupt line x where x(0..31)
192
* Output         : None
193
* Return         : None
194
*******************************************************************************/
195
void WIU_ClearITPendingBit(u32 WIU_Line)
196
{
197
  WIU->PR = WIU_Line;
198
}
199
 
200
 
196 killagreg 201
/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/